E, R, T, and P keys

Adds E, R, T, and P keys to the vanilla client

  1. // ==UserScript==
  2. // @name E, R, T, and P keys
  3. // @version 1.0
  4. // @description Adds E, R, T, and P keys to the vanilla client
  5. // @author ZfsrGhS953
  6. // @match *.agar.io/*
  7. // @grant none
  8. // @run-at document-start
  9. // @namespace https://greasyfork.org/users/78372
  10. // ==/UserScript==
  11.  
  12. /************************************************
  13.  
  14. Made by @ZfsrGhS953 on GitHub
  15. Go check out his project! Its really nice :)
  16. https://github.com/ZfsrGhS953/Petridish-Ogar
  17.  
  18. ************************************************/
  19.  
  20.  
  21. setTimeout(function() {
  22. window.__WebSocket = window.WebSocket;
  23. window.fakeWebSocket = function() {
  24. return {
  25. readyState: 0
  26. };
  27. };
  28. window._WebSocket = window.WebSocket = function(ip) {
  29. return new window.fakeWebSocket(ip);
  30. };
  31. window.key = {
  32. e: false,
  33. r: false,
  34. t: false,
  35. p: false
  36. };
  37. window.addEventListener("load", function() {
  38. // код инжектинга
  39. if (!window.OldSocket)
  40. OldSocket = window.__WebSocket;
  41. window._WebSocket = window.WebSocket = window.fakeWebSocket = function(ip) {
  42. var ws = new OldSocket(ip);
  43. ws.binaryType = "arraybuffer";
  44. var fakeWS = {};
  45. for (var i in ws) {
  46. fakeWS[i] = ws[i];
  47. }
  48. fakeWS.send = function() {
  49. if (arguments[0][0] == 16) {
  50. if (window.key.e){
  51. arguments[0] = new Int8Array(1);
  52. arguments[0][0] = 22;
  53. }
  54. if (window.key.r){
  55. arguments[0] = new Int8Array(1);
  56. arguments[0][0] = 23;
  57. }
  58. if (window.key.t){
  59. arguments[0] = new Int8Array(1);
  60. arguments[0][0] = 24;
  61. }
  62. if (window.key.p) {
  63. arguments[0] = new Int8Array(1);
  64. arguments[0][0] = 25;
  65. }
  66. window.key.e = window.key.r = window.key.t = window.key.p = false;
  67. }
  68. return ws.send.apply(ws, arguments);
  69. };
  70. ws.onmessage = function() {
  71. fakeWS.onmessage && fakeWS.onmessage.apply(ws, arguments);
  72. };
  73. ws.onopen = function() {
  74. fakeWS.readyState = 1;
  75. fakeWS.onopen.apply(ws, arguments);
  76. };
  77. ws.onclose = function(){
  78. fakeWS.onclose.apply(ws, arguments);
  79. };
  80. return fakeWS;
  81. };
  82. });
  83. document.addEventListener('keydown', function(e) {
  84. var key = e.keyCode || e.which;
  85. switch (key) {
  86. case 69:
  87. window.key.e = true;
  88. break;
  89. case 82:
  90. window.key.r = true;
  91. break;
  92. case 84:
  93. window.key.t = true;
  94. break;
  95. case 80:
  96. window.key.p = true;
  97. break;
  98. }
  99. });
  100. }, 200);