// ==UserScript== // @name The Pirate Bay Cleaner v3 // @description THERE ARE TOO MANY FEATURES TO LIST IN THE DESCRIPTION! Auto Sorting, Torrentifying, Theme Change, Search Change, SSL/HTTPS and more... (see the 3rd screen shot for a list of features) // @namespace https://userscripts.org/users/boku/145020/v3 // @icon https://s3.amazonaws.com/uso_ss/icon/145020/large.png?1368115417 // @license The Pirate Bay Cleaner is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. // @include http*thepiratebay.* // @exclude *google.com* // @exclude http*thepiratebay.*/ajax* // @exclude http*rss.thepiratebay.* // @version 3.10.0 // @require https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js // @grant GM_getValue // @grant GM_setValue // @noframes // @downloadURL none // ==/UserScript== /* Set all the variables that I will need and defaults if not used etc. */ torrentify=GM_getValue("torrentify",true); imdb=GM_getValue("imdb",true); linkify_all=GM_getValue("linkify_all",false); info=GM_getValue("info",true); alternate=GM_getValue("alternate",false); ebay=GM_getValue("ebay",false); amazon=GM_getValue("amazon",false); color_code=GM_getValue("color_code",true); color_code_yday=GM_getValue("color_code_yday","#FF7F7F"); color_code_today=GM_getValue("color_code_today","#FFE77F"); color_code_minutes=GM_getValue("color_code_minutes","#7FFF8C"); trust=GM_getValue("trust",true); filter=GM_getValue("filter",true); filter_text=GM_getValue("filter_text","malayalam|cam|dvdscr|hdrip|webrip|vcd|tv rip|hindi|hdtvrip|screener"); pornfilter=GM_getValue("pornfilter",false); pornfilter_text=GM_getValue("pornfilter_text",""); pornremove=GM_getValue("pornremove",false); magnet=GM_getValue("magnet",false); anonymous=GM_getValue("anonymous",true); sorting=GM_getValue("sorting",false); sorting_value=GM_getValue("sorting_value","sd"); https=GM_getValue("https",true); theme=GM_getValue("theme",false); google=GM_getValue("google",true); stretch=GM_getValue("stretch",true); ads=GM_getValue("ads",true); single=GM_getValue("single",false); images=GM_getValue("images",true); comments=GM_getValue("comments",true); remotetorrent=GM_getValue("remotetorrent",true); remotetorrent_client = GM_getValue("remotetorrent_client",'1'); remotetorrent_client_mode = GM_getValue("remotetorrent_client_mode",'lightbox'); transmission_url=GM_getValue("transmission_url",''); if(transmission_url.length > 0 && !/^(ht)tps?:\/\//i.test(transmission_url)) transmission_url = 'http://'+transmission_url; save_history=GM_getValue("save_history",true); torrent_history=GM_getValue("torrent_history",''); torrent_history_array = torrent_history.split(','); save_faves=GM_getValue("save_faves",true); the_faves=GM_getValue("the_faves",''); the_faves_array = the_faves.split(','); refresh=GM_getValue("refresh",false); refresh_duration=GM_getValue("refresh_duration",1800000) refresh_duration_int=refresh_duration; url=location.href; domain=url.split('/')[2]; PageRefresher = false; window.Escapable = false; /* Declare all the functions that will be used throughout script */ /* Set cookies function, name, value and days until expiry */ function setCookie(c_name,value,exdays){ var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; path=/; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } /* Retrieve a cookie value */ function getCookie(c_name){ var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i form').submit(function(e){ e.preventDefault(); if(google==true){ if (https==true){ var qval = $('.https_form').val(); $('.https_form').val(qval + ' site:' + domain + '/torrent'); } else { var qval = $('#inp > input').val(); $('#inp > input').val(qval + ' site:' + domain + '/torrent'); } } this.submit(); }); $('#header > form').submit(function(e){ e.preventDefault(); if(google==true){ if (https==true){ var qval = $('.searchBox').val(); $('.searchBox').val(qval + ' site:' + domain + '/torrent'); } else { var qval = $('.inputbox').val(); $('.inputbox').val(qval + ' site:' + domain + '/torrent'); } } this.submit(); }); /* If told to use HTTPS then set page to it */ if(url.substring(0,5)=="http:" && https==true){ if ( !getCookie('lw') && single==true ){ setCookie('lw','s',999); } location.replace(url.replace(url.substring(0,5),"https:")); } else if(url.substring(0,6)=="https:" && https==false){ if ( !getCookie('lw') && single==true ){ setCookie('lw','s',999); } location.replace(url.replace(url.substring(0,6),"http:")); } /* Update cookies that potentially causes popups to expire in the year 2050 */ var FutureDate = new Date(); FutureDate.setFullYear( 2050 ); if( getCookie('tpbpop') ){ document.cookie = "tpbpop=" + getCookie('tpbpop') +"; path=/; expires=" + FutureDate.toUTCString(); }if( getCookie('__PPU_SESSION_0-3') ){ document.cookie = "__PPU_SESSION_0-3=" + getCookie('__PPU_SESSION_0-3') +"; path=/; expires=" + FutureDate.toUTCString(); } document.cookie = "__PPU_CHECK=1; path=/; expires=" + FutureDate.toUTCString(); /* Checks if supposed to be single or double row and converts it if not set correctly */ if (!getCookie('lw') && single==true){ setCookie('lw','s',999); location.reload(); } else if (getCookie('lw') && single==false){ setCookie('lw','',-9999); } /* Convert milliseconds to real time HH:MM:SS */ function msToTime(s){ var arrTime = new Array(); var ms = s % 1000; s = (s - ms) / 1000; var secs = s % 60; s = (s - secs) / 60; var mins = s % 60; var hrs = (s - mins) / 60; strHrs = "0" + hrs; strHrs = strHrs.substr(strHrs.length - 2); strMins = "0" + mins; strMins = strMins.substr(strMins.length - 2); strSecs = "0" + secs; strSecs = strSecs.substr(strSecs.length - 2); if(hrs > 0){ arrTime['TheTime'] = strHrs + ':' + strMins; arrTime['TheTimeAsWords'] = hrs + " Hours and " + mins + " Minutes"; } else if(mins > 0){ arrTime['TheTime'] = strMins + ':' + strSecs; arrTime['TheTimeAsWords'] = mins + " Minutes and " + secs + " Seconds"; } else if(secs > 0){ arrTime['TheTime'] = strSecs; arrTime['TheTimeAsWords'] = secs + " Seconds"; } return arrTime; } /* The page refresh function */ function TogglePageRefresh(){ if(!PageRefresher){ setCookie(url, 'AutoRefresh',999); refresh_duration=GM_getValue("refresh_duration") $("#refresh_button").attr('onmouseover' , "this.style.background='url(//i.imgur.com/u4tV1h1.png) 0px 40px'"); $("#refresh_button").attr('onmouseout' , "this.style.background='url(//i.imgur.com/u4tV1h1.png) 0px 0px'"); $("#refresh_button").attr('title' , "Turn Off Auto Refresh"); var noti_bubble = document.createElement('div'); noti_bubble.id = "noti_bubble"; noti_bubble.style.cssText = 'z-index:9999; max-width:80px; position:absolute; padding:1px 2px 1px 2px; color:white; font-weight:bold; border-radius:30px; float:right; box-shadow:1px 1px 1px gray; left:' + $("#refresh_button").position().left + 'px;'; $('#tpbc_btn_container').append(noti_bubble); /* Set the initial countdown time appearance */ var TimeDetails = msToTime(refresh_duration); $('#noti_bubble').html( TimeDetails['TheTime'] ); noti_bubble.title = TimeDetails['TheTimeAsWords'] + " Until Refresh"; if(refresh_duration <= 60000){ noti_bubble.style.backgroundColor = "red"; } else if (refresh_duration <= 300000){ noti_bubble.style.backgroundColor = "orange"; } else{ noti_bubble.style.backgroundColor = "green"; } /* Now with the timer running, make sure we're keeping up appearances ;) */ PageRefresher = setInterval(function(){ refresh_duration = refresh_duration - 1000; var TimeDetails = msToTime(refresh_duration); $('#noti_bubble').html( TimeDetails['TheTime'] ); noti_bubble.title = TimeDetails['TheTimeAsWords'] + " Until Refresh"; if(refresh_duration <= 60000){ noti_bubble.style.backgroundColor = "red"; } else if (refresh_duration <= 300000){ noti_bubble.style.backgroundColor = "orange"; } else{ noti_bubble.style.backgroundColor = "green"; } if(refresh_duration <= 0){ document.title = "Refreshing..."; location.reload(); } },1000); } else if (PageRefresher){ /* Remove etc. when no timer running */ setCookie(url, 'AutoRefresh',-999); clearInterval(PageRefresher); $("#refresh_button").attr('onmouseover' , "this.style.background='url(//i.imgur.com/u4tV1h1.png) 0px 0px'"); $("#refresh_button").attr('onmouseout' , "this.style.background='url(//i.imgur.com/u4tV1h1.png) 0px 40px'"); $("#refresh_button").attr('title' , "Turn On Auto Refresh"); $('#noti_bubble').remove(); PageRefresher = false; } } /* This shows a black translucent background, exactly like a lightbox background */ function LightboxBG(){ $("body").append($('
').hide().fadeIn('fast')); } /* Depending on the type, url and nobg. type can be www for websites, img for an image, code for text or settings for TPBC settings window. With www, you'll also need the url to be set and you can choose to use nobg or not, which is whether or not you want to show the black background */ function Lightbox(type, url, nobg){ /* if nobg has nothing set, then show the background */ if(!nobg) LightboxBG(); switch (type){ /* Show a website */ case 'www': if(url){ window.Escapable = true; var scrWidth = $(window).width(); var scrHeight = $(window).height(); $('