AgarB13

ScriptPublic||hackskin2016

Apr 28th, 2016
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.25 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AgarB13|SkinsFree
  3. // @namespace AgarB13Skin
  4. // @version 1.0
  5. // @description AgarB13Skin- Skin
  6. // @author AgarB13 YT
  7. // @license AndreTJ
  8. // @match http://agar.io/*
  9. // @require http://pastebin.com/raw/Mu15DJtj
  10. // @grant none
  11. // @run-at document-start
  12. // ==/UserScript==
  13. setTimeout(function() {
  14. var socket = io.connect('ws://127.0.0.1:8081'),
  15. moveToMouse = true,
  16. moveEvent = new Array(2),
  17. canvas = document.getElementById("canvas");
  18. last_transmited_game_server = null;
  19.  
  20. function isMe(cell) {
  21. for (var i = 0; i < window.agar.myCells.length; i++) {
  22. if (window.agar.myCells[i] == cell.id) {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. function getCell() {
  29. var me = [];
  30. for (var key in window.agar.allCells) {
  31. var cell = window.agar.allCells[key];
  32. if (isMe(cell)) {
  33. me.push(cell);
  34. }
  35. }
  36. return me[0];
  37. }
  38. var skin_var = 1;
  39.  
  40. function emitPosition() {
  41. x = (mouseX - window.innerWidth / 2) / window.agar.drawScale + window.agar.rawViewport.x;
  42. y = (mouseY - window.innerHeight / 2) / window.agar.drawScale + window.agar.rawViewport.y;
  43.  
  44. if (!moveToMouse) {
  45. x = getCell().x;
  46. y = getCell().y;
  47. }
  48.  
  49. socket.emit("pos", {
  50. "x": x,
  51. "y": y,
  52. "dimensions": agar.dimensions,
  53. "suicide_targets": agar.myCells
  54. });
  55. }
  56. function emitSplit() {
  57. socket.emit("cmd", {
  58. "name": "split"
  59. });
  60. }
  61. function emitMassEject() {
  62. socket.emit("cmd", {
  63. "name": "eject"
  64. });
  65. }
  66. function changeSkin() {
  67. // Criado por AgarB13||Skin free funcional >IGNORE<(http://migre.me/tCZ9O) ?????????????????LOOK YOUR SKIN FREE/ESCOLHA SUA SKIN FREE
  68. var values = ["%kraken"]
  69. var i = 0;
  70. setInterval(function(){
  71. if (i > values.length -1) {
  72. i = 0;
  73. }
  74. skin = values[i];
  75. i++;
  76. }, 1000);
  77. for (i = 0; i < agar.myCells.length; i++) {
  78. agar.allCells[agar.myCells[i]].C = skin;
  79. }
  80.  
  81. }
  82.  
  83. interval_id = setInterval(function() {
  84. emitPosition();
  85. }, 1);
  86. interval_id2 = setInterval(function() {
  87. transmit_game_server_if_changed();
  88. }, 5000);
  89. interval_id3 = setInterval(function() {
  90. changeSkin();
  91. }, 1000);
  92.  
  93. document.addEventListener('keydown', function(e) {
  94. var key = e.keyCode || e.which;
  95. switch(key) {
  96. case 65: // A (Toggle position)
  97. moveToMouse = !moveToMouse;
  98. break;
  99.  
  100. case 68: // D (Toggle Movement)
  101. toggleMovement();
  102. break;
  103.  
  104. case 69: // E (Split bots)
  105. emitSplit();
  106. break;
  107.  
  108. case 82: // R (Bot eject)
  109. emitMassEject();
  110. break;
  111. }
  112. });
  113. function transmit_game_server_if_changed() {
  114. if (last_transmited_game_server != window.agar.ws) {
  115. transmit_game_server();
  116. }
  117. }
  118.  
  119. function transmit_game_server() {
  120. last_transmited_game_server = window.agar.ws;
  121. socket.emit("cmd", {
  122. "name": "connect_server",
  123. "ip": last_transmited_game_server
  124. });
  125. }
  126.  
  127. var mouseX = 0,
  128. mouseY = 0;
  129.  
  130. $("body").mousemove(function(event) {
  131. mouseX = event.clientX;
  132. mouseY = event.clientY;
  133. });
  134.  
  135. window.agar.minScale = -30;
  136. }, 1);
  137.  
  138. var allRules = [
  139. { hostname: ["agar.io"],
  140. scriptUriRe: /^http:\/\/agar\.io\/main_out\.js/,
  141. replace: function (m) {
  142. m.removeNewlines()
  143.  
  144. m.replace("var:allCells",
  145. /(=null;)(\w+)(.hasOwnProperty\(\w+\)?)/,
  146. "$1" + "$v=$2;" + "$2$3",
  147. "$v = {}")
  148.  
  149. m.replace("var:myCells",
  150. /(case 32:)(\w+)(\.push)/,
  151. "$1" + "$v=$2;" + "$2$3",
  152. "$v = []")
  153.  
  154. m.replace("var:top",
  155. /case 49:[^:]+?(\w+)=\[];/,
  156. "$&" + "$v=$1;",
  157. "$v = []")
  158.  
  159. m.replace("var:ws",
  160. /new WebSocket\((\w+)[^;]+?;/,
  161. "$&" + "$v=$1;",
  162. "$v = ''")
  163.  
  164. m.replace("var:topTeams",
  165. /case 50:(\w+)=\[];/,
  166. "$&" + "$v=$1;",
  167. "$v = []")
  168.  
  169. var dr = "(\\w+)=\\w+\\.getFloat64\\(\\w+,!0\\);\\w+\\+=8;\\n?"
  170. var dd = 7071.067811865476
  171. m.replace("var:dimensions",
  172. RegExp("case 64:"+dr+dr+dr+dr),
  173. "$&" + "$v = [$1,$2,$3,$4],",
  174. "$v = " + JSON.stringify([-dd,-dd,dd,dd]))
  175.  
  176. var vr = "(\\w+)=\\w+\\.getFloat32\\(\\w+,!0\\);\\w+\\+=4;"
  177. m.save() &&
  178. m.replace("var:rawViewport:x,y var:disableRendering:1",
  179. /else \w+=\(29\*\w+\+(\w+)\)\/30,\w+=\(29\*\w+\+(\w+)\)\/30,.*?;/,
  180. "$&" + "$v0.x=$1; $v0.y=$2; if($v1)return;") &&
  181. m.replace("var:disableRendering:2 hook:skipCellDraw",
  182. /(\w+:function\(\w+\){)(if\(this\.\w+\(\)\){\+\+this\.[\w$]+;)/,
  183. "$1" + "if($v || $H(this))return;" + "$2") &&
  184. m.replace("var:rawViewport:scale",
  185. /Math\.pow\(Math\.min\(64\/\w+,1\),\.4\)/,
  186. "($v.scale=$&)") &&
  187. m.replace("var:rawViewport:x,y,scale",
  188. RegExp("case 17:"+vr+vr+vr),
  189. "$&" + "$v.x=$1; $v.y=$2; $v.scale=$3;") &&
  190. m.reset_("window.agar.rawViewport = {x:0,y:0,scale:1};" +
  191. "window.agar.disableRendering = false;") ||
  192. m.restore()
  193.  
  194.  
  195.  
  196. m.replace("reset",
  197. /new WebSocket\(\w+[^;]+?;/,
  198. "$&" + m.reset)
  199.  
  200. m.replace("property:scale",
  201. /function \w+\(\w+\){\w+\.preventDefault\(\);[^;]+;1>(\w+)&&\(\1=1\)/,
  202. `;${makeProperty("scale", "$1")};$&`)
  203.  
  204. m.replace("var:minScale",
  205. /;1>(\w+)&&\(\1=1\)/,
  206. ";$v>$1 && ($1=$v)",
  207. "$v = 1")
  208.  
  209. m.replace("var:region",
  210. /console\.log\("Find "\+(\w+\+\w+)\);/,
  211. "$&" + "$v=$1;",
  212. "$v = ''")
  213.  
  214. m.replace("cellProperty:isVirus",
  215. /((\w+)=!!\(\w+&1\)[\s\S]{0,400})((\w+).(\w+)=\2;)/,
  216. "$1$4.isVirus=$3")
  217.  
  218. m.replace("var:dommousescroll",
  219. /("DOMMouseScroll",)(\w+),/,
  220. "$1($v=$2),")
  221.  
  222. m.replace("var:skinF hook:cellSkin",
  223. /(\w+.fill\(\))(;null!=(\w+))/,
  224. "$1;" +
  225. "if($v)$3 = $v(this,$3);" +
  226. "if($h)$3 = $h(this,$3);" +
  227. "$2");
  228.  
  229. /*m.replace("bigSkin",
  230. /(null!=(\w+)&&\((\w+)\.save\(\),)(\3\.clip\(\),\w+=)(Math\.max\(this\.size,this\.\w+\))/,
  231. "$1" + "$2.big||" + "$4" + "($2.big?2:1)*" + "$5")*/
  232.  
  233. m.replace("hook:afterCellStroke",
  234. /\((\w+)\.strokeStyle="#000000",\1\.globalAlpha\*=\.1,\1\.stroke\(\)\);\1\.globalAlpha=1;/,
  235. "$&" + "$H(this);")
  236.  
  237. m.replace("var:showStartupBg",
  238. /\w+\?\(\w\.globalAlpha=\w+,/,
  239. "$v && $&",
  240. "$v = true")
  241.  
  242.  
  243. var vAlive = /\((\w+)\[(\w+)\]==this\){\1\.splice\(\2,1\);/.exec(m.text)
  244. var vEaten = /0<this\.[$\w]+&&(\w+)\.push\(this\)}/.exec(m.text)
  245. !vAlive && console.error("Expose: can't find vAlive")
  246. !vEaten && console.error("Expose: can't find vEaten")
  247. if (vAlive && vEaten)
  248. m.replace("var:aliveCellsList var:eatenCellsList",
  249. RegExp(vAlive[1] + "=\\[\\];" + vEaten[1] + "=\\[\\];"),
  250. "$v0=" + vAlive[1] + "=[];" + "$v1=" + vEaten[1] + "=[];",
  251. "$v0 = []; $v1 = []")
  252.  
  253. m.replace("hook:drawScore",
  254. /(;(\w+)=Math\.max\(\2,(\w+\(\))\);)0!=\2&&/,
  255. "$1($H($3))||0!=$2&&")
  256.  
  257. m.replace("hook:beforeTransform hook:beforeDraw var:drawScale",
  258. /(\w+)\.save\(\);\1\.translate\((\w+\/2,\w+\/2)\);\1\.scale\((\w+),\3\);\1\.translate\((-\w+,-\w+)\);/,
  259. "$v = $3;$H0($1,$2,$3,$4);" + "$&" + "$H1($1,$2,$3,$4);",
  260. "$v = 1")
  261.  
  262. m.replace("hook:afterDraw",
  263. /(\w+)\.restore\(\);(\w+)&&\2\.width&&\1\.drawImage/,
  264. "$H();" + "$&")
  265.  
  266.  
  267. m.replace("hook:cellColor",
  268. /(\w+=)this\.color;/,
  269. "$1 ($h && $h(this, this.color) || this.color);")
  270.  
  271. m.replace("var:drawGrid",
  272. /(\w+)\.globalAlpha=(\.2\*\w+);/,
  273. "if(!$v)return;" + "$&",
  274. "$v = true")
  275.  
  276. m.replace("hook:drawCellMass",
  277. /&&\((\w+\|\|0==\w+\.length&&\(!this\.\w+\|\|this\.\w+\)&&20<this\.size)\)&&/,
  278. "&&( $h ? $h(this,$1) : ($1) )&&")
  279.  
  280. m.replace("hook:cellMassText",
  281. /(\.\w+)(\(~~\(this\.size\*this\.size\/100\)\))/,
  282. "$1( $h ? $h(this,$2) : $2 )")
  283.  
  284. m.replace("hook:cellMassTextScale",
  285. /(\.\w+)\((this\.\w+\(\))\)([\s\S]{0,1000})\1\(\2\/2\)/,
  286. "$1($2)$3$1( $h ? $h(this,$2/2) : ($2/2) )")
  287.  
  288. var template = (key,n) =>
  289. `this\\.${key}=\\w+\\*\\(this\\.(\\w+)-this\\.(\\w+)\\)\\+this\\.\\${n};`
  290. var re = new RegExp(template('x', 2) + template('y', 4) + template('size', 6))
  291. var match = re.exec(m.text)
  292. if (match) {
  293. m.cellProp.nx = match[1]
  294. m.cellProp.ny = match[3]
  295. m.cellProp.nSize = match[5]
  296. } else
  297. console.error("Expose: cellProp:x,y,size search failed!")
  298.  
  299. }},
  300. ]
  301.  
  302. function makeProperty(name, varname) {
  303. return "'" + name + "' in window.agar || " +
  304. "Object.defineProperty( window.agar, '"+name+"', " +
  305. "{get:function(){return "+varname+"},set:function(){"+varname+"=arguments[0]},enumerable:true})"
  306. }
  307.  
  308. if (window.top != window.self)
  309. return
  310.  
  311. if (document.readyState !== 'loading')
  312. return console.error("Expose: this script should run at document-start")
  313.  
  314. var isFirefox = /Firefox/.test(navigator.userAgent)
  315.  
  316. // Stage 1: Find corresponding rule
  317. var rules
  318. for (var i = 0; i < allRules.length; i++)
  319. if (allRules[i].hostname.indexOf(window.location.hostname) !== -1) {
  320. rules = allRules[i]
  321. break
  322. }
  323. if (!rules)
  324. return console.error("Expose: cant find corresponding rule")
  325.  
  326.  
  327. // Stage 2: Search for `main_out.js`
  328. if (isFirefox) {
  329. function bse_listener(e) { tryReplace(e.target, e) }
  330. window.addEventListener('beforescriptexecute', bse_listener, true)
  331. } else {
  332. // Iterate over document.head child elements and look for `main_out.js`
  333. for (var i = 0; i < document.head.childNodes.length; i++)
  334. if (tryReplace(document.head.childNodes[i]))
  335. return
  336. // If there are no desired element in document.head, then wait until it appears
  337. function observerFunc(mutations) {
  338. for (var i = 0; i < mutations.length; i++) {
  339. var addedNodes = mutations[i].addedNodes
  340. for (var j = 0; j < addedNodes.length; j++)
  341. if (tryReplace(addedNodes[j]))
  342. return observer.disconnect()
  343. }
  344. }
  345. var observer = new MutationObserver(observerFunc)
  346. observer.observe(document.head, {childList: true})
  347. }
  348.  
  349. // Stage 3: Replace found element using rules
  350. function tryReplace(node, event) {
  351. var scriptLinked = rules.scriptUriRe && rules.scriptUriRe.test(node.src)
  352. var scriptEmbedded = rules.scriptTextRe && rules.scriptTextRe.test(node.textContent)
  353. if (node.tagName != "SCRIPT" || (!scriptLinked && !scriptEmbedded))
  354. return false // this is not desired element; get back to stage 2
  355.  
  356. if (isFirefox) {
  357. event.preventDefault()
  358. window.removeEventListener('beforescriptexecute', bse_listener, true)
  359. }
  360.  
  361. var mod = {
  362. reset: "",
  363. text: null,
  364. history: [],
  365. cellProp: {},
  366. save() {
  367. this.history.push({reset:this.reset, text:this.text})
  368. return true
  369. },
  370. restore() {
  371. var state = this.history.pop()
  372. this.reset = state.reset
  373. this.text = state.text
  374. return true
  375. },
  376. reset_(reset) {
  377. this.reset += reset
  378. return true
  379. },
  380. replace(what, from, to, reset) {
  381. var vars = [], hooks = []
  382. what.split(" ").forEach((x) => {
  383. x = x.split(":")
  384. x[0] === "var" && vars.push(x[1])
  385. x[0] === "hook" && hooks.push(x[1])
  386. })
  387. function replaceShorthands(str) {
  388. function nope(letter, array, fun) {
  389. str = str
  390. .split(new RegExp('\\$' + letter + '([0-9]?)'))
  391. .map((v,n) => n%2 ? fun(array[v||0]) : v)
  392. .join("")
  393. }
  394. nope('v', vars, (name) => "window.agar." + name)
  395. nope('h', hooks, (name) => "window.agar.hooks." + name)
  396. nope('H', hooks, (name) =>
  397. "window.agar.hooks." + name + "&&" +
  398. "window.agar.hooks." + name)
  399. return str
  400. }
  401. var newText = this.text.replace(from, replaceShorthands(to))
  402. if(newText === this.text) {
  403. console.error("Expose: `" + what + "` replacement failed!")
  404. return false
  405. } else {
  406. this.text = newText
  407. if (reset)
  408. this.reset += replaceShorthands(reset) + ";"
  409. return true
  410. }
  411. },
  412. removeNewlines() {
  413. this.text = this.text.replace(/([,\/])\n/mg, "$1")
  414. },
  415. get: function() {
  416. var cellProp = JSON.stringify(this.cellProp)
  417. return `window.agar={hooks:{},cellProp:${cellProp}};` +
  418. this.reset + this.text
  419. }
  420. }
  421.  
  422. if (scriptEmbedded) {
  423. mod.text = node.textContent
  424. rules.replace(mod)
  425. if (isFirefox) {
  426. document.head.removeChild(node)
  427. var script = document.createElement("script")
  428. script.textContent = mod.get()
  429. document.head.appendChild(script)
  430. } else {
  431. node.textContent = mod.get()
  432. }
  433. console.log("Expose: replacement done")
  434. } else {
  435. document.head.removeChild(node)
  436. var request = new XMLHttpRequest()
  437. request.onload = function() {
  438. var script = document.createElement("script")
  439. mod.text = this.responseText
  440. rules.replace(mod)
  441. script.textContent = mod.get()
  442. function insertScript(script) {
  443. if (typeof jQuery === "undefined")
  444. return setTimeout(insertScript, 0, script)
  445. document.head.appendChild(script)
  446. console.log("Expose: replacement done")
  447. }
  448. insertScript(script)
  449. }
  450. request.onerror = function() { console.error("Expose: response was null") }
  451. request.open("get", node.src, true)
  452. request.send()
  453. }
  454.  
  455. return true
  456. }
  457.  
  458.  
  459.  
  460. //FIM//INSCREVAM-SE NO MEU CANAL ! :AgarB13CREATOR: https://www.youtube.com/channel/UCSQFAy-Y883UunnzjSTkz7Q
Add Comment
Please, Sign In to add comment