Skip to content

Instantly share code, notes, and snippets.

@WhiteAls
Last active December 14, 2015 17:39
Show Gist options
  • Save WhiteAls/5124089 to your computer and use it in GitHub Desktop.
Save WhiteAls/5124089 to your computer and use it in GitHub Desktop.
Reveals hidden torrents on Nyaa.eu
// ==UserScript==
// @author ъыь <Als@admin.ru.net> http://juick.com/Als/
// @name Nyaa unhider
// @description Reveals hidden torrents on Nyaa.eu
// @include http://www.nyaa.eu/
// @include http://www.nyaa.eu/?page=torrents&offset=*
// @version 1.0.1
// ==/UserScript==
var all_links = getElementsByXPath("//td[@class='tlistname']/a", document.getElementsByClassName("tlist")[0]);
var ptid = 0;
for (var link = 0; link < all_links.length; link++) {
var node = all_links[link];
var tid = parseFloat(node.href.split("tid=")[1]);
if (!ptid) {
ptid = tid;
continue;
}
if (ptid - tid < 2) {
for (var temp = 1; temp < ptid - tid; temp++) {
hid_tor_tr = insert_row(temp+tid);
node.parentNode.parentNode.parentNode.insertBefore(hid_tor_tr, node.parentNode.parentNode);
}
} else if (ptid - tid == 2) {
hid_tor_tr = insert_row(tid+1);
node.parentNode.parentNode.parentNode.insertBefore(hid_tor_tr, node.parentNode.parentNode);
}
ptid = tid;
}
function insert_row(tid) {
var hid_tor_tr = document.createElement("tr");
hid_tor_tr.setAttribute("class", "hidden tlistrow");
hid_tor_tr.setAttribute("style", "height: 39px;");
var hid_tor_td = document.createElement("td");
hid_tor_td.setAttribute("class", "tlistname");
hid_tor_td.setAttribute("colspan", "8");
hid_tor_td.setAttribute("style", "padding-left: 87px;");
var hid_tor_a = document.createElement("a");
hid_tor_a.setAttribute("href", "http://www.nyaa.eu/?page=torrentinfo&tid=" + tid);
hid_tor_a.textContent = "Probably hidden unknown torrent";
hid_tor_td.appendChild(hid_tor_a);
hid_tor_tr.appendChild(hid_tor_td);
return hid_tor_tr
}
function getElementsByXPath(xpath, root){
var result = document.evaluate(xpath, root, null, 0, null);
var nodes = new Array();
i = 0;
while (node = result.iterateNext()) {
nodes[i] = node;
i++;
}
return nodes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment