Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro No-Script Key Remapper
  3. // @description Key remapper for no-script groups
  4. // @version 0.1
  5. // @author Some Ball -1
  6. // @match *://*.koalabeast.com/game
  7. // @include http://tagpro-test.koalabeast.com/*
  8. // @include http://tagpro-*.koalabeast.com:*
  9. // @include http://tagpro-*.koalabeast.com/textures/
  10. // @include http://tagpro-*.koalabeast.com:*
  11. // @include http://tagpro-test.koalabeast.com/game
  12. // @match *://*.koalabeast.com/game
  13. // @include http://*.koalabeast.com:*
  14. // @include http://tangent.jukejuice.com:*
  15. // @include http://tagpro-radius.koalabeast.com/*
  16. // @include http://tagpro-pi.koalabeast.com/*
  17. // @include http://tagpro-sphere.koalabeast.com/*
  18. // @include http://tagpro-origin.koalabeast.com/*
  19. // @include http://tagpro-newyork.koalabeast.com/*
  20. // @include http://tagpro-test.koalabeast.com/*
  21. // @include http://*.newcompte.fr:*
  22. // @match *://*.koalabeast.com/game
  23. // @include http://tagpro-*.koalabeast.com/textures/
  24. // @include http://tagpro-*.koalabeast.com:*
  25. // @include http://tagpro-test.koalabeast.com/game
  26. // @match *://*.koalabeast.com/game
  27. // @run-at document-end
  28. // @grant unsafeWindow
  29. // ==/UserScript==
  30.  
  31. (function(window) {
  32. 'use strict';
  33. if(!window.tagpro) {
  34.  
  35. // Number on left side is the keyCode of the key you want to use
  36. // Number on the right side is the keyCode of the key you want to remap/replace
  37. // Get keyCodes from here: http://keycode.info/
  38. // For example: 73 and 87 are the keyCodes for I and W, respectively
  39. // 73: 87 would remap the I key to W so pressing I would act the same as if you pressed W
  40. const remap = {
  41. 83: 87, // S acts like W
  42. 90: 65, // Z acts like A
  43. 88: 83, // X acts like S
  44. 67: 68, // C acts like D
  45. };
  46.  
  47. /////////////////////////////////////////////////////
  48.  
  49. $(document).on('keydown keyup keypress',function(e) { //probably don't even need to handle keypress here
  50. if(!e.fake && remap.hasOwnProperty(e.keyCode)) { //check fake to not get triggered by macro script keypresses
  51. e.keyCode = remap[e.keyCode];
  52. }
  53. });
  54.  
  55. //move our listener events from the back to the front so they're triggered before all other listeners
  56. $._data(document).events.keydown.unshift($._data(document).events.keydown.pop());
  57. $._data(document).events.keyup.unshift($._data(document).events.keyup.pop());
  58. $._data(document).events.keypress.unshift($._data(document).events.keypress.pop());
  59.  
  60. }
  61. })(unsafeWindow);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement