Fake bot Change Villa

Change villa every iteration

Versione datata 21/01/2025. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Fake bot Change Villa
// @version      1.35
// @description  Change villa every iteration
// @include      https://*/game.php*screen=place*
// @namespace https://greasyfork.org/users/1388863
// ==/UserScript==

(function() {
    'use strict';

    // Create UI container
    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 = '10px';
    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 = '16px';
    loopCounterDisplay.style.textAlign = 'center';
    loopCounterDisplay.textContent = 'Remaining Loops: 0';
    container.appendChild(loopCounterDisplay);

    // Start/Stop button
    const startStopButton = document.createElement('button');
    startStopButton.textContent = 'Start';
    startStopButton.style.padding = '5px';
    startStopButton.style.fontSize = '16px';
    startStopButton.style.backgroundColor = '#4CAF50';
    startStopButton.style.color = '#fff';
    startStopButton.style.border = 'none';
    startStopButton.style.borderRadius = '3px';
    startStopButton.style.cursor = 'pointer';
    startStopButton.style.width = '100%';
    container.appendChild(startStopButton);

    // Set Loops button
    const loopButton = document.createElement('button');
    loopButton.textContent = 'Set Loops';
    loopButton.style.padding = '5px';
    loopButton.style.fontSize = '16px';
    loopButton.style.backgroundColor = '#FF9800';
    loopButton.style.color = '#fff';
    loopButton.style.border = 'none';
    loopButton.style.borderRadius = '3px';
    loopButton.style.cursor = 'pointer';
    loopButton.style.width = '100%';
    container.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();
            }
        }
    }
})();