Re-add RainbowPls emote

Re-adds RainbowPls as an emote

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Re-add RainbowPls emote
// @namespace    intercorpse.neoVeryPog
// @version      2025-01-20
// @description  Re-adds RainbowPls as an emote
// @author       intercorpse
// @match        https://www.destiny.gg/embed/chat*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_addStyle
// @license      MIT
// @downloadURL
// @updateURL
// ==/UserScript==
// With thanks to yuniDev, shamefully lifted and edited PEPE

(function() {
    'use strict';
    GM_addStyle(`.emote.VeryPog_OG { width:32px; height: 30px; background-image: url('https://wikicdn.destiny.gg/0/01/VeryPog.png') }`);
    GM_addStyle(`.msg-chat .emote.VeryPog_OG { margin-top: -30px; top: 7.5px; }`);
    GM_addStyle(`.emote.RainbowPls { width:32px; height: 32px; background-image: url('https://wikicdn.destiny.gg/f/f4/GRainbowPls.png') }`);
    GM_addStyle(`.msg-chat .emote.RainbowPls { margin-top: -30px; top: 7.5px; }`);

    function mutationCallback(mutationsList) {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                for (const addedNode of mutation.addedNodes) {
                    const textContainer = addedNode.querySelector(".text");
                    textContainer.innerHTML = textContainer.innerHTML.replace(/(^|\s|>)VeryPog_OG(?=\s|$|<)/g, '$1<div class="emote VeryPog_OG">VeryPog_OG</div>');
                    textContainer.innerHTML = textContainer.innerHTML.replace(/(^|\s|>)RainbowPls(?=\s|$|<)/g, '$1<div class="emote RainbowPls">RainbowPls</div>');
                }
            }
        }
    }

    const targetElement = document.getElementById("chat-win-main").querySelector(".chat-lines");

    if (targetElement) {
        const observer = new MutationObserver(mutationCallback);
        observer.observe(targetElement, { childList: true });
    }
})();