Skip to content

Instantly share code, notes, and snippets.

@HiFiPhile
Last active March 31, 2021 21:02
Show Gist options
  • Save HiFiPhile/e259343f9f87a6cfec5a6e81b479d02d to your computer and use it in GitHub Desktop.
Save HiFiPhile/e259343f9f87a6cfec5a6e81b479d02d to your computer and use it in GitHub Desktop.
PTS Alpha
// ==UserScript==
// @name PTS Show Alpha
// @namespace http://tampermonkey.net/
// @version 0.12
// @description try to take over the world!
// @author You
// @match https://pt.btschool.club/torrents.php*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var torrents = document.getElementsByClassName('torrents')[0];
var alpha = torrents.rows[0].insertCell(-1);
var ratio = torrents.rows[0].insertCell(-1);
alpha.innerText = "Alpha";
ratio.innerText = "Ratio";
for (var r=1; r<torrents.rows.length; r++){
alpha = torrents.rows[r].insertCell();
ratio = torrents.rows[r].insertCell();
// Calc Ti
var ti = (Date.now() - Date.parse(torrents.rows[r].cells[3].getElementsByTagName("span")[0].title)) / 1000;
var tz = new Date();
ti += tz.getTimezoneOffset() * 60 + 8 * 3600;
ti /= 86400 * 7;
// Calc Si
var sz = torrents.rows[r].cells[4].innerText.split('\n');
var si = parseFloat(sz[0]);
if(sz[1] == "KB"){
si /= 1000000;
}
if(sz[1] == "MB"){
si /= 1000;
}
if(sz[1] == "TB"){
si *= 1000;
}
// Get Ni
var ni = parseFloat(torrents.rows[r].cells[5].innerText);
// Constant
var t0 = 200;
var no = 7;
// Calc
alpha.innerText = ((1 - Math.pow(10, -ti / t0)) * si * (1 + 1.1412 * Math.pow(10, (-ni - 1) / (no - 1)))).toFixed(2);
ratio.innerText = ((1 - Math.pow(10, -ti / t0)) * si * (1 + 1.1412 * Math.pow(10, (-ni - 1) / (no - 1))) / si).toFixed(2);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment