Change villa every iteration
目前為
// ==UserScript==
// @name Fake bot Change Villa
// @version 1.4
// @description Change villa every iteration
// @include https://*/game.php*screen=place*
// @namespace https://greasyfork.org/users/1388863
// ==/UserScript==
(function() {
'use strict';
const container = document.createElement('div');
container.style.position = 'fixed';
container.style.bottom = '20px';
container.style.right = '20px';
container.style.backgroundColor = '#333';
container.style.color = '#fff';
container.style.padding = '8px';
container.style.borderRadius = '5px';
container.style.zIndex = '10000';
container.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
container.style.display = 'flex';
container.style.flexDirection = 'column';
container.style.gap = '10px';
document.body.appendChild(container);
// Remaining loops display
const loopCounterDisplay = document.createElement('div');
loopCounterDisplay.style.fontSize = '14px'; // Smaller text size
loopCounterDisplay.style.textAlign = 'center';
loopCounterDisplay.textContent = 'Remaining Loops: 0';
container.appendChild(loopCounterDisplay);
// Create a flex container for buttons to be side by side
const buttonContainer = document.createElement('div');
buttonContainer.style.display = 'flex';
buttonContainer.style.gap = '10px'; // Add space between buttons
buttonContainer.style.width = '100%'; // Ensure the container spans the full width
container.appendChild(buttonContainer);
// Start/Stop button
const startStopButton = document.createElement('button');
startStopButton.textContent = 'Start';
startStopButton.style.padding = '5px 8px'; // Smaller padding
startStopButton.style.fontSize = '14px'; // Smaller font size
startStopButton.style.backgroundColor = '#4CAF50';
startStopButton.style.color = '#fff';
startStopButton.style.border = 'none';
startStopButton.style.borderRadius = '3px';
startStopButton.style.cursor = 'pointer';
startStopButton.style.flex = '1'; // Allow button to take equal space
buttonContainer.appendChild(startStopButton);
// Set Loops button
const loopButton = document.createElement('button');
loopButton.textContent = 'Set';
loopButton.style.padding = '5px 8px'; // Smaller padding
loopButton.style.fontSize = '14px'; // Smaller font size
loopButton.style.backgroundColor = '#FF9800';
loopButton.style.color = '#fff';
loopButton.style.border = 'none';
loopButton.style.borderRadius = '3px';
loopButton.style.cursor = 'pointer';
loopButton.style.flex = '1'; // Allow button to take equal space
buttonContainer.appendChild(loopButton);
// Retrieve the last state from localStorage
let isRunning = localStorage.getItem('botState') === 'running';
let remainingLoops = parseFloat(localStorage.getItem('remainingLoops')) || 0;
// Set initial button and loop counter state
startStopButton.textContent = isRunning ? 'Stop' : 'Start';
loopCounterDisplay.textContent = `Remaining Loops: ${remainingLoops}`;
// Start the bot if it was running
if (isRunning) {
startBot();
}
// Start/Stop button event
startStopButton.addEventListener('click', () => {
if (isRunning) {
stopBot();
} else {
startBot();
}
});
// Loop button event
loopButton.addEventListener('click', () => {
const loopsInput = parseInt(prompt("Enter the number of loops to run:", remainingLoops), 10);
if (!isNaN(loopsInput) && loopsInput > 0) {
remainingLoops = loopsInput;
localStorage.setItem('remainingLoops', remainingLoops);
loopCounterDisplay.textContent = `Remaining Loops: ${remainingLoops}`;
console.log(`Set loops to: ${remainingLoops}`);
}
});
function startBot() {
isRunning = true;
localStorage.setItem('botState', 'running');
startStopButton.textContent = 'Stop';
startStopButton.style.backgroundColor = '#FF0000';
console.log("Bot started");
loopCounterDisplay.textContent = `Remaining Loops: ${remainingLoops}`;
runBotLoop();
}
function stopBot() {
isRunning = false;
localStorage.setItem('botState', 'stopped');
startStopButton.textContent = 'Start';
startStopButton.style.backgroundColor = '#4CAF50';
console.log("Bot stopped");
}
function runBotLoop() {
if (remainingLoops > 0) {
console.log("Executing loop...");
remainingLoops--;
localStorage.setItem('remainingLoops', remainingLoops);
loopCounterDisplay.textContent = `Remaining Loops: ${remainingLoops}`;
if (remainingLoops > 0) {
setTimeout(runBotLoop, 2000); // Example delay
} else {
stopBot();
}
}
}
})();