Advertisement
Guest User

Untitled

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