// ==UserScript== // @name KickassTorrents Screenshot Redirect. // @version 0.1.2 // @description Redirects user to one of the screenshot links in the torrent's description after a delay. Also includes a link to search for screenshots on google images using a cleaned up version of the torrent's title. // @match kat.cr/* // @namespace https://greasyfork.org/users/13708 // @downloadURL none // ==/UserScript== //User Adjustable Variables & Arrays: //----------------------------------- //Amount of seconds to delay before redirecting. var TotalSeconds = 10; //Phrases to look for in links located in the description when deciding which links go to image hosting sites. var terms = ["funimg","imgextra","imgcandy","imgstudio","imgdino","imgmega","imgzap","imgtiger","imagedecode","pixsor","imgstudio","screens","imgtrex","damimage","image","pornleech","imgserve","imgclick","imgbb","screen"]; //Phrases to take out of the torrent's title when adding it to the screenshot search link. var titleterms = ["mp4"," xxx ","1080p","720p","Split Scenes","new release","dvdrip"," sd ","new","web-dl","x264","sparrow"]; //Empty variables. var timer; var titletermregex; var dateregex; var titledate; //Grab the description element. var desc = document.getElementById("desc"); //Create an element for redirect information. var node = document.createElement("P"); desc.insertBefore(node,desc.childNodes[0]); //Create an element for title search information. var searchbutton = document.createElement("P"); desc.insertBefore(searchbutton,desc.childNodes[0]); //Grab the title of the torrent. var torrenttitle = document.getElementsByClassName("novertmarg")[0].getElementsByTagName("a")[0].textContent; //Go through the titleterms and remove any instances of them. for (var i3 = 0 ; i3 < titleterms.length; i3++){ titletermregex = new RegExp(titleterms[i3],"gi"); torrenttitle = torrenttitle.replace(titletermregex," ");} //Find a date in the title and eventually replace it with the year. var dateextract = /\d{2}\/\d{2}\/\d{2,4}/g; //Formats for 00/00/0000 or 00/00/00 var founddate = dateextract.exec(torrenttitle); //Find the date in the torrent tittle. console.log("founddate: " + founddate); if (founddate == null){ //If its unable to find a date formatted 00/00/0000, look for one formatted 00.00.0000 console.log("Initial founddate was null, searching with another format."); var dateextract = /\d{2}.\d{2}.\d{2,4}/g; //Formats for 00.00.0000 or 00.00.00 var founddate = dateextract.exec(torrenttitle); //Find the date in the torrent tittle. console.log("We had to look for a second date: " + founddate); } var yearextract = /\d{2,4}$/g; //Formats for two to four digits at the end of the input. var foundyear = yearextract.exec(founddate); //Find the year in the found date. console.log("foundyear: " + foundyear); if (foundyear !== null){ //Check to see if any year was found. if (foundyear.toString().length == 4){ //If the found year is four digits long console.log("foundyear is 4 digits long."); torrenttitle = torrenttitle.replace(founddate,foundyear); //Replace the found date with the found year. console.log("Replaced: " + founddate + " with " + foundyear); } else if (foundyear.toString().length == 2){ //If the found year is not four digits long but is two digits long. console.log("foundyear is 2 digits long."); torrenttitle = torrenttitle.replace(founddate,"20"+foundyear); //Replace the found date with the found year with "20" infront of it. console.log("Replaced: " + founddate + " with " + "20"+foundyear); } } else { //If no year was found. console.log("No year is found."); } //Look for date formatted Month 00, 0000. (Not included in the above code since both are sometimes included.) var dateextract = /[a-zA-Z]{3,9}\s+\d{1,2}\s*,?\s*\d{4}/g; //Formats Month 00, 0000. http://www.htmlgoodies.com/html5/javascript/date-parsing-using-javascript-and-regular-expressions.html#fbid=bYzXbVT0mSd var founddate2 = dateextract.exec(torrenttitle); //Find the date in the title. console.log("founddate2: " + founddate2); if (founddate2 !== null){ //If we found a date formated Month 00, 0000. console.log("founddate2 exists, lookng for the year."); var yearextract = /\d{4}$/g; //Formats for four digits at the end of the input. var foundyear2 = yearextract.exec(founddate2); //Find the year in the found date. console.log("Found year: " + foundyear2 + " from founddate2."); if(torrenttitle.indexOf(foundyear2) >= -1 && foundyear !== null){ //Find if the foundyear2 is in torrenttittle and year1 was found console.log(foundyear2 + " already belongs in torrenttitle from another search."); torrenttitle = torrenttitle.replace(founddate2," "); //Remove the found date from the title. console.log("Removed " + founddate2 + " from torrenttitle."); }else{ console.log(foundyear2 + " belongs in the torrenttittle but not from another search"); torrenttitle = torrenttitle.replace(founddate2,foundyear2); //Replace the found date with the found year. console.log("Replaced: " + founddate2 + " with " + foundyear2); } } else{ console.log("No Month 00, 0000 date found."); } //Remove special characters. torrenttitle = torrenttitle.replace(/[\-\[\]\/\{\}\(\)\=\*\+\.\\\^\$\|]/g, " "); //Create a link to search for screenshots. var searchlinktext = "Search Google Images for screenshots."; var searchlink = searchlinktext.link("https://www.google.com/search?q=" + torrenttitle + "+porn&tbm=isch"); searchbutton.innerHTML = "