LztStreamerMode

Режим стримера для Lolzteam

当前为 2023-08-11 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         LztStreamerMode
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Режим стримера для Lolzteam
// @author       vuchaev2015
// @match        https://zelenka.guru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru
// @grant        none
// @run-at       document-start
// ==/UserScript==

document.addEventListener("DOMContentLoaded", () => {
    const selectors = [
        "#ConversationListItems",
        ".bbCodeHide",
        ".listPlaceholder",
        "#AlertPanels",
        "#AccountMenu > ul > li.Popup.PopupInPopup.DisableHover > a > span.left",
    ];

    const applyBlur = (selector) => {
        const elements = document.querySelectorAll(selector);

        elements.forEach((el) => {
            if (el.classList.contains("blurred")) return;

            if (selector === ".bbCodeHide") {
                const quote = el.querySelector("div.quote");
                const quoteContainer = el.querySelector(
                    "blockquote.quoteContainer.hideContainer"
                );
                const attribution = el.querySelector("aside > div.attribution.type");

                if (quote && quoteContainer && attribution) {
                    quote.style.filter = "blur(5px)";
                    el.classList.add("blurred");

                    quoteContainer.addEventListener("click", function (event) {
                        if (event.target === quoteContainer) {
                            quote.style.filter = quote.style.filter.includes("blur")
                                ? "none"
                            : "blur(5px)";
                        }
                    });

                    quote.addEventListener("click", function (event) {
                        if (event.target === quote) {
                            quote.style.filter = quote.style.filter.includes("blur")
                                ? "none"
                            : "blur(5px)";
                        }
                    });
                }
            } else {
                el.style.filter = "blur(5px)";
                el.classList.add("blurred");

                el.addEventListener("mouseover", function () {
                    el.style.filter = "none";
                });

                el.addEventListener("mouseout", function () {
                    el.style.filter = "blur(5px)";
                });
            }
        });
    };

    const applyBlurToAllSelectors = () =>
    selectors.forEach((selector) => applyBlur(selector));

    applyBlurToAllSelectors();

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                applyBlur('.bbCodeHide');
                applyBlur('[id^="imn-XenForoUniq"] span.message');
                applyBlur('.liveAlert.listItemText li[id^="alert"]');
            }
        });
    });

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