real-debrid torrents: textbox with all links

adds a button which when pressed creates a textbox with all links for you to copy in jDownloader2

当前为 2022-01-23 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         real-debrid torrents: textbox with all links
// @namespace    https://greasyfork.org/en/users/12725-alistair1231
// @version      0.2
// @description  adds a button which when pressed creates a textbox with all links for you to copy in jDownloader2
// @author       Alistair1231
// @match        https://real-debrid.com/torrents
// @icon         https://icons.duckduckgo.com/ip2/real-debrid.com.ico
// @grant        none
// @require     https://code.jquery.com/jquery-3.6.0.min.js
// @license GPL-3.0
// ==/UserScript==

(function () {


    var linkButton = document.createElement("input");
    linkButton.type = "button";
    linkButton.value = "Show Links";
    linkButton.onclick = function () {
        createTextArea();
    }
    // align right
    jQuery(linkButton).css("float", "inline-end");
    // make vertically centered
    jQuery(linkButton).css("margin-top", "10px");

    jQuery(".content_separator_mini")[1].append(linkButton);


    function createTextArea() {
        var textbox = document.createElement("textarea");

        jQuery(textbox).css({ "position": "fixed", "width": "80%", "height": "80%", "z-index": "999998", "background": "rgba(0,0,0,0.7)", "color": "#fff", "font-size": "16px", "font-family": "Consolas", "padding": "10px", "resize": "none", "outline": "none", "border": "none", "box-shadow": "0 0 10px #fff", "-webkit-box-shadow": "0 0 10px #fff", "-moz-box-shadow": "0 0 10px #fff", "-o-box-shadow": "0 0 10px #fff", "left": "10%", "top": "8%" });
        // get all the links
        var links = jQuery.makeArray(jQuery("tr form[action='./downloader'] textarea")).map(e => e.value);
        var names = jQuery.makeArray(jQuery("tbody  td.t-left span")).map(x => x.innerText);
        names.forEach((x, i) => {
            links[i] = links[i] + "#name=" + x;
            console.log(links[i]);
        });
        // add the links to the textbox
        textbox.value = links.join('\n');

        document.getElementsByTagName("body")[0].prepend(textbox);
        // highlight the text in the textbox
        textbox.select();


        //create close button in top right corner
        var close = document.createElement("div");
        jQuery(close).css({ "position": "fixed", "top": "10%", "right": "10%", "width": "30px", "height": "30px", "background": "#fff", "border-radius": "50%", "cursor": "pointer", "text-align": "center", "line-height": "30px", "font-size": "25px", "font-weight": "bold", "color": "#000", "z-index": "999999" });
        close.innerHTML = "X";
        //when button clicked remove elements
        jQuery(close).click(function () {
            jQuery(textbox).remove();
            jQuery(close).remove();
        });

        // remove elements when escape is pressed
        jQuery(document).keyup(function (e) {
            if (e.keyCode == 27) {
                jQuery(textbox).remove();
                jQuery(close).remove();
            }
        });

        //remove elements when clicked outside of them
        jQuery(document).click(function (e) {
            if (e.target != textbox && e.target != close && e.target != linkButton) {
                jQuery(textbox).remove();
                jQuery(close).remove();
            }
        });
        document.getElementsByTagName("body")[0].prepend(close);


    }
})();