Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Allows you to use "1", "2", "3" and "4" to press the review buttons in the review tools.

View ReviewKeyboard.user.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
// ==UserScript==
// @author Tom Wijsman
// @name Review Keyboard
// @description Allows you to use "1", "2", "3" and "4" to press the review buttons in the review tools.
// @include http://*superuser.com/review-beta/*
// ==/UserScript==
 
function EmbedCodeOnPage(javascript_code) {
var code_element = document.createElement('script');
code_element.type = 'text/javascript';
code_element.textContent = javascript_code;
document.getElementsByTagName('head')[0].appendChild(code_element);
}
 
function EmbedFunctionOnPageAndExecute(function_contents) {
EmbedCodeOnPage("(" + function_contents.toString() + ")()");
}
 
EmbedFunctionOnPageAndExecute(function() {
function keyCheck(e)
{
if (e.keyCode >= 49 && e.keyCode <= 52 && $('.comment-form textarea').length === 0)
{
var reviewButton = $('.review-actions').find('input')[e.keyCode - 49];
if (document.createEvent) {
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0,
false, false, false, false,
0, null);
reviewButton.dispatchEvent(event);
}
else if (reviewButton.fireEvent) {
reviewButton.fireEvent("onclick");
}
else {
window.alert('Your browser is not supported.');
}
}
}
 
window.addEventListener('keydown', keyCheck, true);
});
iglvzx commented

Good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.