// ==UserScript==
// @name MrMenu
// @version 1.1
// @description MrMenu - ClearLag - Flood Room
// @author MrBonkeiro
// @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==
const CSS =
`
.MrModal
{
position: absolute;
top: 50%;
left: 50%;
width: 80%;
height: 80%;
transform: translate(-50%, -50%);
background-color: #121212;
color: white;
z-index: 1000;
display: flex;
flex-direction: column;
border-radius: 8px;
overflow: hidden;
}
#tabContent
{
height: 40px;
width: 100%;
background-color: #333;
display: flex;
align-items: center;
padding: 0 10px;
box-sizing: border-box;
user-select: none;
position: relative;
}
#modalContent
{
padding: 10px;
overflow-y: auto;
}
#title
{
color: white;
font-size: 12px;
margin-right: 5px;
white-space: nowrap;
font-family: "futurept_b1";
}
#tabsContainer
{
flex: 1;
overflow: hidden;
display: flex;
margin-right: 5px;
margin-left: 5px;
}
#closeModal
{
display: flex;
align-items: center;
margin-left: 5px;
}
#closeButton
{
border-radius: 50%;
cursor: pointer;
background: #f25056;
border: none;
width: 13px!important;
height: 13px!important;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
z-index: 1001;
}
#tabs
{
display: flex;
flex: 1;
overflow-x: hidden;
overflow-y: hidden;
scrollbar-width: none;
ms-overflow-style: none;
white-space: nowrap;
}
#tabs::-webkit-scrollbar
{
display: none;
}
.tab
{
background-color: #a688fa;
padding: 3px 10px;
margin-right: 5px;
cursor: pointer;
border-radius: 4px;
white-space: nowrap;
font-family: "futurept_b1";
font-size: 12px;
white-space: nowrap;
display: flex;
align-items: center;
justify-content: center;
}
.tab:hover {
background-color: #5e43f3;
}
.tab > svg
{
margin-right: 8px;
width: 18px;
height: 18px;
}
#modalContent > .section > *
{
font-size: 12px;
font-family: "futurept_b1";
}
.container { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 20px; font-size: 13px; }
.container * { color: white;}
.container > .row > *:not(:last-child) {margin-right: 7px}
.container input, .container button {height: 30px;}
.container input { background: #333333; font-size: 13px; outline: none; border: none}
.container button { background: #a688fa; padding-right: 10px; padding-left: 10px; font-family: "futurept_b1"; font-size: 13px; outline: none; border: none; } .row { display: flex; align-items: center; margin: 10px 0; }
`;
let tabAttackFloodRoom =
`
<div class="container">
<div class="row">
<label for="room-name">Name room: </label>
<input type="text" id="room-name" maxlength="37" style="width: 200px;">
</div>
<div class="row">
<label for="range">Select range:</label>
<span id="range-label" class="slider-label" style="width: 20px;">50</span>
</div>
<input type="range" id="range" class="slider" min="0" max="100" style="width: 150px;">
<br>
<button id="attackflood">Attack</button>
</div>
`;
let scriptAttackFloodRoom =
`
const rangeInput = document.getElementById('range');
const rangeLabel = document.getElementById('range-label');
rangeInput.addEventListener('input', function() {
rangeLabel.textContent = rangeInput.value;
});
const rname = document.getElementById('room-name');
const attackflood = document.getElementById('attackflood');
attackflood.addEventListener('click', function() {
const rangeValue = parseInt(rangeInput.value, 10); // Converte o valor para número inteiro
const modalMr = document.getElementById('MrMenu');
modalMr.style.display = 'none';
const bonkMODAL = document.getElementById('roomlistcreatewindowcontainer');
bonkMODAL.style.visibility = "visible";
bonkMODAL.style.opacity = "1";
for (let i = 0; i <= rangeValue; i++)
{
const bonk = document.getElementById('roomlistcreatewindowgamename');
const bonkbutton = document.getElementById('roomlistcreatecreatebutton');
bonk.value = rname.value + i;
bonkbutton.click();
const bonkstart = document.getElementById('roomlistcreatewindowgamename');
bonkstart.click();
}
});
`;
let teamChangerHTML =
`
<div class="container">
<div class="row">
<button id="MrRed">Red</button>
<button id="MrBlue">Blue</button>
<button id="MrYellow">Yellow</button>
<button id="MrGreen">Green</button>
</div>
<button id="buff">ClearLag</button>
</div>
`;
let teamChangerscript =
`
const MrRed = document.getElementById('MrRed');
MrRed.addEventListener('click', function() {
const red = document.getElementById('newbonklobby_redbutton');
red.click();
const modalMr = document.getElementById('MrMenu');
modalMr.style.display = 'none';
});
// Evento para o botão azul
const MrBlue = document.getElementById('MrBlue');
MrBlue.addEventListener('click', function() {
const blue = document.getElementById('newbonklobby_bluebutton');
blue.click();
const modalMr = document.getElementById('MrMenu');
modalMr.style.display = 'none';
});
const MrGreen = document.getElementById('MrGreen');
MrGreen.addEventListener('click', function() {
const green = document.getElementById('newbonklobby_greenbutton');
green.click();
const modalMr = document.getElementById('MrMenu');
modalMr.style.display = 'none';
});
// Evento para o botão amarelo
const MrYellow = document.getElementById('MrYellow');
MrYellow.addEventListener('click', function() {
const yellow = document.getElementById('newbonklobby_yellowbutton');
yellow.click();
const modalMr = document.getElementById('MrMenu');
modalMr.style.display = 'none';
});
const buff = document.getElementById('buff');
buff.addEventListener('click', function()
{
parent.MrClear();
modalMr.style.display = 'none';
});
`;
function MrClear()
{
const iframes = document.querySelectorAll('iframe');
const iframeArray = Array.from(iframes);
const iframesToKeep = iframeArray.filter(iframe => iframe.src.includes('gameframe-release.html'));
iframeArray.forEach(iframe => {
if (!iframesToKeep.includes(iframe)) {
iframe.remove();
}
});
alert(`MrClear Run Sucess`);
}
class MrMenu {
constructor(title, author) {
this.title = title;
this.author = author;
}
getIframe(iframeID)
{
const iframe = document.getElementById(iframeID);
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (!iframe) { console.error('[MrMenu] Iframe not found'); return null; }
if (!iframeDoc) { console.error('[MrMenu] Iframe not found'); return null; }
return iframeDoc;
}
addCSS(mrDocument, css) {
let cssMrMenu = mrDocument.createElement('style');
cssMrMenu.innerHTML = css;
mrDocument.head.appendChild(cssMrMenu);
}
createElement(document, { type, attributes = {}, textContent = '' }) {
const element = document.createElement(type);
// Define os atributos do elemento
Object.keys(attributes).forEach(key => {
element.setAttribute(key, attributes[key]);
});
// Define o conteúdo textual do elemento
element.textContent = textContent;
return element;
}
toggleModal(document) {
const modal = document.getElementById('MrMenu');
if (modal) {
if (modal.style.display === 'none' || modal.style.display === '') {
modal.style.display = 'block'; // Mostra o modal
} else {
modal.style.display = 'none'; // Oculta o modal
}
}
}
createTab(tabName, content, f)
{
const tab = document.createElement('div');
tab.className = 'tab';
if (content) {
tab.innerHTML = content;
} else {
tab.textContent = tabName;
}
tab.addEventListener('click', () => this.showSection(tabName));
if (f) {tab.addEventListener('click', f);}
return tab;
}
showSection(tabName)
{
const iframe = this.getIframe('maingameframe');
const sections = iframe.querySelectorAll('.section');
sections.forEach(section => {
section.style.display = section.id === tabName ? 'block' : 'none';
});
}
createSection(sectionName, content) {
const iframe = this.getIframe('maingameframe');
const section = iframe.createElement('div');
section.className = 'section';
section.id = sectionName;
section.style.display = 'none';
const contentElement = iframe.createElement('div');
contentElement.innerHTML = content;
section.appendChild(contentElement);
return section;
}
}
function Init()
{
let mrMenu = new MrMenu('MrMenu v1.0.0', 'MrBonkeiro');
const iframe = mrMenu.getIframe('maingameframe');
mrMenu.addCSS(iframe, CSS);
const modalElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'MrMenu', class: 'MrModal' }});
iframe.getElementById('bonkiocontainer').appendChild(modalElement);
const tabContentElement = mrMenu.createElement(iframe, {type: 'div', attributes: { id: 'tabContent'}});
iframe.getElementById('MrMenu').appendChild(tabContentElement);
const modalContentElement = mrMenu.createElement(iframe, {type: 'div', attributes: { id: 'modalContent'}});
iframe.getElementById('MrMenu').appendChild(modalContentElement);
const titleElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'title'}, textContent: '' + mrMenu.title + ' by ' + mrMenu.author});
iframe.getElementById('tabContent').appendChild(titleElement);
const tabsContainerElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'tabsContainer'}});
iframe.getElementById('tabContent').appendChild(tabsContainerElement);
const closeModalElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'closeModal'}});
iframe.getElementById('tabContent').appendChild(closeModalElement);
const closebtnElement = mrMenu.createElement(iframe, { type: 'button', attributes: { id: 'closeButton'}});
iframe.getElementById('closeModal').appendChild(closebtnElement);
closebtnElement.addEventListener('click', () => mrMenu.toggleModal(iframe));
function handleKeyPress(event)
{
if (event.key === 'Delete') {
mrMenu.toggleModal(iframe);
}
}
iframe.addEventListener('keydown', handleKeyPress);
const tabsElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'tabs'}});
iframe.getElementById('tabsContainer').appendChild(tabsElement);
uptabs(mrMenu, 'Flood Room', null, tabAttackFloodRoom, scriptAttackFloodRoom);
uptabs(mrMenu, 'Team Changer', null, teamChangerHTML, teamChangerscript);
}
function uptabs(mrMenu, title, fUpdate, sectionContent, scriptContent)
{
const xiframe = mrMenu.getIframe('maingameframe');
let idx = title.replace(/\s+/g, ''); // Remove todos os espaços
const tabs = xiframe.getElementById('tabs');
tabs.appendChild(mrMenu.createTab(idx, title, fUpdate));
const modalContentDiv = xiframe.getElementById('modalContent');
modalContentDiv.appendChild(mrMenu.createSection(idx, sectionContent));
///
let scriptId = "tabScript";
let existingScript = xiframe.getElementById(scriptId);
// Se o script existir, remova-o
if (existingScript) {
existingScript.remove();
}
// Crie um novo script
const xscript = xiframe.createElement('script');
xscript.id = scriptId;
xscript.type = 'text/javascript';
xscript.textContent = scriptContent;
// Adicione o novo script ao body do iframe
xiframe.body.appendChild(xscript);
}
function ScriptInjector(f) {
if (window.location == window.parent.location) {
if (document.readyState == 'complete') { setTimeout(f, 200); }
else { document.addEventListener('readystatechange', function () { setTimeout(f, 1500);});
}
}
}
ScriptInjector(Init);