MrMenu

Best Manager bonk.io

目前為 2024-10-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MrMenu
// @version      1.34
// @description  Best Manager bonk.io
// @author       MrBonkeiro
// @namespace    https://greasyfork.org/en/scripts/504571-mrmenu
// @match        https://bonk.io/
// @match        https://bonk.io/*
// @match        https://bonkisback.io/*
// @match        https://multiplayer.gg/physics/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bonk.io
// @grant        none
// @unwrap
// @namespace https://greasyfork.org/users/1355760
// ==/UserScript==

function ScriptInjector(f)
{
    if (window.location.href == `https://bonk.io/gameframe-release.html`)
    {
        if (document.readyState == 'complete'){ setTimeout(f, 200); }
        else
        { document.addEventListener('readystatechange', function () { setTimeout(f, 1500); }); }
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////

let UICSS =
    `
@import url('https://fonts.googleapis.com/css2?family=Arimo:ital,wght@0,400..700;1,400..700&display=swap');
div#MrMenu
{
    background-color: #1f1f1f; display: flex; position: absolute; top: 50%; left: 50%; width: 80%; height: 80%; transform: translate(-50%, -50%); user-select: none; box-sizing: border-box; font-family: 'Arimo'; color: white;
}

div#MrMenu .sidebar
{
    background-color: #252525; width: 220px; height: 100%; overflow-x: auto;
}

div#MrMenu .sidebar ul
{
  list-style: none; padding: 12px;
}

div#MrMenu .sidebar li
{
  padding: 15px; margin-bottom: 10px; cursor: pointer; border-radius: 8px; text-align: center; transition: background-color 0.3s, color 0.3s;
}

div#MrMenu .sidebar li:hover
{
  background-color: #333;
}

div#MrMenu .content
{
  display: flex; width: calc(100% - 220px); padding: 20px; overflow-y: auto; position: relative;
}

div#MrMenu .content .tab
{
  display: none;
}

div#MrMenu .content .tab.active
{
  display: block; overflow-y: auto; overflow-x: hidden; width: 100%; height: 100%; padding-right: 10px
}

div#MrMenu .content .row
{
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; width: 100%;
}

div#MrMenu .content .info
{
  flex-basis: 50%; max-width: 50%; color: #cccccc;
}

div#MrMenu .content label
{
  font-weight: bold; margin-bottom: 5px; display: block; font-size: 17px;
}

div#MrMenu .content p
{
  font-size: 12px; color: #aaa; margin-top: 5px;
}

.action
{
  flex-basis: 45%; display: flex; justify-content: flex-end; align-items: center;
}


div#MrMenu .content input[type="text"], div#MrMenu .content button
{
  width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #555; background-color: #333; color: white; transition: background-color 0.3s, border-color 0.3s;
}

div#MrMenu .content button.active
{
  background-color: #2A51F4;
}

button:not(last-child)
{
  margin-right: 5px;
}

input[type="text"]:focus, button:focus
{
  outline: none;
}

div#MrMenu .content input[type="range"]
{
  appearance: none; width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #555; background-color: #333; transition: background-color 0.3s, border-color 0.3s;
}
`;

let UIHTML =
    `
<div id="MrMenu">
    <div class="sidebar">
        <ul>
            <li data-tab="tab1" class="active">UI TEST</li>
            <li data-tab="tab3">XP Involker</li>
        </ul>
    </div>
    <div class="content">
    </div>
</div>
`;

let UITab1 =
    `
<div class="tab" data-tab="tab1">
<div class="row">
        <div class="info">
            <label>Freejoin</label>
            <p>When you are a host and activated, players can join without restarting the room</p>
        </div>
        <div class="action">
            <button>Enable</button>
        <button>Disable</button></div>
    </div>
<div class="row">
        <div class="info">
            <label>Color</label>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
        </div>
        <div class="action">
            <input type="text">
        </div>
</div>
<div class="row">
        <div class="info">
            <label>Color</label>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
        </div>
        <div class="action">
            <input type="range">
        </div>
</div>
</div>
`;

let UITab3 =
    `
<div class="tab" data-tab="tab3">
    <div class="row">
        <div class="info">
            <label>XP Farm</label>
            <p>When you are in a match and enabled, you start with +100 XP</p>
        </div>
        <div class="action">
            <button id="XPfarmEnable">Enable</button>
            <button class="active" id="XPfarmDisable">Disable</button>
        </div>
    </div>
    <div class="row">
        <div class="info">
            <label>Delay: <span id="MrMenuXPDelay"></span></label>
            <p>Defines an interval in milliseconds if 'Farm XP' is activated</p>
        </div>
        <div class="action">
            <input type="range" min="7000" max="30000" value="15000" step="500" id="MrMenuXPinputRangeDelay">
        </div>
    </div>
</div>
`;


/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////

function addCSS(ID, cssString, replace = false)
{
    let styleElement = document.getElementById(ID);

    if (styleElement) {
        if (replace) {
            styleElement.innerHTML = cssString;
        } else {
            styleElement.innerHTML += `\n${cssString}`;
        }
    } else {
        styleElement = document.createElement('style');
        styleElement.id = ID;
        styleElement.innerHTML = cssString;
        document.head.appendChild(styleElement);
    }
}

function addHTML(htmlString, selector, beforeSelector = null)
{
    const targetElement = document.querySelector(selector);
    if (!targetElement) { return; }

    const parser = new DOMParser();
    const doc = parser.parseFromString(htmlString, 'text/html');
    const newElements = Array.from(doc.body.childNodes);

    if (beforeSelector) {
        const beforeElement = document.querySelector(beforeSelector);
        if (!beforeElement) { return; }
        newElements.forEach(node => {
            beforeElement.parentNode.insertBefore(node, beforeElement);
        });
    } else {
        newElements.forEach(node => {
            targetElement.appendChild(node);
        });
    }
}

function toggleMenu()
{
    const menu = document.querySelector('div#MrMenu');
    const visible = window.getComputedStyle(menu).visibility === 'visible';

    menu.style.visibility = visible ? 'hidden' : 'visible';
    menu.style.opacity = visible ? '0' : '1';
    menu.style.zIndex = visible ? '-100' : '100';
}

function sidebarMenu(event)
{
    if(event.target.tagName === 'LI')
    {
        const dataTab = event.target.getAttribute('data-tab');
        if(dataTab == 'tab1')
        {
            alert('No Work || Não funciona');
        }
        document.querySelectorAll("div#MrMenu > div.content > div[data-tab]").forEach(item => { item.classList.remove('active'); });
        document.querySelector(`div[data-tab="${dataTab}"]`).classList.add('active');
    }
}

function XPWSS()
{
    function getXP()
    {
        if(window.MrMenu.WSS.bonkWSS && document.getElementById("gamerenderer").style["visibility"] != "hidden")
        {
            window.MrMenu.WSS.bonkWSS.send(`42[38]`);
        }
    }
    if(document.getElementById(`XPfarmEnable`).classList.contains('active'))
    {
        window.MrMenu.WSS.XPLoop = setInterval(() => { getXP(); }, document.getElementById(`MrMenuXPinputRangeDelay`).value );
    }

    if(document.getElementById(`XPfarmDisable`).classList.contains('active'))
    {
        clearInterval(window.MrMenu.WSS.XPLoop);
        window.MrMenu.WSS.XPLoop = null;
    }
}

function XPfarmClick(event)
{
    event.target.parentElement.querySelectorAll("button").forEach(button => { button.classList.remove('active'); });
    event.target.classList.add('active');
    XPWSS();
}

function XPDelayInputRange(event)
{
    document.getElementById(`MrMenuXPDelay`).innerHTML = event.target.value + " ms";
    XPWSS()
}

function InterceptWSS()
{
    var originalSend = WebSocket.prototype.send;
    WebSocket.prototype.send = function(args)
    {
        window.MrMenu.WSS.bonkWSS = this;
        var originalReceive = this.onmessage;

        this.onmessage = function(event)
        {

            return originalReceive.call(this, event);
        };
        return originalSend.call(this, args);
    }
}

function Init()
{
    InterceptWSS();
    addCSS('MrUI', UICSS);
    addHTML(UIHTML, '#bonkiocontainer');
    addHTML(UITab1, 'div#MrMenu > div.content');
    addHTML(UITab3, 'div#MrMenu > div.content');

    window.MrMenu = {
        WSS:
        {
            bonkWSS: null,
            XPLoop: null,
        },
        UI:
        {
            toggleMenu: toggleMenu,
            sidebarMenu: sidebarMenu,
            XPfarmClick: XPfarmClick,
            XPDelayInputRange: XPDelayInputRange,
        },
    };

    document.querySelector("body").addEventListener("keydown", (event) => { if (event.key === 'Delete') { window.MrMenu.UI.toggleMenu(); } });
    document.querySelector(`div#pretty_top_name`).addEventListener(`click`, () => { window.MrMenu.UI.toggleMenu(); });

    document.querySelector("div#MrMenu > div.sidebar > ul").addEventListener("click", (event) => { window.MrMenu.UI.sidebarMenu(event); });

    document.querySelector("div#MrMenu > div.content #XPfarmEnable").addEventListener("click", (event) => { window.MrMenu.UI.XPfarmClick(event); });
    document.querySelector("div#MrMenu > div.content #XPfarmDisable").addEventListener("click", (event) => { window.MrMenu.UI.XPfarmClick(event); });

    document.querySelector("div#MrMenu > div.content #MrMenuXPinputRangeDelay").addEventListener("input", (event) => { window.MrMenu.UI.XPDelayInputRange(event); });


}

ScriptInjector(Init);