Advertisement
facundop

Server

Aug 27th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.62 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Free Agar.io Bots (Vanilla Version)
  3. // @version 1.0.1
  4. // @description Free open source agar.io bots
  5. // @author Nel
  6. // @grant none
  7. // @run-at document-start
  8. // @match *://agar.io/*
  9. // ==/UserScript==
  10.  
  11. /* START OF USER SETTINGS */
  12.  
  13. window.SERVER_HOST = '34.76.68.236'
  14. window.SERVER_PORT = 8083 // Port number used on the server where the bots are running [Default = 1337]
  15.  
  16. window.BOTS_SPLIT_KEY = 'a' // Keyboard key to make the bots split, value must be between a-z (lowercase) or 0-9 [Default = t]
  17.  
  18. window.BOTS_FEED_KEY = 'c' // Keyboard key to make the bots feed, value must be between a-z (lowercase) or 0-9 [Default = a]
  19.  
  20. window.BOTS_AI_KEY = 'f' // Keyboard key to enable/disable bots AI (Artificial Intelligence), value must be between a-z (lowercase) or 0-9 [Default = f]
  21.  
  22. window.MACRO_FEED_KEY = 'e' // Keyboard key to make the user macro feed, value must be between a-z (lowercase) or 0-9 [Default = e]
  23.  
  24. window.DOUBLE_SPLIT_KEY = 'q' // Keyboard key to make the user double split, value must be between a-z (lowercase) or 0-9 [Default = q]
  25.  
  26. window.SIXTEEN_SPLIT_KEY = 'r' // Keyboard key to make the user sixteen split, value must be between a-z (lowercase) or 0-9 [Default = r]
  27.  
  28. window.ZOOM_SPEED = 0.85 // Numerical value that indicates the speed of the mouse wheel when zooming, value must be between 0.01-0.99 [Default = 0.85]
  29.  
  30. window.EXTENDED_ZOOM = true // Boolean value that indicates whether to extend the zoom or not, possible values are true and false [Default = true]
  31.  
  32. window.DRAW_MAP_GRID = false // Boolean value that indicates whether to draw the map grid or not, possible values are true and false [Default = false]
  33.  
  34. window.SHOW_ALL_PLAYERS_MASS = true // Boolean value that indicates whether to show all players mass or not, possible values are true and false [Default = true]
  35.  
  36. /* END OF USER SETTINGS */
  37.  
  38. class Writer {
  39. constructor(size){
  40. this.dataView = new DataView(new ArrayBuffer(size))
  41. this.byteOffset = 0
  42. }
  43. writeUint8(value){
  44. this.dataView.setUint8(this.byteOffset++, value)
  45. }
  46. writeInt32(value){
  47. this.dataView.setInt32(this.byteOffset, value, true)
  48. this.byteOffset += 4
  49. }
  50. writeUint32(value){
  51. this.dataView.setUint32(this.byteOffset, value, true)
  52. this.byteOffset += 4
  53. }
  54. writeString(string){
  55. for(let i = 0; i < string.length; i++) this.writeUint8(string.charCodeAt(i))
  56. this.writeUint8(0)
  57. }
  58. }
  59.  
  60. window.buffers = {
  61. startBots(url, protocolVersion, clientVersion, userStatus, botsName, botsAmount){
  62. const writer = new Writer(13 + url.length + botsName.length)
  63. writer.writeUint8(0)
  64. writer.writeString(url)
  65. writer.writeUint32(protocolVersion)
  66. writer.writeUint32(clientVersion)
  67. writer.writeUint8(Number(userStatus))
  68. writer.writeString(botsName)
  69. writer.writeUint8(botsAmount)
  70. return writer.dataView.buffer
  71. },
  72. mousePosition(x, y){
  73. const writer = new Writer(9)
  74. writer.writeUint8(6)
  75. writer.writeInt32(x)
  76. writer.writeInt32(y)
  77. return writer.dataView.buffer
  78. }
  79. }
  80.  
  81. window.connection = {
  82. ws: null,
  83. connect(){
  84. this.ws = new WebSocket(`ws://${window.SERVER_HOST}:${window.SERVER_PORT}`)
  85. this.ws.binaryType = 'arraybuffer'
  86. this.ws.onopen = this.onopen.bind(this)
  87. this.ws.onmessage = this.onmessage.bind(this)
  88. this.ws.onclose = this.onclose.bind(this)
  89. },
  90. send(buffer){
  91. if(this.ws && this.ws.readyState === WebSocket.OPEN) this.ws.send(buffer)
  92. },
  93. onopen(){
  94. document.getElementById('userStatus').style.color = '#00C02E'
  95. document.getElementById('userStatus').innerText = 'Connected'
  96. document.getElementById('connect').disabled = true
  97. document.getElementById('startBots').disabled = false
  98. document.getElementById('stopBots').disabled = false
  99. },
  100. onmessage(message){
  101. const dataView = new DataView(message.data)
  102. switch(dataView.getUint8(0)){
  103. case 0:
  104. document.getElementById('startBots').disabled = true
  105. document.getElementById('stopBots').disabled = false
  106. document.getElementById('startBots').style.display = 'none'
  107. document.getElementById('stopBots').style.display = 'inline'
  108. document.getElementById('stopBots').innerText = 'Stop Bots'
  109. window.user.startedBots = true
  110. break
  111. case 1:
  112. document.getElementById('stopBots').disabled = true
  113. document.getElementById('stopBots').innerText = 'Stopping Bots...'
  114. break
  115. case 2:
  116. document.getElementById('botsAI').style.color = '#DA0A00'
  117. document.getElementById('botsAI').innerText = 'Disabled'
  118. document.getElementById('startBots').disabled = false
  119. document.getElementById('stopBots').disabled = true
  120. document.getElementById('startBots').style.display = 'inline'
  121. document.getElementById('stopBots').style.display = 'none'
  122. document.getElementById('stopBots').innerText = 'Stop Bots'
  123. window.user.startedBots = false
  124. window.bots.ai = false
  125. break
  126. case 3:
  127. alert('Your IP has captcha and bots are unable to spawn, change your ip with a VPN or something to one that doesn\'t has captcha in order to use the bots')
  128. break
  129. }
  130. },
  131. onclose(){
  132. document.getElementById('userStatus').style.color = '#DA0A00'
  133. document.getElementById('userStatus').innerText = 'Disconnected'
  134. document.getElementById('botsAI').style.color = '#DA0A00'
  135. document.getElementById('botsAI').innerText = 'Disabled'
  136. document.getElementById('connect').disabled = false
  137. document.getElementById('startBots').disabled = true
  138. document.getElementById('stopBots').disabled = true
  139. document.getElementById('startBots').style.display = 'inline'
  140. document.getElementById('stopBots').style.display = 'none'
  141. window.user.startedBots = false
  142. window.bots.ai = false
  143. }
  144. }
  145.  
  146. window.game = {
  147. url: '',
  148. protocolVersion: 0,
  149. clientVersion: 0
  150. }
  151.  
  152. window.user = {
  153. startedBots: false,
  154. isAlive: false,
  155. mouseX: 0,
  156. mouseY: 0,
  157. offsetX: 0,
  158. offsetY: 0,
  159. macroFeedInterval: null
  160. }
  161.  
  162. window.bots = {
  163. name: '',
  164. amount: 0,
  165. ai: false
  166. }
  167.  
  168. function modifyCore(core){
  169. return core
  170. .replace(/if\(\w+\.MC&&\w+\.MC\.onPlayerSpawn\)/, `
  171. $&
  172. window.user.isAlive = true
  173. if(window.user.startedBots) window.connection.send(new Uint8Array([5, Number(window.user.isAlive)]).buffer)
  174. `)
  175. .replace(/if\(\w+\.MC&&\w+\.MC\.onPlayerDeath\)/, `
  176. $&
  177. window.user.isAlive = false
  178. if(window.user.startedBots) window.connection.send(new Uint8Array([5, Number(window.user.isAlive)]).buffer)
  179. `)
  180. .replace(/new\s+WebSocket\((\w+\(\w+\))\)/, `
  181. $&
  182. if(window.user.startedBots) window.connection.send(new Uint8Array([1]).buffer)
  183. window.game.url = $1
  184. window.user.isAlive = false
  185. window.user.macroFeedInterval = null
  186. `).replace(/(\w+)=~~\(\+\w+\[\w+\+\d+>>3]\+\s+\+\(\(\w+\[\w+\+\d+>>2]\|0\)-\(\(\w+\[\d+]\|0\)\/2\|0\)\|0\)\/\w+\);(\w+)=~~\(\+\w+\[\w+\+\d+>>3]\+\s+\+\(\(\w+\[\w+\+\d+>>2]\|0\)-\(\(\w+\[\d+]\|0\)\/2\|0\)\|0\)\/\w+\)/, `
  187. $&
  188. window.user.mouseX = $1 - window.user.offsetX
  189. window.user.mouseY = $2 - window.user.offsetY
  190. if(window.user.startedBots && window.user.isAlive) window.connection.send(window.buffers.mousePosition(window.user.mouseX, window.user.mouseY))
  191. `)
  192. .replace(/\w+\[\w+\+272>>3]=(\w+);\w+\[\w+\+280>>3]=(\w+);\w+\[\w+\+288>>3]=(\w+);\w+\[\w+\+296>>3]=(\w+)/, `
  193. $&
  194. if(~~($3 - $1) === 14142 && ~~($4 - $2) === 14142){
  195. window.user.offsetX = ($1 + $3) / 2
  196. window.user.offsetY = ($2 + $4) / 2
  197. }
  198. `)
  199. .replace(/\(\.9,/, '(window.ZOOM_SPEED,')
  200. .replace(/;if\((\w+)<1\.0\)/, ';if($1 < (window.EXTENDED_ZOOM ? 0.05 : 1))')
  201. .replace(/(\w+\(\d+,\w+\|0,\.5,\.5\)\|0);(\w+\(\d+,\w+\|0,\.5,50\.5\)\|0);(\w+\(\d+,\w+\|0,\.5,\.5\)\|0);(\w+\(\d+,\w+\|0,50\.5,\.5\)\|0)/, `
  202. $1
  203. if(window.DRAW_MAP_GRID) $2
  204. $3
  205. if(window.DRAW_MAP_GRID) $4
  206. `)
  207. .replace(/while\(0\);(\w+)=\(\w+\|0\)!=\(\w+\|0\);/, `
  208. $&
  209. if(window.SHOW_ALL_PLAYERS_MASS) $1 = true
  210. `)
  211. }
  212.  
  213. function setKeysEvents(){
  214. document.addEventListener('keydown', e => {
  215. if(!document.getElementById('overlays')){
  216. switch(e.key){
  217. case window.BOTS_SPLIT_KEY:
  218. if(window.user.startedBots && window.user.isAlive) window.connection.send(new Uint8Array([2]).buffer)
  219. break
  220. case window.BOTS_FEED_KEY:
  221. if(window.user.startedBots && window.user.isAlive) window.connection.send(new Uint8Array([3]).buffer)
  222. break
  223. case window.BOTS_AI_KEY:
  224. if(window.user.startedBots && window.user.isAlive){
  225. if(!window.bots.ai){
  226. document.getElementById('botsAI').style.color = '#00C02E'
  227. document.getElementById('botsAI').innerText = 'Enabled'
  228. window.bots.ai = true
  229. window.connection.send(new Uint8Array([4, Number(window.bots.ai)]).buffer)
  230. }
  231. else {
  232. document.getElementById('botsAI').style.color = '#DA0A00'
  233. document.getElementById('botsAI').innerText = 'Disabled'
  234. window.bots.ai = false
  235. window.connection.send(new Uint8Array([4, Number(window.bots.ai)]).buffer)
  236. }
  237. }
  238. break
  239. case window.MACRO_FEED_KEY:
  240. if(!window.user.macroFeedInterval){
  241. window.core.eject()
  242. window.user.macroFeedInterval = setInterval(window.core.eject, 80)
  243. }
  244. break
  245. case window.DOUBLE_SPLIT_KEY:
  246. window.core.split()
  247. setTimeout(window.core.split, 40)
  248. break
  249. case window.SIXTEEN_SPLIT_KEY:
  250. window.core.split()
  251. setTimeout(window.core.split, 40)
  252. setTimeout(window.core.split, 80)
  253. setTimeout(window.core.split, 120)
  254. break
  255. }
  256. }
  257. })
  258. document.addEventListener('keyup', e => {
  259. if(!document.getElementById('overlays') && e.key === window.MACRO_FEED_KEY && window.user.macroFeedInterval){
  260. clearInterval(window.user.macroFeedInterval)
  261. window.user.macroFeedInterval = null
  262. }
  263. })
  264. }
  265.  
  266. function setGUI(){
  267. document.getElementById('advertisement').innerHTML = `
  268. <h2 id="botsInfo">
  269. <a href="https://discord.gg/SDMNEcJ" target="_blank">Free Agar.io Bots</a>
  270. </h2>
  271. <h5 id="botsAuthor">
  272. Developed by <a href="https://www.youtube.com/channel/UCZo9WmnFPWw38q65Llu5Lug" target="_blank">Nel</a>
  273. </h5>
  274. <span id="statusText">Status: <b id="userStatus">Disconnected</b></span>
  275. <br>
  276. <br>
  277. <span id="aiText">Bots AI: <b id="botsAI">Disabled</b></span>
  278. <br>
  279. <input type="text" id="botsName" placeholder="Bots Name" maxlength="15" spellcheck="false">
  280. <input type="number" id="botsAmount" placeholder="Bots Amount" min="10" max="199" spellcheck="false">
  281. <button id="connect">Connect</button>
  282. <br>
  283. <button id="startBots" disabled>Start Bots</button>
  284. <button id="stopBots">Stop Bots</button>
  285. `
  286. if(localStorage.getItem('localStoredBotsName') !== null){
  287. window.bots.name = localStorage.getItem('localStoredBotsName')
  288. document.getElementById('botsName').value = window.bots.name
  289. }
  290. if(localStorage.getItem('localStoredBotsAmount') !== null){
  291. window.bots.amount = JSON.parse(localStorage.getItem('localStoredBotsAmount'))
  292. document.getElementById('botsAmount').value = String(window.bots.amount)
  293. }
  294. }
  295.  
  296. function setGUIStyle(){
  297. document.getElementsByTagName('head')[0].innerHTML += `
  298. <style type="text/css">
  299. #mainui-ads {
  300. height: 360px !important;
  301. }
  302. #botsInfo > a, #botsAuthor > a {
  303. color: #3894F8;
  304. text-decoration: none;
  305. }
  306. #botsAuthor {
  307. margin-top: -15px;
  308. letter-spacing: 1px;
  309. }
  310. #statusText, #aiText {
  311. font-weight: bold;
  312. }
  313. #userStatus, #botsAI {
  314. color: #DA0A00;
  315. }
  316. #botsName, #botsAmount {
  317. margin-top: 15px;
  318. width: 144px;
  319. border: 1px solid black;
  320. border-radius: 5px;
  321. padding: 8px;
  322. font-size: 14.5px;
  323. outline: none;
  324. }
  325. #botsName:focus, #botsAmount:focus {
  326. border-color: #7D7D7D;
  327. }
  328. #connect, #startBots, #stopBots {
  329. color: white;
  330. border: none;
  331. border-radius: 5px;
  332. padding: 7px;
  333. width: 160px;
  334. font-size: 18px;
  335. outline: none;
  336. margin-top: 15px;
  337. letter-spacing: 1px;
  338. }
  339. #connect {
  340. display: inline;
  341. margin-left: 5px;
  342. background-color: #0074C0;
  343. }
  344. #startBots {
  345. display: inline;
  346. background-color: #00C02E;
  347. }
  348. #stopBots {
  349. display: none;
  350. background-color: #DA0A00;
  351. }
  352. #connect:active {
  353. background-color: #004E82;
  354. }
  355. #startBots:active {
  356. background-color: #009A25;
  357. }
  358. #stopBots:active {
  359. background-color: #9A1B00;
  360. }
  361. </style>
  362. `
  363. }
  364.  
  365. function setGUIEvents(){
  366. document.getElementById('botsAmount').addEventListener('keypress', e => {
  367. e.preventDefault()
  368. })
  369. document.getElementById('botsName').addEventListener('change', function(){
  370. window.bots.name = this.value
  371. localStorage.setItem('localStoredBotsName', window.bots.name)
  372. })
  373. document.getElementById('botsAmount').addEventListener('change', function(){
  374. window.bots.amount = Number(this.value)
  375. localStorage.setItem('localStoredBotsAmount', window.bots.amount)
  376. })
  377. document.getElementById('connect').addEventListener('click', () => {
  378. if(!window.connection.ws || window.connection.ws.readyState !== WebSocket.OPEN) window.connection.connect()
  379. })
  380. document.getElementById('startBots').addEventListener('click', () => {
  381. if(window.game.url && window.game.protocolVersion && window.game.clientVersion && !window.user.startedBots){
  382. if(window.bots.name && window.bots.amount && !document.getElementById('socialLoginContainer')) window.connection.send(window.buffers.startBots(window.game.url, window.game.protocolVersion, window.game.clientVersion, window.user.isAlive, window.bots.name, window.bots.amount))
  383. else alert('Bots name and amount are required before starting the bots, also you need to be logged in to your agar.io account in order to start the bots')
  384. }
  385. })
  386. document.getElementById('stopBots').addEventListener('click', () => {
  387. if(window.user.startedBots) window.connection.send(new Uint8Array([1]).buffer)
  388. })
  389. }
  390.  
  391. WebSocket.prototype.storedSend = WebSocket.prototype.send
  392. WebSocket.prototype.send = function(buffer){
  393. this.storedSend(buffer)
  394. const dataView = new DataView(new Uint8Array(buffer).buffer)
  395. if(!window.game.protocolVersion && dataView.getUint8(0) === 254) window.game.protocolVersion = dataView.getUint32(1, true)
  396. else if(!window.game.clientVersion && dataView.getUint8(0) === 255) window.game.clientVersion = dataView.getUint32(1, true)
  397. }
  398.  
  399. new MutationObserver(mutations => {
  400. mutations.forEach(({addedNodes}) => {
  401. addedNodes.forEach(node => {
  402. if(node.nodeType === 1 && node.tagName === 'SCRIPT' && node.src && node.src.includes('agario.core.js')){
  403. node.type = 'javascript/blocked'
  404. node.parentElement.removeChild(node)
  405. fetch(node.src)
  406. .then(res => res.text())
  407. .then(core => {
  408. Function(modifyCore(core))()
  409. setKeysEvents()
  410. setTimeout(() => {
  411. setGUI()
  412. setGUIStyle()
  413. setGUIEvents()
  414. }, 3500)
  415. })
  416. }
  417. })
  418. })
  419. }).observe(document.documentElement, {
  420. childList: true,
  421. subtree: true
  422. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement