Greasy Fork

Redirect Avistaz Profile

Redirects Avistaz profiles to a specific URL

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

// ==UserScript==
// @name         Redirect Avistaz Profile
// @namespace    http://your-namespace.com
// @version      1.1
// @description  Redirects Avistaz profiles to a specific URL
// @author       Your Name
// @match        https://avistaz.to/profile/*/history
// @match        https://avistaz.to/profile/*/history*
// @grant        none
// @run-at       document-end
// ==/UserScript==

function AddedSeeding() {
  const table = document.querySelector("table"); // Assuming there's only one table
  const rows = table.querySelectorAll("tr");

  for (let i = 1; i < rows.length; i++) { // Start from index 1 to skip the header row
    const cells = rows[i].querySelectorAll("td");

    // const Title = cells[1].querySelector('.torrent-filename').getAttribute('data-original-title');
    // const Href =  cells[1].querySelector('.torrent-filename').getAttribute('href');
    // const Active = cells[3].textContent;
    // const Completed = cells[4].textContent;
    // const Seeders = cells[1].querySelector('.fa-arrow-up.text-green').textContent;
    // const Leechers = cells[1].querySelector('.text-red').textContent;
    // const CompletedNr = cells[1].querySelector('.text-blue').textContent;
    // const rawFilesize = cells[1].querySelector('.text-orange').textContent;
    // const Filesize= rawFilesize.match(/\d+(\.\d+)?/g);
    const rawDownload = cells[6].querySelector('.text-red').textContent;
    const Download = rawDownload.match(/\d+(\.\d+)?/g);
    // const rawUpload = cells[5].querySelector('.text-green').textContent;
    // const Upload = rawUpload.match(/\d+(\.\d+)?/g);
    // const Ratio = cells[7].querySelector('.text-bold').textContent;
    const Seededtimeraw=cells[10].querySelector('span').getAttribute('data-original-title');
    const reggy = /(\d+(\.\d+)?)/g;
    const Seedingtimeraw= Seededtimeraw.match(reggy);
    const intSeed = parseInt(Seedingtimeraw);
    const Seedingtime=Math.ceil(intSeed/60);
    var regex=/(\d+(\.\d+)?)\s*(GB|MB|KB|TB|B)\b/i;
    var match = rawDownload.match(regex);
    if (match == null) {
      match = "0";
  } else {

      var value = parseFloat(match[1]);
      var unit = match[3];

      if (unit === "GB") {
          value = value;
      } else if (unit === "TB") {
          value = value * 1024;
      } else if (unit === "KB") {
          value = value / 1024 / 1024;
      } else if (unit === "MB") {
          value = value / 1024;
      }
  }

    var roundedNumber3 = value;
    unit=match[3];

    if (roundedNumber3===0)
    {
      result="0"
    }
    else if (roundedNumber3 <= 1)
    {
      result = 72;
    }
    else if (roundedNumber3 > 1 && roundedNumber3 < 50)
    {
      result = 72 + 2 * roundedNumber3;
    }
    else if (roundedNumber3 > 50)
    {
      result = 100 * Math.log(roundedNumber3) - 219.2023;
    }

    result = Math.ceil(result);

    difference=result-Seedingtime

  const appendedValue = Seedingtime; // Change this to your calculated value

  const cellToModify = cells[10];
  const textToDisplay = Seedingtime + 'h / ' + result + 'h';
  // Set the text content of the cell to the created text string
  cellToModify.textContent = textToDisplay;
  }
}

AddedSeeding()