BMO BOT

BMO

当前为 2023-08-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name BMO BOT
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description BMO
  6. // @author Bambi1
  7. // @match https://pixelplace.io/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=pixelplace.io
  9. // @run-at document-start
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13. let drawBMO = false;
  14. var fillHeight = 10;
  15. var fillWidth = 10;
  16. var color = 5;
  17. var lineLength = 5;
  18. function fix(a, b) {
  19. Object.defineProperty(window.console, a, { configurable: false, enumerable: true, writable: false, value: b });
  20. }
  21.  
  22. fix('log', console.log);
  23. fix('warn', console.warn);
  24. fix('error', console.error);
  25. fix('info', console.info);
  26.  
  27. const originalWebSocket = window.WebSocket;
  28. var socket;
  29.  
  30. class WebSocketHook extends originalWebSocket {
  31. constructor(a, b) {
  32. super(a, b);
  33. socket = this;
  34. }
  35. }
  36.  
  37. window.WebSocket = WebSocketHook;
  38.  
  39. document.addEventListener('keydown', function (event) {
  40. if (event.key === 'm') {//Change to change menu button
  41. if (menuContainer.style.display === 'none') {
  42. menuContainer.style.display = 'block';
  43. } else {
  44. fillHeight = parseFloat(heightInput.querySelector('input').value);
  45. fillWidth = parseFloat(widthInput.querySelector('input').value);
  46. color = parseFloat(colorInput.querySelector('input').value);
  47. lineLength = parseFloat(lineInput.querySelector('input').value);
  48. menuContainer.style.display = 'none';
  49. }}});
  50.  
  51. document.addEventListener('keydown', function (event) {
  52. if (event.key === 'f') {//Change to change fill button
  53. var coordinatesElement = document.getElementById('coordinates');
  54. var coordinatesValue = coordinatesElement.textContent;
  55. var [x, y] = coordinatesValue.split(',');
  56. // Convert x and y to integers using parseInt()
  57. x = parseInt(x);
  58. y = parseInt(y);
  59.  
  60. console.log(x, y);
  61. fillTool(x, y, color);
  62. }
  63. });
  64. document.addEventListener('keydown', function (event) {
  65. if (event.key === 'i') {//Change to change up line button
  66. var coordinatesElement = document.getElementById('coordinates');
  67. var coordinatesValue = coordinatesElement.textContent;
  68. var [x, y] = coordinatesValue.split(',');
  69. // Convert x and y to integers using parseInt()
  70. x = parseInt(x);
  71. y = parseInt(y);
  72.  
  73. console.log(x, y);
  74. drawUpLine(x, y, color);
  75. }
  76. });
  77. document.addEventListener('keydown', function (event) {
  78. if (event.key === 'k') {//Change to change down line button
  79. var coordinatesElement = document.getElementById('coordinates');
  80. var coordinatesValue = coordinatesElement.textContent;
  81. var [x, y] = coordinatesValue.split(',');
  82. // Convert x and y to integers using parseInt()
  83. x = parseInt(x);
  84. y = parseInt(y);
  85.  
  86. console.log(x, y);
  87. drawDownLine(x, y, color);
  88. }
  89. });
  90. document.addEventListener('keydown', function (event) {
  91. if (event.key === 'j') {//Change to change left line button
  92. var coordinatesElement = document.getElementById('coordinates');
  93. var coordinatesValue = coordinatesElement.textContent;
  94. var [x, y] = coordinatesValue.split(',');
  95. // Convert x and y to integers using parseInt()a
  96. x = parseInt(x);
  97. y = parseInt(y);
  98.  
  99. console.log(x, y);
  100. drawLeftLine(x, y, color);
  101. }
  102. });
  103. document.addEventListener('keydown', function (event) {
  104. if (event.key === 'l') {//Change to change right line button
  105. var coordinatesElement = document.getElementById('coordinates');
  106. var coordinatesValue = coordinatesElement.textContent;
  107. var [x, y] = coordinatesValue.split(',');
  108. // Convert x and y to integers using parseInt()
  109. x = parseInt(x);
  110. y = parseInt(y);
  111.  
  112. console.log(x, y);
  113. drawRightLine(x, y, color);
  114. }
  115. });
  116. document.addEventListener('keydown', function (event) {
  117. if (event.key === 'b') {//Change to change BMO button
  118. if (drawBMO === true){
  119. var coordinatesElement = document.getElementById('coordinates');
  120. var coordinatesValue = coordinatesElement.textContent;
  121. var [x, y] = coordinatesValue.split(',');
  122. // Convert x and y to integers using parseInt()
  123. x = parseInt(x);
  124. y = parseInt(y);
  125.  
  126. console.log(x, y);
  127. BMO(x, y, color);
  128. }}
  129. });
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. function placePix(x, y, col) {
  138. socket.send(`42["p",[${x},${y},${col},1]]`);
  139. }
  140.  
  141. function fillTool(SX, SY, color) {
  142. let i = 0;
  143. let j = 0;
  144.  
  145. function placePixelWithDelay() {
  146. if (j < fillHeight) {
  147. if (i < fillWidth) {
  148. placePix(SX + i, SY + j, color);
  149. i++;
  150. setTimeout(placePixelWithDelay, 25);// <---- Delay change with caution
  151. } else {
  152. i = 0;
  153. j++;
  154. setTimeout(placePixelWithDelay, 25);//<---- Delay change with caution
  155. }
  156. }
  157. }
  158.  
  159. placePixelWithDelay();
  160. }
  161.  
  162. function drawUpLine(SX,SY,color){
  163. let a = 0;
  164. function placeUpLine(){
  165. if (a < lineLength){
  166. placePix(SX, SY - a , color)
  167. a++
  168. setTimeout(placeUpLine , 25)
  169. }}
  170. placeUpLine();}
  171. function drawDownLine(SX,SY,color){
  172. let b = 0;
  173. function placeDownLine(){
  174. if (b < lineLength){
  175. placePix(SX, SY + b , color)
  176. b++
  177. setTimeout(placeDownLine , 25)
  178. }}
  179. placeDownLine();}
  180. function drawLeftLine(SX,SY,color){
  181. let c = 0;
  182. function placeLeftLine(){
  183. if (c < lineLength){
  184. placePix(SX - c, SY , color)
  185. c++
  186. setTimeout(placeLeftLine , 25)
  187. }}placeLeftLine();}
  188. function drawRightLine(SX,SY,color){
  189. let d = 0;
  190. function placeRightLine(){
  191. if (d < lineLength){
  192. placePix(SX + d, SY, color)
  193. d++
  194. setTimeout(placeRightLine , 25)
  195. }}placeRightLine();}
  196. function sleep(ms) {
  197. return new Promise(resolve => setTimeout(resolve, ms));
  198. }
  199. async function BMO(SX, SY) {
  200. const pixelArray = [
  201. [0 ,0 ,0 ,0 ,0 ,37 ,37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//1
  202. [0, 0, 0, 0, 0, 37, 48, 48, 48, 48, 48, 48, 48, 37, 36, 36, 36, 36, 36],//2
  203. [0, 0, 0, 0, 0, 37, 48, 5, 48, 48, 48, 5, 48, 37, 36, 36, 36, 36, 36],//3
  204. [0, 0, 0, 0, 0, 37, 48, 48, 48, 48, 48, 48, 48, 37, 36, 36, 36, 36, 36],//4
  205. [0, 0, 0, 0, 0, 37, 48, 5, 5, 5, 5, 5, 48, 37, 36, 36, 36, 36 ,36],//5
  206. [0, 37, 0, 0, 0, 37, 48, 48, 5, 5, 5, 48, 48, 37, 36, 36, 36, 36, 36],//6
  207. [0, 37, 0, 0, 0, 37, 48, 48, 48, 48, 48, 48, 48, 37, 36, 36, 36, 36, 36],//7
  208. [0, 0, 37, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//8
  209. [0, 0, 0, 37, 37, 37, 3, 3, 3, 3, 3, 37, 44, 37, 36, 47, 36, 36, 36],//9
  210. [0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 47, 36, 36, 36],//10
  211. [0, 0, 0, 0, 0, 37, 37, 11, 37, 37, 37, 37, 37, 37, 36, 47, 36, 36, 36],//11
  212. [0, 0, 0, 0, 0, 37, 11, 11, 11, 37, 37, 37, 37, 37, 36, 47, 36, 36, 36],//12
  213. [0, 0, 0, 0, 0, 37, 37, 11, 37, 37, 37, 32, 37, 37, 36, 47, 36, 36, 36],//13
  214. [0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 20, 37, 7, 37, 36, 36, 36, 36, 36],//14
  215. [0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//15
  216. [0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//16
  217. [0, 0, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0],//17
  218. [0, 0, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0],//18
  219. [0, 0, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0],//19
  220. // Add more rows as needed
  221. ];
  222. for (let y = 0; y < pixelArray.length; y++) {
  223. for (let x = 0; x < pixelArray[y].length; x++) {
  224. const col = pixelArray[y][x];
  225. placePix(SX + x, SY + y, col);
  226. await sleep(25);
  227. }
  228. }
  229. }
  230.  
  231.  
  232. const menuContainer = document.createElement('div');
  233. menuContainer.style.display = 'none';
  234. menuContainer.style.position = 'fixed';
  235. menuContainer.style.backgroundColor = 'white';
  236. menuContainer.style.border = '1px solid #ccc';
  237. menuContainer.style.padding = '10px';
  238. menuContainer.style.boxShadow = '0px 0px 10px rgba(0, 0, 0, 0.1)';
  239. menuContainer.style.fontFamily = 'Arial, sans-serif';
  240. menuContainer.style.top = '50%';
  241. menuContainer.style.left = '50%';
  242. menuContainer.style.transform = 'translate(-50%, -50%)';
  243.  
  244.  
  245. function createInputWithLabel(labelText, defaultValue) {
  246. const inputWrapper = document.createElement('div');
  247.  
  248. const label = document.createElement('label');
  249. label.textContent = labelText + ':';
  250. label.style.fontWeight = 'bold';
  251. label.style.marginBottom = '4px';
  252.  
  253. const input = document.createElement('input');
  254. if (typeof defaultValue === 'boolean') {
  255. input.type = 'checkbox';
  256. input.checked = defaultValue;
  257. input.addEventListener('change', function () {
  258. drawBMO = this.checked;
  259. });
  260. } else {
  261. input.type = 'number';
  262. input.placeholder = defaultValue;
  263. input.style = `
  264. padding: 5px;
  265. border: 1px solid #ccc;
  266. border-radius: 4px;
  267. width: 100px;
  268. margin-bottom: 10px;
  269. `;
  270. }
  271.  
  272. inputWrapper.appendChild(label);
  273. inputWrapper.appendChild(input);
  274.  
  275. return inputWrapper;
  276. }
  277.  
  278. const header = document.createElement('div');
  279. header.textContent = 'Fill Tool Settings';
  280. header.style.fontSize = '18px';
  281. header.style.fontWeight = 'bold';
  282. header.style.marginBottom = '10px';
  283.  
  284. const heightInput = createInputWithLabel('Fill Height', '10');
  285. const widthInput = createInputWithLabel('Fill Width', '10');
  286. const lineInput = createInputWithLabel('Line Length', '5');
  287. const colorInput = createInputWithLabel('Color', '5');
  288. const drawBMOInput = createInputWithLabel('Draw BMO', false);
  289.  
  290. const submitButton = document.createElement('button');
  291. submitButton.textContent = 'Submit (m)';
  292. submitButton.style.backgroundColor = '#007bff';
  293. submitButton.style.color = 'white';
  294. submitButton.style.padding = '8px 12px';
  295. submitButton.style.border = 'none';
  296. submitButton.style.borderRadius = '4px';
  297. submitButton.style.cursor = 'pointer';
  298. submitButton.style.marginTop = '10px';
  299.  
  300. menuContainer.appendChild(header);
  301. menuContainer.appendChild(heightInput);
  302. menuContainer.appendChild(widthInput);
  303. menuContainer.appendChild(lineInput);
  304. menuContainer.appendChild(colorInput);
  305. menuContainer.appendChild(drawBMOInput);
  306. menuContainer.appendChild(submitButton);
  307.  
  308. document.body.appendChild(menuContainer);
  309.  
  310.  
  311. submitButton.addEventListener('click', () => {
  312. fillHeight = parseFloat(heightInput.querySelector('input').value);
  313. fillWidth = parseFloat(widthInput.querySelector('input').value);
  314. color = parseFloat(colorInput.querySelector('input').value);
  315. lineLength = parseFloat(lineInput.querySelector('input').value);
  316. menuContainer.style.display = 'none';
  317. });