SatySlidePageRouting

try to take over the world!

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Advertisement:

// ==UserScript==
// @name         SatySlidePageRouting
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  try to take over the world!
// @author       Chenyu
// @match        http://bytes.usc.edu/cs585/*
// @grant        none
// ==/UserScript==

setTimeout(function() {
    'use strict';

    document.getElementById("clockHolder").style.display = "none";

    if (window.nextSlide === undefined) {
        console.log("This page does not have slidy.js. ");
        return;
    }

    let oldPrevioudSlide = previousSlide;
    let oldNextSlide = nextSlide;

    function setSlideNum() {
        console.log("setSlideNum");
        if (!document.location.href.includes("#?")) {
            document.location.href += "#?";
        }
        if (document.location.href.includes("slidenum=")) {
            document.location.href = document.location.href.replace(/slidenum=[0-9]+/, "slidenum=" + slidenum);
        } else {
            let optionalAnd = document.location.href.includes("&") ? "&" : "";
            document.location.href += optionalAnd + "slidenum=" + slidenum;
        }
    }

    window.previousSlide = function (arg, modified) {
        console.log(arg, modified);
        oldPrevioudSlide(arg);

        if (modified === false) return;
        setSlideNum();
    }

    window.nextSlide = function (arg, modified) {
        console.log(arg, modified);
        oldNextSlide(arg);

        if (modified === false) return;
        setSlideNum();
    }

    function getUrlVars() {
        var vars = {};
        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
            vars[key] = value;
        });
        return vars;
    }

    let slidenumParam = getUrlVars()["slidenum"]

    if (slidenumParam === undefined) {
       return;
    }

    let urlSlidenum = parseInt(slidenumParam);
    console.log({urlSlidenum});
    for (let i = 0; i < urlSlidenum; i++) {
        nextSlide(true, false);
    }

}, 1500);