Created
March 30, 2012 11:38
-
-
Save cnicodeme/2250981 to your computer and use it in GitHub Desktop.
ShowDates.me improving script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oCouchLis = $('#section-watchlist>li'), oSeriesLis = $('#main>div .list-episodes>ul>li'); | |
function processCouch() { | |
var $this = $(this), | |
title = $this.find ('>p>a:first-of-type').text(), | |
cleanTitle = title.replace (/( )/g, '_').replace(/:/g, ''), | |
code = $this.find ('>p>span.episode-code').text().substring(1), | |
season = code.substring(0, code.indexOf("E")).replace(/^[0]+/g,""), | |
episode = code.substring(code.indexOf("E") + 1).replace(/^[0]+/g,""), | |
// Variables for KAT.ph | |
oBinsearch = $this.find ('>a.button-binsearch'), | |
sSearchQuery = oBinsearch.prop('href').substr(oBinsearch.prop('href').lastIndexOf('search?f=') + 9); | |
// This will Add a button to Addicted | |
$this.append ($('<a />', {'href': 'http://www.addic7ed.com/serie/' + cleanTitle + '/' + season + '/' + episode + '/1', 'title': 'Download subtitles for ' + title, 'class': 'button-link link-episode'}).append ($('<img />', {'src': 'http://www.addic7ed.com/favicon.ico', 'alt': 'Addic7ed'}))); | |
// This will switch from Torrentz to KAT.ph and remove the target=_blank | |
oBinsearch.prop('target', null).children(':first').prop('src', 'http://kastatic.com/images/favicon.ico'); | |
} | |
function processSerie() { | |
var $this = $(this), | |
title = $('#main .show-imageheading h1').text(), | |
cleanTitle = title.replace (/( )/g, '_').replace(/:/g, ''), | |
oBinsearch = $this.find ('>a.button-binsearch'); | |
if (oBinsearch.length === 1) { | |
var sSearchQuery = oBinsearch.prop('href').substr(oBinsearch.prop('href').lastIndexOf('search?f=') + 9), | |
code = sSearchQuery.substr(sSearchQuery.lastIndexOf('+') + 1), | |
season = code.substring(1, code.indexOf("E")).replace(/^[0]+/g,""), | |
episode = code.substring(code.indexOf("E") + 1).replace(/^[0]+/g,""); | |
// This will Add a button to Addicted | |
$this.find ('>span').before ($('<a />', {'href': 'http://www.addic7ed.com/serie/' + cleanTitle + '/' + season + '/' + episode + '/1', 'title': 'Download subtitles for ' + title, 'class': 'button-link link-episode'}).append ($('<img />', {'src': 'http://www.addic7ed.com/favicon.ico', 'alt': 'Addic7ed'}))); | |
$this.find ('>p').css ({'width': '65%'}); // Little fix | |
// This will switch from Torrentz to KAT.ph and remove the target=_blank | |
oBinsearch.prop('target', null).children(':first').prop('src', 'http://kastatic.com/images/favicon.ico'); | |
} | |
// scroll to the last non see episode, avoiding the specials episodes | |
if ('specials' === $('.list-episodes>li:first-child').text().toLowerCase().substring(0, 8)) | |
$('.list-episodes>ul:not(:first) img[src$="img/unwatched.png"]:first').closest('ul').prev()[0].scrollIntoView(true); | |
else | |
$('.list-episodes>ul img[src$="img/unwatched.png"]:first').closest('ul').prev()[0].scrollIntoView(true); | |
} | |
if (oCouchLis.length > 0) oCouchLis.each(processCouch); | |
else if (oSeriesLis.length > 0) oSeriesLis.each(processSerie); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UPDATE has been made to the script, so here is the updated bookmarklet :