Location Fineder for Neal.fun

Bot for Neal.fun site that allows you to skip all unnecesarry locations until you find your desired one!

// ==UserScript==
// @name         Location Fineder for Neal.fun
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Bot for Neal.fun site that allows you to skip all unnecesarry locations until you find your desired one!
// @author       Danylo, discord: codemeteor
// @match        https://neal.fun/wonders-of-street-view/
// @license      Code Meteor Team (CMT)
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to check if the keyword is met in the HTML
    function checkKeyword() {
        const keyword = keywordInput.value.trim();
        const locationDiv = document.querySelector('.info-location');
        if (keyword && locationDiv && locationDiv.textContent.includes(keyword)) {
            clearInterval(interval);
        } else {
            // Press the "Random" button if the keyword doesn't match
            const randomButton = document.querySelector('button.random');
            if (randomButton) {
                randomButton.click();
            }
        }
    }

    // Create GUI elements
    const guiContainer = document.createElement('div');
    guiContainer.id = 'botGuiContainer';
    guiContainer.innerHTML = `
        <style>
            #botGuiContainer {
                position: fixed;
                top: 10px;
                left: 10px;
                z-index: 9999;
                padding: 20px;
                border-radius: 10px;
                display: none;
                animation: fadeIn 0.3s ease-in-out;
                background: rgba(10, 0, 10, 1) url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAOCAYAAAASVl2WAAAAiklEQVQYlY2QMQqCQBBF3xqBgZiDwBR/D0xE8IXZjvFkM8XMwCTMDF8IgAVJnJmDDkM2ThDIJYjAAhA+Zb+wM+h2VZBGSN0MBIz3BVKyixvBzBGObL4Vwb0x1Q0kZShGHDziz5M2TxQwsAHc/LvZBJfIoAAAAASUVORK5CYII=");
                position: relative; /* Added position relative */
                background-size: 400px; /* Set background size to 400px */
                width: 525px; /* Set width to 400px */
            }
            @keyframes fadeIn {
                from { opacity: 0; }
                to { opacity: 1; }
            }
            #botGuiContainer.show {
                display: block;
            }
            #startStopCheckbox {
                margin-right: 15px;
                margin-top: 5px;
            }
            #startStopLabel {
                font-weight: bold;
                margin-right: 10px;
                color: white; /* Change text color to white */
            }
            #keywordInput {
                margin-top: 10px;
                padding: 8px;
                border-radius: 5px;
                border: 1px solid #ccc;
                background-color: #333;
                color: white;
                width: 100%;
                box-sizing: border-box;
            }
            #delaySlider {
                margin-top: 10px;
                width: 100%;
            }
            #delayText {
                margin-top: 5px;
                color: white;
            }
            #watermark {
                position: absolute; /* Positioned within the GUI container */
                bottom: 10px;
                left: 400px; /* Position the watermark 400px from the left side of the screen */
                color: #888;
                font-size: 12px;
                z-index: -1; /* Ensure the watermark is behind other elements */
            }
            /* Dots animation */
            #dotsBackground {
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                right: 0;
                pointer-events: none;
                z-index: -1;
                background-size: 50px 50px;
                background-image: radial-gradient(circle, #888 1px, transparent 1px), radial-gradient(circle, #888 1px, transparent 1px);
                background-position: 0 0, 25px 25px;
                background: rgba(100, 0, 60, 1)
                opacity: 0.5;
                animation: dotsAnimation 10s infinite linear;
            }
            @keyframes dotsAnimation {
                from {
                    background-position: 0 0, 25px 25px;
                }
                to {
                    background-position: 50px 0, 75px 75px;
                }
            }
            #findNextButton {
                margin-top: 10px;
                padding: 10px 20px;
                border: none;
                border-radius: 5px;
                background-color: #666;
                color: white;
                cursor: pointer;
            }
            #findNextButton:hover {
                background-color: #999;
            }
        </style>
        <div id="dotsBackground"></div>
        <input type="checkbox" id="startStopCheckbox">
        <label for="startStopCheckbox" id="startStopLabel">Start bot?</label>
        <input type="text" id="keywordInput" placeholder="Enter Location">
        <input type="range" min="0" max="1500" value="1000" id="delaySlider">
        <div id="delayText"></div> <!-- Element for displaying delay text -->
        <div id="watermark">Bot made by Danylo</div> <!-- Watermark -->
        <button id="findNextButton">Find Next</button> <!-- Button to find next -->
    `;
    document.body.appendChild(guiContainer);

    const startStopCheckbox = document.getElementById('startStopCheckbox');
    const keywordInput = document.getElementById('keywordInput');
    const delaySlider = document.getElementById('delaySlider');
    const delayText = document.getElementById('delayText'); // Get the delay text element
    const findNextButton = document.getElementById('findNextButton'); // Get the find next button

    let interval;

    // Function to start/stop the bot based on checkbox state
    function toggleBot() {
        if (startStopCheckbox.checked) {
            startStopLabel.textContent = 'Stop bot?';
            interval = setInterval(checkKeyword, delaySlider.value); // Use the delay from the slider
        } else {
            startStopLabel.textContent = 'Start bot?';
            clearInterval(interval);
        }
    }

    // Function to update delay text
    function updateDelayText() {
        const delayValue = parseInt(delaySlider.value);
        if (delayValue === 0) {
            delayText.textContent = 'Find as fast as possible';
        } else {
            delayText.textContent = `Delay: ${delayValue}ms`;
        }
    }

    // Function to handle "Find Next" button click
    function findNext() {
        startStopCheckbox.checked = true; // Check the checkbox
        startStopCheckbox.dispatchEvent(new Event('change')); // Dispatch change event
        const randomButton = document.querySelector('button.random');
        if (randomButton) {
            randomButton.click();
        }
    }

    // Toggle GUI visibility on pressing the "Insert" key
    document.addEventListener('keydown', function(event) {
        if (event.code === 'Insert') {
            guiContainer.classList.toggle('show');
        }
    });

    // Add event listeners
    startStopCheckbox.addEventListener('change', toggleBot);
    delaySlider.addEventListener('input', updateDelayText); // Update delay text when slider value changes
    findNextButton.addEventListener('click', findNext); // Add click event listener to find next button

    // Initial update of delay text
    updateDelayText();
})();