Gaver.io Bots

Bots For Gaver.io

  1. // ==UserScript==
  2. // @name Gaver.io Bots
  3. // @namespace JoseFredoBots
  4. // @version 1.0
  5. // @description Bots For Gaver.io
  6. // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js
  7. // @author JoseFredoHD
  8. // @match *.gaver.io/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. window.Client = {
  13. ip: null,
  14. x: 0,
  15. y: 0,
  16. log: false
  17. };
  18.  
  19. const port = 8085;
  20. const cmd = io("ws://JoseAlfredo-josef128339.codeanyapp.com:" + port.toString());
  21.  
  22. function KeyOf(letter){
  23. return letter.charCodeAt(0);
  24. }
  25.  
  26. window.addEventListener("keydown", (e) => {
  27. if(e.keyCode == KeyOf("X")){
  28. cmd.emit("split", true);
  29. }
  30. if(e.keyCode == KeyOf("C")){
  31. cmd.emit("eject", true);
  32. }
  33. });
  34.  
  35. _WebSocket = window.WebSocket;
  36.  
  37. function refer(master, slave, prop) {
  38. Object.defineProperty(master, prop, {
  39. get: function(){
  40. return slave[prop];
  41. },
  42. set: function(val) {
  43. slave[prop] = val;
  44. },
  45. enumerable: true,
  46. configurable: true
  47. });
  48. }
  49.  
  50. window.WebSocket = function(url, protocols) {
  51. if (protocols === undefined) {
  52. protocols = [];
  53. }
  54. var ws = new _WebSocket(url, protocols);
  55. refer(this, ws, 'binaryType');
  56. refer(this, ws, 'bufferedAmount');
  57. refer(this, ws, 'extensions');
  58. refer(this, ws, 'protocol');
  59. refer(this, ws, 'readyState');
  60. refer(this, ws, 'url');
  61. this.send = function(data) {
  62. if(Client.log) console.log(new Uint8Array(data));
  63. let msg = new DataView(arguments[0]);
  64. if(msg.getUint8(0) == 16 && msg.byteLength == 13){
  65. Client.x = msg.getInt32(1, true);
  66. Client.y = msg.getInt32(5, true);
  67. }
  68. cmd.emit("clientPosition", {
  69. x: Client.x,
  70. y: Client.y
  71. });
  72. return ws.send.call(ws, data);
  73. };
  74. this.close = function() {
  75. return ws.close.call(ws);
  76. };
  77. this.onopen = function(event) {};
  78. this.onclose = function(event) {};
  79. this.onerror = function(event) {};
  80. this.onmessage = function(event) {};
  81. ws.onopen = function(event) {
  82. if(this.url !== null) Client.ip = this.url;
  83. setInterval(() => {
  84. cmd.emit("serverIP", {
  85. ip: Client.ip
  86. });
  87. }, 350);
  88. if (this.onopen) return this.onopen.call(ws, event);
  89. }.bind(this);
  90. ws.onmessage = function(event) {
  91. if (this.onmessage) return this.onmessage.call(ws, event);
  92. }.bind(this);
  93. ws.onclose = function(event) {
  94. if (this.onclose) return this.onclose.call(ws, event);
  95. }.bind(this);
  96. ws.onerror = function(event) {
  97. console.log("[CLIENT]: WebSocker Error");
  98. if (this.onerror) return this.onerror.call(ws, event);
  99. }.bind(this);
  100. };
  101. window.WebSocket.prototype = _WebSocket;

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址