Scribd & SlideShare Viewer/Downloader

View or download from Scribd and SlideShare without an account

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