DownArchive Link Extractor

Extract links from DownArchive and copy them to clipboard

目前为 2025-02-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name DownArchive Link Extractor
  3. // @namespace https://greasyfork.org/users/30331-setcher
  4. // @version 0.4
  5. // @description Extract links from DownArchive and copy them to clipboard
  6. // @author Setcher
  7. // @match *://downarchive.org/*
  8. // @grant GM_xmlhttpRequest
  9. // @grant GM_setClipboard
  10. // @connect rg.to
  11. // @connect rapidgator.net
  12. // @connect uploadgig.com
  13. // @connect nitroflare.com
  14. // @connect filextras.com
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // Utility function to create copy button
  21. function createCopyButton(container, text, links, placeholder) {
  22. const button = document.createElement('button');
  23. button.innerText = text;
  24. button.style.marginTop = '10px';
  25. button.style.marginBottom = '10px'; // Add space below button
  26. button.style.marginRight = '10px'; // Add space between buttons
  27. button.onclick = function() {
  28. const clipboardText = links.join('\n');
  29. GM_setClipboard(clipboardText);
  30. alert(`Copied ${links.length} links to clipboard!`);
  31. };
  32.  
  33. // Replace placeholder with the button
  34. container.replaceChild(button, placeholder);
  35. }
  36.  
  37. // Function to create a placeholder (disabled button with "Loading" text)
  38. function createPlaceholder(domain) {
  39. const placeholder = document.createElement('button');
  40. placeholder.disabled = true;
  41. placeholder.innerText = `Loading ${domain} links...`;
  42. placeholder.style.marginTop = '10px';
  43. placeholder.style.marginBottom = '10px'; // Add space below button
  44. placeholder.style.marginRight = '10px'; // Add space between buttons
  45. return placeholder;
  46. }
  47.  
  48. // Extract links from a given folder URL (e.g., rg.to folder)
  49. function extractRGLinks(folderUrl, container, placeholder) {
  50. GM_xmlhttpRequest({
  51. method: 'GET',
  52. url: folderUrl,
  53. onload: function(response) {
  54. const doc = new DOMParser().parseFromString(response.responseText, 'text/html');
  55. const fileLinks = Array.from(doc.querySelectorAll('a[href^="/file/"]')).map(link => "https://rapidgator.net/" + link.getAttribute('href'));
  56.  
  57. // Replace placeholder with the button once the links are loaded
  58. createCopyButton(container, `Copy all ${fileLinks.length} rapidgator.net links`, fileLinks, placeholder);
  59. }
  60. });
  61. }
  62.  
  63. // Main function to process each quote div (excluding rg.to/folder)
  64. function processQuoteDiv(quoteDiv) {
  65. const links = Array.from(quoteDiv.querySelectorAll('a'));
  66.  
  67. let rgLink = null;
  68. const otherLinks = {
  69. 'rapidgator.net': [],
  70. 'uploadgig.com': [],
  71. 'nitroflare.com': [],
  72. 'filextras.com': []
  73. };
  74.  
  75. const placeholders = [];
  76.  
  77. // Step 1: Check for supported servers and add placeholders immediately
  78. links.forEach(link => {
  79. const href = link.href;
  80.  
  81. if (href.startsWith('https://rg.to/folder/')) {
  82. rgLink = href;
  83. } else if (href.includes('rapidgator.net/file/')) {
  84. otherLinks['rapidgator.net'].push(href);
  85. } else if (href.includes('uploadgig.com/file/')) {
  86. otherLinks['uploadgig.com'].push(href);
  87. } else if (href.includes('nitroflare.com/')) {
  88. otherLinks['nitroflare.com'].push(href);
  89. } else if (href.includes('filextras.com/')) {
  90. otherLinks['filextras.com'].push(href);
  91. }
  92. });
  93.  
  94. // Step 2: Place placeholders for supported servers immediately
  95. for (const domain in otherLinks) {
  96. if (otherLinks[domain].length > 0) {
  97. const placeholder = createPlaceholder(domain);
  98. quoteDiv.appendChild(placeholder);
  99. placeholders.push({ domain, placeholder, links: otherLinks[domain] });
  100. }
  101. }
  102.  
  103. // Step 3: Replace the placeholders for other domains immediately
  104. placeholders.forEach(({ domain, placeholder, links }) => {
  105. createCopyButton(quoteDiv, `Copy all ${links.length} ${domain} links`, links, placeholder);
  106. });
  107.  
  108. // Step 4: Place placeholder for rg.to/folder, but don't process yet
  109. if (rgLink) {
  110. const rgPlaceholder = createPlaceholder('rg.to');
  111. quoteDiv.appendChild(rgPlaceholder);
  112. // Store rg.to link to process later
  113. window.rgLinksToProcess = window.rgLinksToProcess || [];
  114. window.rgLinksToProcess.push({ rgLink, quoteDiv, rgPlaceholder });
  115. }
  116. }
  117.  
  118. // Function to process all rg.to/folder links after page load
  119. function processRGFolders() {
  120. if (window.rgLinksToProcess && window.rgLinksToProcess.length > 0) {
  121. window.rgLinksToProcess.forEach(({ rgLink, quoteDiv, rgPlaceholder }) => {
  122. extractRGLinks(rgLink, quoteDiv, rgPlaceholder);
  123. });
  124. // Clear the queue after processing
  125. window.rgLinksToProcess = [];
  126. }
  127. }
  128.  
  129. // Main function to run on page load
  130. window.addEventListener('load', function() {
  131. // Process all quote divs, except rg.to/folder processing
  132. const quoteDivs = document.querySelectorAll('div.quote');
  133. quoteDivs.forEach(quoteDiv => {
  134. processQuoteDiv(quoteDiv);
  135. });
  136.  
  137. // Trigger rg.to folder processing separately after everything else is done
  138. processRGFolders();
  139. });
  140. })();
  141.