Bonk.io Ultimate Enhanced Script

Adds rainbow styles, custom skins, and auto-join functionality to Bonk.io. Activated via commands.

  1. // ==UserScript==
  2. // @name Bonk.io Ultimate Enhanced Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 18.7
  5. // @description Adds rainbow styles, custom skins, and auto-join functionality to Bonk.io. Activated via commands.
  6. // @author YourActualName
  7. // @match https://bonk.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. // States for various features
  15. let isRainbowActive = false;
  16. let isAutoJoinActive = false;
  17. let customSkinColor = null;
  18.  
  19. let hue = 0; // For rainbow style
  20.  
  21. /**
  22. * Command listener
  23. * Listens for commands typed in the chat and executes the associated functionality.
  24. */
  25. function setupCommandListener() {
  26. const chatInput = document.querySelector('#chatinput');
  27. if (!chatInput) return;
  28.  
  29. chatInput.addEventListener('keydown', (e) => {
  30. if (e.key === 'Enter') {
  31. const command = chatInput.value.trim().toLowerCase();
  32. chatInput.value = ''; // Clear input after processing
  33.  
  34. switch (command) {
  35. case '/rainbowstyle':
  36. isRainbowActive = !isRainbowActive;
  37. console.log(`Rainbow Style: ${isRainbowActive ? 'Enabled' : 'Disabled'}`);
  38. break;
  39.  
  40. case '/autojoin':
  41. isAutoJoinActive = !isAutoJoinActive;
  42. console.log(`Auto-Join: ${isAutoJoinActive ? 'Enabled' : 'Disabled'}`);
  43. break;
  44.  
  45. case '/setskin':
  46. setCustomSkin();
  47. break;
  48.  
  49. default:
  50. console.log(`Unknown command: ${command}`);
  51. }
  52. }
  53. });
  54. }
  55.  
  56. /**
  57. * Rainbow effect for rectangle
  58. * Continuously updates the rectangle color and applies opposite colors to level and name.
  59. */
  60. function applyRainbowEffect() {
  61. function updateRainbow() {
  62. if (!isRainbowActive) return;
  63.  
  64. hue = (hue + 5) % 360; // Increment hue for a smooth rainbow effect
  65. const rectangleColor = `hsl(${hue}, 100%, 50%)`;
  66. const oppositeColor = `hsl(${(hue + 180) % 360}, 100%, 50%)`;
  67.  
  68. try {
  69. // Update rectangle colors
  70. if (window.bonkHost && window.bonkHost.p) {
  71. window.bonkHost.p.color = rectangleColor;
  72. window.bonkHost.p.outline = rectangleColor;
  73. }
  74.  
  75. // Update name and level colors
  76. const playerName = document.querySelector('.playerName');
  77. const levelText = document.querySelector('.levelText');
  78. if (playerName) playerName.style.color = oppositeColor;
  79. if (levelText) levelText.style.color = oppositeColor;
  80.  
  81. } catch (e) {
  82. console.error('Error applying rainbow effect:', e);
  83. }
  84.  
  85. requestAnimationFrame(updateRainbow);
  86. }
  87.  
  88. updateRainbow();
  89. }
  90.  
  91. /**
  92. * Auto-join games
  93. * Automatically joins available games when the feature is enabled.
  94. */
  95. function autoJoinGames() {
  96. function checkJoinButton() {
  97. if (!isAutoJoinActive) return;
  98.  
  99. try {
  100. const joinButton = document.querySelector('.joinGameButton');
  101. if (joinButton && joinButton.disabled === false) {
  102. joinButton.click();
  103. console.log('Auto-Joined a game!');
  104. }
  105. } catch (e) {
  106. console.error('Error with Auto-Join:', e);
  107. }
  108.  
  109. setTimeout(checkJoinButton, 1000);
  110. }
  111.  
  112. checkJoinButton();
  113. }
  114.  
  115. /**
  116. * Set custom skin color
  117. * Prompts the user to enter a hex code for their rectangle color.
  118. */
  119. function setCustomSkin() {
  120. const inputColor = prompt('Enter a hex color for your skin (e.g., #ff0000):');
  121. if (inputColor && /^#([0-9A-F]{3}|[0-9A-F]{6})$/i.test(inputColor)) {
  122. customSkinColor = inputColor;
  123. applyCustomSkin();
  124. } else {
  125. alert('Invalid hex color! Please try again.');
  126. }
  127. }
  128.  
  129. /**
  130. * Apply custom skin color
  131. * Applies the custom skin color to the game elements.
  132. */
  133. function applyCustomSkin() {
  134. if (window.bonkHost && window.bonkHost.p) {
  135. window.bonkHost.p.color = customSkinColor;
  136. window.bonkHost.p.outline = customSkinColor;
  137. console.log(`Custom skin set to: ${customSkinColor}`);
  138. } else {
  139. // If game elements are not yet available, wait and try again
  140. setTimeout(applyCustomSkin, 100);
  141. }
  142. }
  143.  
  144. /**
  145. * Initialize the script
  146. * Waits for Bonk.io to load before activating features.
  147. */
  148. const waitForGame = setInterval(() => {
  149. if (typeof window.bonkHost !== 'undefined' && window.bonkHost.p !== undefined) {
  150. clearInterval(waitForGame); // Stop checking once the game is ready
  151. setupCommandListener(); // Set up commands
  152. applyRainbowEffect(); // Apply rainbow effects if toggled
  153. autoJoinGames(); // Auto-join games if toggled
  154. }
  155. }, 100);
  156. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址