Skip to content

Instantly share code, notes, and snippets.

@Flummi
Last active May 20, 2019 10:58
Show Gist options
  • Save Flummi/4f187ce4b0d4c427d3c1891311ae0371 to your computer and use it in GitHub Desktop.
Save Flummi/4f187ce4b0d4c427d3c1891311ae0371 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Accesskeys ftw
// @version 1.1
// @description Schnellzauber mit shift+Zahl nutzen statt über die üblichen Accesskeys.
// @author Flummi
// @namespace Flummi
// @match http*://*.freewar.de/freewar/internal/*.php*
// @grant none
// ==/UserScript==
(() => {
'use strict';
const accesskeys = { // charCode -> accesskey
33: 1, 34: 2, 167: 3,
36: 4, 37: 5, 38: 6,
47: 7, 40: 8, 41: 9
};
window.addEventListener("keypress", e => {
if(e.isTrusted && e.shiftKey) {
if(document.querySelectorAll(":focus").length === 0) {
if(accesskeys.hasOwnProperty(e.charCode)) {
parent.itemFrame.document.querySelector(`a#accessfast${accesskeys[e.charCode]}`).click();
parent.itemFrame.focus();
e.preventDefault();
}
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment