Greasy Fork is available in English.
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. -
当前为
// ==UserScript==
// @name Avistaz Plus
// @version 1.4.1
// @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*
// @match https://avistaz.to/torrent*
// @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 Seededtimeraw = cells[10].querySelector('span').getAttribute('data-original-title');
const Seedingtimeraw = Seededtimeraw.match(/(\d+(\.\d+)?)/g);
const Seedingtime = Math.ceil(parseInt(Seedingtimeraw) / 60);
const Ratio = cells[7].querySelector('.text-bold').textContent;
const rawDownload = cells[6].querySelector('.text-red').textContent;
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];
unit === "TB" ? DownloadedGB *= 1024 : unit === "MB" ? DownloadedGB /= 1024 : unit === "KB" ? DownloadedGB /= 1024 ** 2 : DownloadedGB = DownloadedGB
}
else Match = "0";
var result = DownloadedGB <= 1 ? result = 72 : DownloadedGB > 1 && DownloadedGB < 50 ? result = Math.ceil(72 + 2 * DownloadedGB) : DownloadedGB > 50 ? result = Math.ceil(100 * Math.log(DownloadedGB) - 219.2023) : 0
var difference = result - Seedingtime
const appendedValue = Seedingtime;
const seedingCell = cells[10];
const textToDisplay = Seedingtime + 'h / ' + result + 'h';
seedingCell.textContent = textToDisplay;
Seedingtime > result ? seedingCell.style.color = 'green' : seedingCell.style.color = 'red';
const ratioCell = cells[7];
ratioCell.textContent = Ratio;
ratioCell.classList.add('badge-extra'); // Add the classes
ratioCell.style.marginLeft = '5px'; // Adjust the left spacing as needed
ratioCell.style.marginTop = '5px'; // Adjust the top spacing as needed
Ratio > 0.9 ? ratioCell.style.color = 'green' : ratioCell.style.color = 'lightcoral';
});
}
function HitandRun() {
const data = [];
var table = document.querySelector("#content-area > div:nth-child(5) > div.table-responsive");
document.querySelectorAll('tbody > tr').forEach(el => {
const cells = el.querySelectorAll('td');
var name = cells[0].innerText;
console.log(name)
if (name.includes('Size')) {
const rawDownload = cells[1].textContent;
console.log(rawDownload)
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];
unit === "TB" ? DownloadedGB *= 1024 : unit === "MB" ? DownloadedGB /= 1024 : unit === "KB" ? DownloadedGB /= 1024 ** 2 : DownloadedGB = DownloadedGB
}
var result = DownloadedGB <= 1 ? result = 72 : DownloadedGB > 1 && DownloadedGB < 50 ? result = Math.ceil(72 + 2 * DownloadedGB) : DownloadedGB > 50 ? result = Math.ceil(100 * Math.log(DownloadedGB) - 219.2023) : 0
var days = Math.floor(result / 24);
// Calculate the remaining hours
var hours = result % 24;
// Now, 'days' contains the whole days, and 'hours' contains the remaining hours
console.log(days + ' days and ' + hours + ' hours');
const size = cells[1].textContent;
var clone = el.cloneNode(true);
var cloneCells = clone.querySelectorAll('td');
cloneCells[0].textContent = "Hit and Run";
cloneCells[0].style.fontWeight = 'bold';
cloneCells[1].textContent = `If you download this torrent you will need to upload ${rawDownload} or seed for ${days} days and ${hours} hours.`;
el.parentNode.insertBefore(clone, el.nextSibling);
return;
}
})
}
// This checks the URL and picks which function to run.
var currentURL = window.location.href;
console.log(currentURL)
// Check the URL and decide which function to execute
if (currentURL.includes("/history")) {
AddedSeeding(); // Execute function for Type 1 URL
} else if (currentURL.includes("/torrent")) {
HitandRun(); // Execute function for Type 2 URL
} else {
// Handle other URLs or provide a default action
console.log("This URL doesn't match any known types");
}
// Many thanks to the kind person that showed interest in this code!