Bonk.io Color Change Command

Adds a shared rainbow effect to the name, level, and the word 'level' in Bonk.io, visible to other users with this script.

当前为 2024-12-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Bonk.io Color Change Command
// @namespace   http://tampermonkey.net/
// @version     15.7.8
// @match       *://bonk.io/*
// @grant       GM_addStyle
// @description Adds a shared rainbow effect to the name, level, and the word 'level' in Bonk.io, visible to other users with this script.
// ==/UserScript==

// Listen for chat input to change colors
document.addEventListener('keydown', function (e) {
  if (e.key === 'Enter') {  // Check if the Enter key is pressed (for chat)
    setTimeout(() => {  // Wait for chat message to be input
      let chatInput = document.querySelector('input[type="text"]');
      if (!chatInput) return;

      let message = chatInput.value.trim();
      if (message.startsWith('/color')) {
        let args = message.split(' ');  // Split command and arguments
        let colorCommand = args[1];

        if (colorCommand) {
          // Apply the color or rainbow effect based on the command
          if (colorCommand === 'rainbow') {
            applyRainbowEffect();
          } else {
            applyColor(colorCommand);
          }
        }
      }
    }, 100);
  }
});

// Function to apply a single color to the player name and level
function applyColor(color) {
  GM_addStyle(`
    #player-name, #player-level, .level-text {
      color: ${color} !important;
    }
  `);
  console.log(`Changed name and level color to ${color}`);
}

// Function to apply a rainbow effect to the player name and level
function applyRainbowEffect() {
  GM_addStyle(`
    #player-name, #player-level, .level-text {
      color: red;
      animation: rainbow 3s infinite;
    }

    @keyframes rainbow {
      0% { color: red; }
      14% { color: orange; }
      28% { color: yellow; }
      42% { color: green; }
      57% { color: blue; }
      71% { color: indigo; }
      85% { color: violet; }
      100% { color: red; }
    }
  `);
  console.log('Applied rainbow effect to name and level');
}