Skip to content

Instantly share code, notes, and snippets.

@JCGrant
Last active November 10, 2016 23:05
Show Gist options
  • Save JCGrant/45fdb9a8a14d7c05dc6ac70123f2d7cb to your computer and use it in GitHub Desktop.
Save JCGrant/45fdb9a8a14d7c05dc6ac70123f2d7cb to your computer and use it in GitHub Desktop.
Adds various features to Shush.se
// ==UserScript==
// @name Shush.se - Extra Features
// @namespace https://gist.github.com/JCGrant/45fdb9a8a14d7c05dc6ac70123f2d7cb
// @version 0.5
// @description Adds various features to Shush.se
// @author JCGrant
// @match http://www.shush.se/index.php*
// @grant none
// @updateURL https://gist.github.com/JCGrant/45fdb9a8a14d7c05dc6ac70123f2d7cb/raw/shush.se-x.user.js
// ==/UserScript==
(function() {
'use strict';
function getQueryValues(key) {
var query = window.location.search.substring(1);
var values = query.split('&')
.map(function(pairStr) {
return pairStr.split('=');
})
.filter(function(pair) {
return pair[0] == key;
})
.map(function(pair) {
return pair[1];
});
return values;
}
var showName = getQueryValues('show')[0];
var episodeId = parseInt(getQueryValues('id')[0]);
var prevEpisodeId = episodeId - 1;
var nextEpisodeId = episodeId + 1;
var prevEpisodeLink = document.createElement('a');
prevEpisodeLink.href = '?id=' + prevEpisodeId + '&show=' + showName;
prevEpisodeLink.innerText = 'Prev Episode';
var nextEpisodeLink = document.createElement('a');
nextEpisodeLink.href = '?id=' + nextEpisodeId + '&show=' + showName;
nextEpisodeLink.innerText = 'Next Episode';
var episodeListLink = document.createElement('a');
episodeListLink.href = '?showlist=' + showName;
episodeListLink.innerText = 'Episode List';
var div = document.getElementsByClassName('episode')[0];
div.innerHTML += '<br/>';
div.appendChild(prevEpisodeLink);
div.innerHTML += ' | ';
div.appendChild(nextEpisodeLink);
div.innerHTML += ' | ';
div.appendChild(episodeListLink);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment