ClipTags (RED/OPS)

Adds a button to copy tags as comma-separated from RED/OPS torrents, artists and requests pages.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         ClipTags (RED/OPS)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a button to copy tags as comma-separated from RED/OPS torrents, artists and requests pages.
// @match        https://redacted.sh/torrents.php?id=*
// @match        https://orpheus.network/torrents.php?id=*
// @match        https://redacted.sh/artist.php?id=*
// @match        https://orpheus.network/artist.php?id=*
// @match        https://redacted.sh/requests.php?action=view&id=*
// @match        https://orpheus.network/requests.php?action=view&id=*
// @grant        GM_setClipboard
// @author       rodriguito
// ==/UserScript==

(function() {
    'use strict';

    function extractTags(container) {
        const tagLinks = container.querySelectorAll('a[href*="taglist="]');

        const tags = Array.from(tagLinks)
            .map(a => a.textContent.trim())
            .filter(Boolean);

        return [...new Set(tags)].join(',');
    }

    function findTagsContainer() {
        const elements = document.querySelectorAll('div, td, li');

        for (let el of elements) {
            const text = (el.innerText || el.textContent || "").trim();

            if (text.startsWith("Tags")) {
                return el;
            }
        }

        return null;
    }

    function findTagsLabel(container) {
        const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT);

        let node;
        while (node = walker.nextNode()) {
            if (node.nodeValue.trim() === "Tags") {
                return node.parentElement;
            }
        }

        return null;
    }

    function insertButton(labelEl, container) {
        if (!labelEl || labelEl.querySelector('.copy-tags-btn')) return;

        labelEl.style.display = 'flex';
        labelEl.style.justifyContent = 'space-between';
        labelEl.style.alignItems = 'center';

        const btn = document.createElement('button');
        btn.textContent = "Copy Tags";
        btn.className = "copy-tags-btn";
        btn.style.padding = "2px 6px";
        btn.style.fontSize = "11px";
        btn.style.cursor = "pointer";

        btn.addEventListener('click', () => {
            const result = extractTags(container);

            if (!result) {
                alert("No tags found.");
                return;
            }

            GM_setClipboard(result);

            btn.textContent = "Copied!";
            setTimeout(() => btn.textContent = "Copy Tags", 1500);
        });

        labelEl.appendChild(btn);
    }

    function init() {
        const container = findTagsContainer();
        if (!container) return;

        const label = findTagsLabel(container);
        if (!label) return;

        insertButton(label, container);
    }

    window.addEventListener('load', () => {
        setTimeout(init, 500);
    });

})();