Greasy Fork is available in English.

CodeSchool Keyboard Shortcuts

Adds much-needed and much-requested keyboard shortcuts to go to the next section in a course.

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 or Violentmonkey 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!)

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!)

// ==UserScript==
// @name         CodeSchool Keyboard Shortcuts
// @namespace    http://jonas.ninja
// @version      1.1.0
// @description  Adds much-needed and much-requested keyboard shortcuts to go to the next section in a course.
// @author       @_jnblog
// @match        http*://campus.codeschool.com/courses/*/level/*/section/*
// @match        http*://campus.codeschool.com/courses/*/level/*/wrap-up
// @grant        none
// ==/UserScript==

(function() {
    document.body.onkeyup = function(e) {
        if (e.altKey && e.key === 'Enter') {
            var button = getContinueButton();

            if (button) {
                click(button);
            }
        }
    };

    function getContinueButton() {
        /// identify the continue button. If it cannot be identified, returns undefined.

        var buttons = document.getElementsByClassName('btn--continue');
        // on the wrap-up screen, there's a single 'btn--next' but no 'btn--continue's, so use that.
        if (buttons.length === 0) {
            buttons = document.getElementsByClassName('btn--next');
        }
        if (getTheVisibleButtons(buttons).length === 1) {
            return buttons[0];
        }
        return undefined;
    }

    function getTheVisibleButtons(list) {
        list = [].slice.call(list); // convert the 'HtmlCollection' to a list
        return list.filter(function(el) {
            return isVisible(el);
        });
    }

    function isVisible(el) {
        return (el.offsetHeight > 0 && el.offsetWidth > 0);
    }

    function click(el) {
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent("click", true, true);
        (el).dispatchEvent(evt);
    }
})();