Split and Macro

Shift is split, Q is macro

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