Extract Magnet Links

Extracts magnet links for selected rows and copies them to clipboard

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Extract Magnet Links
// @namespace    huichen3161.top
// @version      1.0
// @description  Extracts magnet links for selected rows and copies them to clipboard
// @author       huichen3161
// @match        https://u9a9.*
// @grant        GM_setClipboard
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create a button for selecting rows and copying magnet links
    const button = document.createElement('button');
    button.innerHTML = 'Copy Magnet Links';
    button.style.position = 'fixed';
    button.style.bottom = '20px';
    button.style.right = '20px';
    button.style.zIndex = '9999';
    button.addEventListener('click', copyMagnetLinks);
    document.body.appendChild(button);

    // Function to extract magnet links
    function extractMagnetLinks() {
        const rows = document.querySelectorAll('tr.default'); // Adjust this selector according to the structure of the webpage

        rows.forEach(row => {
            const checkbox = document.createElement('input');
            checkbox.type = 'checkbox';
            checkbox.style.marginRight = '5px';
            row.prepend(checkbox);
        });
    }

    // Function to copy selected magnet links to clipboard
    function copyMagnetLinks() {
        const selectedRows = document.querySelectorAll('tr.default input[type="checkbox"]:checked');

        const magnetLinks = [];
        selectedRows.forEach(row => {
            const link = row.parentNode.querySelector('a[href^="magnet:"]'); // Adjust this selector according to the structure of the webpage
            if (link) {
                magnetLinks.push(link.href);
            }
        });

        if (magnetLinks.length > 0) {
            const magnetLinksText = magnetLinks.join('\n');
            GM_setClipboard(magnetLinksText, 'text');
            alert('Magnet links copied to clipboard!');
        } else {
            alert('No magnet links found for the selected rows.');
        }
    }

    extractMagnetLinks();
})();