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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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');
}