Advertisement
Guest User

План захвата

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