MrMenu

MrMenu - ClearLag - Flood Room

当前为 2024-08-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MrMenu
  3. // @version 1.1
  4. // @description MrMenu - ClearLag - Flood Room
  5. // @author MrBonkeiro
  6. // @match https://bonk.io/
  7. // @match https://bonk.io/*
  8. // @match https://bonkisback.io/*
  9. // @match https://multiplayer.gg/physics/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=bonk.io
  11. // @grant none
  12. // @unwrap
  13. // @namespace https://greasyfork.org/users/1355760
  14. // ==/UserScript==
  15.  
  16. const CSS =
  17. `
  18. .MrModal
  19. {
  20. position: absolute;
  21. top: 50%;
  22. left: 50%;
  23. width: 80%;
  24. height: 80%;
  25. transform: translate(-50%, -50%);
  26. background-color: #121212;
  27. color: white;
  28. z-index: 1000;
  29. display: flex;
  30. flex-direction: column;
  31. border-radius: 8px;
  32. overflow: hidden;
  33. }
  34.  
  35. #tabContent
  36. {
  37. height: 40px;
  38. width: 100%;
  39. background-color: #333;
  40. display: flex;
  41. align-items: center;
  42. padding: 0 10px;
  43. box-sizing: border-box;
  44. user-select: none;
  45. position: relative;
  46. }
  47.  
  48. #modalContent
  49. {
  50. padding: 10px;
  51. overflow-y: auto;
  52. }
  53.  
  54. #title
  55. {
  56. color: white;
  57. font-size: 12px;
  58. margin-right: 5px;
  59. white-space: nowrap;
  60. font-family: "futurept_b1";
  61. }
  62.  
  63. #tabsContainer
  64. {
  65. flex: 1;
  66. overflow: hidden;
  67. display: flex;
  68. margin-right: 5px;
  69. margin-left: 5px;
  70. }
  71.  
  72. #closeModal
  73. {
  74. display: flex;
  75. align-items: center;
  76. margin-left: 5px;
  77. }
  78.  
  79. #closeButton
  80. {
  81. border-radius: 50%;
  82. cursor: pointer;
  83. background: #f25056;
  84. border: none;
  85. width: 13px!important;
  86. height: 13px!important;
  87. display: flex;
  88. align-items: center;
  89. justify-content: center;
  90. cursor: pointer;
  91. z-index: 1001;
  92. }
  93.  
  94. #tabs
  95. {
  96. display: flex;
  97. flex: 1;
  98. overflow-x: hidden;
  99. overflow-y: hidden;
  100. scrollbar-width: none;
  101. ms-overflow-style: none;
  102. white-space: nowrap;
  103. }
  104.  
  105. #tabs::-webkit-scrollbar
  106. {
  107. display: none;
  108. }
  109.  
  110. .tab
  111. {
  112. background-color: #a688fa;
  113. padding: 3px 10px;
  114. margin-right: 5px;
  115. cursor: pointer;
  116. border-radius: 4px;
  117. white-space: nowrap;
  118. font-family: "futurept_b1";
  119. font-size: 12px;
  120. white-space: nowrap;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. }
  125.  
  126. .tab:hover {
  127. background-color: #5e43f3;
  128. }
  129.  
  130. .tab > svg
  131. {
  132. margin-right: 8px;
  133. width: 18px;
  134. height: 18px;
  135. }
  136.  
  137. #modalContent > .section > *
  138. {
  139. font-size: 12px;
  140. font-family: "futurept_b1";
  141. }
  142. .container { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 20px; font-size: 13px; }
  143. .container * { color: white;}
  144. .container > .row > *:not(:last-child) {margin-right: 7px}
  145. .container input, .container button {height: 30px;}
  146. .container input { background: #333333; font-size: 13px; outline: none; border: none}
  147. .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; }
  148. `;
  149.  
  150.  
  151. let tabAttackFloodRoom =
  152. `
  153. <div class="container">
  154. <div class="row">
  155. <label for="room-name">Name room: </label>
  156. <input type="text" id="room-name" maxlength="37" style="width: 200px;">
  157. </div>
  158. <div class="row">
  159. <label for="range">Select range:</label>
  160. <span id="range-label" class="slider-label" style="width: 20px;">50</span>
  161. </div>
  162. <input type="range" id="range" class="slider" min="0" max="100" style="width: 150px;">
  163. <br>
  164. <button id="attackflood">Attack</button>
  165. </div>
  166. `;
  167.  
  168. let scriptAttackFloodRoom =
  169. `
  170. const rangeInput = document.getElementById('range');
  171. const rangeLabel = document.getElementById('range-label');
  172.  
  173. rangeInput.addEventListener('input', function() {
  174. rangeLabel.textContent = rangeInput.value;
  175. });
  176.  
  177. const rname = document.getElementById('room-name');
  178. const attackflood = document.getElementById('attackflood');
  179.  
  180. attackflood.addEventListener('click', function() {
  181. const rangeValue = parseInt(rangeInput.value, 10); // Converte o valor para número inteiro
  182. const modalMr = document.getElementById('MrMenu');
  183. modalMr.style.display = 'none';
  184.  
  185. const bonkMODAL = document.getElementById('roomlistcreatewindowcontainer');
  186.  
  187. bonkMODAL.style.visibility = "visible";
  188. bonkMODAL.style.opacity = "1";
  189.  
  190. for (let i = 0; i <= rangeValue; i++)
  191. {
  192. const bonk = document.getElementById('roomlistcreatewindowgamename');
  193. const bonkbutton = document.getElementById('roomlistcreatecreatebutton');
  194. bonk.value = rname.value + i;
  195. bonkbutton.click();
  196.  
  197. const bonkstart = document.getElementById('roomlistcreatewindowgamename');
  198. bonkstart.click();
  199. }
  200. });
  201. `;
  202.  
  203. let teamChangerHTML =
  204. `
  205. <div class="container">
  206. <div class="row">
  207. <button id="MrRed">Red</button>
  208. <button id="MrBlue">Blue</button>
  209. <button id="MrYellow">Yellow</button>
  210. <button id="MrGreen">Green</button>
  211. </div>
  212. <button id="buff">ClearLag</button>
  213. </div>
  214. `;
  215.  
  216. let teamChangerscript =
  217. `
  218. const MrRed = document.getElementById('MrRed');
  219. MrRed.addEventListener('click', function() {
  220. const red = document.getElementById('newbonklobby_redbutton');
  221. red.click();
  222. const modalMr = document.getElementById('MrMenu');
  223. modalMr.style.display = 'none';
  224. });
  225.  
  226. // Evento para o botão azul
  227. const MrBlue = document.getElementById('MrBlue');
  228. MrBlue.addEventListener('click', function() {
  229. const blue = document.getElementById('newbonklobby_bluebutton');
  230. blue.click();
  231. const modalMr = document.getElementById('MrMenu');
  232. modalMr.style.display = 'none';
  233. });
  234.  
  235. const MrGreen = document.getElementById('MrGreen');
  236. MrGreen.addEventListener('click', function() {
  237. const green = document.getElementById('newbonklobby_greenbutton');
  238. green.click();
  239. const modalMr = document.getElementById('MrMenu');
  240. modalMr.style.display = 'none';
  241. });
  242.  
  243. // Evento para o botão amarelo
  244. const MrYellow = document.getElementById('MrYellow');
  245. MrYellow.addEventListener('click', function() {
  246. const yellow = document.getElementById('newbonklobby_yellowbutton');
  247. yellow.click();
  248. const modalMr = document.getElementById('MrMenu');
  249. modalMr.style.display = 'none';
  250. });
  251.  
  252.  
  253. const buff = document.getElementById('buff');
  254. buff.addEventListener('click', function()
  255. {
  256. parent.MrClear();
  257. modalMr.style.display = 'none';
  258. });
  259.  
  260. `;
  261.  
  262. function MrClear()
  263. {
  264. const iframes = document.querySelectorAll('iframe');
  265. const iframeArray = Array.from(iframes);
  266. const iframesToKeep = iframeArray.filter(iframe => iframe.src.includes('gameframe-release.html'));
  267. iframeArray.forEach(iframe => {
  268. if (!iframesToKeep.includes(iframe)) {
  269. iframe.remove();
  270. }
  271. });
  272. alert(`MrClear Run Sucess`);
  273. }
  274.  
  275.  
  276. class MrMenu {
  277. constructor(title, author) {
  278. this.title = title;
  279. this.author = author;
  280. }
  281.  
  282. getIframe(iframeID)
  283. {
  284. const iframe = document.getElementById(iframeID);
  285. const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
  286.  
  287. if (!iframe) { console.error('[MrMenu] Iframe not found'); return null; }
  288. if (!iframeDoc) { console.error('[MrMenu] Iframe not found'); return null; }
  289. return iframeDoc;
  290. }
  291.  
  292. addCSS(mrDocument, css) {
  293. let cssMrMenu = mrDocument.createElement('style');
  294. cssMrMenu.innerHTML = css;
  295. mrDocument.head.appendChild(cssMrMenu);
  296. }
  297.  
  298. createElement(document, { type, attributes = {}, textContent = '' }) {
  299. const element = document.createElement(type);
  300.  
  301. // Define os atributos do elemento
  302. Object.keys(attributes).forEach(key => {
  303. element.setAttribute(key, attributes[key]);
  304. });
  305.  
  306. // Define o conteúdo textual do elemento
  307. element.textContent = textContent;
  308.  
  309. return element;
  310. }
  311.  
  312. toggleModal(document) {
  313. const modal = document.getElementById('MrMenu');
  314. if (modal) {
  315. if (modal.style.display === 'none' || modal.style.display === '') {
  316. modal.style.display = 'block'; // Mostra o modal
  317. } else {
  318. modal.style.display = 'none'; // Oculta o modal
  319. }
  320. }
  321. }
  322.  
  323. createTab(tabName, content, f)
  324. {
  325. const tab = document.createElement('div');
  326. tab.className = 'tab';
  327.  
  328. if (content) {
  329. tab.innerHTML = content;
  330. } else {
  331. tab.textContent = tabName;
  332. }
  333.  
  334. tab.addEventListener('click', () => this.showSection(tabName));
  335. if (f) {tab.addEventListener('click', f);}
  336. return tab;
  337. }
  338.  
  339. showSection(tabName)
  340. {
  341. const iframe = this.getIframe('maingameframe');
  342.  
  343. const sections = iframe.querySelectorAll('.section');
  344. sections.forEach(section => {
  345. section.style.display = section.id === tabName ? 'block' : 'none';
  346. });
  347. }
  348.  
  349. createSection(sectionName, content) {
  350. const iframe = this.getIframe('maingameframe');
  351.  
  352. const section = iframe.createElement('div');
  353. section.className = 'section';
  354. section.id = sectionName;
  355. section.style.display = 'none';
  356.  
  357. const contentElement = iframe.createElement('div');
  358. contentElement.innerHTML = content;
  359. section.appendChild(contentElement);
  360.  
  361. return section;
  362. }
  363.  
  364. }
  365.  
  366. function Init()
  367. {
  368. let mrMenu = new MrMenu('MrMenu v1.0.0', 'MrBonkeiro');
  369.  
  370. const iframe = mrMenu.getIframe('maingameframe');
  371. mrMenu.addCSS(iframe, CSS);
  372.  
  373. const modalElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'MrMenu', class: 'MrModal' }});
  374. iframe.getElementById('bonkiocontainer').appendChild(modalElement);
  375.  
  376. const tabContentElement = mrMenu.createElement(iframe, {type: 'div', attributes: { id: 'tabContent'}});
  377. iframe.getElementById('MrMenu').appendChild(tabContentElement);
  378.  
  379. const modalContentElement = mrMenu.createElement(iframe, {type: 'div', attributes: { id: 'modalContent'}});
  380. iframe.getElementById('MrMenu').appendChild(modalContentElement);
  381.  
  382. const titleElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'title'}, textContent: '' + mrMenu.title + ' by ' + mrMenu.author});
  383. iframe.getElementById('tabContent').appendChild(titleElement);
  384.  
  385. const tabsContainerElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'tabsContainer'}});
  386. iframe.getElementById('tabContent').appendChild(tabsContainerElement);
  387.  
  388. const closeModalElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'closeModal'}});
  389. iframe.getElementById('tabContent').appendChild(closeModalElement);
  390.  
  391. const closebtnElement = mrMenu.createElement(iframe, { type: 'button', attributes: { id: 'closeButton'}});
  392. iframe.getElementById('closeModal').appendChild(closebtnElement);
  393. closebtnElement.addEventListener('click', () => mrMenu.toggleModal(iframe));
  394.  
  395. function handleKeyPress(event)
  396. {
  397. if (event.key === 'Delete') {
  398. mrMenu.toggleModal(iframe);
  399. }
  400. }
  401. iframe.addEventListener('keydown', handleKeyPress);
  402.  
  403. const tabsElement = mrMenu.createElement(iframe, { type: 'div', attributes: { id: 'tabs'}});
  404. iframe.getElementById('tabsContainer').appendChild(tabsElement);
  405.  
  406. uptabs(mrMenu, 'Flood Room', null, tabAttackFloodRoom, scriptAttackFloodRoom);
  407. uptabs(mrMenu, 'Team Changer', null, teamChangerHTML, teamChangerscript);
  408.  
  409. }
  410.  
  411. function uptabs(mrMenu, title, fUpdate, sectionContent, scriptContent)
  412. {
  413. const xiframe = mrMenu.getIframe('maingameframe');
  414. let idx = title.replace(/\s+/g, ''); // Remove todos os espaços
  415.  
  416. const tabs = xiframe.getElementById('tabs');
  417. tabs.appendChild(mrMenu.createTab(idx, title, fUpdate));
  418.  
  419. const modalContentDiv = xiframe.getElementById('modalContent');
  420. modalContentDiv.appendChild(mrMenu.createSection(idx, sectionContent));
  421.  
  422. ///
  423. let scriptId = "tabScript";
  424. let existingScript = xiframe.getElementById(scriptId);
  425.  
  426. // Se o script existir, remova-o
  427. if (existingScript) {
  428. existingScript.remove();
  429. }
  430.  
  431. // Crie um novo script
  432. const xscript = xiframe.createElement('script');
  433. xscript.id = scriptId;
  434. xscript.type = 'text/javascript';
  435. xscript.textContent = scriptContent;
  436.  
  437. // Adicione o novo script ao body do iframe
  438. xiframe.body.appendChild(xscript);
  439.  
  440. }
  441.  
  442. function ScriptInjector(f) {
  443. if (window.location == window.parent.location) {
  444. if (document.readyState == 'complete') { setTimeout(f, 200); }
  445. else { document.addEventListener('readystatechange', function () { setTimeout(f, 1500);});
  446. }
  447. }
  448. }
  449.  
  450. ScriptInjector(Init);