بوت رسم Gartic.io Drawing Bot

png أو jpg هاذا البوت يقوم برسم اي صورة تريدها يجب ان تكون بصيغة

  1. // ==UserScript==
  2. // @name بوت رسم Gartic.io Drawing Bot
  3. // @namespace gartic-haifa0000-v1
  4. // @version 1.0
  5. // @description png أو jpg هاذا البوت يقوم برسم اي صورة تريدها يجب ان تكون بصيغة
  6. // @author Queen Haifa (githun.com: haifa0000)
  7. // @license GPLv3
  8. // @match https://gartic.io/*
  9. // @icon https://w0.peakpx.com/wallpaper/1022/369/HD-wallpaper-pretty-anime-girl-cute-fun.jpg
  10. // @run-at document-start
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // Anti change name
  15.  
  16. class YuriWSOriginal extends WebSocket {}
  17. const YuriAPI = {
  18. roomCode: 1677864451914,
  19. ws: undefined,
  20. setColor: function([r,g,b]) {
  21. var hex = 'x';
  22. hex += [r, g, b].map(x => {
  23. const hex = x.toString(16)
  24. return hex.length === 1 ? '0' + hex : hex
  25. }).join('').toUpperCase();
  26. if (this.color === hex) return;
  27. this.color = hex;
  28. this.ws.send(`42[10,${this.roomCode},[5,"${hex}"]]`)
  29. },
  30. setScale: function(scale) {
  31. // Primitive but gets the job done, shut the fuck up
  32. this.ws.send(`42[10,${this.roomCode},[6,"${scale}"]]`);
  33. this.scale = scale;
  34. },
  35. scale: 0,
  36. color: undefined,
  37. rect: function(sx, sy, w, h) {
  38. this.ws.send(`42[10,${this.roomCode},[1,2,${sx},${sy},${sx+w},${sy+h}]]`)
  39. },
  40. putPixel: function(x, y) {
  41. this.ws.send(`42[10,${this.roomCode},[2,${x},${y}]]`);
  42. },
  43. inputFile: function() {
  44. const sx = 200, sy = 200, scale = 2;
  45. const el = document.createElement('input');
  46. el.type = 'file'
  47. const fr = new FileReader();
  48. const looper = [];
  49. el.onchange = function() {
  50. const file = el.files[0];
  51. if (!file) return;
  52. fr.readAsDataURL(file);
  53.  
  54. fr.onload = function() {
  55. const src = fr.result;
  56. const img = new Image();
  57. img.src = src;
  58. img.onload = function() {
  59. const canvas = document.createElement('canvas');
  60. const ctx = canvas.getContext('2d');
  61. ctx.drawImage(img, 0, 0);
  62. const data = ctx.getImageData(0, 0, img.width, img.height).data;
  63. for (let y = 0;y < img.height;y++) {
  64. for (let x = 0;x < img.width;x++) {
  65. var i = 4*((y*img.width)+x);
  66. var r = data[i];
  67. var g = data[i+1];
  68. var b = data[i+2];
  69. var packet = {
  70. rgb: [r,g,b],
  71. x: sx + (scale * x),
  72. y: sy + (scale * y)
  73. }
  74. looper.push(packet);
  75. }
  76. }
  77. }
  78. };
  79.  
  80. fr.onerror = function() {
  81. console.log(fr.error);
  82. };
  83. }
  84. el.click();
  85. setInterval(function() {
  86. var packet = looper.shift();
  87. if (!packet) return;
  88. var {rgb,x,y} = packet;
  89. YuriAPI.setColor(rgb);
  90. YuriAPI.putPixel(x, y);
  91. }, 1);
  92. console.log(el);
  93. },
  94. ui: function() {
  95. const button = document.createElement('button');
  96. button.textContent = 'بوت رسم';
  97. button.addEventListener('click', this.inputFile);
  98. button.style.position = 'absolute';
  99. button.style.left = '100px';
  100. button.style.top = '50px';
  101. button.style.zIndex = '1000';
  102. button.style.background = 'lime';
  103. button.style.width = '100px';
  104. button.style.fontFamily = 'Verdana';
  105. button.style.height = '50px';
  106. document.body.append(button);
  107. }
  108. }
  109. window.YuriAPI = YuriAPI;
  110. YuriAPI.ui();
  111. window.WebSocket = class extends WebSocket {
  112. constructor(a,b) {
  113. super(a,b);
  114. if (YuriAPI.ws != undefined) console.warn('Refreshing YuriWS');
  115. console.info('Hooked WebSocket');
  116. YuriAPI.ws = this;
  117. this.constructor.toString = YuriWSOriginal.constructor.toString;
  118. this.addEventListener('message', a => {
  119. const str = a.data;
  120. if (!str.startsWith('42')) return;
  121. const json_str = str.slice(2);
  122. const json = JSON.parse(json_str);
  123. if (json[0] == 5) {
  124. YuriAPI.roomCode = json[2];
  125. console.info('Room code: '+YuriAPI.roomCode);
  126. }
  127. })
  128. }
  129. toString() {
  130. super.toString();
  131. }
  132. }