Skip to content

Instantly share code, notes, and snippets.

@neckothy
Created September 17, 2023 06:33
Show Gist options
  • Save neckothy/fd580d7f6d0be583707b8d2d9114c276 to your computer and use it in GitHub Desktop.
Save neckothy/fd580d7f6d0be583707b8d2d9114c276 to your computer and use it in GitHub Desktop.
simple text and regex filtering for results on nyaa.si
// ==UserScript==
// @name nyaa filter
// @namespace Violentmonkey Scripts
// @match https://nyaa.si/
// @grant none
// @version 1.01
// @author neck
// @description simple text and regex filtering for results on nyaa.si
// ==/UserScript==
// list of strings to filter (case sensitive)
const filters = [
"Digital-Compilation",
"Webtoon",
"Scanlation",
"Audiobook",
"Colored",
"Officially Translated Light Novels",
];
// list of regex to filter
const filtersRe = [
/\((Oak|anadius|empyrealarrow|Tapas|Tappytoon|Manta)\)( \[[Cc]ompleted?\]| \| Ongoing)?$/,
/^\[(Dalte|Pajeet)\]/,
/\[(CBR|CBZ)( \| (CBR|CBZ))?\]/,
/prepub/i
];
const torrents = document.querySelectorAll(".table-responsive > table > tbody > tr");
let count = 0;
for (torrent of torrents) {
const title = torrent.querySelector("td:nth-child(2)").innerText;
let filtered = false;
for (const filter of filters) {
if (title.includes(filter)) {
torrent.parentNode.removeChild(torrent);
count++;
filtered = true;
break;
}
}
if (!filtered) {
for (const filter of filtersRe) {
if (title.match(filter)) {
torrent.parentNode.removeChild(torrent);
count++;
filtered = true;
break;
}
}
}
}
console.log("nyaa filter: removed " + count + " torrents from results")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment