isCapsLockEnabled.js

This script causes an alert message to pop up if the user types a character and caps lock is enabled.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         isCapsLockEnabled.js
// @namespace    https://bitbucket.org/azuelsdorf16
// @version      1.0.0
// @date         23 February 2015
// @description  This script causes an alert message to pop up if the user types a character and caps lock is enabled.
// @author       Andrew Zuelsdorf
// @include      https://*
// @include      http://*
// @grant        none
// ==/UserScript==

//For use with Chrome Developer Tools debuggin
debugger;

function isAlpha(character) {
    if (character >= String.fromCharCode(0x41) &&
        character <= String.fromCharCode(0x5A)) {
        return true;
    }
    else if (character >= String.fromCharCode(0x61) &&
        character <= String.fromCharCode(0x7A)) {
        return true;
    }
    else if (character >= String.fromCharCode(0xC0) &&
             character <= String.fromCharCode(0x2B8)) {
        return true;
    }
    else if (character >= String.fromCharCode(0x363) &&
             character <= String.fromCharCode(0x1FFF)) {
        return true;
    }
    else {
        return false;
    }
}

var continuePopupMessages = true;

document.onkeypress = function(e) {
    if (continuePopupMessages) {
        e = e || window.event;
        var s = String.fromCharCode(e.keyCode || e.which);
        if ((s.toUpperCase() === s && !e.shiftKey) || (e.shiftKey && s.toLowerCase() === s)) {
            if (isAlpha(s)) {
                continuePopupMessages = (true === confirm("Caps lock is on! Press \"Cancel\" to stop receiving this message on this page. Press \"OK\" otherwise"));
            }
        }
    }
};