Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2016
103,358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.00 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Zekebot v5
  3. // @version 5.0.0
  4. // @description This bots are insane
  5. // @author Edit By: Zeke
  6. // @license MIT
  7. // @match http://agar.io/*
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.4/socket.io.min.js
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12. // By: Break
  13.  
  14. var botServerIP = "127.0.0.1:8081";
  15.  
  16. setTimeout(function() {
  17.  
  18. var socket = io.connect('ws://' + botServerIP);
  19. var canMove = true;
  20. var moveEvent = new Array(2);
  21. var canvas = document.getElementById("canvas");
  22. last_transmited_game_server = null;
  23.  
  24. socket.on('force-login', function (data) {
  25. socket.emit("login", {"uuid":client_uuid, "type":"client"});
  26. transmit_game_server();
  27. });
  28.  
  29. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 250px; top: 100px; left: 10px; display: block; position: absolute; text-align: center; font-size: 25px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'>Bots: <a id='minionCount' >π“£π“‘π“π“˜π“›</a> </div>" );
  30. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 600px; top: 10px; left: 10px; display: block; position: absolute; text-align: center; font-size: 33px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'>ZekeBot<a id='client_uuid' > Best Bots</a> </div> For <a id='clientuuid' > A𝓰π“ͺ𝓻.𝓲𝓸</a> </div>" );
  31. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 185px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >ZekeBot v6</a> </div>" );
  32. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 250px; left: 10px; display: block; position: absolute; text-align: center; font-size: 28px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'>Controls<a id='client_uuid' >:</a> </div>" );
  33. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 325px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >E = S𝓹𝓡𝓲𝓽B𝓸𝓽𝓼</a> </div>" );
  34. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 375px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >R = B𝔬𝔱E𝔧𝔒𝔠𝔱</a> </div>" );
  35. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 425px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >D = S𝓽𝓸𝓹M𝓸𝓿𝒆𝓢𝒆𝓷𝓽</a> </div>" );
  36. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 475px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >W = F𝓲𝓻𝒆F𝒆𝒆𝓭</a> </div>" );
  37. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 205px; top: 525px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >Wheel = Z𝓸𝓸𝓢</a> </div>" );
  38. $( "#canvas" ).after( "<div style='background-color: #000000; -moz-opacity: 0.4; -khtml-opacity: 0.4; opacity: 0.4; filter: alpha(opacity=40); zoom: 1; width: 305px; top: 575px; left: 10px; display: block; position: absolute; text-align: center; font-size: 18px; color: #ffffff; padding: 5px; font-family: Ubuntu;'> <div style='color:#ffffff; display: inline; -moz-opacity:1; -khtml-opacity: 1; opacity:1; filter:alpha(opacity=100); padding: 10px;'><a id='client_uuid' >3 Cell features 2 Bot features</a> </div>" );
  39.  
  40. socket.on('spawn-count', function (data) {
  41. document.getElementById('minionCount').innerHTML = data;
  42. counter = data;
  43. });
  44.  
  45. var client_uuid = localStorage.getItem('client_uuid');
  46.  
  47. if(client_uuid == null){
  48. console.log("generating a uuid for this user");
  49.  
  50. client_uuid = ""; var ranStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  51. for (var ii = 0; ii < 15; ii++) client_uuid += ranStr.charAt(Math.floor(Math.random() * ranStr.length));
  52. localStorage.setItem('client_uuid', client_uuid);
  53. }
  54.  
  55. socket.emit("login", client_uuid);
  56. $("#instructions").replaceWith('<hr><div class="input-group"><span class="input-group-addon" style="margin-top: -100px;" id="basic-addon1">UUID</span><input type="text" value="' + client_uuid + '" readonly class="form-control"</div></div><br><div class="input-group"><span class="input-group-addon" style="margin-top: -100px;" id="basic-addon1">Bot IP</span><input type="text" value="' + botServerIP + '" readonly class="form-control"</div></div><br><div class="input-group"><span class="input-group-addon" style="margin-top: -100px;" id="basic-addon1">Version:</span><input type="text" value="V6" readonly class="form-control"</div></div>');
  57.  
  58. // values in --> window.agar
  59.  
  60. function isMe(cell){
  61. for (var i = 0; i < window.agar.myCells.length; i++){
  62. if (window.agar.myCells[i] == cell.id){
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68.  
  69. function getCell(){
  70. var me = [];
  71. for (var key in window.agar.allCells){
  72. var cell = window.agar.allCells[key];
  73. if (isMe(cell)){
  74. me.push(cell);
  75. }
  76. }
  77. return me[0];
  78. }
  79.  
  80. function emitCellID(){
  81. socket.emit("cellid", getCell().id);
  82. }
  83.  
  84. function emitSplit(){
  85. socket.emit("cmd", {"name":"split"} );
  86. }
  87.  
  88. function emitMassEject(){
  89. socket.emit("cmd", {"name":"eject"} );
  90. }
  91.  
  92. function toggleMovement(){
  93. canMove = !canMove;
  94.  
  95. switch(canMove)
  96. {
  97. case true:
  98. canvas.onmousemove = moveEvent[0];
  99. moveEvent[0] = null;
  100.  
  101. canvas.onmousedown = moveEvent[1];
  102. moveEvent[1] = null;
  103. break;
  104.  
  105. case false:
  106. moveEvent[0] = canvas.onmousemove;
  107. canvas.onmousemove({clientX: (innerWidth / 2), clientY: (innerHeight / 2)});
  108. canvas.onmousemove = null;
  109.  
  110. moveEvent[1] = canvas.onmousedown;
  111. canvas.onmousedown = null;
  112. break;
  113. }
  114. }
  115.  
  116. interval_id = setInterval(function() {
  117. emitCellID();
  118. }, 100);
  119.  
  120. interval_id2 = setInterval(function() {
  121. transmit_game_server_if_changed();
  122. }, 5000);
  123.  
  124. document.addEventListener('keydown',function(e){
  125. var key = e.keyCode || e.which;
  126. switch(key)
  127. {
  128. case 68://d has been pressed. (Toggle Movement)
  129. toggleMovement();
  130. break;
  131.  
  132. case 69://e has been pressed. (Split Bots)
  133. emitSplit();
  134. break;
  135.  
  136. case 82://r has been pressed. (Eject Mass from Bots)
  137. emitMassEject();
  138. break;
  139. }
  140. });
  141.  
  142. function transmit_game_server_if_changed(){
  143. if(last_transmited_game_server != window.agar.ws){
  144. transmit_game_server();
  145. }
  146. }
  147.  
  148. function transmit_game_server(){
  149. last_transmited_game_server = window.agar.ws;
  150. socket.emit("cmd", {"name":"connect_server", "ip": last_transmited_game_server } );
  151. }
  152.  
  153. window.agar.minScale = -30;
  154. }, 1000);
  155.  
  156.  
  157.  
  158. var allRules = [
  159. { hostname: ["agar.io"],
  160. scriptUriRe: /^http:\/\/agar\.io\/main_out\.js/,
  161. replace: function (m) {
  162. m.removeNewlines()
  163.  
  164. m.replace("var:allCells",
  165. /(=null;)(\w+)(.hasOwnProperty\(\w+\)?)/,
  166. "$1" + "$v=$2;" + "$2$3",
  167. "$v = {}")
  168.  
  169. m.replace("var:myCells",
  170. /(case 32:)(\w+)(\.push)/,
  171. "$1" + "$v=$2;" + "$2$3",
  172. "$v = []")
  173.  
  174. m.replace("var:top",
  175. /case 49:[^:]+?(\w+)=\[];/,
  176. "$&" + "$v=$1;",
  177. "$v = []")
  178.  
  179. m.replace("var:ws",
  180. /new WebSocket\((\w+)[^;]+?;/,
  181. "$&" + "$v=$1;",
  182. "$v = ''")
  183.  
  184. m.replace("var:topTeams",
  185. /case 50:(\w+)=\[];/,
  186. "$&" + "$v=$1;",
  187. "$v = []")
  188.  
  189. var dr = "(\\w+)=\\w+\\.getFloat64\\(\\w+,!0\\);\\w+\\+=8;\\n?"
  190. var dd = 7071.067811865476
  191. m.replace("var:dimensions",
  192. RegExp("case 64:"+dr+dr+dr+dr),
  193. "$&" + "$v = [$1,$2,$3,$4],",
  194. "$v = " + JSON.stringify([-dd,-dd,dd,dd]))
  195.  
  196. var vr = "(\\w+)=\\w+\\.getFloat32\\(\\w+,!0\\);\\w+\\+=4;"
  197. m.save() &&
  198. m.replace("var:rawViewport:x,y var:disableRendering:1",
  199. /else \w+=\(29\*\w+\+(\w+)\)\/30,\w+=\(29\*\w+\+(\w+)\)\/30,.*?;/,
  200. "$&" + "$v0.x=$1; $v0.y=$2; if($v1)return;") &&
  201. m.replace("var:disableRendering:2 hook:skipCellDraw",
  202. /(\w+:function\(\w+\){)(if\(this\.\w+\(\)\){\+\+this\.[\w$]+;)/,
  203. "$1" + "if($v || $H(this))return;" + "$2") &&
  204. m.replace("var:rawViewport:scale",
  205. /Math\.pow\(Math\.min\(64\/\w+,1\),\.4\)/,
  206. "($v.scale=$&)") &&
  207. m.replace("var:rawViewport:x,y,scale",
  208. RegExp("case 17:"+vr+vr+vr),
  209. "$&" + "$v.x=$1; $v.y=$2; $v.scale=$3;") &&
  210. m.reset_("window.agar.rawViewport = {x:0,y:0,scale:1};" +
  211. "window.agar.disableRendering = false;") ||
  212. m.restore()
  213.  
  214.  
  215.  
  216. m.replace("reset",
  217. /new WebSocket\(\w+[^;]+?;/,
  218. "$&" + m.reset)
  219.  
  220. m.replace("property:scale",
  221. /function \w+\(\w+\){\w+\.preventDefault\(\);[^;]+;1>(\w+)&&\(\1=1\)/,
  222. `;${makeProperty("scale", "$1")};$&`)
  223.  
  224. m.replace("var:minScale",
  225. /;1>(\w+)&&\(\1=1\)/,
  226. ";$v>$1 && ($1=$v)",
  227. "$v = 1")
  228.  
  229. m.replace("var:region",
  230. /console\.log\("Find "\+(\w+\+\w+)\);/,
  231. "$&" + "$v=$1;",
  232. "$v = ''")
  233.  
  234. m.replace("cellProperty:isVirus",
  235. /((\w+)=!!\(\w+&1\)[\s\S]{0,400})((\w+).(\w+)=\2;)/,
  236. "$1$4.isVirus=$3")
  237.  
  238. m.replace("var:dommousescroll",
  239. /("DOMMouseScroll",)(\w+),/,
  240. "$1($v=$2),")
  241.  
  242. m.replace("var:skinF hook:cellSkin",
  243. /(\w+.fill\(\))(;null!=(\w+))/,
  244. "$1;" +
  245. "if($v)$3 = $v(this,$3);" +
  246. "if($h)$3 = $h(this,$3);" +
  247. "$2");
  248.  
  249. m.replace("hook:afterCellStroke",
  250. /\((\w+)\.strokeStyle="#000000",\1\.globalAlpha\*=\.1,\1\.stroke\(\)\);\1\.globalAlpha=1;/,
  251. "$&" + "$H(this);")
  252.  
  253. m.replace("var:showStartupBg",
  254. /\w+\?\(\w\.globalAlpha=\w+,/,
  255. "$v && $&",
  256. "$v = true")
  257.  
  258.  
  259. var vAlive = /\((\w+)\[(\w+)\]==this\){\1\.splice\(\2,1\);/.exec(m.text)
  260. var vEaten = /0<this\.[$\w]+&&(\w+)\.push\(this\)}/.exec(m.text)
  261. !vAlive && console.error("Expose: can't find vAlive")
  262. !vEaten && console.error("Expose: can't find vEaten")
  263. if (vAlive && vEaten)
  264. m.replace("var:aliveCellsList var:eatenCellsList",
  265. RegExp(vAlive[1] + "=\\[\\];" + vEaten[1] + "=\\[\\];"),
  266. "$v0=" + vAlive[1] + "=[];" + "$v1=" + vEaten[1] + "=[];",
  267. "$v0 = []; $v1 = []")
  268.  
  269. m.replace("hook:drawScore",
  270. /(;(\w+)=Math\.max\(\2,(\w+\(\))\);)0!=\2&&/,
  271. "$1($H($3))||0!=$2&&")
  272.  
  273. m.replace("hook:beforeTransform hook:beforeDraw var:drawScale",
  274. /(\w+)\.save\(\);\1\.translate\((\w+\/2,\w+\/2)\);\1\.scale\((\w+),\3\);\1\.translate\((-\w+,-\w+)\);/,
  275. "$v = $3;$H0($1,$2,$3,$4);" + "$&" + "$H1($1,$2,$3,$4);",
  276. "$v = 1")
  277.  
  278. m.replace("hook:afterDraw",
  279. /(\w+)\.restore\(\);(\w+)&&\2\.width&&\1\.drawImage/,
  280. "$H();" + "$&")
  281.  
  282.  
  283. m.replace("hook:cellColor",
  284. /(\w+=)this\.color,/,
  285. "$1 ($h && $h(this, this.color) || this.color),")
  286.  
  287. m.replace("var:drawGrid",
  288. /(\w+)\.globalAlpha=(\.2\*\w+);/,
  289. "if(!$v)return;" + "$&",
  290. "$v = true")
  291.  
  292. m.replace("hook:drawCellMass",
  293. /&&\((\w+\|\|0==\w+\.length&&\(!this\.\w+\|\|this\.\w+\)&&20<this\.size)\)&&/,
  294. "&&( $h ? $h(this,$1) : ($1) )&&")
  295.  
  296. m.replace("hook:cellMassText",
  297. /(\.\w+)(\(~~\(this\.size\*this\.size\/100\)\))/,
  298. "$1( $h ? $h(this,$2) : $2 )")
  299.  
  300. m.replace("hook:cellMassTextScale",
  301. /(\.\w+)\((this\.\w+\(\))\)([\s\S]{0,1000})\1\(\2\/2\)/,
  302. "$1($2)$3$1( $h ? $h(this,$2/2) : ($2/2) )")
  303.  
  304. var template = (key,n) =>
  305. `this\\.${key}=\\w+\\*\\(this\\.(\\w+)-this\\.(\\w+)\\)\\+this\\.\\${n};`
  306. var re = new RegExp(template('x', 2) + template('y', 4) + template('size', 6))
  307. var match = re.exec(m.text)
  308. if (match) {
  309. m.cellProp.nx = match[1]
  310. m.cellProp.ny = match[3]
  311. m.cellProp.nSize = match[5]
  312. } else
  313. console.error("Expose: cellProp:x,y,size search failed!")
  314.  
  315. }},
  316. ]
  317.  
  318. function makeProperty(name, varname) {
  319. return "'" + name + "' in window.agar || " +
  320. "Object.defineProperty( window.agar, '"+name+"', " +
  321. "{get:function(){return "+varname+"},set:function(){"+varname+"=arguments[0]},enumerable:true})"
  322. }
  323.  
  324. if (window.top != window.self)
  325. return
  326.  
  327. if (document.readyState !== 'loading')
  328. return console.error("Expose: this script should run at document-start")
  329.  
  330. var isFirefox = /Firefox/.test(navigator.userAgent)
  331.  
  332. // Stage 1: Find corresponding rule
  333. var rules
  334. for (var i = 0; i < allRules.length; i++)
  335. if (allRules[i].hostname.indexOf(window.location.hostname) !== -1) {
  336. rules = allRules[i]
  337. break
  338. }
  339. if (!rules)
  340. return console.error("Expose: cant find corresponding rule")
  341.  
  342.  
  343. // Stage 2: Search for `main_out.js`
  344. if (isFirefox) {
  345. function bse_listener(e) { tryReplace(e.target, e) }
  346. window.addEventListener('beforescriptexecute', bse_listener, true)
  347. } else {
  348. // Iterate over document.head child elements and look for `main_out.js`
  349. for (var i = 0; i < document.head.childNodes.length; i++)
  350. if (tryReplace(document.head.childNodes[i]))
  351. return
  352. // If there are no desired element in document.head, then wait until it appears
  353. function observerFunc(mutations) {
  354. for (var i = 0; i < mutations.length; i++) {
  355. var addedNodes = mutations[i].addedNodes
  356. for (var j = 0; j < addedNodes.length; j++)
  357. if (tryReplace(addedNodes[j]))
  358. return observer.disconnect()
  359. }
  360. }
  361. var observer = new MutationObserver(observerFunc)
  362. observer.observe(document.head, {childList: true})
  363. }
  364.  
  365. // Stage 3: Replace found element using rules
  366. function tryReplace(node, event) {
  367. var scriptLinked = rules.scriptUriRe && rules.scriptUriRe.test(node.src)
  368. var scriptEmbedded = rules.scriptTextRe && rules.scriptTextRe.test(node.textContent)
  369. if (node.tagName != "SCRIPT" || (!scriptLinked && !scriptEmbedded))
  370. return false // this is not desired element; get back to stage 2
  371.  
  372. if (isFirefox) {
  373. event.preventDefault()
  374. window.removeEventListener('beforescriptexecute', bse_listener, true)
  375. }
  376.  
  377. var mod = {
  378. reset: "",
  379. text: null,
  380. history: [],
  381. cellProp: {},
  382. save() {
  383. this.history.push({reset:this.reset, text:this.text})
  384. return true
  385. },
  386. restore() {
  387. var state = this.history.pop()
  388. this.reset = state.reset
  389. this.text = state.text
  390. return true
  391. },
  392. reset_(reset) {
  393. this.reset += reset
  394. return true
  395. },
  396. replace(what, from, to, reset) {
  397. var vars = [], hooks = []
  398. what.split(" ").forEach((x) => {
  399. x = x.split(":")
  400. x[0] === "var" && vars.push(x[1])
  401. x[0] === "hook" && hooks.push(x[1])
  402. })
  403. function replaceShorthands(str) {
  404. function nope(letter, array, fun) {
  405. str = str
  406. .split(new RegExp('\\$' + letter + '([0-9]?)'))
  407. .map((v,n) => n%2 ? fun(array[v||0]) : v)
  408. .join("")
  409. }
  410. nope('v', vars, (name) => "window.agar." + name)
  411. nope('h', hooks, (name) => "window.agar.hooks." + name)
  412. nope('H', hooks, (name) =>
  413. "window.agar.hooks." + name + "&&" +
  414. "window.agar.hooks." + name)
  415. return str
  416. }
  417. var newText = this.text.replace(from, replaceShorthands(to))
  418. if(newText === this.text) {
  419. console.error("Expose: `" + what + "` replacement failed!")
  420. return false
  421. } else {
  422. this.text = newText
  423. if (reset)
  424. this.reset += replaceShorthands(reset) + ";"
  425. return true
  426. }
  427. },
  428. removeNewlines() {
  429. this.text = this.text.replace(/([,\/])\n/mg, "$1")
  430. },
  431. get: function() {
  432. var cellProp = JSON.stringify(this.cellProp)
  433. return `window.agar={hooks:{},cellProp:${cellProp}};` +
  434. this.reset + this.text
  435. }
  436. }
  437.  
  438. if (scriptEmbedded) {
  439. mod.text = node.textContent
  440. rules.replace(mod)
  441. if (isFirefox) {
  442. document.head.removeChild(node)
  443. var script = document.createElement("script")
  444. script.textContent = mod.get()
  445. document.head.appendChild(script)
  446. } else {
  447. node.textContent = mod.get()
  448. }
  449. console.log("Expose: replacement done")
  450. } else {
  451. document.head.removeChild(node)
  452. var request = new XMLHttpRequest()
  453. request.onload = function() {
  454. var script = document.createElement("script")
  455. mod.text = this.responseText
  456. rules.replace(mod)
  457. script.textContent = mod.get()
  458. // `main_out.js` should not executed before jQuery was loaded, so we need to wait jQuery
  459. function insertScript(script) {
  460. if (typeof jQuery === "undefined")
  461. return setTimeout(insertScript, 0, script)
  462. document.head.appendChild(script)
  463. console.log("Expose: replacement done")
  464. }
  465. insertScript(script)
  466. }
  467. request.onerror = function() { console.error("Expose: response was null") }
  468. request.open("get", node.src, true)
  469. request.send()
  470. }
  471.  
  472. return true
  473. }
  474.  
  475. (function() {
  476. var amount = 1;
  477. var duration = 10; //ms
  478.  
  479. var overwriting = function(evt) {
  480. if (evt.keyCode === 87) { // When S key is pushed
  481. for (var i = 0; i < amount; ++i) {
  482. setTimeout(function() {
  483. window.onkeydown({keyCode: 87}); // Simulates W key being pushed
  484. window.onkeyup({keyCode: 87});
  485. }, i * duration);
  486. }
  487. }
  488. };
  489.  
  490. window.addEventListener('keydown', overwriting);
  491. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement