Last active
November 13, 2019 12:06
-
-
Save KCCat/e7e681c1595bfa80bd1e7fedf222122e to your computer and use it in GitHub Desktop.
自动BAN吸血雷 QBit,推荐使用/query/getLog页面来跑脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 自动BAN吸血雷 QBit | |
// @namespace QBit-KCC | |
// @author KCC | |
// @version 0.01.0 | |
// @match *://0.0.0.0:9898/* | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== | |
function interval(func, wait){ | |
var interv = function(){ | |
func.call(null); | |
setTimeout(interv, wait); | |
}; | |
setTimeout(interv, wait); | |
} | |
var BL = {}; | |
var main = () => fetch('/api/v2/torrents/info?filter=active') ///fetch(new Request('/api/v2/torrents/info?filter=active')) | |
.then((response) => response.json()) | |
.then((_list) => _list.map((e) => e.hash )) | |
.then((tHash) => Promise.all(tHash.map((e) => fetch('/api/v2/sync/torrentPeers?hash='+ e ) | |
.then((response) => response.json()) | |
.then((e) => Object.values(e.peers)) | |
.then((_list) => _list.filter((e) => !e.client.indexOf("-XL") && e.downloaded < 1024)) | |
.then((_list) => _list.map((e) => BL[e.ip]=Date.now())) | |
) | |
) | |
) | |
.then((_) => Object.keys(BL).filter((e) => BL[e] < Date.now()-60*60*1000 )) | |
.then((_list) => {_list.map((e) => {delete BL[e];return "_"} );if ( Object.keys(BL).length ){ return "_" } else { throw "pass" };}) | |
.then((_) => fetch("/api/v2/app/setPreferences", {"headers":{"content-type":"application/x-www-form-urlencoded"},"method":"POST","body":"json="+JSON.stringify( {"banned_IPs": Object.keys(BL).join("\n")} )}) | |
) | |
.catch( (e)=>"console.log(e)" ) | |
GM_registerMenuCommand('BAN 吸血雷', ()=>interval(main,10000)); | |
"#()=>setInterval(main,10000)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment