Skip to content

Instantly share code, notes, and snippets.

@SomeBall-1
Last active July 18, 2020 22:33
// ==UserScript==
// @name TagPro No-Script Key Remapper
// @description Key remapper for no-script groups
// @version 0.1
// @author Some Ball -1
// @include http://tagpro-*.koalabeast.com:*
// @run-at document-end
// @grant unsafeWindow
// ==/UserScript==
(function(window) {
'use strict';
if(!window.tagpro) {
// Number on left side is the keyCode of the key you want to use
// Number on the right side is the keyCode of the key you want to remap/replace
// Get keyCodes from here: http://keycode.info/
// For example: 73 and 87 are the keyCodes for I and W, respectively
// 73: 87 would remap the I key to W so pressing I would act the same as if you pressed W
const remap = {
73: 87, // I acts like W
74: 65, // J acts like A
75: 83, // K acts like S
76: 68, // L acts like D
};
/////////////////////////////////////////////////////
$(document).on('keydown keyup keypress',function(e) { //probably don't even need to handle keypress here
if(!e.fake && remap.hasOwnProperty(e.keyCode)) { //check fake to not get triggered by macro script keypresses
e.keyCode = remap[e.keyCode];
}
});
//move our listener events from the back to the front so they're triggered before all other listeners
$._data(document).events.keydown.unshift($._data(document).events.keydown.pop());
$._data(document).events.keyup.unshift($._data(document).events.keyup.pop());
$._data(document).events.keypress.unshift($._data(document).events.keypress.pop());
}
})(unsafeWindow);
@chrisstevensjunior
Copy link

Hey, do you have a version of this script that will work in pubs or without the no script option enabled in groups?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment