Emoji Party

Replaces keywords with emojis to add a fun twist to webpages.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Emoji Party
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Replaces keywords with emojis to add a fun twist to webpages.
// @match        http://*/*
// @match        https://*/*
// @grant        none
// @author       Kiwv
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const keywordMap = {
        'cat': '🐱',
        'dog': '🐶',
        'happy': '😄',
        'sad': '😢',
        'love': '❤️',
        'pizza': '🍕',
        'coffee': '☕',
        'thumbs up': '👍',
        'thumbs down': '👎',
        'rocket': '🚀',
        'sun': '☀️',
        'moon': '🌙',
        'star': '⭐',
        'rainbow': '🌈',
        'flower': '🌸',
        'tree': '🌳',
        'beach': '🏖️',
        'mountain': '⛰️',
        'book': '📚',
        'music': '🎵',
        'movie': '🎥',
        'camera': '📷',
        'guitar': '🎸',
        'game': '🎮',
        'soccer': '⚽',
        'basketball': '🏀',
        'baseball': '⚾',
        'tennis': '🎾',
        'globe': '🌍',
        'clock': '⏰',
        'money': '💰',
        'gift': '🎁',
        'fire': '🔥',
        'party': '🎉',
        'smile': '😊',
        'cry': '😭',
        'laugh': '😂',
        'wink': '😉',
        'kiss': '💋',
        'thumbs up': '👍',
        'thumbs down': '👎',
        'heart': '❤️',
        'bomb': '💣',
        'ghost': '👻',
        'robot': '🤖',
        'unicorn': '🦄',
        'rocket': '🚀',
        'crown': '👑',
        'cake': '🍰',
        'cookie': '🍪',
        'car': '🚗',
        'bicycle': '🚲',
        'train': '🚆',
        'ship': '🚢',
        'airplane': '✈️',
        'rocket': '🚀',
        'football': '🏈',
        'swimmer': '🏊',
        'runner': '🏃'
        // Add more keyword mappings here
    };

    const observer = new MutationObserver((mutationsList) => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList') {
                replaceKeywordsInNode(mutation.target);
            }
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });

    function replaceKeywordsInNode(node) {
        if (node.nodeType === Node.TEXT_NODE) {
            const content = node.textContent;
            let replacedContent = content;

            for (const keyword in keywordMap) {
                const emoji = keywordMap[keyword];
                const regex = new RegExp(keyword, 'gi');
                replacedContent = replacedContent.replace(regex, emoji);
            }

            if (replacedContent !== content) {
                const newNode = document.createTextNode(replacedContent);
                node.parentNode.replaceChild(newNode, node);
            }
        } else if (node.nodeType === Node.ELEMENT_NODE) {
            for (const childNode of node.childNodes) {
                replaceKeywordsInNode(childNode);
            }
        }
    }
})();