SHARE
TWEET

Server #3

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