// ==UserScript== // @name Homeunstuck // @namespace abrad45 // @description adds homestuck navigation and pages remaining // @include http://www.mspaintadventures.com/* // @include http://mspaintadventures.com/* // @require https://code.jquery.com/jquery-2.2.3.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.1/js.cookie.js // @version 1.3.0 // @grant none // @history 1.0 20121125 - Initial Release // @history 1.0.1 20121202 - Modified `endings` to include page 7411, End of A6I4 // @history 1.0.2 20121204 - Changed erroneous ending page number of A6I4 from 7441 to 7411 // @history 1.0.3 20130113 - Modified `endings` to include page 7613, End of A6A5A1 // @history 1.0.4 20130414 - Modified `endings` to remove page 7613, and add 7826 and 8135 // @history 1.1 20130415 - Formatting Changes; Enabled Keyboard Navigation with Left/Right Arrows // @history 1.2 20130421 - Includes "You've not saved since comic ##" notification // @history 1.3 20160416 - We're back! Formatting, final update to `endings`, jquery version bump and switch from jquery-cookie to js-cookie. // @downloadURL none // ==/UserScript== $(function () { if (/s=6/.test(window.location.search)) { var URL = window.location.search; var root = URL.substr(0,URL.length-4); var comic = +URL.substr(-4); var firstPage = 1901; var lastPage = 10028; if (!comic) { root = "?s=6&p=00"; comic = 1901; } var nextURL = '/' + root + (+comic+1); var prevURL = '/' + root + (+comic-1); // starting from the top so I can display nothing if there is no end to the current act var endings = [ 2147, // End of Act I 2658, // End of Act II 3053, // End of Act III 3257, // End of Intermission 1 3888, // End of Act IV 4525, // End of Act V Act I 6010, // End of Act V 6012, // End of Intermission 2 6184, // End of Act VI Act I 6290, // End of Act VI Intermission 1 6566, // End of Act VI Act II 6716, // End of Act VI Intermission 2 7162, // End of Act VI Act III 7337, // End of Act VI Intermission 3 7339, // End of Act VI Act IV 7411, // End of Act VI Intermission 4 7826, // End of Act VI Act V 8135, // End of Act VI Intermission 5 8177, // End of Act VI Act VI Act I 8374, // End of Act VI Act VI Intermission 1 8430, // End of Act VI Act VI Act II 8752, // End of Act VI Act VI Intermission 2 8801, // End of Act VI Act VI Act III 8820, // End of Act VI Act VI Intermission 3 8843, // End of Act VI Act VI Act IV 9308, // End of Act VI Act VI Intermission 4 9348, // End of Act VI Act VI Act V 9986, // End of Act VI Act VI Intermission 5 10026, // End of Act VI Act VI Act VI 10028 // End of Act VI ]; // Find out which part of the story we're in var currentStorySection = endings.length; while(comic < endings[--currentStorySection]) {} // We've gone too far. Course correct! currentStorySection++; $('table[width=600]') .first() .parent() .css('position', 'relative') .prepend( $('
', { 'id': 'homeunstuck', 'css': { 'position': 'absolute', 'left': '35px', 'width': '100px', } }) ); $('#homeunstuck') .append( $('', { 'id': 'homeunstuck-prev', 'href': prevURL, 'html': '←', 'css': { 'margin-right': '10px' } }) ).append( $('', { 'id': 'homeunstuck-next', 'href': nextURL, 'html': '→', }) ); if (comic === firstPage) { $('#homeunstuck-prev').remove(); } else if(comic === lastPage) { $('#homeunstuck-next').remove(); } if (!isNaN(endings[currentStorySection] - comic)) { $('#homeunstuck') .append($('', { 'text': endings[currentStorySection] - comic + ' left', 'id': 'homeunstuck_pages_left' }) ); } var story = Cookies.get('s_cookie'); var page = Cookies.get('p_cookie'); if ( !!story && !!page && Number(story) === 6 && (comic - page.substr(-4) > 24) ) { $('#homeunstuck').append( $('', { 'text': "You've not saved since comic " + Cookies.get('p_cookie').substr(-4), 'css': { 'color': '#900', 'font-weight': 'bold' } } ) ); } $(window).keyup(function (e) { if (e.which === 37) { window.location = prevURL; } else if (e.which === 39) { window.location = nextURL; } }); } });