Extract links from DownArchive and copy them to clipboard
当前为
// ==UserScript==
// @name DownArchive Link Extractor
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Extract links from DownArchive and copy them to clipboard
// @author Setcher
// @match *://downarchive.org/*
// @grant GM_xmlhttpRequest
// @grant GM_setClipboard
// @connect rg.to
// @connect rapidgator.net
// @connect uploadgig.com
// @connect nitroflare.com
// @connect filextras.com
// ==/UserScript==
(function() {
'use strict';
// Utility function to create copy button
function createCopyButton(container, text, links) {
const button = document.createElement('button');
button.innerText = text;
button.style.marginTop = '10px';
button.style.marginBottom = '10px'; // Add space below button
button.onclick = function() {
const clipboardText = links.join('\n');
GM_setClipboard(clipboardText);
alert(`Copied ${links.length} links to clipboard!`);
};
container.appendChild(button);
}
// Extract rg.to folder links and add button to copy
function extractRGLinks(folderUrl, container) {
GM_xmlhttpRequest({
method: 'GET',
url: folderUrl,
onload: function(response) {
const doc = new DOMParser().parseFromString(response.responseText, 'text/html');
const fileLinks = Array.from(doc.querySelectorAll('a[href^="/file/"]')).map(link => "https://rapidgator.net/" + link.getAttribute('href'));
createCopyButton(container, `Copy all ${fileLinks.length} rapidgator.net links`, fileLinks);
}
});
}
// Main function to process each quote div
function processQuoteDiv(quoteDiv) {
const links = Array.from(quoteDiv.querySelectorAll('a'));
let rgLink = null;
const otherLinks = {
'rapidgator.net': [],
'uploadgig.com': [],
'nitroflare.com': [],
'filextras.com': []
};
links.forEach(link => {
const href = link.href;
if (href.startsWith('https://rg.to/folder/')) {
rgLink = href;
} else if (href.includes('rapidgator.net/file/')) {
otherLinks['rapidgator.net'].push(href);
} else if (href.includes('uploadgig.com/file/')) {
otherLinks['uploadgig.com'].push(href);
} else if (href.includes('nitroflare.com/')) {
otherLinks['nitroflare.com'].push(href);
} else if (href.includes('filextras.com/')) {
otherLinks['filextras.com'].push(href);
}
});
// First, create the buttons for rg.to links if available
if (rgLink) {
extractRGLinks(rgLink, quoteDiv);
}
// Then, create a "Copy all X links" button for each domain with links
for (const domain in otherLinks) {
if (otherLinks[domain].length > 0) {
createCopyButton(quoteDiv, `Copy all ${otherLinks[domain].length} ${domain} links`, otherLinks[domain]);
}
}
}
// Main function to run on page load
window.addEventListener('load', function() {
const quoteDivs = document.querySelectorAll('div.quote');
quoteDivs.forEach(quoteDiv => {
processQuoteDiv(quoteDiv);
});
});
})();