您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Similar to rstyle in bonk commands! :)
当前为
- // ==UserScript==
- // @name Bonk.io RainbowStyle Enhanced
- // @namespace http://tampermonkey.net/
- // @version 6.8
- // @description Similar to rstyle in bonk commands! :)
- // @author hello_me101
- // @match *://bonk.io/* *://bonkisback.io/*
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- console.log("Enhanced RainbowStyle script loaded!");
- // Rainbow color generator
- function generateRainbowColor(hue) {
- return `hsl(${hue}, 100%, 50%)`;
- }
- // Apply rainbow effect to an element (name, level, or "level" label)
- function startRainbowEffect(targetElement) {
- let hue = 0;
- const interval = setInterval(() => {
- hue = (hue + 5) % 360; // Cycle through hues
- targetElement.style.color = generateRainbowColor(hue);
- }, 100); // Update every 100ms
- return interval;
- }
- // Broadcast the RainbowStyle command via DOM
- function broadcastRainbowStyle(playerName) {
- const signal = document.createElement('div');
- signal.className = 'rainbow-command';
- signal.dataset.playerName = playerName;
- signal.style.display = 'none'; // Hidden element
- document.body.appendChild(signal);
- setTimeout(() => signal.remove(), 100); // Remove signal after broadcasting
- }
- // Listen for RainbowStyle broadcasts
- function listenForRainbowCommands() {
- const observer = new MutationObserver((mutations) => {
- for (const mutation of mutations) {
- mutation.addedNodes.forEach((node) => {
- if (node.className === 'rainbow-command') {
- const playerName = node.dataset.playerName;
- applyRainbowToPlayer(playerName);
- }
- });
- }
- });
- observer.observe(document.body, { childList: true, subtree: true });
- }
- // Apply the rainbow effect to a player by their name
- function applyRainbowToPlayer(playerName) {
- const playerElements = findPlayerElementsByName(playerName);
- if (playerElements) {
- console.log(`Applying rainbow effect to ${playerName}`);
- // Apply to all relevant parts: name, level, and "level" label
- if (playerElements.name) startRainbowEffect(playerElements.name);
- if (playerElements.level) startRainbowEffect(playerElements.level);
- if (playerElements.levelLabel) startRainbowEffect(playerElements.levelLabel);
- } else {
- console.warn(`Player elements for ${playerName} not found!`);
- }
- }
- // Find the elements corresponding to a player's name, level, and "level" label
- function findPlayerElementsByName(playerName) {
- const playerList = document.querySelectorAll('.playerContainer'); // Adjust to Bonk.io structure
- for (const playerContainer of playerList) {
- const nameElement = playerContainer.querySelector('.playerName'); // Name element
- if (nameElement && nameElement.textContent.trim() === playerName) {
- // Assuming level and label are siblings of the name element; adjust selectors as needed
- const levelElement = playerContainer.querySelector('.playerLevel');
- const levelLabelElement = playerContainer.querySelector('.levelLabel');
- return {
- name: nameElement,
- level: levelElement,
- levelLabel: levelLabelElement
- };
- }
- }
- return null;
- }
- // Monitor chat for the !rainbowstyle command
- function monitorChat() {
- const chatBox = document.querySelector(".chatBox"); // Adjust selector
- if (!chatBox) {
- console.warn("Chat box not found!");
- return;
- }
- chatBox.addEventListener("keydown", (event) => {
- if (event.key === "Enter") {
- const chatInput = chatBox.value;
- if (chatInput.startsWith("!rainbowstyle")) {
- const playerName = getLocalPlayerName(); // Get your own name
- broadcastRainbowStyle(playerName);
- }
- chatBox.value = ""; // Clear input
- }
- });
- }
- // Get the local player's name
- function getLocalPlayerName() {
- const localPlayer = document.querySelector('.localPlayerName'); // Adjust selector
- return localPlayer ? localPlayer.textContent.trim() : "UnknownPlayer";
- }
- // Wait for game to load, then initialize
- function init() {
- const gameLoadedCheck = setInterval(() => {
- const chatBox = document.querySelector(".chatBox"); // Adjust selector
- if (chatBox) {
- clearInterval(gameLoadedCheck);
- listenForRainbowCommands();
- monitorChat();
- console.log("Enhanced RainbowStyle initialized!");
- }
- }, 1000); // Check every second
- }
- // Start the script
- init();
- })();