A simple script to remove dead torrents from the browser/search section of Nyaa.
当前为
// ==UserScript==
// @name NyaaTorrents
// @namespace http://tampermonkey.net/
// @version 1.0
// @description A simple script to remove dead torrents from the browser/search section of Nyaa.
// @author Arjix
// @match https://nyaa.si/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener("load", function () {
const title = document.querySelector("title").innerText
const allMeta = document.head.querySelectorAll("meta")
const desc = allMeta[allMeta.length - 1].content
if ("Browse :: Nyaa" === title || desc === "Nyaa homepage") {
let torrents = document.querySelectorAll(".table-responsive > table > tbody > tr")
var torrentsCount = torrents.length
for (var count=0; count < torrents.length; count++) {
if (torrents[count].childNodes[11].innerText == "0") {
torrents[count].parentNode.removeChild(torrents[count])
console.log("Removed torrent with index of: " + count.toString())
torrentsCount = torrentsCount-1
}
}
if (torrentsCount <= 0) {
let pagination = document.querySelectorAll("ul.pagination > li")
let nextPage = pagination[pagination.length - 1].childNodes[0].href
window.location.replace(nextPage)
}
}
}, false)
})();