Click to add tasks to local rrshare download service

try to take over the world!

目前為 2020-10-09 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Click to add tasks to local rrshare download service
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  try to take over the world!
// @author       You
// @match        *://*/*
// @grant        GM_xmlhttpRequest
// @require    https://code.jquery.com/jquery-3.5.1.min.js
// ==/UserScript==

(function() {

    $(document).ready(function(){
        // 延时绑定点击事件
        setTimeout(function(){
            console.log(100);
            doBind();
        }, 100);
        // 延时绑定点击事件
        setTimeout(function(){
            console.log(200);
            doBind();
        }, 200);
        // 延时绑定点击事件
        setTimeout(function(){
            console.log(300);
            doBind();
        }, 300);
    });

    // 任意点击绑定点击事件
    $(document).click(function(){
        doBind();
    });

    function doBind(){
        $('a').click(function(){
            if($(this).attr('href')){
                var link = $(this).attr('href');
                if(link.indexOf('yyets://') == 0){
                    GM_xmlhttpRequest({
                        method: 'post',
                        url: "http://{IP:PORT}/api/addtask",
                        data: "tasks="+"[\""+link+"\"]",
                        headers: {'Access-Control-Allow-Origin': '*','Content-Type': "application/x-www-form-urlencoded", 'Cookie':"session={Your session}"},
                        onload: function(response) {
                            console.log(link);
                        }
                    });

                }
            }
        });
    }
})();