// ==UserScript==
// @name Fill Tool
// @namespace http://tampermonkey.net/
// @version 0.2
// @description FillTool
// @author Bambi1
// @match https://pixelplace.io/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pixelplace.io
// @run-at document-start
// @grant none
// @license MIT
// ==/UserScript==
let drawBMO = false;
var fillHeight = 10;
var fillWidth = 10;
var color = 5;
var lineLength = 5;
function fix(a, b) {
Object.defineProperty(window.console, a, { configurable: false, enumerable: true, writable: false, value: b });
}
fix('log', console.log);
fix('warn', console.warn);
fix('error', console.error);
fix('info', console.info);
const originalWebSocket = window.WebSocket;
var socket;
class WebSocketHook extends originalWebSocket {
constructor(a, b) {
super(a, b);
socket = this;
}
}
window.WebSocket = WebSocketHook;
document.addEventListener('keydown', function (event) {
if (event.key === 'm') {//Change to change menu button
if (menuContainer.style.display === 'none') {
menuContainer.style.display = 'block';
} else {
fillHeight = parseFloat(heightInput.querySelector('input').value);
fillWidth = parseFloat(widthInput.querySelector('input').value);
color = parseFloat(colorInput.querySelector('input').value);
lineLength = parseFloat(lineInput.querySelector('input').value);
menuContainer.style.display = 'none';
}}});
document.addEventListener('keydown', function (event) {
if (event.key === 'f') {//Change to change fill button
var coordinatesElement = document.getElementById('coordinates');
var coordinatesValue = coordinatesElement.textContent;
var [x, y] = coordinatesValue.split(',');
// Convert x and y to integers using parseInt()
x = parseInt(x);
y = parseInt(y);
console.log(x, y);
fillTool(x, y, color);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'i') {//Change to change up line button
var coordinatesElement = document.getElementById('coordinates');
var coordinatesValue = coordinatesElement.textContent;
var [x, y] = coordinatesValue.split(',');
// Convert x and y to integers using parseInt()
x = parseInt(x);
y = parseInt(y);
console.log(x, y);
drawUpLine(x, y, color);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'k') {//Change to change down line button
var coordinatesElement = document.getElementById('coordinates');
var coordinatesValue = coordinatesElement.textContent;
var [x, y] = coordinatesValue.split(',');
// Convert x and y to integers using parseInt()
x = parseInt(x);
y = parseInt(y);
console.log(x, y);
drawDownLine(x, y, color);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'j') {//Change to change left line button
var coordinatesElement = document.getElementById('coordinates');
var coordinatesValue = coordinatesElement.textContent;
var [x, y] = coordinatesValue.split(',');
// Convert x and y to integers using parseInt()a
x = parseInt(x);
y = parseInt(y);
console.log(x, y);
drawLeftLine(x, y, color);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'l') {//Change to change right line button
var coordinatesElement = document.getElementById('coordinates');
var coordinatesValue = coordinatesElement.textContent;
var [x, y] = coordinatesValue.split(',');
// Convert x and y to integers using parseInt()
x = parseInt(x);
y = parseInt(y);
console.log(x, y);
drawRightLine(x, y, color);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'b') {//Change to change BMO button
if (drawBMO === true){
var coordinatesElement = document.getElementById('coordinates');
var coordinatesValue = coordinatesElement.textContent;
var [x, y] = coordinatesValue.split(',');
// Convert x and y to integers using parseInt()
x = parseInt(x);
y = parseInt(y);
console.log(x, y);
BMO(x, y, color);
}}
});
function placePix(x, y, col) {
socket.send(`42["p",[${x},${y},${col},1]]`);
}
function fillTool(SX, SY, color) {
let i = 0;
let j = 0;
function placePixelWithDelay() {
if (j < fillHeight) {
if (i < fillWidth) {
placePix(SX + i, SY + j, color);
i++;
setTimeout(placePixelWithDelay, 25);// <---- Delay change with caution
} else {
i = 0;
j++;
setTimeout(placePixelWithDelay, 25);//<---- Delay change with caution
}
}
}
placePixelWithDelay();
}
function drawUpLine(SX,SY,color){
let a = 0;
function placeUpLine(){
if (a < lineLength){
placePix(SX, SY - a , color)
a++
setTimeout(placeUpLine , 25)
}}
placeUpLine();}
function drawDownLine(SX,SY,color){
let b = 0;
function placeDownLine(){
if (b < lineLength){
placePix(SX, SY + b , color)
b++
setTimeout(placeDownLine , 25)
}}
placeDownLine();}
function drawLeftLine(SX,SY,color){
let c = 0;
function placeLeftLine(){
if (c < lineLength){
placePix(SX - c, SY , color)
c++
setTimeout(placeLeftLine , 25)
}}placeLeftLine();}
function drawRightLine(SX,SY,color){
let d = 0;
function placeRightLine(){
if (d < lineLength){
placePix(SX + d, SY, color)
d++
setTimeout(placeRightLine , 25)
}}placeRightLine();}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function BMO(SX, SY) {
const pixelArray = [
[0 ,0 ,0 ,0 ,0 ,37 ,37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//1
[0, 0, 0, 0, 0, 37, 48, 48, 48, 48, 48, 48, 48, 37, 36, 36, 36, 36, 36],//2
[0, 0, 0, 0, 0, 37, 48, 5, 48, 48, 48, 5, 48, 37, 36, 36, 36, 36, 36],//3
[0, 0, 0, 0, 0, 37, 48, 48, 48, 48, 48, 48, 48, 37, 36, 36, 36, 36, 36],//4
[0, 0, 0, 0, 0, 37, 48, 5, 5, 5, 5, 5, 48, 37, 36, 36, 36, 36 ,36],//5
[0, 37, 0, 0, 0, 37, 48, 48, 5, 5, 5, 48, 48, 37, 36, 36, 36, 36, 36],//6
[0, 37, 0, 0, 0, 37, 48, 48, 48, 48, 48, 48, 48, 37, 36, 36, 36, 36, 36],//7
[0, 0, 37, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//8
[0, 0, 0, 37, 37, 37, 3, 3, 3, 3, 3, 37, 44, 37, 36, 47, 36, 36, 36],//9
[0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 47, 36, 36, 36],//10
[0, 0, 0, 0, 0, 37, 37, 11, 37, 37, 37, 37, 37, 37, 36, 47, 36, 36, 36],//11
[0, 0, 0, 0, 0, 37, 11, 11, 11, 37, 37, 37, 37, 37, 36, 47, 36, 36, 36],//12
[0, 0, 0, 0, 0, 37, 37, 11, 37, 37, 37, 32, 37, 37, 36, 47, 36, 36, 36],//13
[0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 20, 37, 7, 37, 36, 36, 36, 36, 36],//14
[0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//15
[0, 0, 0, 0, 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36, 36, 36],//16
[0, 0, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0],//17
[0, 0, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0],//18
[0, 0, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0, 0, 37, 36, 0, 0, 0, 0],//19
// Add more rows as needed
];
for (let y = 0; y < pixelArray.length; y++) {
for (let x = 0; x < pixelArray[y].length; x++) {
const col = pixelArray[y][x];
placePix(SX + x, SY + y, col);
await sleep(25);
}
}
}
const menuContainer = document.createElement('div');
menuContainer.style.display = 'none';
menuContainer.style.position = 'fixed';
menuContainer.style.backgroundColor = 'white';
menuContainer.style.border = '1px solid #ccc';
menuContainer.style.padding = '10px';
menuContainer.style.boxShadow = '0px 0px 10px rgba(0, 0, 0, 0.1)';
menuContainer.style.fontFamily = 'Arial, sans-serif';
menuContainer.style.top = '50%';
menuContainer.style.left = '50%';
menuContainer.style.transform = 'translate(-50%, -50%)';
function createInputWithLabel(labelText, defaultValue) {
const inputWrapper = document.createElement('div');
const label = document.createElement('label');
label.textContent = labelText + ':';
label.style.fontWeight = 'bold';
label.style.marginBottom = '4px';
const input = document.createElement('input');
if (typeof defaultValue === 'boolean') {
input.type = 'checkbox';
input.checked = defaultValue;
input.addEventListener('change', function () {
drawBMO = this.checked;
});
} else {
input.type = 'number';
input.placeholder = defaultValue;
input.style = `
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
width: 100px;
margin-bottom: 10px;
`;
}
inputWrapper.appendChild(label);
inputWrapper.appendChild(input);
return inputWrapper;
}
const header = document.createElement('div');
header.textContent = 'Fill Tool Settings';
header.style.fontSize = '18px';
header.style.fontWeight = 'bold';
header.style.marginBottom = '10px';
const heightInput = createInputWithLabel('Fill Height', '10');
const widthInput = createInputWithLabel('Fill Width', '10');
const lineInput = createInputWithLabel('Line Length', '5');
const colorInput = createInputWithLabel('Color', '5');
const drawBMOInput = createInputWithLabel('Draw BMO', false);
const submitButton = document.createElement('button');
submitButton.textContent = 'Submit (m)';
submitButton.style.backgroundColor = '#007bff';
submitButton.style.color = 'white';
submitButton.style.padding = '8px 12px';
submitButton.style.border = 'none';
submitButton.style.borderRadius = '4px';
submitButton.style.cursor = 'pointer';
submitButton.style.marginTop = '10px';
menuContainer.appendChild(header);
menuContainer.appendChild(heightInput);
menuContainer.appendChild(widthInput);
menuContainer.appendChild(lineInput);
menuContainer.appendChild(colorInput);
menuContainer.appendChild(drawBMOInput);
menuContainer.appendChild(submitButton);
document.body.appendChild(menuContainer);
submitButton.addEventListener('click', () => {
fillHeight = parseFloat(heightInput.querySelector('input').value);
fillWidth = parseFloat(widthInput.querySelector('input').value);
color = parseFloat(colorInput.querySelector('input').value);
lineLength = parseFloat(lineInput.querySelector('input').value);
menuContainer.style.display = 'none';
});