DownArchive Link Extractor

Extract links from DownArchive and copy them to clipboard

  1. // ==UserScript==
  2. // @name DownArchive Link Extractor
  3. // @namespace https://greasyfork.org/users/30331-setcher
  4. // @version 0.6
  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. function createCopyButton(container, text, links, placeholder) {
  21. const button = document.createElement('button');
  22. button.innerText = text;
  23. button.style.marginTop = '10px';
  24. button.style.marginBottom = '10px';
  25. button.style.marginRight = '10px';
  26. button.onclick = function() {
  27. const clipboardText = links.join('\n');
  28. GM_setClipboard(clipboardText);
  29. alert(`Copied ${links.length} links to clipboard!`);
  30. };
  31. container.replaceChild(button, placeholder);
  32. }
  33.  
  34. function createPlaceholder(domain) {
  35. const placeholder = document.createElement('button');
  36. placeholder.disabled = true;
  37. placeholder.innerText = `Loading ${domain} links...`;
  38. placeholder.style.marginTop = '10px';
  39. placeholder.style.marginBottom = '10px';
  40. placeholder.style.marginRight = '10px';
  41. return placeholder;
  42. }
  43.  
  44. function extractRGLinks(folderUrl, container, placeholder) {
  45. GM_xmlhttpRequest({
  46. method: 'GET',
  47. url: folderUrl,
  48. onload: function(response) {
  49. const doc = new DOMParser().parseFromString(response.responseText, 'text/html');
  50. const fileLinks = Array.from(doc.querySelectorAll('a[href^="/file/"]')).map(link => "https://rapidgator.net" + link.getAttribute('href'));
  51.  
  52. let totalSize = 0;
  53. const sizeElements = doc.querySelectorAll('.td-for-select');
  54. sizeElements.forEach(el => {
  55. const match = el.innerText.match(/([0-9.]+)\s*(MB|GB)/i);
  56. if (match) {
  57. let size = parseFloat(match[1]);
  58. if (match[2].toUpperCase() === 'GB') {
  59. size *= 1024;
  60. }
  61. totalSize += size;
  62. }
  63. });
  64. totalSize = Math.round(totalSize);
  65.  
  66. createCopyButton(container, `Copy all ${fileLinks.length} rapidgator.net links (${totalSize} MB)`, fileLinks, placeholder);
  67. }
  68. });
  69. }
  70.  
  71. function processQuoteDiv(quoteDiv) {
  72. const links = Array.from(quoteDiv.querySelectorAll('a'));
  73.  
  74. let rgLink = null;
  75. const otherLinks = {
  76. 'rapidgator.net': [],
  77. 'uploadgig.com': [],
  78. 'nitroflare.com': [],
  79. 'filextras.com': []
  80. };
  81.  
  82. const placeholders = [];
  83.  
  84. links.forEach(link => {
  85. const href = link.href;
  86. if (href.startsWith('https://rg.to/folder/')) {
  87. rgLink = href;
  88. } else if (href.includes('rapidgator.net/file/')) {
  89. otherLinks['rapidgator.net'].push(href);
  90. } else if (href.includes('uploadgig.com/file/')) {
  91. otherLinks['uploadgig.com'].push(href);
  92. } else if (href.includes('nitroflare.com/')) {
  93. otherLinks['nitroflare.com'].push(href);
  94. } else if (href.includes('filextras.com/')) {
  95. otherLinks['filextras.com'].push(href);
  96. }
  97. });
  98.  
  99. for (const domain in otherLinks) {
  100. if (otherLinks[domain].length > 0) {
  101. const placeholder = createPlaceholder(domain);
  102. quoteDiv.appendChild(placeholder);
  103. placeholders.push({ domain, placeholder, links: otherLinks[domain] });
  104. }
  105. }
  106.  
  107. placeholders.forEach(({ domain, placeholder, links }) => {
  108. createCopyButton(quoteDiv, `Copy all ${links.length} ${domain} links`, links, placeholder);
  109. });
  110.  
  111. if (rgLink) {
  112. const rgPlaceholder = createPlaceholder('rg.to');
  113. quoteDiv.appendChild(rgPlaceholder);
  114. window.rgLinksToProcess = window.rgLinksToProcess || [];
  115. window.rgLinksToProcess.push({ rgLink, quoteDiv, rgPlaceholder });
  116. }
  117. }
  118.  
  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. window.rgLinksToProcess = [];
  125. }
  126. }
  127.  
  128. window.addEventListener('load', function() {
  129. const quoteDivs = document.querySelectorAll('div.quote');
  130. quoteDivs.forEach(quoteDiv => {
  131. processQuoteDiv(quoteDiv);
  132. });
  133. processRGFolders();
  134. });
  135. })();