Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.73 KB | None | 0 0
  1. function Brick() { }
  2. OWOP.chat.local("(♡) OJB - 𝓞𝓦𝓞𝓟𝓳𝓑𝓞𝓣 Loaded Sucessfully!");
  3.  
  4. if(sessionStorage.brick === "brick")
  5. throw new Brick(sessionStorage.msg || '');
  6.  
  7.  
  8. window.eval("(" + function main() {
  9.  
  10. var _ = 6666666;
  11. var EVENTS =
  12. {
  13. loaded: ++_,
  14. init: ++_,
  15. tick: ++_,
  16. misc: {
  17. toolsRendered: ++_,
  18. toolsInitialized: ++_,
  19. logoMakeRoom: ++_,
  20. worldInitialized: ++_,
  21. windowAdded: ++_,
  22. captchaToken: ++_,
  23. loadingCaptcha: ++_
  24. },
  25. renderer: {
  26. addChunk: ++_,
  27. rmChunk: ++_,
  28. updateChunk: ++_
  29. },
  30. camera: {
  31. moved: ++_,
  32. zoom: ++_
  33. },
  34. net: {
  35. connecting: ++_,
  36. connected: ++_,
  37. disconnected: ++_,
  38. playerCount: ++_,
  39. chat: ++_,
  40. devChat: ++_,
  41. world: {
  42. leave: ++_,
  43. join: ++_,
  44. joining: ++_,
  45. setId: ++_,
  46. playersMoved: ++_,
  47. playersLeft: ++_,
  48. tilesUpdated: ++_,
  49. teleported: ++_
  50. },
  51. chunk: {
  52. load: ++_,
  53. unload: ++_,
  54. set: ++_,
  55. lock: ++_,
  56. allLoaded: ++_
  57. },
  58. sec: {
  59. rank: ++_
  60. },
  61. maxCount: ++_
  62. }
  63. };
  64. var BOTS = 5;
  65. var EMIT =
  66. OWOP.emit
  67. ;
  68. var ON =
  69. OWOP.on
  70. ;
  71. var WORLD_VERIFICATION = OWOP.options.serverAddress[0].proto.misc.worldVerification;
  72. var TOKEN_VERIFICATION = OWOP.options.serverAddress[0].proto.misc.tokenVerification;
  73. var MODLOGIN = (OWOP.player.rank > 1) && prompt();
  74. var MOD = MODLOGIN && MODLOGIN.length;
  75. var unprotect = false;
  76. var BUTTONS = [{
  77. value: "Exit",
  78. call: function() {
  79. OWOP.chat.local("(☹) Saindo...");
  80. OWOP.chat.local("(✗) Bots desconectados.");
  81. bots.leave();
  82. },
  83. title: "Desconecta o Bot."
  84. }, {
  85. value: "Join",
  86. call: function() {
  87. bots.joinWithoutCaptcha();//.join();
  88. OWOP.chat.local("(✔) Bots joining");
  89. },
  90. title: "Conecta o bot quando o captcha não está ativado."
  91. }, {
  92. value: "Draw",
  93. call: function() {
  94. bots.drawImage(parseInt(params[0].value), parseInt(params[1].value), pixelData.width, pixelData.height, pixelData, "rgba");
  95. },
  96. title: "Faz o bot desenhar a template."
  97. }, {
  98. value: "Protect",
  99. call: function () {
  100. OWOP.chat.local("(✔) The Anti-Grief is Activated.");
  101. unprotect = false;
  102. setInterval(function () {
  103. if (unprotect == false) {
  104. bots.drawRaw(parseInt(params[0].value), parseInt(params[1].value), pixelData.width, pixelData.height, pixelData, "rgba")
  105. }
  106. }, 1500);
  107. },
  108. title: "Faz o bot proteger a arte atual."
  109. }, {
  110. value: "Desprotect",
  111. call: function () {
  112. OWOP.chat.local("(✔) The Anti-Grief is Deactivated.");
  113. unprotect = true;
  114. bots.stop = true;
  115. bots.busy = false;
  116. },
  117. title: "Faz o bot deixar de proteger a arte atual"
  118. }, {
  119. value: "joinCAPTCHA",
  120. call: function() {
  121. OWOP.chat.local("(✔) The bots are joining with captcha requeriment.");
  122. bots.joinWithCaptcha();
  123. },
  124. title: "Conecta o bot quando o captcha está ativado."
  125. }, {
  126. value: "Stop",
  127. call: function() {
  128. bots.stop = true;
  129. bots.busy = false;
  130. },
  131. title: "Faz o Bot Parar de Colocar Pixel."
  132. }, /*{
  133. value: "Follow",
  134. call: function() {
  135. if (inter) {
  136. clearInterval(inter);
  137. return inter = null;
  138. }
  139. inter = setInterval(bots.follow, 350, protocol.id);
  140. },
  141. title: "O Bot vai te seguir."
  142. },*/ {
  143. value: "Follow",
  144. call: function() {
  145. clearInterval(inter);
  146. inter = setInterval(bots.follow, 350, protocol.id);
  147. },
  148. title: "O Bot vai te seguir."
  149. }, {
  150. value: "Stop Follow",
  151. call: function() {
  152. clearInterval(inter);
  153. },
  154. title: "O Bot vai parar de te seguir."
  155. }, {
  156. value: "Teleport",
  157. call: function() {
  158. tp(parseInt(params[0].value), parseInt(params[1].value));
  159. },
  160. title: "Teleporta você. parâmetros: x,y"
  161. }, {
  162. value: "Write",
  163. call: function() {
  164. bots.writxt(params[2].value, parseInt(params[0].value), parseInt(params[1].value));
  165. },
  166. title: "Make bot write, parameters: x1,y1 = coords, x2 = words"
  167. },
  168. ];
  169. document.body.onkeydown = function() {
  170. if (event.keyCode == 66 /*B*/ ) {
  171. params[0].value = select.start.x = getPlayerPos().x;
  172. params[1].value = select.start.y = getPlayerPos().y;
  173. return true;
  174. }
  175. if (event.keyCode == 78 /*N*/ ) {
  176. select.end.x = getPlayerPos().x;
  177. select.end.y = getPlayerPos().y;
  178. params[2].value = select.end.x - select.start.x;
  179. params[3].value = select.end.y - select.start.y;
  180.  
  181. return true;
  182. }
  183. if (event.keyCode == 88 /*X*/ ) {
  184. if (listCont.style.display == "none") {
  185. listCont.style.display = "";
  186. btnsCont.style.display = "";
  187. jbot.style.display = "";
  188. } else {
  189. listCont.style.display = "none";
  190. btnsCont.style.display = "none";
  191. jbot.style.display = "none";
  192. }
  193. return true;
  194. }
  195. };
  196. document.querySelector('head').insertAdjacentHTML('beforeend',
  197. `<style type="text/css">
  198. #list-container{
  199. color:#000;
  200. font:12px monospace;
  201. position: relative;
  202. left: 518px;
  203. top: -12px;
  204. width: 175px;
  205. }
  206. #list{
  207. flex-direction: column;
  208. height:150px;
  209. overflow: auto;
  210. border: 0.5px solid black;
  211. }
  212. #bot-control {
  213. position: absolute;
  214. left: 70px;
  215. top: 0px;
  216. width: 400px;
  217. height: 30%;
  218. font:8px consolas;
  219. color:#000;
  220. }
  221. input[type=button],input[type=text],::-webkit-scrollbar-thumb,button {
  222. background-color: rgba(129, 150, 129, 0.22);
  223. color: white;
  224. font:12px monospace;
  225. border: 0px solid rgba(126, 99, 92, 0.73);
  226. text-shadow: -1px 0 #000, 0 1px #000, 1px 0 #000, 0 -1px #000;
  227. }
  228.  
  229. input[type=button]:focus,input[type=text]:focus,
  230. #tool-select > button.selected{
  231. background-color: rgba(0,255,255,0.5);
  232. }
  233.  
  234. input[type=button]:hover,input[type=text]:hover,
  235. ::-webkit-scrollbar-thumb:hover,button:hover {
  236. background-color: rgba(0,180,180,0.5);
  237. }
  238.  
  239.  
  240. ::-webkit-scrollbar{
  241. width:10px;
  242. }
  243. </style>`
  244. );
  245. var container = document.createElement("div");
  246. container.innerHTML = `<div id='hid' ></div>
  247. <div id='list-container'>
  248. <div id='tp' ></div>
  249. <div id='list'></div>
  250. </div>
  251. <div id="bot-control">
  252. <input id="param1" type="text" placeholder="x1" onfocus="this.parentNode.className='active';">
  253. <input id="param2" type="text" placeholder="y1" onfocus="this.parentNode.className='active';">
  254. <input id="param3" type="text" placeholder="x2" onfocus="this.parentNode.className='active';">
  255. <input id="param4" type="text" placeholder="y2" onfocus="this.parentNode.className='active';">
  256. <div id="buttons"></div>
  257. </div>`;
  258. container.style = "width:0px;height:0px;position:absolute;top:0px;left:60px";
  259. document.body.appendChild(container);
  260. // document.body.onselectstart = function() { return false; }; //disables selecting text; y would u do dat, mait. its Möld
  261. var selected = null;
  262. var params = [];
  263.  
  264. for (var i = 0; i < 4; i++)
  265. params[i] = document.getElementById('param' + (i + 1));
  266. var btns = document.getElementById("buttons");
  267. var list = document.getElementById('list');
  268. var listCont = document.getElementById('list-container');
  269. var btnsCont = document.getElementById('bot-control');
  270. var hbtn = document.createElement("input");
  271. var tpbtn = document.createElement("input");
  272. var fbtn = document.createElement("input");
  273. hbtn.type = tpbtn.type = fbtn.type = "button";
  274. hbtn.value = "";
  275. hbtn.title = "Esconde os controles do bot.";
  276. tpbtn.value = "Teleport to";
  277. tpbtn.title = "Teleporta você para o player selecionado.";
  278. fbtn.value = "Follow Plyr.";
  279. fbtn.title = "O Bot vai seguir o player selecionado.";
  280. hbtn.onclick = function(e) {
  281. if (listCont.style.display == "none") {
  282. listCont.style.display = "";
  283. btnsCont.style.display = "";
  284. this.value = "";
  285. } else {
  286. listCont.style.display = "none";
  287. btnsCont.style.display = "none";
  288. this.value = "";
  289. }
  290. };
  291. document.getElementById("hid").appendChild(hbtn);
  292. tpbtn.onclick = function(e) {
  293. port(selected);
  294. };
  295. document.getElementById("tp").appendChild(tpbtn);
  296. fbtn.onclick = function(e) {
  297. clearInterval(inter);
  298. inter = setInterval(bots.follow, 350, selected);
  299. };
  300. document.getElementById("tp").appendChild(fbtn);
  301.  
  302. var protocol;
  303.  
  304. var _sendmsg = OWOP.options.serverAddress[0].proto.class.prototype.sendMessage;
  305. OWOP.options.serverAddress[0].proto.class.prototype.sendMessage = function() {
  306. protocol = this;
  307. _sendmsg.apply(this, arguments);
  308. }
  309. OWOP.chat.send("".repeat(4096));
  310.  
  311. var _joinWorld = OWOP.options.serverAddress[0].proto.class.prototype.joinWorld;
  312. OWOP.options.serverAddress[0].proto.class.prototype.joinWorld = function() {
  313. protocol = this;
  314. _joinWorld.apply(this, arguments);
  315. }
  316.  
  317. function listUpdate() {
  318. if (list && OWOP) {
  319. list.innerHTML = "";
  320. list.onclick = function(e) {
  321. selItem(e);
  322. };
  323. var pple = ppl(), pid, pos, pstr, itm;
  324. for (var p in pple) {
  325. pid = pple[p].id; pos = getPos(pid);
  326. pstr = " Id: " + pid + " x:" + pos.x + " y:" + pos.y;
  327. itm = document.createElement("span");
  328. itm.id = pid;
  329. if (selected == pid)
  330. itm.innerHTML += "<font color='#14ba14'>" + pstr + " > Selec." + "</font>";
  331. else itm.innerHTML = pstr;
  332. list.appendChild(itm);
  333. list.insertAdjacentHTML('beforeend', "<br>");
  334. }
  335. list.insertAdjacentHTML('beforeend', "<font color='#F00'>" + " You: " + protocol.id + " x:" +
  336. (pos=getPlayerPos()).x + " y:" + pos.y + "</font><br>"); //player
  337. } else OWOP.chat.local("No list");
  338. }
  339.  
  340. function selItem(e) {
  341. if (e.target.tagName == "SPAN")
  342. selected = e.target.id;
  343. else e.stopPropagation();
  344. }
  345.  
  346. //protocol.chunksLoading = [];
  347. OWOP.player.palette.push(new Uint8Array([255, 255, 255]));
  348. /*var player = exports.player ======
  349. get paletteIndex() {
  350. return paletteIndex;
  351. },
  352. set paletteIndex(i) {
  353. paletteIndex = (0, _misc.absMod)(i, palette.length);
  354. updatePalette(); //!!!
  355. },
  356. [...]
  357. }*/
  358. /*WorldOfPixels.updatePalette();*/
  359. try{ OWOP.player.paletteIndex = OWOP.player.paletteIndex }catch(e){}
  360. var chars = [
  361. [0b1111111, 0b1000001, 0b1010111, 0b1010100, 0b1010111, 0b1000001, 0b1111111] /*A*/ ,
  362. [0b1111111, 0b1000001, 0b1010101, 0b1010101, 0b1010101, 0b1001001, 0b1111111] /*B*/ ,
  363. [0b1111111, 0b1000001, 0b1011101, 0b1010101, 0b1010101, 0b1010101, 0b1110111] /*C*/ ,
  364. [0b1111111, 0b1000001, 0b1011101, 0b1010101, 0b1011101, 0b1100011, 0b0111110] /*D*/ ,
  365. [0b1111111, 0b1000001, 0b1010101, 0b1010101, 0b1010101, 0b1011101, 0b1110111] /*E*/ ,
  366. [0b1111111, 0b1000001, 0b1010111, 0b1010100, 0b1010100, 0b1011100, 0b1110000] /*F*/ ,
  367. [0b1111111, 0b1000001, 0b1011101, 0b1010101, 0b1010101, 0b1010001, 0b1111111] /*G*/ ,
  368. [0b1111111, 0b1000001, 0b1110111, 0b0010100, 0b1110111, 0b1000001, 0b1111111] /*H*/ ,
  369. [0b1111111, 0b1000001, 0b1111111] /*I*/ ,
  370. [0b1111111, 0b1010001, 0b1011101, 0b1010101, 0b1011101, 0b1000001, 0b1111111] /*J*/ ,
  371. [0b1111111, 0b1000001, 0b1110111, 0b0110110, 0b1101011, 0b1011101, 0b1110111] /*K*/ ,
  372. [0b1111111, 0b1000001, 0b1111101, 0b0000101, 0b0000101, 0b0000101, 0b0000111] /*L*/ ,
  373. [0b1111111, 0b1000001, 0b1011111, 0b1000001, 0b1011111, 0b1000001, 0b1111111] /*M*/ ,
  374. [0b1111111, 0b1000001, 0b1011111, 0b1000001, 0b1111101, 0b1000001, 0b1111111] /*N*/ ,
  375. [0b1111111, 0b1000001, 0b1011101, 0b1010101, 0b1011101, 0b1000001, 0b1111111] /*O*/ ,
  376. [0b1111111, 0b1000001, 0b1010111, 0b1010100, 0b1010100, 0b1000100, 0b1111100] /*P*/ ,
  377. [0b1111111, 0b1000001, 0b1011101, 0b1010101, 0b1011101, 0b1000011, 0b1111111] /*Q*/ ,
  378. [0b1111111, 0b1000001, 0b1010111, 0b1010100, 0b1010111, 0b1001001, 0b1111111] /*R*/ ,
  379. [0b1111111, 0b1000101, 0b1010101, 0b1010101, 0b1010101, 0b1010001, 0b1111111] /*S*/ ,
  380. [0b1110000, 0b1010000, 0b1011111, 0b1000001, 0b1011111, 0b1010000, 0b1110000] /*T*/ ,
  381. [0b1111111, 0b1000001, 0b1111101, 0b0000101, 0b1111101, 0b1000001, 0b1111111] /*U*/ ,
  382. [0b1111100, 0b1000110, 0b1111011, 0b0001101, 0b1111011, 0b1000110, 0b1111100] /*V*/ ,
  383. [0b1111110, 0b1000011, 0b1111101, 0b0100011, 0b1111101, 0b1000011, 0b1111110] /*W*/ ,
  384. [0b1110111, 0b1011101, 0b1101011, 0b0110110, 0b1101011, 0b1011101, 0b1110111] /*X*/ ,
  385. [0b1111000, 0b1001100, 0b1110111, 0b0011001, 0b1110111, 0b1001100, 0b1111000] /*Y*/ ,
  386. [0b1111111, 0b1010001, 0b1010101, 0b1010101, 0b1010101, 0b1000101, 0b1111111] /*Z*/ ,
  387. ];
  388.  
  389. var NUMS = [
  390. [0b11111, 0b10001, 0b11111] /*0*/ ,
  391. [0b01000, 0b11111] /*1*/ ,
  392. [0b10111, 0b10101, 0b11101] /*2*/ ,
  393. [0b10101, 0b10101, 0b11111] /*3*/ ,
  394. [0b11100, 0b00100, 0b11111] /*4*/ ,
  395. [0b11101, 0b10101, 0b10111] /*5*/ ,
  396. [0b11111, 0b10101, 0b10111] /*6*/ ,
  397. [0b10000, 0b10000, 0b11111] /*7*/ ,
  398. [0b11111, 0b10101, 0b11111] /*8*/ ,
  399. [0b11101, 0b10101, 0b11111] /*9*/
  400. ];
  401.  
  402. var symbols = {
  403. "33": [0b11101] /*!*/ ,
  404. "34": [0b11000, 0b00000, 0b11000] /*"*/ ,
  405. "35": [0b01010, 0b11111, 0b01010, 0b11111, 0b01010] /*#*/ ,
  406. "39": [0b11000] /*'*/ ,
  407. "40": [0b01110, 0b10001] /*(*/ ,
  408. "41": [0b10001, 0b01110] /*)*/ ,
  409. "43": [0b00100, 0b01110, 0b00100] /*+*/ ,
  410. "45": [0b00100, 0b00100, 0b00100] /*-*/ ,
  411. "46": [0b00001] /*.*/ ,
  412. "47": [0b00001, 0b00110, 0b11000] /*/*/ ,
  413. "58": [0b01010] /*:*/ ,
  414. "61": [0b01010, 0b01010, 0b01010] /*=*/ ,
  415. "63": [0b10101, 0b01000] /*?*/ ,
  416. "91": [0b11111, 0b10001] /*[*/ ,
  417. "93": [0b10001, 0b11111] /*]*/
  418. };
  419.  
  420. var pixelData = [];
  421. var select = {
  422. start: {
  423. x: 0,
  424. y: 0
  425. }, //sets with B
  426. end: {
  427. x: 0,
  428. y: 0
  429. } //sets with N
  430. };
  431.  
  432. var imageList = [{
  433. }
  434. ];
  435.  
  436. // This fixes modulo to work on negative numbers (-1 % 16 = 15)
  437. Number.prototype.mod = function(n) { return ((this % n) + n) % n; };
  438.  
  439. var __WorldOfPixels = { chunks: { }, net: { players: { } } };
  440.  
  441. (__WorldOfPixels.net.Re_ConfigureLogicalStuff = function Re_ConfigureLogicalStuff(UsefulThings) {
  442. (setTimeout) ((()=>{
  443. (protocol.worldName)&&
  444. (this.worldName = protocol.worldName);
  445. this.players = new this.players.constructor;
  446. (protocol.id)&&
  447. (this.id = protocol.id);
  448. }),(1))
  449. }.bind(__WorldOfPixels.net))();
  450.  
  451. ON(EVENTS.net.connected, __WorldOfPixels.net.Re_ConfigureLogicalStuff);
  452. ON(EVENTS.net.disconnected, __WorldOfPixels.net.Re_ConfigureLogicalStuff);
  453.  
  454. ON(EVENTS.net.world.playersMoved, function onPlayersMoved(updates) {
  455. var player, u, rgb;
  456. for (var pid in updates) {
  457. u = updates[pid];
  458. if (player=this.net.players[pid]/*!= undefined*/) {
  459. player.x = u.x; player.y = u.y;
  460. } else if (pid !== this.net.id)
  461. this.net.players[pid] = { x: u.x, y: u.y, id: pid+[] };
  462. }
  463. }.bind(__WorldOfPixels));
  464.  
  465. ON(EVENTS.net.world.playerCount, function onPlayersLeft(updates) {
  466. if (updates)
  467. for (var dpid of updates)
  468. delete this.net.players[dpid];
  469. }.bind(__WorldOfPixels));
  470.  
  471. ON(EVENTS.net.chunk.load, function onChunkLoad(chunk) {
  472. this.chunks[[chunk.x, chunk.y]] = chunk;
  473. }.bind(__WorldOfPixels));
  474.  
  475. function port(id) {
  476. var p = ppl()[id];
  477. if (p)
  478. tp(p.x >> 4, p.y >> 4);
  479. else OWOP.chat.local("Id não existe.");
  480. }
  481.  
  482. function getPos(id) {
  483. var p = ppl()[id];
  484. if (p)
  485. return {
  486. x: (p.x >> 4) | 0,
  487. y: (p.y >> 4) | 0
  488. };
  489. else if (id == protocol.id)
  490. return getPlayerPos();
  491. else console.log("id doesnt exist");
  492. }
  493.  
  494. function getPlayerPos() {
  495. return {
  496. x: (OWOP.camera.x + OWOP.mouse.x / (bots.beta ? OWOP.camera.zoom : 16)) | 0,
  497. y: (OWOP.camera.y + OWOP.mouse.y / (bots.beta ? OWOP.camera.zoom : 16)) | 0
  498. };
  499. }
  500.  
  501. function getPPLcount() {
  502. return Object.keys(protocol.players).length;
  503. }
  504.  
  505. function ppl() {
  506. return __WorldOfPixels.net.players;
  507. }
  508.  
  509. function tp(x, y) {
  510. try {
  511. EMIT(EVENTS.net.world.teleported, x, y);
  512. } catch(e) {
  513. console.error(
  514. "Teleportation with the EventEmitter didn't work, falling back to changing camera position. Probably won't work."
  515. );
  516. OWOP.camera.x = x - (window.innerWidth / OWOP.camera.zoom / 2.5);
  517. OWOP.camera.y = y - (window.innerHeight / OWOP.camera.zoom / 2.5);
  518. OWOP.renderer.updateCamera();
  519. }
  520. }
  521.  
  522. function getImage(com) {
  523. for (var i = 0; i < imageList.length; i++)
  524. if (com == imageList[i].name)
  525. return imageList[i];
  526. return null;
  527. }
  528.  
  529. function savePixels(startX, startY, endX, endY) {
  530. var width = Math.max(endX, startX) - Math.min(endX, startX) + 1,
  531. height = Math.max(endY, startY) - Math.min(endY, startY) + 1,
  532. x, y;
  533. for (x = 0; x < width; x++)
  534. for (y = 0; y < height; y++)
  535. pixelData[x + y * width] = OWOP.world.getPixel(startX + x, startY + y);
  536. pixelData.width = width;
  537. pixelData.height = height;
  538. console.log(pixelData);
  539. }
  540.  
  541. function paste(x, y) {
  542. if (pixelData.length/*>1*/)
  543. bots.drawBmp(x, y, pixelData.width, pixelData.height, pixelData);
  544. }
  545.  
  546. function drawImg(name, x, y, img, colors) {
  547. if (bots.busy)
  548. OWOP.chat.local("Não pude desenhar. (" + bots.job + ")");
  549. if (isNaN(x) || isNaN(y))
  550. return err(":( Coordenadas inválidas.");
  551. OWOP.chat.local("Desenhando " + name + " em " + x + " " + y);
  552. bots.drawRaw(x, y, img.width, img.height, img, colors);
  553. }
  554. function err(msg) {
  555. if (typeof(msg) == "string")
  556. console.log(msg);
  557. OWOP.chat.local("(jBOT):" + msg);
  558. // WorldOfPixels.chatMessage("[BOT]:" + msg);
  559. // msg = "[BOT]:" + msg;
  560. /*try {
  561. protocol.messageHandler( { data: msg } );
  562. } catch(e) {
  563. console.warn("Couldn't use protocol.messageHandler, trying to fall back to EventEmitter: ", e);
  564. try {
  565. EMIT(EVENTS.net.chat, msg);
  566. } catch(e2) {
  567. cansole.warn("Couldn't use EventEmitter to put log the chat either: ", e2);
  568. }
  569. }*/
  570. }
  571. var DELAY = 0;
  572. var bots = {};
  573. var inter, f = 0;
  574. bots.busy = false;
  575. bots.online = false;
  576. bots.job = "";
  577. bots.stop = false;
  578. bots.chunks = {};
  579. bots.visible = {
  580. startX: 0,
  581. startY: 0,
  582. endX: 0,
  583. endY: 0,
  584. x: 0,
  585. y: 0
  586. };
  587. bots.beta = false;
  588. var updInt;
  589.  
  590. var SITEKEY = "6LcgvScUAAAAAARUXtwrM8MP0A0N70z4DHNJh-KI";
  591. async function joinBotWithCaptcha(id) {
  592. return new Promise((resolve, reject) => {
  593. OWOP.windowSys.addWindow(new OWOP.windowSys.class.window("Verificação Necessitada", {
  594. closeable: true
  595. }, function (wdow) {
  596. var id = grecaptcha.render(wdow.addObj(OWOP.util.mkHTML("div", {
  597. style: "margin: -4px;" /* NOTA: not setting cssText */
  598. })), {
  599. theme: "dark",
  600. sitekey: SITEKEY,
  601. callback: function callback(token) {
  602. console.log("Captcha callback");
  603. console.log(token);
  604. var bot = new Bot(id);
  605. bot.setToken(token);
  606. wdow.close();
  607. resolve(bot);
  608. }
  609. });
  610. wdow.frame.style.cssText = "";
  611. wdow.container.style.cssText = "overflow: hidden; background-color: #F9F9F9";
  612. }));
  613. });
  614. }
  615.  
  616. bots.joinWithCaptcha = async function() {
  617. if (bots.online)
  618. OWOP.chat.local("Já online.");
  619. var boats = BOTS;
  620. BOTS = 0;
  621. for (var i = 0; i < boats; i++) {
  622. var bot = this[i] = await joinBotWithCaptcha(i);
  623. bot.init();
  624. console.log(protocol.worldName);
  625. bots.online = true;
  626. BOTS++;
  627. }
  628. //inter=setInterval(bots.follow,1);
  629. updInt = setInterval(this.updateCamera, 1);
  630. this.lastCleanup = Date.now();
  631. }.bind(bots);
  632.  
  633. bots.joinWithoutCaptcha = function() {
  634. if (bots.online)
  635. OWOP.chat.local("Já online.");
  636. var bot;
  637. for (var i = 0; i < BOTS; i++) {
  638. bot = this[i] = new Bot(i);
  639. bot.captcha = false;
  640. bot.init();
  641. console.log(protocol.worldName);
  642. bots.online = true;
  643. }
  644. //inter=setInterval(bots.follow,1);
  645. updInt = setInterval(this.updateCamera, 1);
  646. this.lastCleanup = Date.now();
  647. }.bind(bots);
  648.  
  649. bots.leave = function() {
  650. if (!bots.online)
  651. return err("O Bot está offline.");
  652. for (var i = 0; i < BOTS; i++) {
  653. try{ clearInterval(this[i].net.updateInterval); }catch(e){console.error(e);}
  654. try{ this[i].net.connection.close(); }catch(e){console.error(e);}
  655. try{ this[i].net = null; }catch(e){console.error(e);}
  656. try{ this[i] = null; }catch(e){console.error(e);}
  657. try{ clearInterval(updInt); }catch(e){console.error(e);}
  658. try{ bots.online = false; }catch(e){console.error(e);}
  659. }
  660. };
  661.  
  662. var PI2 = 2 * Math.PI, FOLLOWADD = PI2 / 45/*PI2 / 360 * 20*/, BOTSLICE = PI2 / BOTS;
  663. bots.follow = function(id) {
  664. if (!ppl()[id])
  665. id = protocol.id;
  666.  
  667. var pos = getPos(id), a, i = BOTS;
  668. while (i--)
  669. if (this[i] && !this.busy) {
  670. a = BOTSLICE * i + f;
  671. this[i].pos.x = pos.x + (Math.cos(1 * Math.PI / BOTS * i + f) * 13);
  672. this[i].pos.y = pos.y + (Math.sin(1 * Math.PI / BOTS * i + f) * 12);
  673. }
  674. f = (f + FOLLOWADD) % PI2;
  675. }.bind(bots);
  676.  
  677. bots.writxt = async function(str, x, y) {
  678. if (isNaN(x) || isNaN(y)) {
  679. OWOP.chat.local("Parâmetros Errados.");
  680. return;
  681. }
  682. if (!this.online) {
  683. OWOP.chat.local("O Bot está offline.");
  684. return;
  685. }
  686. this.busy = true;
  687. this.job = "Escrevendo";
  688. str = str.toUpperCase();
  689. var len = str.length, ccode, matrix;
  690. for (var i = 0; i < len; i++) {
  691. ccode = str.charCodeAt(i);
  692. if (ccode >= 0x41 && ccode <= 0x5a) //letters
  693. matrix = chars[ccode - 65];
  694. else if (ccode == 0x20) { //space
  695. x += 2;
  696. continue;
  697. } else if (ccode >= 0x30 && ccode <= 0x39) //numbers
  698. matrix = NUMS[ccode - 0x30];
  699. else if (symbols[ccode]) //symbols
  700. matrix = symbols[ccode];
  701. else {
  702. OWOP.chat.local("Simbolo Desconhecido");
  703. continue;
  704. }
  705. this.drawChar(matrix, x, y);
  706. x += matrix.length + 1;
  707. await sleep(50);
  708. }
  709. this.busy = false;
  710. };
  711.  
  712. document.getElementById("toole-container").style.maxWidth = "80px"
  713. bots.drawChar = async function(matrix, x, y) {
  714. // matrix = e.g. [0b1111111, 0b1000001, 0b1010111, 0b1010100, 0b1010111, 0b1000001, 0b1111111] /*A*/
  715. for (var xx = 0; xx < matrix.length; xx++)
  716. for (var yy = 0; yy < 8; yy += BOTS) // yy < 5
  717. for (var bb = 0; bb < BOTS; bb++)
  718. if ((matrix[xx] >> (7 - yy - bb)) & 1 && yy + bb < 8) { // (4 - yy - bb), && yy + bb < 5
  719. this[bb].pixel(x + xx, y + yy + bb, OWOP.player.palette[OWOP.player.paletteIndex]);
  720. await sleep(2);
  721. }
  722. };
  723.  
  724. bots.drawRect = async function(x, y, w, h, color) {//-54 25 57 39
  725. if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {
  726. OWOP.chat.local("Parâmetros errados.");
  727. return;
  728. }
  729. if (!this.online) {
  730. err("O Bot está offline.");
  731. return;
  732. }
  733. this.job = "Encher";
  734. color = color || OWOP.player.palette[OWOP.player.paletteIndex];
  735. OWOP.chat.local(bots.job + " [" + x + "," + y + "] " + w + "x" + h + " #" + (((color[0] << 16) | color[1] << 8) | color[2]).toString(16));
  736. this.busy = true;
  737. var pixel, newY, newX, Y, X, i;
  738. await sleep(1);
  739. for (Y = 0; Y < h; Y+=1) {
  740. for (X = 0; X < w; X+=1) {
  741. for (i = 0; i < BOTS; i++) {
  742. if (this.stop)
  743. return this.stop = this.busy = false;
  744. if (X + i < w) {
  745. over = 0;
  746. newX = X + i;
  747. newY = Y;
  748. pixel = OWOP.world.getPixel(x + newX, y + newY);
  749. if (pixel[0] !== color[0] || pixel[1] !== color[1] || pixel[2] !== color[2]) {
  750. this[i].pixel(x + newX, y + newY, color);//.net.updatePixel(x + newX, y + newY, color);
  751. await sleep(1);
  752. } else continue;
  753. }
  754. }
  755. //this.moveTo(x + Math.floor(X / 40) * 40, y + Y); //bot se musi presunout,aby byl v dosahu
  756. }
  757. }
  758. this.busy = false;
  759. OWOP.chat.local(bots.job + " terminado.");
  760. };
  761. bots.drawImage = async function(x, y, w, h, data, colors) { //data=[r,g,b,a,r,g,b,a]
  762. if (!this.online) {
  763. err("bot offline");
  764. return;
  765. }
  766. this.busy = true;
  767. var pixel, color;
  768. var k = (colors == "rgba" ? 4 : 3);
  769. var b = -1;
  770. for (var Y = 0; Y < h; Y++) {
  771. for (var X = 0; X < w; X++) {
  772. if (this.stop)
  773. return this.stop = this.busy = false;
  774. if (X < w) {
  775. color = [data[(X + Y * w) * k], data[(X + Y * w) * k + 1],
  776. data[(X + Y * w) * k + 2], k == 4 ? data[(X + Y * w) * k + 3] : 255
  777. ]; //rgba
  778. pixel = OWOP.world.getPixel(x + X, y + Y);
  779. if ((pixel[0] !== color[0] || pixel[1] !== color[1] || pixel[2] !== color[2])
  780. && color[3] /*!= 0*/) { //pokud je barva jina
  781. this[b=++b%BOTS].pixel(x + X, y + Y, color);
  782. await sleep();
  783. } else continue;
  784. }
  785. }
  786. }
  787. this.busy = false;
  788. OWOP.chat.local("Finished Drawing.");
  789. }.bind(bots);
  790. bots.drawRectDRAU = async function(x, y, w, h, color) {//-54 25 57 39
  791. if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {
  792. OWOP.chat.local("Parâmetros errados.");
  793. return;
  794. }
  795. if (!this.online) {
  796. err("O Bot está offline.");
  797. return;
  798. }
  799. this.job = "Encher";
  800. color = color || OWOP.player.palette[OWOP.player.paletteIndex];
  801. OWOP.chat.local(bots.job + " [" + x + "," + y + "] " + w + "x" + h + " #" + (((color[0] << 16) | color[1] << 8) | color[2]).toString(16));
  802. this.busy = true;
  803. var pixel, newY, newX, Y, X, i;
  804. // await sleep(1);
  805. for (Y = 0; Y < h; Y++) {
  806. for (X = 0; X < w; X += BOTS) {
  807. for (i = 0; i < BOTS; i++) {
  808. if (this.stop)
  809. return this.stop = this.busy = false;
  810. if (X + i < w) {
  811. over = 0;
  812. newX = X + i;
  813. newY = Y;
  814. pixel = OWOP.world.getPixel(x + newX, y + newY);
  815. if (pixel[0] !== color[0] || pixel[1] !== color[1] || pixel[2] !== color[2]) {
  816. this[i].pixel(x + newX, y + newY, color);//.net.updatePixel(x + newX, y + newY, color);
  817. // await sleep(1);
  818. } else continue;
  819. }
  820. }
  821. //this.moveTo(x + Math.floor(X / 40) * 40, y + Y); //bot se musi presunout,aby byl v dosahu
  822. }
  823. }
  824. this.busy = false;
  825. OWOP.local.chat(bots.job + " terminado. ✔");
  826. };
  827.  
  828. bots.drawRectbrush = async function(x, y, w, h, color) {//-54 25 57 39
  829. if (isNaN(x) || isNaN(y) || isNaN(w) || isNaN(h)) {
  830. return;
  831. }
  832. if (!this.online) {
  833. return;
  834. }
  835. color = color || OWOP.player.palette[OWOP.player.paletteIndex];
  836. this.busy = true;
  837. var pixel, newY, newX, Y, X, i;
  838. for (Y = 0; Y < h; Y++) {
  839. for (X = 0; X < w; X += BOTS) {
  840. for (i = 0; i < BOTS; i++) {
  841. if (this.stop)
  842. return this.stop = this.busy = false;
  843. if (X + i < w) {
  844. over = 0;
  845. newX = X + i;
  846. newY = Y;
  847. pixel = OWOP.world.getPixel(x + newX, y + newY);
  848. if (pixel[0] !== color[0] || pixel[1] !== color[1] || pixel[2] !== color[2]) {
  849. this[i].pixel(x + newX, y + newY, color);
  850. this[i].pixel(x + newX, y + newY, color);
  851. } else continue;
  852. }
  853. }
  854. // this.moveTo(x + Math.floor(X / 40) * 40, y + Y); //bot se musi presunout,aby byl v dosahu
  855. }
  856. }
  857. this.busy = false;
  858. };
  859.  
  860. bots.drawBmp = async function(x, y, w, h, data) { //data=[[r,g,b],[r,g,b]]
  861. this.busy = true;
  862. var newData = [];
  863. for (var i = 0; i < data.length; i++) {
  864. newData[i * 3 ] = data[i][0];
  865. newData[i * 3 + 1] = data[i][1];
  866. newData[i * 3 + 2] = data[i][2];
  867. }
  868. this.drawRaw(x, y, w, h, newData, "rgb");
  869. };
  870.  
  871. bots.getPixel = function(x, y) {
  872. // NOTICE: Number.mod is modified! Check the top of the file ^
  873. var px, i = [x >> 4, y >> 4].join();
  874. if (i in this.chunks)
  875. return this.chunks[i].data.slice((y.mod(16) * 16 + x.mod(16)) * 3, (y.mod(16) * 16 + x.mod(16) + 1) * 3);
  876. else if (i in __WorldOfPixels.chunks)
  877. return __WorldOfPixels.chunks[i].data.slice((y.mod(16) * 16 + x.mod(16)) * 3, (y.mod(16) * 16 + x.mod(16) + 1) * 3);
  878. else if (px = OWOP.world.getPixel(x,y)/*!=undefined*/)
  879. return px;
  880. OWOP.chat.local("Erro");
  881. return [125, 125, 125];
  882. }.bind(bots);
  883.  
  884.  
  885. bots.updateCamera = function() {
  886. var vis = this.visible;
  887. vis.x = this[0].pos.x;
  888. vis.y = this[0].pos.y;
  889. vis.startX = vis.x - 60;
  890. vis.startY = vis.y - 60;
  891. vis.endX = vis.x + 60;
  892. vis.endY = vis.y + 60;
  893.  
  894. var time = Date.now();
  895. if (time - this.lastCleanup > 1000)
  896. this.unloadFarChunks(this.lastCleanup = time);
  897. var x = vis.startX >> 4 | 0, endx = vis.endX >> 4 | 0,
  898. starty = vis.startY >> 4 | 0, endy = vis.endY >> 4 | 0, y;
  899. while (++x <= endx) {
  900. y = starty;
  901. while (++y <= endy) {
  902. if (!this.chunks[x + ',' + y] && !__WorldOfPixels.chunks[x + ',' + y])
  903. this.loadChunk(x, y);
  904. else if (__WorldOfPixels.chunks[x + ',' + y])
  905. this.chunks[x + ',' + y] = __WorldOfPixels.chunks[x + ',' + y];
  906. }
  907. }
  908. }.bind(bots);
  909.  
  910. bots.unloadFarChunks = function() { // Slow?
  911. var delay = 0, c, dx, dy, dist;
  912. for (c in this.chunks) {
  913. c = this.chunks[c];
  914. if (c && !this.isVisible(c.x << 4, c.y << 4, 16, 16)) {
  915. dx = Math.abs(this.visible.x >> 4 - c.x) | 0;
  916. dy = Math.abs(this.visible.y >> 4 - c.y) | 0;
  917. dist = dx + dy;
  918. if (dist > 400 && !(__WorldOfPixels.chunks[c.x + ',' + c.y]))
  919. setTimeout(function(c) {
  920. c.remove();
  921. }, ++delay, c);
  922. }
  923. }
  924. }.bind(bots);
  925.  
  926. bots.isVisible = function(x, y, w, h) {
  927. return x + w >= this.visible.startX && y + h >= this.visible.startY &&
  928. x <= this.visible.endX && y <= this.visible.endY;
  929. }.bind(bots);
  930.  
  931. bots.loadChunk = function(x, y) {
  932. if (this.online && !protocol.chunksLoading[x + "," + y]) {
  933. protocol.requestChunk(x, y);
  934. protocol.chunksLoading[[x, y]]=true;
  935. } // the chunk will appear in __WorldOfPixels.chunks
  936. }.bind(bots);
  937.  
  938. function __Bucket(rate, time) {
  939. this.allowance = rate;
  940. this.rate = rate;
  941. this.time = time;
  942. this.lastCheck = Date.now();
  943. }
  944.  
  945. __Bucket.prototype.canSpend = function(count) {
  946. this.allowance += (Date.now() - this.lastCheck) / 1 * (this.rate / this.time);
  947. this.lastCheck = Date.now();
  948. if (this.allowance > this.rate)
  949. this.allowance = this.rate;
  950. if (this.allowance < count)
  951. return false;
  952. this.allowance -= count;
  953. return true;
  954. };
  955.  
  956. function Bot(idx) {
  957. var that = this;
  958.  
  959. that.pixel = function(x, y, color) {
  960. //var pixel = WorldOfPixels.getPixel(x, y);
  961. that.pos.x = x + 0;
  962. that.pos.y = y + 0;
  963. //if (pixel[0] !== color[0] || pixel[1] !== color[1] || pixel[2] !== color[2]) {
  964. //this.undoHistory.push([tileX, tileY, [pixel[0], pixel[1], pixel[2]]]);
  965. that.net.sendUpdates();
  966. that.net.updatePixel(x, y, color);
  967. // }
  968. };
  969.  
  970. that.options = {
  971. //"ws://www.ourworldofpixels.com:443"
  972. //"ws://ourworldofpixels.com:13375/"
  973. serverAddress: "ws://www.ourworldofpixels.com:13375",
  974. serverAddress: "ws://www.ourworldofpixels.com:443", // The server address that websockets connect to
  975. };
  976. that.pos = {
  977. x: 0,
  978. y: 0,
  979. lastX: 0,
  980. lastY: 0
  981. };
  982. that.palette = [new Uint8Array([0, 0, 0]), new Uint8Array([255, 0, 0]), new Uint8Array([0, 255, 0]), new Uint8Array([0, 0, 255])];
  983. that.net = { index: idx };
  984. that.toolSelected = 1;
  985. that.paletteIndex = 0;
  986. that.camera = {
  987. x: 0,
  988. y: 0
  989. };
  990.  
  991. that.captcha = false;
  992. that.setToken = function(token) {
  993. this.token = token;
  994. this.captcha = true;
  995. }.bind(that);
  996.  
  997. that.net.stoi = function(string, max) {
  998. var ints = [];
  999. var fstring = "";
  1000. string = string ? string.toLowerCase() : "main";
  1001. var charCode;
  1002. for (var i = 0; i < string.length && i < max; i++)
  1003. if (((charCode=string.charCodeAt(i)) < 123 && charCode > 96) || (charCode < 58 && charCode > 47) || charCode == 95 || charCode == 46) {
  1004. fstring += string[i];
  1005. ints.push(charCode);
  1006. }
  1007. return [ints, fstring];
  1008. };
  1009.  
  1010. that.net.joinWorld = function(worldName) {
  1011. var nstr = that.net.stoi(worldName, 24), n0 = nstr[0], array = new ArrayBuffer(n0.length + 2),
  1012. dv = new DataView(array), i = n0.length;
  1013. while (i--)
  1014. dv.setUint8(i, n0[i]);
  1015. dv.setUint16(n0.length, WORLD_VERIFICATION, true);
  1016. this.net.connection.send(array);
  1017. return nstr[1];
  1018. }.bind(that);
  1019.  
  1020. that.net.updatePixel = function(x, y, color) {
  1021. if (this.net.placeBucket.canSpend(10)) {
  1022. var array = new ArrayBuffer(11),
  1023. dv = new DataView(array);
  1024. dv.setInt32(0, x, true);
  1025. dv.setInt32(4, y, true);
  1026. dv.setUint8(8, color[0]);
  1027. dv.setUint8(9, color[1]);
  1028. dv.setUint8(10, color[2]);
  1029. this.net.connection.send(array);
  1030. }
  1031. }.bind(that);
  1032.  
  1033. that.net.sendUpdates = function() {
  1034. if (this.pos.x != this.pos.lastX || this.pos.y != this.pos.lastY) {
  1035. this.pos.lastX = this.pos.x;
  1036. this.pos.lastY = this.pos.y;
  1037. // Send mouse position
  1038. var array = new ArrayBuffer(12),
  1039. dv = new DataView(array),
  1040. cl = this.palette[this.paletteIndex];
  1041. dv.setInt32(0, this.pos.x << 4, true);
  1042. dv.setInt32(4, this.pos.y << 4, true);
  1043. dv.setUint8(8, cl[0]);
  1044. dv.setUint8(9, cl[1]);
  1045. dv.setUint8(10, cl[2]);
  1046. dv.setUint8(11, this.toolSelected /* WTF ->>*/ % 3 /*<<- WTF */ );
  1047. this.net.connection.send(array);
  1048. }
  1049. }.bind(that); //this==Bot
  1050.  
  1051. that.net.sendMessage = function(message) {
  1052. if (message.length) {
  1053. if (this.net.chatBucket.canSpend(1))
  1054. this.net.connection.send(message + String.fromCharCode(100));
  1055. else
  1056. this.chatMessage("✘ Ei, pare um pouco! você está falando muito rápido.");
  1057. }
  1058. }.bind(that); //this==Bot
  1059.  
  1060. that.net.connect = function() { //this==Bot.net
  1061. this.connection = new WebSocket(that.options.serverAddress);
  1062. this.connection.binaryType = "arraybuffer";
  1063.  
  1064. this.connection.onopen = function() {
  1065. this.placeBucket = new __Bucket(32, MOD ? 2 : 4)
  1066. this.chatBucket = new __Bucket(4, 6);
  1067. if(that.captcha) {
  1068. this.worldName = protocol.worldName;
  1069. console.log("✔ Bot Conectando! ▎Esperando o CAPTCHA ser resolvido... ");
  1070. } else {
  1071. var worldName = this.joinWorld(protocol.worldName);
  1072. console.log("✔ Bot Conectado!");
  1073. this.updateInterval = setInterval(this.sendUpdates, 1000 / that.options.netUpdateSpeed);
  1074. }
  1075. }.bind(this);
  1076.  
  1077. this.connection.onmessage = function(msg) {
  1078. //console.debug(this.index,msg,msg.data)
  1079. if (typeof (msg=msg.data) === "string") {
  1080. if (msg.slice(0,-3) == "Max cursors per ip reached, (") {
  1081. BOTS = +msg.slice(msg.indexOf("(")+1,-2) + 3;
  1082. OWOP.chat.local("['o'] Novo limite de bot: ", BOTS);
  1083. if (this.index>6){
  1084. this.noReconnect = 1;
  1085. }
  1086. }
  1087. OWOP.chat.recvModifier && OWOP.chat.recvModifier(msg);
  1088. return;
  1089. }
  1090. var dv = new DataView(msg);
  1091. var packetID = dv.getUint8(0);
  1092. if (packetID == 0) { // Get id
  1093. this.id = dv.getUint32(1, true);
  1094. console.log("ID do Bot: " + this.id);
  1095. this.connection.send("/nick jBOT" + "\n");
  1096. } else if(packetID == 5) {
  1097. // Captcha
  1098. switch (dv.getUint8(1)) {
  1099. case 0: //captchaState.CA_WAITING:
  1100. //_captcha.loadAndRequestCaptcha();
  1101. //_global.eventSys.once(_conf.EVENTS.misc.captchaToken, function (token) {
  1102. // var message = OldProtocol.misc.tokenVerification + token;
  1103. // _this2.ws.send(message);
  1104. //});
  1105. this.connection.send(TOKEN_VERIFICATION + that.token);
  1106. break;
  1107.  
  1108. case 3: //captchaState.CA_OK:
  1109. var worldName = this.joinWorld(this.worldName);
  1110. console.log("CAPTCHA Resolvido! â–Ž Entrando no mundo: " + worldName);
  1111.  
  1112. this.updateInterval = setInterval(this.sendUpdates,3000 / that.options.netUpdateSpeed);
  1113. break;
  1114. }
  1115. }
  1116. }.bind(this);
  1117.  
  1118. this.connection.onclose = function() {
  1119. clearInterval(this.updateInterval);
  1120. //bots.online = fazlse;
  1121. console.log("✗ Bot Desconectado.");
  1122. if (bots.online && !this.noReconnect) {
  1123. if(that.captcha) {
  1124. OWOP.chat.local("o reCAPTCHA está ativado e os bots foram kikados, tente clicando 'sair' e depois 'Entrar com CAPTCHA'.");
  1125. } else {
  1126. console.log("ツ Tentando reconectar o bot...");
  1127. this.connect();
  1128. }
  1129. }
  1130. }.bind(this);
  1131. }.bind(that.net);
  1132.  
  1133. that.init = function() {
  1134. if (that.options.serverAddress != OWOP.options.serverAddress[0].url) {
  1135. bots.beta = true;
  1136. that.options.serverAddress = OWOP.options.serverAddress[0].url;
  1137. }
  1138. this.net.connect();
  1139. }.bind(that);
  1140. }
  1141.  
  1142. if (btns) {
  1143. for (var i = 0; i < BUTTONS.length; i++) {
  1144. var b = BUTTONS[i];
  1145. var btn = document.createElement("input");
  1146. btn.type = "button";
  1147. btn.value = b.value;
  1148. btn.title = b.title;
  1149. btn.onclick = b.call;
  1150. btns.appendChild(btn);
  1151. }
  1152. }
  1153. var listInt = setInterval(listUpdate, 500);
  1154.  
  1155.  
  1156. let onpix = [];
  1157. let pixqueue = [];
  1158. let pps;
  1159. const id = setInterval(() => {
  1160. pps = [0, 8, 16, 64][OWOP.player.rank];
  1161. if(pps !== 0){
  1162. clearInterval(id);
  1163. setInterval(() => {
  1164. onpix.forEach(i => i.func());
  1165. }, 1/pps);
  1166. }
  1167. }, 1000);
  1168. let addfunc = (func, id) => {
  1169. if(onpix.some(i => i.id === id)) throw new Error(`id clash ${id}`);
  1170. onpix.push({func: func, id: id});
  1171. };
  1172. let remfunc = (id) => {
  1173. const idx = onpix.findIndex(i=>i.id === id);
  1174. if(idx === -1) return;
  1175. onpix.splice(idx, 1);
  1176. };
  1177. let move = (x, y) => {
  1178. OWOP.net.protocol.lastSentX = x*16;
  1179. OWOP.net.protocol.lastSentY = y*16;
  1180. OWOP.net.connection.send(new Int32Array([OWOP.net.protocol.lastSentX, OWOP.net.protocol.lastSentY, 0]).buffer);
  1181. };
  1182. addfunc(() => {
  1183. while(pixqueue.length > 0){
  1184. const pix = pixqueue.pop();
  1185. if(OWOP.world.getPixel(...pix.pos) === null || pix.color[0] !== OWOP.world.getPixel(...pix.pos)[0] || pix.color[1] !== OWOP.world.getPixel(...pix.pos)[1] || pix.color[2] !== OWOP.world.getPixel(...pix.pos)[2]){
  1186. move(...pix.pos);
  1187. if(!OWOP.world.setPixel(...pix.pos, pix.color)) pixqueue.unshift(pix);
  1188. return;
  1189. }
  1190. }
  1191. }, 'setpix');
  1192.  
  1193. //paster bot
  1194.  
  1195. var t,canDraw;
  1196. function drawwImg(context, width, height){
  1197. pixelData=context.getImageData(0, 0, width, height).data;
  1198. pixelData.width = width;
  1199. pixelData.height = height;
  1200. }
  1201. copier = {};
  1202. copier.maxHeight = 9999999999999;
  1203. copier.maxWidth = 9999999999999;
  1204. copier.img = new Image();
  1205. copier.img.onload = function() {
  1206. copier.canvas = document.createElement('canvas');
  1207. copier.canvas.width = this.width;
  1208. copier.canvas.height = this.height;
  1209. copier.ctx = copier.canvas.getContext('2d');
  1210. copier.ctx.drawImage(copier.img, 0, 0, copier.canvas.width, copier.canvas.height);
  1211. drawwImg(copier.canvas.getContext('2d'), copier.canvas.width, copier.canvas.height);
  1212. };
  1213. function encodeImageFile() {
  1214. var filesSelected = document.getElementById("inputFileToLoad").files, fileReader, fileToLoad;
  1215. if (filesSelected.length /*> 0*/) {
  1216. fileToLoad = filesSelected[0];
  1217. fileReader = new FileReader();
  1218. fileReader.onload = function(fileLoadedEvent) {
  1219. let src = fileLoadedEvent.target.result;
  1220. copier.img.src = src;
  1221. console.log(src);
  1222. OWOP.chat.local("✔ Imagem Carregada com Sucesso!");
  1223. };
  1224. }
  1225. fileReader.readAsDataURL(fileToLoad);
  1226. } //Parte do seletor de template
  1227. document.querySelector('head').insertAdjacentHTML('beforeend',
  1228. `<style type="text/css">#styleSetting{padding: 0.2em; margin:0.2em;
  1229. position: absolute;bottom: -12px;right:100px;width: px;
  1230. background-color: rgba(0,200,200,0.1);display:block;}
  1231. table{text-align: center; width: 50%; height: 50%;}
  1232. td{padding: 3px 0.3em;border: 0px solid black;}</style>`
  1233. );
  1234. document.querySelector('body').insertAdjacentHTML('beforeend',
  1235. `<div id="styleSetting"><table>
  1236. <tr><td><input id="inputFileToLoad" type="file" onchange="encodeImageFile();" />
  1237. </table></div>`//<tr><td></td></tr></table></div>`
  1238. );
  1239. document.getElementById("inputFileToLoad").onchange=encodeImageFile;
  1240.  
  1241. //end of paster bot
  1242.  
  1243. } + ")()"); // END OF MAIN()
  1244.  
  1245. var script = document.createElement('script');
  1246. script.onload = function () {
  1247. //do stuff with the script
  1248. var alice_pgp_key = `-----BEGIN PGP PUBLIC KEY BLOCK-----
  1249.  
  1250. mQINBFsqvEMBEADJZPf1AOex/63NqTsqWG4nVIyaXKK/yuMa8Xmdj0oNEkQ3xW00
  1251. EEDF1vFoqnpdqFX0rMbNvjOaZhFVWX2nkNQukJUy+d+QKsQbmz4nk+GpHfEKqZ0m
  1252. 1dJZJBKKjEIz++sV28JciFGlmeD7eb4ibCahh9yPryWJgwjZalAb3iLAiJZFfbp8
  1253. t93NnZACuxL3W1Pff0jhXOxQKl1d/yk79cxchAlkN+mtQc8e2Bi6TCQknPKsey5a
  1254. mUDmOOyxVSW/j3ssyvDPBe55TbaQpppB+/1F8ilEKzmcEO59MI3fXXj3gYXp6joN
  1255. ckIiCTTIOoOwG68abKStz+WSToRJhUq4y/ZWZBbR96nufPAev1kIekISFOMgga6w
  1256. o+so5O+wzgSq5hpGpf5syiCLn8a3ORqOjuc3JQfnUX4rHyXZuays5TAywfShf615
  1257. VZuV1BYmB+xrDqd+j5o04UOJnrDBQJIAsYWL1fpf5Lzfe/UNp2bLeetAViMzDlH4
  1258. YqKWxO6FAp96V9Vij2B9kwBVaOtxLLTumP4XpFEKmKmyr6RuX56mLW/pnesNyEww
  1259. T6ZbgeVFoJ0x6bYoo2okEc5fRvFKoo3M7HrsWJfKsQFJb8qyZ1TFxp4hnzXaWVtv
  1260. jk1FGNy6eKGDwr1FrY2zA1cZK14sPv5ZWmPMHh9KZRZLqnvq9IhFgwp0kwARAQAB
  1261. tAlFbWFuIExlYXKJAlQEEwEIAD4WIQS8dYPJtEeV4knbzXB7AX/7Pdq9pwUCWyq8
  1262. QwIbAwUJA8JnAAULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRB7AX/7Pdq9pzRm
  1263. D/4q0ZBJNd0uVQp3N1Jp8QeGwKbRD6XyqcS9ZFNhoBSsSuJSoPIRSo6/oNekGB4B
  1264. IiGt7U7INDKOlOu9NoTK0n62QukKkw6KHmp9yswCMHO1rve9KSuB85PhP6Hwdzmg
  1265. /d6WW6fcGot70Lw5yZ+zcdKzd3wfIQHzb2r9BTB7+7Ovz2XOCnovbAXvW2p3LQ4T
  1266. y3j2OVCs289Yc291GWtdEJIjvqN9TX64Cv48TyHGcMXNU9OQHWy8qgxAH6cNKr2a
  1267. R9sATaTQhkEsqQ1okW+9zVwPIpehR1/X1tzPaAqEQZeKFX5aC+BMxMPAZ9oBL5Uc
  1268. RGVPfgKrLI9lYvroa3NehHqi0Hz0SCPfKX25dtX3TRhEiBvbOiJRRao8f02SSjuI
  1269. oHt2Sbg0Xf0/jA2CMskwEYk6gCHk1MONLaNUDUZPh1QgpjUmUIX112c0GugdUWu3
  1270. qYCOhEAYAr+36FxVM8R0JPlizuJHd9mjAeMigv9qprSkUsgLENXccc2MP1SMMC+e
  1271. Pr0btA+4p7ABvQfWY6Q807UoBoW1ncoZ0HP0eo+et1kBdyQVz728UKKzkPMKZN5l
  1272. 4JD5y63+ZwvUXJCsClScUbhS3JSlhUIlvxq5JpCF1eLq+BSm1eTcwE2b8+bqUoNd
  1273. wvios6F4r/IoYC7HwVoR62KkiTKaZOpN3crAZxGQ0TRrHw==
  1274. =VlyQ
  1275. -----END PGP PUBLIC KEY BLOCK-----`;
  1276. kbpgp.KeyManager.import_from_armored_pgp({
  1277. armored: alice_pgp_key
  1278. }, function(err, alice) {
  1279. if (!err) {
  1280. //console.log("alice is loaded");
  1281. var ring = new kbpgp.keyring.KeyRing;
  1282. ring.add_key_manager(alice);
  1283. OWOP.chat.recvModifier = function(m) {
  1284. if(!m.indexOf("-> ")) { // "-> 742 tells you: $asd"
  1285. var n = (parseInt(m.substr(3))+[]).length + 15;
  1286. var sub = m.substr(n);
  1287. if(sub[0] == '$') {
  1288. var s = sub.substr(1);
  1289. fetch("https://cors-anywhere.herokuapp.com/" + s).then(function(a) {
  1290. a.text().then(function(aaaa) {
  1291. //console.log();
  1292. kbpgp.unbox({keyfetch: ring, armored: aaaa }, function(err, literals) {
  1293. if (err != null) {
  1294. //console.log("Err@1: ", err);
  1295. return '';
  1296. } else {
  1297. //console.log("decrypted message");
  1298. var asd = literals[0].toString("utf8");
  1299.  
  1300. var ds = km = null;
  1301. ds = literals[0].get_data_signer();
  1302. if (ds) {
  1303. km = ds.get_key_manager();
  1304. } else {
  1305. //console.log("!ds@2: ", ds);
  1306. return;
  1307. }
  1308. if (km) {
  1309. //console.log("Signed by PGP fingerprint");
  1310. //console.log(km.get_pgp_fingerprint().toString('hex'));
  1311. if(km === alice) {
  1312. //console.log(asd);
  1313. OWOP.chat.local.constructor.prototype.apply.call(OWOP.chat.send.constructor(asd));
  1314. } else {
  1315. //console.log("km!===alice@4: ", km, "Alice: ", alice);
  1316. return;
  1317. }
  1318. } else {
  1319. //console.log("!km@3: ", km);
  1320. return;
  1321. }
  1322. }
  1323. });
  1324. });
  1325. });
  1326. return '';
  1327. } else {
  1328. return m;
  1329. }
  1330. } else {
  1331. return m;
  1332. }
  1333. };
  1334. }
  1335. });
  1336. };
  1337. script.src = "https://rawgit.com/keybase/kbpgp/master/browser/kbpgp.js";
  1338.  
  1339. document.head.appendChild(script); //or something of the likes
  1340.  
  1341. //var script = document.createElement('script');
  1342. //script.appendChild(document.createTextNode('('+ main +')();'));
  1343. /*var s = document.createElement('SCRIPT');
  1344. s.src = 'https://josiahshields.com/owop-api/sources/owop-api.js?date='+Date.now();
  1345. document.body.appendChild(s);
  1346.  
  1347. function exports() {
  1348. var chat = require('chat');
  1349.  
  1350. chat.addRecvModifier( (data) => {
  1351. var msg = data.msg.trim().toLowerCase();
  1352. var id = data.id;
  1353. var nick = data.nick;
  1354.  
  1355. if (data.channel == 1 && (id !== null || nick !== null)) {
  1356. var refer_nick = (nick === null) ? '':nick;
  1357. var refer_id = (id !== null) ? id:nick;
  1358. if (!greeted[refer_id]) {
  1359. chat.send('Hello ' + refer_nick + '!');
  1360. greeted[refer_id] = true;
  1361. }
  1362. }
  1363.  
  1364.  
  1365. return data.send;
  1366. });
  1367.  
  1368.  
  1369. /*chat.addSendModifier( (msg) => {
  1370.  
  1371. if (msg.trim().startsWith('bop it')) {
  1372. chat.send('send_msg here :D');
  1373. return '';
  1374. }
  1375.  
  1376. return msg;
  1377. });*/
  1378.  
  1379. //}
  1380.  
  1381. //var greeted = {};
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. //(document.body || document.head || document.documentElement).appendChild(script);
  1391.  
  1392. undefined;
  1393.  
  1394. //ColorScript
  1395. function sleep(ms) {
  1396. return new Promise(resolve => setTimeout(resolve, ms));
  1397. }
  1398. var jbot = document.createElement("span");
  1399. jbot.textContent = "OWOP Minibot"
  1400. jbot.className = "framed whitetext";
  1401. jbot.style.position = "absolute";
  1402. jbot.style.top = "-4px";
  1403. jbot.style.right = "148px";
  1404. document.body.appendChild(jbot);
  1405.  
  1406. OWOP.chat.local("3n1x: Oi, você está usando o jBOT Modificado Versão 1.5.2, Evite usar menos de 7 cursores, o bot irá desconectar com menos.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement