Spellsbee Animation

Add animation to keys-button hex on Spellsbee website when matching key is pressed.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Spellsbee Animation
// @namespace    http://tampermonkey.net/
// @version      0.1
// @icon         https://image.winudf.com/v2/image1/Y29tLnNtcGxlYS5zcGVsbGluZ2JlZV9pY29uXzE2NzIzMzQ0NDRfMDk3/icon.webp?w=280&fakeurl=1&type=.webp
// @description  Add animation to keys-button hex on Spellsbee website when matching key is pressed.
// @author       David
// @match        https://spellsbee.com/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Add your custom CSS animations
    GM_addStyle(`
        @keyframes pulse {
            0% { transform: scale(1); background-color: transparent; }
            50% { transform: scale(1.2); background-color: rgba(128, 128, 128, 0.5); }
            100% { transform: scale(1); background-color: transparent; }
        }

        @keyframes fastPulse {
            0% { transform: scale(1); filter: brightness(1); }
            50% { transform: scale(1.2); filter: brightness(1.5); }
            100% { transform: scale(1); filter: brightness(1); }
        }

        .pulse-animation {
            animation: pulse 0.5s;
        }

        .fast-pulse-animation {
            animation: fastPulse 0.5s;
        }
    `);

    // Add keydown event listener to the page
    document.addEventListener('keydown', function(event) {
        const keyPressed = event.key.toLowerCase();
        const hexButtons = document.querySelectorAll('.keys-button.hex, .keys-button.middle.hex');

        hexButtons.forEach(button => {
            const buttonText = button.textContent.trim().toLowerCase();

            if (keyPressed === buttonText) {
                if (button.classList.contains('middle')) {
                    button.classList.add('fast-pulse-animation');
                    setTimeout(() => {
                        button.classList.remove('fast-pulse-animation');
                    }, 200);
                } else {
                    button.classList.add('pulse-animation');
                    setTimeout(() => {
                        button.classList.remove('pulse-animation');
                    }, 200);
                }
            }
        });
    });
})();