Split and Macro

Shift is split, Q is macro

当前为 2016-01-14 提交的版本,查看 最新版本

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