Last active
April 15, 2024 17:39
-
-
Save edgesider/e727a3d8455861e77e5a5339ba889076 to your computer and use it in GitHub Desktop.
显示MTeam-余额(分享率大于3)
This file contains hidden or 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 M-Team 余额 | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-02-25 | |
// @description try to take over the world! | |
// @author You | |
// @match https://kp.m-team.cc/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=m-team.cc | |
// @grant none | |
// ==/UserScript== | |
function toMB(amount, unit) { | |
if (unit === 'T') { | |
return amount * 1024 * 1024; | |
} else if (unit === 'G') { | |
return amount * 1024; | |
} | |
} | |
(function() { | |
'use strict'; | |
let ok = false; | |
let tries = 0; | |
const timer = setInterval(() => { | |
if (tries > 10) { | |
clearInterval(timer); | |
return; | |
} | |
tries += 1; | |
const text = document.querySelector('div.ant-row:nth-child(4)').innerText.replaceAll('\n', ' '); | |
const [_, ratio, up, upUnit, down, downUnit] = /分享率:([\d\.]*) 上傳量:([\d\.]*) (.)B 下載量:([\d\.]*) (.)B/.exec(text); | |
const upMB = toMB(up, upUnit) | |
const downMB = toMB(down, downUnit); | |
console.log(upMB, downMB) | |
const remainGB = (upMB / 3 - downMB) / 1024; | |
const parent = document.querySelector('div.ant-row:nth-child(4) > div:nth-child(1) > div:nth-child(1)'); | |
parent.innerHTML += ` <span><span style="color: #008B8B">余额:</span><span>${remainGB.toFixed(2)}GB</span></span>`;; | |
ok = true; | |
clearInterval(timer); | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment