// ==UserScript== // @name qBittorrent禁止迅雷用户 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description qBittorrent禁止迅雷用户 // @author Dahaozi // @match http://192.168.96.128:8081/ // ==/UserScript== const XMLHTTP = new XMLHttpRequest(); const TYPE = "GET"; const SYNC = "false"; const XUNLEI = ["XL", "Xunlei"] const IP = "192.168.96.128:8081" //按照此格式填写你的qBittorrent ip和端口 const url = "http://"+IP+"/api/v2/sync/torrentPeers?"; function send(hash) { const url_ = url + "rid=" + Math.ceil(Math.random(0, 1000) * 1000) + "&hash=" + hash XMLHTTP.open(TYPE, url_, SYNC); XMLHTTP.send(); }; function post(hash, peers) { const url_ = "http://"+IP+"/api/v2/transfer/banPeers?" + Math.ceil(Math.random() * 100000) const xhr = new XMLHttpRequest() xhr.open("POST", url_, false); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send("hash=" + hash + "&peers=" + peers.split(":")[0] + "%3A" + peers.split(":")[1]) //todo 打印结果 }; function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); }; async function fun(trs) { for (const i of trs) { send(i.rowId) XMLHTTP.onreadystatechange = function () { if (XMLHTTP.readyState == 4) { if (XMLHTTP.status == 200) { var re = JSON.parse(XMLHTTP.responseText) if(!re.peers) return; const keys = Object.keys(re.peers) const containsXL = keys.filter(v => { const node = re.peers[v].client return XUNLEI.filter(m => node.includes(m)).length != 0 }); for (const j of containsXL) j console.log("禁止用户=======================》") console.log(j) post(i.rowId, j) } } } } await sleep(500) } } (function () { 'use strict'; setInterval(() => { var trs = document.getElementById("torrentsTableDiv").children[0].children[1].children; fun(trs) }, 10000) })();