Mouse Click Buttons for sploop.io

Adds left and right mouse click buttons to the top left corner of the sploop.io webpage.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Mouse Click Buttons for sploop.io
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds left and right mouse click buttons to the top left corner of the sploop.io webpage.
// @author       hayden422
// @match        https://sploop.io/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Create a container div
    const container = document.createElement('div');
    container.style.position = 'fixed';
    container.style.top = '0';
    container.style.left = '0';
    container.style.padding = '10px';
    document.body.appendChild(container);

    // Create left mouse click button
    const leftClickButton = document.createElement('button');
    leftClickButton.textContent = 'LMB';
    leftClickButton.style.padding = '10px 25px';
    leftClickButton.style.backgroundColor = '#007bff';
    leftClickButton.style.color = '#fff';
    leftClickButton.style.border = 'none';
    leftClickButton.style.cursor = 'pointer';
    container.appendChild(leftClickButton);

    // Create right mouse click button
    const rightClickButton = document.createElement('button');
    rightClickButton.textContent = 'RMB';
    rightClickButton.style.padding = '10px 25px';
    rightClickButton.style.backgroundColor = '#dc3545';
    rightClickButton.style.color = '#fff';
    rightClickButton.style.border = 'none';
    rightClickButton.style.cursor = 'pointer';
    container.appendChild(rightClickButton);

    // Function to toggle button color
    function toggleButtonColor(button) {
        const originalColor = button.dataset.originalColor || '';
        const currentColor = button.style.backgroundColor || '';

        if (originalColor && currentColor) {
            button.style.backgroundColor = currentColor === originalColor ? '#f0f0f0' : originalColor;
        } else {
            button.dataset.originalColor = currentColor;
            button.style.backgroundColor = '#f0f0f0';
        }
    }

    // Add mousedown event listeners to toggle button colors
    document.addEventListener('mousedown', (event) => {
        if (event.button === 0) { // Left mouse button (LMB)
            toggleButtonColor(leftClickButton);
        } else if (event.button === 2) { // Right mouse button (RMB)
            toggleButtonColor(rightClickButton);
        }
    });

    // Add mouseup event listeners to reset button colors
    document.addEventListener('mouseup', () => {
        leftClickButton.style.backgroundColor = '#007bff';
        rightClickButton.style.backgroundColor = '#dc3545';
    });
})();