NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name shushtvtools // @version 0.0.1 // @description A Set of tools for watching TV series on shush.se. Gives you previous and next episode links, and remembers what episodes you watch. // @author 0.0.1 // @match http://www.shush.se/* // @grant GM_setValue // @grant GM_getValue // ==/UserScript== !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";a("./showlist"),a("./episodepage")},{"./episodepage":2,"./showlist":3}],2:[function(a,b,c){var d=/\?id=(\d+)&show=(\w+)/i,e=function(){if(d.test(document.location.search)){var a=document.location.search.match(d),b=a[2],c=a[1],e=this.buildContainer();e.appendChild(this.getShowListLink(b,c)),e.appendChild(document.createElement("br")),e.appendChild(this.getPreviousEpisodeLink(b,c)),e.appendChild(document.createElement("br")),e.appendChild(this.getCurrentEpisodeText(b,c)),e.appendChild(document.createElement("br")),e.appendChild(this.getNextEpisodeLink(b,c)),this.updateWatched(b,c);var f=document.querySelector("#disqus_thread");f.parentNode.insertBefore(e,f)}};e.prototype.buildContainer=function(){var a=document.createElement("div");return a.style.position="relative",a.style.top="170px",a.style.width="854px",a.style.margin="0 auto",a.style.display="block",a.style.zIndex="1",a.id="shushtvtools-episode-controls",a},e.prototype.updateWatched=function(a,b){var c=this.getEpisodes(a),d=c[b];d.watched=!0,GM_setValue(a,c)},e.prototype.getEpisodes=function(a){return GM_getValue(a)},e.prototype.getNextEpisode=function(a,b){var c=this.getEpisodes(a),d=Object.keys(c).sort(function(a,b){return parseInt(a)<parseInt(b)?-1:1});return c[d[d.indexOf(b)+1]]},e.prototype.getCurrentEpisode=function(a,b){var c=this.getEpisodes(a);return c[b]},e.prototype.getPreviousEpisode=function(a,b){if(parseInt(b)>0){var c=this.getEpisodes(a),d=Object.keys(c).sort(function(a,b){return parseInt(a)<parseInt(b)?-1:1});return c[d[d.indexOf(b)-1]]}return null},e.prototype.getShowListLink=function(a,b){var c=document.createElement("a");return c.href=document.location.href,c.search="?showlist="+a,c.hash=b,c.innerText="== Episode List",c},e.prototype.getNextEpisodeLink=function(a,b){var c=this.getNextEpisode(a,b),d=document.createElement("a");return d.href=c.link,d.innerText=">> "+c.name+(c.watched?" (watched)":""),d},e.prototype.getCurrentEpisodeText=function(a,b){var c=this.getCurrentEpisode(a,b),d=document.createElement("span");return d.innerText="-- "+c.name+(c.watched?" (watched)":""),d},e.prototype.getPreviousEpisodeLink=function(a,b){var c=this.getPreviousEpisode(a,b),d=document.createElement("a");return d.href=c.link,d.innerText="<< "+c.name+(c.watched?" (watched)":""),d},b.exports=new e},{}],3:[function(a,b,c){function d(){if(e.test(document.location.search)){var a=document.location.search.match(e),b=this.getEpisodeIds(a[1]);this.markWatchedEpisodes(a[1]),document.location.hash&&setTimeout(function(){window.scroll(0,document.querySelector("a[href^='index.php?id="+document.location.hash.replace("#","")+"']").offsetTop)},100),GM_setValue(a[1],b)}}var e=/\?showlist=(\w+)/i;d.prototype.markWatchedEpisodes=function(a){var b=document.querySelectorAll("a[href^='index.php?id=']"),c=GM_getValue(a);if(c)for(var d=0;d<b.length;d++){var e=b[d].search.match(/\?id=(\d+)/i);c[e[1]]&&c[e[1]].watched===!0&&(b[d].innerText+=" (watched)")}},d.prototype.getEpisodeIds=function(a){for(var b=document.querySelectorAll("a[href^='index.php?id=']"),c=GM_getValue(a)||{},d=0;d<b.length;d++){var e=b[d].search.match(/id=(\d+)/i);if(c[e[1]])c[e[1]].name=b[d].innerText,c[e[1]].link=b[d].href;else{var f={name:b[d].innerText,link:b[d].href};c[e[1]]=f}}return c},b.exports=new d},{}]},{},[1]);