Greasy Fork

Avistaz +

This extension simply calculates the required seeding time and displays it in the hours seeded box. Colors Ratio accordingly. Many other QOL features to come. - This is not affiliated with Avistaz. At all. -

目前为 2023-09-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         Avistaz +
// @version      1.3
// @description  This extension simply calculates the required seeding time and displays it in the hours seeded box. Colors Ratio accordingly. Many other QOL features to come.  - This is not affiliated with Avistaz. At all. - 
// @author       Improved Avistaz
// @match        https://avistaz.to/profile/*/history*
// @grant        none
// @run-at       document-end
// @namespace http://your-namespace.com
// ==/UserScript==

function AddedSeeding() {
    document.querySelectorAll('tbody > tr').forEach(el =>
    {
        const cells = el.querySelectorAll('td');
        const rawDownload = cells[6].querySelector('.text-red').textContent;
        const Seededtimeraw = cells[10].querySelector('span').getAttribute('data-original-title');
        const Seedingtimeraw = Seededtimeraw.match(/(\d+(\.\d+)?)/g);
        const Seedingtime = Math.ceil(parseInt(Seedingtimeraw) / 60);
        var Match = rawDownload.match(/(\d+(\.\d+)?)\s*(GB|MB|KB|TB|B)\b/i);
        if (Match)
        {
            var DownloadedGB = parseFloat(Match[1]);
            var unit = Match[3];
            if (unit === "TB") DownloadedGB *= 1024;
            if (unit === "GB") DownloadedGB = DownloadedGB;
            if (unit === "MB") DownloadedGB /= 1024;
            if (unit === "KB") DownloadedGB /= 1024 **2 ;

        }
        else Match = "0";

        if (DownloadedGB === 0) var result = "0";
        if (DownloadedGB <= 1) result = 72;
        if (DownloadedGB > 1 && DownloadedGB < 50) result = 72 + 2 * DownloadedGB;
        if (DownloadedGB > 50) result = 100 * Math.log(DownloadedGB) - 219.2023;

        result = Math.ceil(result);

        var difference = result - Seedingtime;
        const appendedValue = Seedingtime;
        const cellToModify = cells[10];
        const textToDisplay = Seedingtime + 'h / ' + result + 'h';
        cellToModify.textContent = textToDisplay;
        Seedingtime > result ? cellToModify.style.color = 'green' : cellToModify.style.color = 'lightcoral';
    });
}
AddedSeeding();

// Many thanks to the kind person that showed interest in this code!