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.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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);
    }
})();