Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name MyEpisodes torrent link
- // @description Change the link on the episode from tvrage to torrentpage - piratebay
- // @include http://myepisodes.com/*
- // @include http://*.myepisodes.com/*
- // @match http://myepisodes.com/*
- // @match http://*.myepisodes.com/*
- // @version 1.1
- // @author kamilio
- // ==/UserScript==
- // settings
- // %s will be replaced with searched expression
- // search engine - default pirate bay
- var engine = "http://thepiratebay.org/search/%s/0/7/0";
- // var engine = "http://www.mininova.org/search/%s/seeds";
- (function( ) {
- // include jQuery
- var headID = document.getElementsByTagName("head")[0];
- var newScript = document.createElement('script');
- newScript.type = 'text/javascript';
- newScript.id = 'myjQuery';
- newScript.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js';
- headID.appendChild(newScript);
- // format 01x02 -> S01E02
- function getEpisode(string) {
- return "S"+string.replace("x","E");
- }
- // replace whitespace to +
- function replaceSpace(string) {
- return string.replace(" ","+");
- }
- // get the search expression
- function getExpression(selector) {
- var showname = replaceSpace($(".showname a",$(selector).parent()).text());
- if (showname.trim() == "") { // didnt work in series view
- showname = replaceSpace($(".showname",$(selector).parent()).text());
- }
- var episode = getEpisode($(".longnumber",$(selector).parent()).text());
- return showname+"+"+episode;
- }
- // get the search link
- function search(selector) {
- return engine.replace("%s",getExpression(selector))
- }
- window.addEventListener('load', function (e) {
- // jquery usage
- $(document).ready(function(){
- $(".epname").each(function(){ // foreach epname
- $("a",this).attr("href",search(this)); // replace link in the name of episode
- });
- })
- }, false);
- })( );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement