Scribd Download Button

Add a download button on Scribd pages to redirect to a custom download service in the same tab, supporting document, doc, and presentation URLs.

  1. // ==UserScript==
  2. // @name Scribd Download Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description Add a download button on Scribd pages to redirect to a custom download service in the same tab, supporting document, doc, and presentation URLs.
  6. // @author Mayclin.IT
  7. // @match https://www.scribd.com/document/*
  8. // @match https://www.scribd.com/doc/*
  9. // @match https://www.scribd.com/presentation/*
  10. // @icon https://www.google.com/s2/favicons?domain=scribd.com
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. console.log("📌 Tampermonkey script is running...");
  18.  
  19. // Extract version number from metadata
  20. const scriptVersion = GM_info.script.version;
  21. console.log("📌 Script Version:", scriptVersion);
  22.  
  23. // Get the current URL
  24. const currentUrl = window.location.href;
  25.  
  26. // Regular expression to match URL format correctly
  27. const urlMatch = currentUrl.match(/https:\/\/www\.scribd\.com\/(?:document|doc|presentation)\/(\d+)\/(.+)/);
  28.  
  29. if (urlMatch) {
  30. // Extract the document ID and title
  31. const docId = urlMatch[1]; // Document ID
  32. let docTitle = urlMatch[2]; // Document title
  33.  
  34. // Debugging
  35. console.log("📌 Extracted docId:", docId);
  36. console.log("📌 Extracted raw docTitle:", docTitle);
  37.  
  38. // Fix docTitle: Replace `/` with `-` and encode special characters
  39. docTitle = docTitle.replace(/\//g, '-'); // Replace slashes with dashes
  40. docTitle = encodeURIComponent(docTitle); // Encode special characters
  41.  
  42. // Construct the new download URL with "/document/" path
  43. const downloadUrl = `https://scribd.downloader.tips/document/${docId}/${docTitle}`;
  44. console.log("📌 Final download URL:", downloadUrl);
  45.  
  46. // Create a download button
  47. const button = document.createElement('button');
  48. button.textContent = `Download v${scriptVersion}`;
  49. button.style.position = 'fixed';
  50. button.style.top = '10px';
  51. button.style.right = '10px';
  52. button.style.padding = '10px 15px';
  53. button.style.backgroundColor = '#007bff';
  54. button.style.color = '#fff';
  55. button.style.border = 'none';
  56. button.style.borderRadius = '5px';
  57. button.style.cursor = 'pointer';
  58. button.style.zIndex = '10000';
  59.  
  60. // Add click event to redirect to the download URL in the same tab
  61. button.addEventListener('click', () => {
  62. window.location.href = downloadUrl;
  63. });
  64.  
  65. // Append the button to the body
  66. document.body.appendChild(button);
  67. console.log("✅ Download button added successfully!");
  68. } else {
  69. console.warn("❌ No matching document found in the URL.");
  70. }
  71. })();