NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name KickAssOptimizer
// @namespace KickAssOptimizer
// @include https://kat.cr/*
// @version 1
// @grant none
// ==/UserScript==
var trs, td;
trs = document.querySelectorAll("table table.data.frontPageWidget tr");
AjaxTorrent = function(){
var l,dl;
if(this.hasAttribute("ajaxedMark")){
return false;
}
else{
this.setAttribute("ajaxedMark",true);
if(this.querySelector("a.cellMainLink")){
l = this.querySelector("a.cellMainLink");
dl=document.createElement("a");
dl.className = "telechargement kaButton smallButton rightButton floatright";
dl.textContent = "Torrent";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState==4 && (xhr.status==200 || xhr.status==0)) {
if(xhr.responseText.length>=0){
dl.href="https://torcache.net/"+xhr.responseText.match(/torrent\/[A-F0-9]{35,}/gm)[0]+".torrent?title="+l.innerHTML.replace(/ /g,'%20');
l.parentNode.parentNode.insertBefore( dl, l.parentNode.parentNode.children[1] );
}
}
}
xhr.open("GET", l.href, true);
xhr.send(null);
}
}
}
for(var i=0; i<trs.length; i++){
td=trs[i].cells[0];
td.addEventListener("mouseover",AjaxTorrent,false);
//AjaxTorrent.call(td);
}