Advertisement
Guest User

Untitled

a guest
Oct 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.66 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Pixel Bot
  3. // @namespace https://tampermonkey.net/
  4. // @version 3.0
  5. // @description try to take over the world!
  6. // @author Flyink13, igoose
  7. // @match https://pixel.vkforms.ru/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function PixelBot() {
  12. //window.PixelBot = PixelBot;
  13.  
  14. function qe(x) {
  15. if(!document.querySelectorAll(x)) return false;
  16. return document.querySelectorAll(x)[0];
  17. }
  18.  
  19. PixelBot.pts = 60;
  20. PixelBot.v = 3.0;
  21. PixelBot.tc = "rgb(17, 17, 17)";
  22. PixelBot.src = "https://i.imgur.com/CghdwgA.jpg";
  23.  
  24. PixelBot.state = document.createElement("div");
  25. PixelBot.state.textContent = "Загрузка приложения...";
  26. console.log("Загрузка приложения...");
  27. Object.assign(PixelBot.state.style, {
  28. background: "rgba(0,0,0,0.5)",
  29. top: "0px",
  30. right: "0px",
  31. width: "100%",
  32. height: "100%",
  33. lineHeight: "57px",
  34. textAlign: "center",
  35. color: "#fff",
  36. position: "fixed",
  37. zIndex: 10000
  38. });
  39. document.body.appendChild(PixelBot.state);
  40.  
  41. PixelBot.loger = document.createElement("div");
  42. Object.assign(PixelBot.loger.style, {
  43. background: "rgba(0,0,0,0)",
  44. top: "0px",
  45. left: "0px",
  46. width: "250px",
  47. height: "100%",
  48. color: "#fff",
  49. position: "fixed",
  50. borderRight: "1px solid #fff",
  51. fontSize: "11px",
  52. padding: "12px",
  53. zIndex: 10001,
  54. overflow: "auto",
  55. boxSizing: "border-box"
  56. });
  57. document.body.appendChild(PixelBot.loger);
  58.  
  59. PixelBot.log = function(x) {
  60. PixelBot.loger.innerHTML += x + "<br>";
  61. // PixelBot.loger.scrollTo(0, 10000);
  62. };
  63.  
  64. PixelBot.setState = function(s) {
  65. PixelBot.state.innerHTML = "PixelBot (" + PixelBot.v + ") " + s;
  66. // PixelBot.log(s);
  67. };
  68.  
  69. PixelBot.reloadImage = function() {
  70. PixelBot.img = new Image();
  71. PixelBot.img2 = new Image();
  72. var canvas = document.createElement("canvas"),
  73. ctx = canvas.getContext("2d");
  74. PixelBot.img.crossOrigin = "Anonymous";
  75. PixelBot.img.onload = PixelBot.img2.onload = function() {
  76. this.loaded = this.src;
  77. if(PixelBot.img.src != PixelBot.img.loaded || PixelBot.img2.src != PixelBot.img2.loaded) return;
  78. canvas.width = PixelBot.img.width;
  79. canvas.height = PixelBot.img.height;
  80. ctx.clearRect(0, 0, canvas.width, canvas.height);
  81. ctx.drawImage(PixelBot.img, 0, 0, canvas.width, canvas.height);
  82. var imd = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
  83. ctx.drawImage(PixelBot.img2, 0, 0, canvas.width, canvas.height);
  84. var imd2 = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
  85. PixelBot.pixs = [];
  86. for (var i = 0; i < imd.length; i += 4) {
  87. var x = (i / 4) % canvas.width + 1,
  88. y = ~~((i / 4) / canvas.width) + 1;
  89. if (PixelBot.getColor(imd, i) !== PixelBot.tc && PixelBot.getColor(imd2, i) !== PixelBot.getColor(imd, i)) {
  90. PixelBot.pixs.push([x, y, PixelBot.getColor(imd, i)]);
  91. }
  92. }
  93. PixelBot.pixs = PixelBot.pixs
  94. .sort(function (a, b) { return a[1] - b[1]; })
  95. .sort(function (a, b) { return b[0] - a[0]; });
  96.  
  97. canvas = ctx = null;
  98. console.log("перезагрузил зону защиты." + PixelBot.pixs.length + "px");
  99. };
  100. PixelBot.img.src = PixelBot.src + "?r=" + Math.random();
  101. PixelBot.img2.src = "https://pixel.vkforms.ru/data/1.bmp?r=" + Math.random();
  102. };
  103.  
  104. PixelBot.canvasEvent = function(type, q) {
  105. if (!PixelBot.canvas) return;
  106. if (type == "mousewheel") {
  107. PixelBot.canvas.dispatchEvent(new WheelEvent("mousewheel", q));
  108. } else {
  109. PixelBot.canvas.dispatchEvent(new MouseEvent(type, q));
  110. }
  111. };
  112.  
  113. PixelBot.canvasClick = function(x, y, color) {
  114. PixelBot.resetZoom();
  115. PixelBot.canvasMoveTo(0, 0);
  116. PixelBot.resetZoom(-200);
  117. PixelBot.canvasMove(-5 * x + 5, -5 * y - 1);
  118. var pxColor = PixelBot.getColor(PixelBot.ctx.getImageData(3, 3, 1, 1).data, 0);
  119. var colorEl = qe('.color[style="background-color: ' + color + ';"]');
  120. if (!colorEl) {
  121. console.log("ошибка подбора цвета %c " + color, 'background:' + color + ';');
  122. PixelBot.setState("ошибка подбора цвета " + color);
  123. return PixelBot.draw();
  124. } else if (pxColor == color) {
  125. //console.log("совпал цвет " + x + "x" + y + "%c " + pxColor, 'background:' + pxColor + ';');
  126. //PixelBot.setState("пропускаю " + x + "x" + y + " совпал цвет");
  127. return PixelBot.draw();
  128. }
  129. colorEl.click();
  130. var q = {
  131. bubbles: true,
  132. cancelable: true,
  133. button: 1,
  134. clientX: 0,
  135. clientY: 0
  136. };
  137. PixelBot.canvasEvent("mousedown", q);
  138. PixelBot.canvasEvent("click", q);
  139. PixelBot.canvasEvent("mousemove", q);
  140. q.button = 0;
  141. PixelBot.canvasEvent("mouseup", q);
  142. qe(".App__confirm button").click();
  143. var xy = document.querySelectorAll(".App__statistic .value")[1].textContent;
  144. console.log(x + "x" + y + "%c " + pxColor + " > %c " + color + " " + xy, 'background:' + pxColor + ';', 'background:' + color + ';');
  145. console.log("поставил точку " + x + "x" + y + " " + xy);
  146. };
  147.  
  148. PixelBot.draw = function() {
  149. var px = 0;
  150. if (!PixelBot.pixs.length) {
  151. console.log("точек нет");
  152. } else {
  153. if (PixelBot.pixs.length < 5) {
  154. px = PixelBot.pixs.shift();
  155. } else {
  156. px = PixelBot.pixs.splice(Math.floor(Math.random() * 5), 1)[0];
  157. }
  158. PixelBot.canvasClick(px[0], px[1], px[2]);
  159. }
  160. };
  161.  
  162. //alert = function() {
  163. // location.reload();
  164. //};
  165.  
  166. PixelBot.canvasMove = function(x, y) {
  167. var q = {
  168. bubbles: true,
  169. cancelable: true,
  170. button: 1,
  171. clientX: 0,
  172. clientY: 0
  173. };
  174. PixelBot.canvasEvent("mousedown", q);
  175. q.clientY = y;
  176. q.clientX = x;
  177. PixelBot.canvasEvent("mousemove", q);
  178. PixelBot.canvasEvent("mouseup", q);
  179. };
  180.  
  181. PixelBot.canvasMoveTo = function(x, y) {
  182. PixelBot.canvasMove(10000, 10000);
  183. PixelBot.canvasMove(-40 - x, -149 - y);
  184. };
  185.  
  186. PixelBot.getColor = function(data, i) {
  187. return "rgb(" + data[i] + ", " + data[i + 1] + ", " + data[i + 2] + ")";
  188. };
  189.  
  190. PixelBot.resetZoom = function(d) {
  191. PixelBot.canvasEvent("mousewheel", {
  192. deltaY: d || 100000,
  193. deltaX: d || 0,
  194. clientX: 0,
  195. clientY: 0,
  196. });
  197. };
  198.  
  199. PixelBot.isTimer = function() {
  200. if(!qe(".Ttl .Ttl__wait")) return false;
  201. return [qe(".Ttl .Ttl__wait"), qe(".Ttl .Ttl__wait").style.display];
  202. };
  203.  
  204. PixelBot.init = function() {
  205. PixelBot.inited = 1;
  206. console.log("запущен.");
  207. };
  208.  
  209. PixelBot.wait = setInterval(function() {
  210. if (!PixelBot.inited && PixelBot.canvas) {
  211. // console.log('hm 1')
  212. PixelBot.ctx = PixelBot.canvas.getContext("2d");
  213. PixelBot.init();
  214. } else if (!PixelBot.pts) {
  215. // console.log('hm 2')
  216. PixelBot.reload();
  217. PixelBot.pts = 60;
  218. } else if (PixelBot.canvas && PixelBot.isTimer()) {
  219. // console.log('hm 3')
  220. PixelBot.timer = 1;
  221. } else if (!PixelBot.canvas) {
  222. // console.log('hm 4')
  223. PixelBot.canvas = Array.prototype.slice.call(document.querySelectorAll('canvas'))[0];
  224. } else if (!PixelBot.pts) {
  225. // console.log('hm 5')
  226. PixelBot.reload();
  227. PixelBot.pts = 60;
  228. } else if (PixelBot.inited && PixelBot.canvas) {
  229. PixelBot.pts--;
  230. PixelBot.draw();
  231. }
  232. }, 500);
  233.  
  234. PixelBot.reload = function() {
  235. // PixelBot.state.outerHTML = "";
  236. // PixelBot.loger.outerHTML = "";
  237. // clearInterval(PixelBot.wait);
  238. // var script = document.createElement('script');
  239. // script.src = "https://raw.githubusercontent.com/one2go/lentachbot/master/lentachbot.js";
  240. // document.body.appendChild(script);
  241. // script.outerHTML = "";
  242. PixelBot.reloadImage();
  243. };
  244.  
  245. // PixelBot.state.onclick = PixelBot.reload;
  246. // PixelBot.loger.onclick = PixelBot.reload;
  247. PixelBot.reloadImage();
  248. console.log("PixelBot loaded");
  249. }
  250.  
  251. function sleep (time) {
  252. return new Promise((resolve) => setTimeout(resolve, time));
  253. }
  254.  
  255. sleep(2000).then(() => {
  256. // var script = document.createElement('script');
  257. // script.appendChild(document.createTextNode('(' + PixelBot + ')();'));
  258. // (document.body || document.head || document.documentElement).appendChild(script);
  259. // script.outerHTML = "";
  260. PixelBot();
  261. });
  262. // window.addEventListener("load", function() {
  263. // window.loaded = 1;
  264. // var script = document.createElement('script');
  265. // script.appendChild(document.createTextNode('(' + PixelBot + ')();'));
  266. // (document.body || document.head || document.documentElement).appendChild(script);
  267. // script.outerHTML = "";
  268. // });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement