Quizlet 'Learn' Mode Global Input Stopper

Disable page click from going to the next question without permission. Additionally, "Enter" key will submit answers, and "space" will override incorrect answers. Only accept 'enter', 'space' keys and 'click' events. | https://greasyfork.org/en/users/3656-kaiko

Verze ze dne 11. 12. 2016. Zobrazit nejnovější verzi.

// ==UserScript==
// @name        Quizlet 'Learn' Mode Global Input Stopper
// @namespace   QZLT_LearnKBMode
// @description Disable page click from going to the next question without permission. Additionally, "Enter" key will submit answers, and "space" will override incorrect answers. Only accept 'enter', 'space' keys and 'click' events. | https://greasyfork.org/en/users/3656-kaiko
// @include     http://quizlet.com/*/learn*
// @include     https://quizlet.com/*/learn*
// @version     1.3.1
// @grant       none
// ==/UserScript==

window.addEventListener('load', function() {
	Element.NativeEvents={click:2,dblclick:0,mouseup:0,mousedown:0,contextmenu:0,mousewheel:0,DOMMouseScroll:0,mouseover:0,mouseout:0,mousemove:0,selectstart:1,selectend:0,keydown:0,keypress:0,keyup:0,input:0,orientationchange:2,touchstart:2,touchmove:2,touchend:2,touchcancel:2,gesturestart:2,gesturechange:2,gestureend:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,paste:2,oninput:2,load:2,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1};

	window.addEventListener("keydown", enter, true);
	
	function enter(charE) {
		var answerBtn = document.getElementById("js-learnModeAnswerButton");
		var checkBtn = document.getElementsByClassName("LearnModeMain-anyKey");
		var overrideBtn = document.getElementsByClassName("LearnModeGradeAnswerView-overrideLink");
		if (charE.keyCode == "13") {
			if (answerBtn){
				answerBtn.click();
			} else if (checkBtn) {
				checkBtn[0].click();
			}
		}
		if (charE.keyCode == "32") {
			if (overrideBtn){
				overrideBtn[0].click();
			} else {
				return;
			}
		}
	}
}, false);