Split and Macro

Shift is split, Q is macro

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

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