Split and Macro

E is split, Q is W macro

  1. // ==UserScript==
  2. // @name Split and Macro
  3. // @namespace agar, absorb
  4. // @version 2
  5. // @description E is split, Q is W macro
  6. // @author Kuda
  7. // @match http://abs0rb.me/*
  8. // @match http://agar.io/*
  9. // @grant none
  10. // ==/UserScript==
  11. / jshint -W097 /
  12. 'use strict';
  13.  
  14. var SplitInterval;
  15. var MacroInterval;
  16. var SplitDebounce = false;
  17. var MacroDebounce = false;
  18. $(document).on('keydown', function(input) {
  19. console.log("got keydown")
  20. if (input.keyCode == 69) {
  21. if (SplitDebounce) {
  22. return;
  23. }
  24. SplitDebounce = true;
  25. SplitInterval = setInterval(function() {
  26. $("body").trigger($.Event("keydown", {
  27. keyCode: 32
  28. }));
  29. $("body").trigger($.Event("keyup", {
  30. keyCode: 32
  31. }));
  32. }, 0);
  33. } else if (input.keyCode == 81) {
  34. if (MacroDebounce) {
  35. return;
  36. }
  37. MacroDebounce = true;
  38. MacroInterval = setInterval(function() {
  39. $("body").trigger($.Event("keydown", {
  40. keyCode: 87
  41. }));
  42. $("body").trigger($.Event("keyup", {
  43. keyCode: 87
  44. }));
  45. }, 0);
  46. }
  47. })
  48.  
  49. $(document).on('keyup', function(input) {
  50. if (input.keyCode == 69) {
  51. SplitDebounce = false;
  52. clearInterval(SplitInterval);
  53. return;
  54. } else if (input.keyCode == 81) {
  55. MacroDebounce = false;
  56. clearInterval(MacroInterval);
  57. return;
  58. }
  59. })