OWOT Purpleizer

Turns most OWOT messages starting with '<' purple.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         OWOT Purpleizer
// @namespace    greasyfork.org/en/users/1213777-logan-usw
// @version      1.0.0
// @description  Turns most OWOT messages starting with '<' purple.
// @author       logan.usw
// @match        https://ourworldoftext.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ourworldoftext.com
// @license      MIT
// @grant        none
// ==/UserScript==

(() => {

function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
// global variable for purple text
var $041db87cc4b43330$exports = {};
$041db87cc4b43330$exports = ".message__content--purple {\n  color: #825fdb;\n}\n";


window.chatPurpleText = true;
const $957b0f1b8a4ef7fc$var$purpleTextCSS = document.createElement("style");
$957b0f1b8a4ef7fc$var$purpleTextCSS.innerHTML = (0, (/*@__PURE__*/$parcel$interopDefault($041db87cc4b43330$exports)));
document.head.appendChild($957b0f1b8a4ef7fc$var$purpleTextCSS);
const $957b0f1b8a4ef7fc$var$chatWatcher = new MutationObserver($957b0f1b8a4ef7fc$var$analyzeMsgs) // mutation observer to scan new messages
;
// analyze new chat messages
function $957b0f1b8a4ef7fc$var$analyzeMsgs(mutations) {
    mutations.forEach((message)=>{
        const msgElem = message.addedNodes[0]?.lastChild, msgContent = msgElem.textContent.trim() // message without start & end spaces
        ;
        // starts with '<' = purple text except if it's possibly a html tag or haert
        if (window.chatPurpleText && msgContent.startsWith("<") && msgContent !== "<3" && !msgContent.includes('>')) msgElem.classList.add("message__content--purple");
    });
}
// start watching page & global
$957b0f1b8a4ef7fc$var$chatWatcher.observe(elm.page_chatfield, {
    attributes: false,
    childList: true,
    characterData: false,
    subtree: false
});
$957b0f1b8a4ef7fc$var$chatWatcher.observe(elm.global_chatfield, {
    attributes: false,
    childList: true,
    characterData: false,
    subtree: false
});

})();