Scribd Viewer/Downloader

View or download from Scribd without an account

当前为 2025-05-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Scribd Viewer/Downloader
  3. // @namespace 0b9
  4. // @match *://www.scribd.com/*
  5. // @grant none
  6. // @version 1.1
  7. // @author 0b9
  8. // @description View or download from Scribd without an account
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const currentUrl = window.location.href;
  16.  
  17. // ===== Scribd =====
  18. if (currentUrl.includes('scribd.com')) {
  19. sessionStorage.setItem('originalUrl', currentUrl);
  20. let originalUrl = null;
  21.  
  22. function redirectToEmbed() {
  23. const currentUrl = window.location.href;
  24. sessionStorage.setItem('originalUrl', currentUrl);
  25. const regex = /https:\/\/www\.scribd\.com\/[^/]+\/([^/]+)\/[^/]+/;
  26. const match = currentUrl.match(regex);
  27.  
  28. if (match) {
  29. const newUrl = `https://www.scribd.com/embeds/${match[1]}/content`;
  30. window.location.href = newUrl;
  31. } else {
  32. alert("Error: No match");
  33. }
  34. }
  35.  
  36. function downloadContent() {
  37. const contentElements = document.querySelectorAll('.text_layer .a');
  38. let content = '';
  39. contentElements.forEach(element => {
  40. content += element.textContent + '\n';
  41. });
  42.  
  43. const blob = new Blob([content], { type: 'text/plain' });
  44. const url = URL.createObjectURL(blob);
  45. const a = document.createElement('a');
  46. a.href = url;
  47. a.download = 'scribd_content.txt';
  48. document.body.appendChild(a);
  49. a.click();
  50. document.body.removeChild(a);
  51. URL.revokeObjectURL(url);
  52. }
  53.  
  54. function downloadContentAsPDF() {
  55. const savedUrl = sessionStorage.getItem('originalUrl');
  56. if (!savedUrl) {
  57. alert('Error: Click the "View Full" button and try again');
  58. return;
  59. }
  60.  
  61. const regex = /https:\/\/www\.scribd\.com\/(?:document|presentation)\/(\d+)\/([^\/?#]+)/;
  62. const match = savedUrl.match(regex);
  63.  
  64. if (match) {
  65. const part1 = match[1];
  66. const part2 = match[2];
  67. const urls = [
  68. `https://compress-pdf.vietdreamhouse.com/?fileurl=https://scribd.downloader.tips/pdownload/${part1}/${part2}&title=${part2}`,
  69. `https://compress.tacz.info/?fileurl=https://scribd.vpdfs.com/pdownload/${part1}/${part2}&title=${part2}`
  70. ];
  71. const randomUrl = urls[Math.floor(Math.random() * urls.length)];
  72. window.location.href = randomUrl;
  73. } else {
  74. alert('Error: Invalid URL');
  75. }
  76. }
  77.  
  78. function createButton(text, top, bgColor, onClick) {
  79. const btn = document.createElement('button');
  80. btn.textContent = text;
  81. btn.style.position = 'fixed';
  82. btn.style.top = top;
  83. btn.style.right = '10px';
  84. btn.style.zIndex = '1000';
  85. btn.style.padding = '10px';
  86. btn.style.backgroundColor = bgColor;
  87. btn.style.color = 'white';
  88. btn.style.border = 'none';
  89. btn.style.borderRadius = '5px';
  90. btn.style.cursor = 'pointer';
  91. btn.addEventListener('click', onClick);
  92. document.body.appendChild(btn);
  93. }
  94.  
  95. createButton('View Full', '10px', '#4CAF50', redirectToEmbed);
  96. createButton('Download TXT', '50px', '#007BFF', downloadContent);
  97. createButton('Download PDF', '90px', '#FF5733', downloadContentAsPDF);
  98. }
  99.  
  100. // ===== SlideShare =====
  101. if (currentUrl.includes('slideshare.net/slideshow/')) {
  102. const match = currentUrl.match(/https:\/\/www\.slideshare\.net\/slideshow\/([^/]+)\/(\d+)/);
  103. let downloadUrl;
  104.  
  105. if (match) {
  106. // If the URL follows the old ID-at-end pattern
  107. downloadUrl = `https://slideshare.vpdfs.com/download/slideshow/${match[1]}/${match[2]}`;
  108. } else {
  109. // Generic fallback - re-use the pathname
  110. const path = window.location.pathname.replace('/slideshow/', '');
  111. downloadUrl = `https://slideshare.vpdfs.com/download/slideshow/${path}`;
  112. }
  113.  
  114. const downloadSlideShareBtn = document.createElement('button');
  115. downloadSlideShareBtn.textContent = 'Download SlideShare';
  116. downloadSlideShareBtn.style.position = 'fixed';
  117. downloadSlideShareBtn.style.top = '10px';
  118. downloadSlideShareBtn.style.right = '10px';
  119. downloadSlideShareBtn.style.zIndex = '1000';
  120. downloadSlideShareBtn.style.padding = '10px';
  121. downloadSlideShareBtn.style.backgroundColor = '#6f42c1';
  122. downloadSlideShareBtn.style.color = 'white';
  123. downloadSlideShareBtn.style.border = 'none';
  124. downloadSlideShareBtn.style.borderRadius = '5px';
  125. downloadSlideShareBtn.style.cursor = 'pointer';
  126.  
  127. downloadSlideShareBtn.addEventListener('click', () => {
  128. window.location.href = downloadUrl;
  129. });
  130.  
  131. document.body.appendChild(downloadSlideShareBtn);
  132. }
  133.  
  134. })();