XP Invoker

XP Free

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Advertisement:

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

Advertisement:

// ==UserScript==
// @name         XP  Invoker
// @version      2.1
// @description  XP Free
// @author       MrBonkeiro & GreninjaOP
// @match        https://bonk.io/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bonk.io
// @run-at       document-idle
// @grant        none
// @namespace https://greasyfork.org/users/1618232
// ==/UserScript==

function getBonk() {
    const iframe = document.getElementById('maingameframe');
    if (!iframe) {
        console.error('[MrMenu] Iframe not found');
        return null;
    }

    const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
    if (!iframeDoc) {
        console.error('[MrMenu] Iframe document not found');
        return null;
    }

    return iframeDoc;
}

function isRoom() {
    const bonkDoc = getBonk();
    if (!bonkDoc) return false;

    const element = bonkDoc.getElementById('gamerenderer');
    if (element) {
        return window.getComputedStyle(element).visibility === 'inherit';
    }

    return false;
}

function Init() {
    let getWS;
    let timer = null;
    let deletePressed = false;

    function XP()
    {
         if (isRoom && getWS != null) { getWS.send('42[38]');}
        console.log('42[38]');
    }

    function handleDeleteKey(event) {
      if (event.key === "Delete"|| event.key === "L" || event.key === "l") {
        if (!deletePressed) {
          deletePressed = true;
          timer = setInterval(XP, 1000);
          getBonk().getElementById('xpbarfill').style.backgroundColor = 'lightgreen';
        } else {
          clearInterval(timer);
          deletePressed = false;
          getBonk().getElementById('xpbarfill').style.backgroundColor = '#473aaf';

        }
      }
    }

    getBonk().addEventListener("keydown", handleDeleteKey);

    const originalSend = getBonk().defaultView.WebSocket.prototype.send;
    getBonk().defaultView.WebSocket.prototype.send = function (...args) {
        if (this.url.includes('socket.io')) {
            getWS = this;

            const originalOnMessage = this.onmessage;
            this.onmessage = function (msg) {
                return originalOnMessage.call(this, msg);
            };

            const originalOnClose = this.onclose;
            this.onclose = function () {
                getWS = null;
                return originalOnClose.call(this);
            };
        }

        return originalSend.apply(this, args);
    };
}

function ScriptInjector(f) {
    if (window.location === window.parent.location) {
        if (document.readyState === 'complete') {
            setTimeout(f, 1200);
        } else {
            document.addEventListener('readystatechange', function () {
                setTimeout(f, 3500);
            });
        }
    }
}


ScriptInjector(Init);