BMO BOT

BMO

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