您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script causes an alert message to pop up if the user types a character and caps lock is enabled.
- // ==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"));
- }
- }
- }
- };