Sploop Improver

Improves Sploop

Versión del día 5/11/2023. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Sploop Improver
// @namespace    -
// @version      -
// @description  Improves Sploop
// @author       Carolina Reaper
// @match        *://sploop.io/*
// @match        *://lostworld.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=sploop.io
// @grant        none
// ==/UserScript==
// Start Injection
let inject1 = Date.now();
console.log("Injecting Script, Sploop Improver.");

// Remove annoying pop-up before tab is closed
window.onbeforeunload = null;

//Element Remover
function remove(e) {
    e.forEach(t => document.getElementById(t) && document.getElementById(t).remove());
};

// Removes unnessecary stuff
setInterval(function() {
    remove(["google_play", "cross-promo", "bottom-wrap", "right-content", "lostworld-io_970x250", "lostworld-io_300x250", "lostworld-io_300x250_1", "lostworld-io_300x250_2", "shop-io-games", "webgames-text", "da-right", "da-left"]);
}, 0);

// Create New Elements
let progress = document.createElement("div"), progressBar = document.createElement("div"), progressTitle = document.createElement("div"),
    percentageValue = document.createElement("div");

// Provide ID and Class to elements
progress.classList.add("progress");
progressBar.classList.add("progressBar");
progressTitle.id = "progressTitle";
percentageValue.id = "percentageValue";

// Append elements to document
document.getElementById("da-bottom").replaceWith(progress);
progress.appendChild(progressBar);
progress.appendChild(progressTitle);
progressBar.appendChild(percentageValue);

// Interval
setInterval(function() {
    let percentage = Math.round((parseInt(document.getElementById("total-score").innerText, 1e1) / (parseInt(document.getElementById("score-left-value").innerText, 1e1) + parseInt(document.getElementById("total-score").innerText, 1e1))) * 1e2);
    progressBar.style.width = percentage.toString() + "%";
    percentageValue.innerHTML = progressBar.style.width;
    progressTitle.innerHTML = "Rank Progress<br>(" + document.getElementById("total-score").innerText + " / " + (parseInt(document.getElementById("score-left-value").innerText) + parseInt(document.getElementById("total-score").innerText)).toString() + ")";
}, 0);

// Add CSS
let styleSheet = document.createElement("style");
styleSheet.innerText = `
#game-bottom-content {
    width: 1000px;
    height: 225px;
}

#percentageValue {
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    text-align: center;
}

#progressTitle {
    font-size: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    border: 5px solid rgba(0,0,0,0);
}

.progress {
    background-color: rgb(20 20 20 / 40%);
    border-radius: 25px;
    border: 5px solid rgb(20 20 20 / 80%);
    height: 50px;
    width: 700px;
    margin: auto;
}

.progressBar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 25px;
    background-color: rgb(20 20 20 / 60%);
    height: 100%;
    width: 0%;
    transition: 1s ease 0.25s;
}
`;
document.head.appendChild(styleSheet);

// FPS + Server
(function() {
    'use strict';
    try {
        window.admob = {
            requestInterstitialAd: () => {},
            showInterstitialAd: () => {}
        };
    } catch (e) {
        console.warn(e)
    };

    let UPDATE_DELAY = 7e2;
    let UPDATE_DELAY1 = 1e2;
    let frames = 0;
    let frames1 = 0;
    let lastUpdate = 0;
    let lastUpdate1 = 0;

    function updateCounter1() {
        let bgColor = getComputedStyle(document.body, null).getPropertyValue("background-color");
        let bgColorValues = cssColorToRGB(bgColor);
        let textColor = getInvertedRGB(bgColorValues);
        let displayBg = getOpaqueRGB(bgColorValues);
        let now = Date.now();
        let elapsed = now - lastUpdate1;

        if (elapsed < UPDATE_DELAY1) frames1++;
        else {
            frames1 = 0;
            lastUpdate1 = now;
        };

        requestAnimationFrame(updateCounter1);
    };

    lastUpdate1 = Date.now();
    requestAnimationFrame(updateCounter1);

    let displayElement = document.createElement("div");
    displayElement.style.padding = "20px";
    displayElement.style = "font-size:20px;"
    displayElement.style.display = "block";
    displayElement.style.position = "absolute";
    displayElement.style.top = "1px";
    displayElement.style.left = "50%";
    displayElement.style.transform = "translateX(-50%)";
    displayElement.textContent = "Loading...";
    displayElement.style.color = "#fff";
    displayElement.style.background = "rgba(255, 255, 255, 0)";
    document.body.appendChild(displayElement);

    function cssColorToRGB(color) {
        let values;

        if (color.startsWith("rgba")) {
            values = color.substring(5, color.length - 1).split(",");
        } else if (color.startsWith("rgb")) {
            values = color.substring(4, color.length - 1).split(",");
        } else if (color.startsWith("#") && color.length === 4) {
            values = [];
            values[0] = "" + parseInt("0x" + color.substr(1, 1));
            values[1] = "" + parseInt("0x" + color.substr(2, 1));
            values[2] = "" + parseInt("0x" + color.substr(3, 1));
        } else if (color.startsWith("#") && color.length === 7) {
            values = [];
            values[0] = "" + parseInt("0x" + color.substr(1, 2));
            values[1] = "" + parseInt("0x" + color.substr(3, 2));
            values[2] = "" + parseInt("0x" + color.substr(5, 2));
        } else return {
            r: 255,
            g: 255,
            b: 255
        };

        return {
            r: Number(values[0]),
            g: Number(values[1]),
            b: Number(values[2])
        };
    };

    function getInvertedRGB(values) {
        return "rgb(" + (255 - values.r) + "," + (255 - values.g) + "," + (255 - values.b) + ")";
    };

    function getOpaqueRGB(values) {
        return "rgba(" + values.r + "," + values.g + "," + values.b + ", 0.7)";
    };

    const dropDown = document.querySelector("#server-select");

    function updateCounter() {
        let bgColor = getComputedStyle(document.body, null).getPropertyValue("background-color");
        let bgColorValues = cssColorToRGB(bgColor);
        let textColor = getInvertedRGB(bgColorValues);
        let displayBg = getOpaqueRGB(bgColorValues);
        let now = Date.now();
        let elapsed = now - lastUpdate;

        if (elapsed < UPDATE_DELAY) frames++;
        else {
            let fps = Math.round(frames / (elapsed / 1e3));
            frames = 0;
            lastUpdate = now;
            displayElement.textContent = `Fps: ${fps} \n ${dropDown.value.split(" -")[0]}`;
        };

        requestAnimationFrame(updateCounter);
    };

    lastUpdate = Date.now();
    requestAnimationFrame(updateCounter);
})();

// Complete Injection
let injectionTime = Date.now() - inject1;
console.log("Injection Complete, Sploop Improver.\nInjection Time: " + injectionTime + "ms");