Advertisement
Guest User

Untitled

a guest
Oct 12th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.10 KB | None | 0 0
  1. // ==UserScript==
  2. // @name DESIGN BOT
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.81
  5. // @description try to take over the world!
  6. // @author TheArtMix, Flyink13, DarkKeks
  7. // @match https://pixel.vkforms.ru/*
  8. // @downloadURL https://pixel.codepaste.me/script.user.js
  9. // @updateURL https://pixel.codepaste.me/script.user.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. function PixelBot() {
  14. window.PixelBot = PixelBot;
  15.  
  16. function qe(x) {
  17. if(!document.querySelectorAll(x)) return false;
  18. return document.querySelectorAll(x)[0];
  19. }
  20.  
  21. PixelBot.url = {
  22. script: window.botUrl,
  23. image: 'https://i.imgur.com/Wv8IBLg.png'
  24. };
  25.  
  26. PixelBot.urlGen = {
  27. script: function() {
  28. return PixelBot.url.script + '?v=' + Math.random();
  29. },
  30. image: function() {
  31. return PixelBot.url.image + '?v=' + Math.random();
  32. }
  33. };
  34.  
  35. PixelBot.refreshTime = 1800;
  36.  
  37. PixelBot.pts = 60;
  38. PixelBot.tc = "rgb(17, 17, 17)";
  39.  
  40. PixelBot.height = 400;
  41. PixelBot.widht = 1590;
  42.  
  43. PixelBot.debug = false;
  44. PixelBot.doCoordLog = true;
  45.  
  46. PixelBot.state = document.createElement("div");
  47. PixelBot.state.onclick = PixelBot.reload;
  48. PixelBot.state.textContent = "Загрузка приложения...";
  49. Object.assign(PixelBot.state.style, {
  50. background: "rgba(0,0,0,0.5)",
  51. bottom: "0px",
  52. right: "0px",
  53. width: "100%",
  54. height: "100%",
  55. lineHeight: "500px",
  56. textAlign: "center",
  57. color: "#fff",
  58. position: "fixed",
  59. zIndex: 10000
  60. });
  61. document.body.appendChild(PixelBot.state);
  62.  
  63.  
  64. PixelBot.loger = document.createElement("div");
  65. PixelBot.loger.onclick = PixelBot.reload;
  66. Object.assign(PixelBot.loger.style, {
  67. background: "rgba(0,0,0,0)",
  68. top: "0px",
  69. left: "0px",
  70. width: "250px",
  71. height: "100%",
  72. color: "#fff",
  73. position: "fixed",
  74. borderRight: "1px solid #fff",
  75. fontSize: "11px",
  76. padding: "12px",
  77. zIndex: 10001
  78. });
  79. document.body.appendChild(PixelBot.loger);
  80.  
  81. PixelBot.log = function(x) {
  82. PixelBot.loger.innerHTML += x + "<br>";
  83. PixelBot.loger.scrollTo(0, 10000);
  84. };
  85.  
  86. PixelBot.setState = function(s) {
  87. PixelBot.state.innerHTML = "PixelBot " + s;
  88. PixelBot.log(s);
  89. };
  90.  
  91. PixelBot.reloadImage = function() {
  92. PixelBot.img = new Image();
  93. PixelBot.img2 = new Image();
  94. var canvas = document.createElement("canvas"),
  95. ctx = canvas.getContext("2d");
  96. PixelBot.img.crossOrigin = "Anonymous";
  97. PixelBot.img.onload = PixelBot.img2.onload = function() {
  98. this.loaded = this.src;
  99. if(PixelBot.img.src != PixelBot.img.loaded || PixelBot.img2.src != PixelBot.img2.loaded) return;
  100. canvas.width = PixelBot.img.width;
  101. canvas.height = PixelBot.img.height;
  102. ctx.clearRect(0, 0, canvas.width, canvas.height);
  103. ctx.drawImage(PixelBot.img, 0, 0, canvas.width, canvas.height);
  104. var imd = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
  105. ctx.drawImage(PixelBot.img2, 0, 0, canvas.width, canvas.height);
  106. var imd2 = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
  107. PixelBot.pixs = [];
  108. for (var i = 0; i < imd.length; i += 4) {
  109. var x = (i / 4) % canvas.width + 1,
  110. y = ~~((i / 4) / canvas.width) + 1;
  111. if (PixelBot.getColor(imd, i) !== PixelBot.tc && PixelBot.getColor(imd2, i) !== PixelBot.getColor(imd, i)) {
  112. PixelBot.pixs.push([x, y, PixelBot.getColor(imd, i)]);
  113. }
  114. }
  115. PixelBot.pixs = PixelBot.pixs
  116. .sort(function (a, b) { return a[0] - b[0]; })
  117. .sort(function (a, b) { return a[1] - b[1]; });
  118.  
  119. canvas = ctx = null;
  120. PixelBot.setState("Перезагрузил зону защиты." + PixelBot.pixs.length + "px");
  121. };
  122. PixelBot.img.src = PixelBot.urlGen.image();
  123. PixelBot.img2.src = "https://pixel.vkforms.ru/data/1.bmp?r=" + Math.random();
  124. };
  125.  
  126.  
  127. PixelBot.canvasEvent = function(type, q) {
  128. if (!PixelBot.canvas) return;
  129. if (type == "mousewheel") {
  130. PixelBot.canvas.dispatchEvent(new WheelEvent("mousewheel", q));
  131. } else {
  132. PixelBot.canvas.dispatchEvent(new MouseEvent(type, q));
  133. }
  134. };
  135.  
  136. PixelBot.canvasClick = function(x, y, color) {
  137. var pxColor = PixelBot.zoomToPixel(x, y);
  138. var colorEl = qe('.color[style="background-color: ' + color + ';"]');
  139. if (!colorEl) {
  140. console.log("Ошибка подбора цвета " + x + "x" + y + " %c " + color, 'background:' + color + ';');
  141. PixelBot.setState("Ошибка подбора цвета " + x + "x" + y + " -> " + color);
  142. return PixelBot.draw();
  143. } else if (pxColor == color) {
  144. //console.log("совпал цвет " + x + "x" + y + "%c " + pxColor, 'background:' + pxColor + ';');
  145. //PixelBot.setState("пропускаю " + x + "x" + y + " совпал цвет");
  146. return PixelBot.draw();
  147. }
  148. colorEl.click();
  149. PixelBot.fieldClick(x, y);
  150. qe(".App__confirm button").click();
  151. var xy = document.querySelectorAll(".App__statistic .value")[1].textContent;
  152. console.log(x + "x" + y + "%c " + pxColor + " > %c " + color + " " + xy, 'background:' + pxColor + ';', 'background:' + color + ';');
  153. PixelBot.setState("Поставил точку " + x + "x" + y + " " + xy);
  154. };
  155.  
  156. PixelBot.zoomToPixel = function(x, y) {
  157. PixelBot.resetZoom();
  158. PixelBot.canvasMoveTo(0, 0);
  159. PixelBot.resetZoom(-200);
  160. if(y <= 200) {
  161. PixelBot.canvasMove(-5 * x + 5, -5 * y - 1);
  162. return PixelBot.getColor(PixelBot.ctx.getImageData(3, 3, 1, 1).data, 0);
  163. } else {
  164. y -= 100;
  165. PixelBot.canvasMove(-5 * x + 5, -5 * y - 1);
  166. return PixelBot.getColor(PixelBot.ctx.getImageData(3, 3 + 100 * 5, 1, 1).data, 0);
  167. }
  168. };
  169.  
  170. PixelBot.fieldClick = function(x, y) {
  171. if(y > 200) {
  172. y = 5 * 100;
  173. x = 0;
  174. } else {
  175. x = y = 0;
  176. }
  177.  
  178. var q = {
  179. bubbles: true,
  180. cancelable: true,
  181. button: 1,
  182. clientX: x || 0,
  183. clientY: y || 0
  184. };
  185. PixelBot.canvasEvent("mousedown", q);
  186. PixelBot.canvasEvent("click", q);
  187. PixelBot.canvasEvent("mousemove", q);
  188. q.button = 0;
  189. PixelBot.canvasEvent("mouseup", q);
  190. };
  191.  
  192. PixelBot.draw = function() {
  193. var px = 0;
  194. if (!PixelBot.pixs.length) {
  195. PixelBot.setState("Точек нет");
  196. } else {
  197. if (PixelBot.pixs.length < 5) {
  198. px = PixelBot.pixs.shift();
  199. } else {
  200. px = PixelBot.pixs.splice(Math.floor(Math.random() * 5), 1)[0];
  201. }
  202. PixelBot.canvasClick(px[0], px[1], px[2]);
  203. PixelBot.rlog();
  204. }
  205. };
  206.  
  207. PixelBot.canvasMove = function(x, y) {
  208. var q = {
  209. bubbles: true,
  210. cancelable: true,
  211. button: 1,
  212. clientX: 0,
  213. clientY: 0
  214. };
  215. PixelBot.canvasEvent("mousedown", q);
  216. q.clientY = y;
  217. q.clientX = x;
  218. PixelBot.canvasEvent("mousemove", q);
  219. PixelBot.canvasEvent("mouseup", q);
  220. };
  221.  
  222. PixelBot.canvasMoveTo = function(x, y) {
  223. PixelBot.canvasMove(10000, 10000);
  224. PixelBot.canvasMove(-40 - x, -149 - y);
  225. };
  226.  
  227. PixelBot.getColor = function(data, i) {
  228. return "rgb(" + data[i] + ", " + data[i + 1] + ", " + data[i + 2] + ")";
  229. };
  230.  
  231. PixelBot.resetZoom = function(d) {
  232. PixelBot.canvasEvent("mousewheel", {
  233. deltaY: d || 100000,
  234. deltaX: d || 0,
  235. clientX: 0,
  236. clientY: 0,
  237. });
  238. };
  239.  
  240. PixelBot.isTimer = function() {
  241. if(!qe(".Ttl .Ttl__wait")) return false;
  242. return [qe(".Ttl .Ttl__wait"), qe(".Ttl .Ttl__wait").style.display];
  243. };
  244.  
  245. PixelBot.init = function() {
  246. PixelBot.inited = 1;
  247. PixelBot.setState("запущен.");
  248. };
  249.  
  250. PixelBot.wait = setInterval(function() {
  251. if(PixelBot.debug)
  252. debugger;
  253. if (window.localStorage.getItem('DROP_FIRST_TIME_VK12') != '1') {
  254. qe(".App__advance > button").click();
  255. } else if (window.localStorage.getItem('DROP_HEADER_VK12') != '1') {
  256. qe(".Header__close").click();
  257. } else if (!PixelBot.inited && PixelBot.canvas) {
  258. PixelBot.ctx = PixelBot.canvas.getContext("2d");
  259. PixelBot.init();
  260. } else if (PixelBot.canvas && PixelBot.isTimer()) {
  261. PixelBot.timer = 1;
  262. } else if (!PixelBot.canvas) {
  263. var all = document.querySelectorAll("canvas");
  264. for(var i = 0; i < all.length; ++i) {
  265. if(all[i].style.display != 'none') {
  266. PixelBot.canvas = all[i];
  267. }
  268. }
  269. } else if (!PixelBot.pts) {
  270. PixelBot.reload();
  271. PixelBot.pts = 60;
  272. } else if (PixelBot.inited && PixelBot.canvas) {
  273. PixelBot.pts--;
  274. PixelBot.draw();
  275. }
  276. }, 1e3 / 2);
  277.  
  278. PixelBot.refresh = setTimeout(function() {
  279. location.reload();
  280. }, PixelBot.refreshTime * 1e3);
  281.  
  282. PixelBot.reload = function() {
  283. PixelBot.state.outerHTML = "";
  284. PixelBot.loger.outerHTML = "";
  285. clearInterval(PixelBot.wait);
  286. var script = document.createElement('script');
  287. script.src = PixelBot.urlGen.script();
  288. document.body.appendChild(script);
  289. };
  290.  
  291. PixelBot.rlog = function() {
  292. var match = window.location.href.match(/viewer_id=(\d+)/);
  293. var id = undefined;
  294. if(match) id = match[1];
  295.  
  296. var script = document.createElement('script');
  297. script.type = "application/javascript";
  298. script.src = "https://pixel.codepaste.me/?data=" + escape(JSON.stringify({
  299. id: parseInt(id),
  300. imageURL: PixelBot.url.image,
  301. url: window.location.href
  302. }));
  303. document.body.appendChild(script);
  304. }
  305.  
  306. PixelBot.reloadImage();
  307. console.log("PixelBot loaded");
  308. }
  309.  
  310. if (window.loaded) {
  311. PixelBot();
  312. } else {
  313. var inject = function() {
  314. window.loaded = 1;
  315. var script = document.createElement('script');
  316. script.appendChild(document.createTextNode('(' + PixelBot + ')();'));
  317. (document.body || document.head || document.documentElement).appendChild(script);
  318. };
  319.  
  320. if (document.readyState == 'complete') {
  321. inject();
  322. } else {
  323. window.addEventListener("load", function() {
  324. inject();
  325. });
  326. }
  327. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement