Torn Grats ekiM_ Button

Quick button to input "Grats ekiM_!" in chat

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Torn Grats ekiM_ Button
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Quick button to input "Grats ekiM_!" in chat
// @author       kek
// @match        https://www.torn.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const EMOJIS = ['🎉', '💕', '🎊', '✨', '🌟', '💖', '🔥', '👏', '🎈', '🏆', '💪', '⭐', '🌈', '💯', '🥳', '🎆', '💝', '🌺', '🎁', '🥇', '🍌'];

    function getRandomEmojis() {
        const shuffled = [...EMOJIS].sort(() => Math.random() - 0.5);
        return shuffled.slice(0, 2).join('');
    }

    function createGratsButton() {
        if (document.getElementById('gratsButton')) return;

        const button = document.createElement('button');
        button.id = 'gratsButton';
        button.textContent = `Grats ekiM_ ${getRandomEmojis()}`;
        button.style.cssText = `
            position: fixed;
            top: 10px;
            right: 10px;
            z-index: 99999;
            padding: 10px 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: bold;
            font-size: 14px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
            transition: all 0.3s ease;
        `;

        button.addEventListener('mouseenter', () => {
            button.style.transform = 'scale(1.1)';
            button.style.boxShadow = '0 6px 12px rgba(0, 0, 0, 0.4)';
        });

        button.addEventListener('mouseleave', () => {
            button.style.transform = 'scale(1)';
            button.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.3)';
        });

        button.addEventListener('click', sendGrats);
        document.body.appendChild(button);
    }

    function sendGrats() {
        const textarea = document.querySelector('textarea.textarea___V8HsV, textarea[placeholder*="Type your message"]');
        if (!textarea) return;

        textarea.value = `Grats ekiM_ ${getRandomEmojis()}`;
        textarea.dispatchEvent(new Event('input', { bubbles: true }));
        textarea.focus();

        const button = document.getElementById('gratsButton');
        if (button) {
            const originalText = button.textContent;
            button.textContent = '✅ Sent!';
            button.style.background = 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)';

            setTimeout(() => {
                button.textContent = originalText;
                button.style.background = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)';
            }, 1000);
        }
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', createGratsButton);
    } else {
        createGratsButton();
    }

    setTimeout(createGratsButton, 1000);
})();