Greasy Fork

Greasy Fork is available in English.

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.8
// @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",
        "#AlertPanels",
        "#AccountMenu > ul > li.Popup.PopupInPopup.DisableHover > a > span.left",
    ];

    const applyBlur = (selector, trigger = 'hover', ignoredSelectors = []) => {
        const elements = document.querySelectorAll(selector);

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

            el.style.filter = "blur(5px)";
            el.classList.add("blurred");

            const isIgnoredSelector = (target) =>
            ignoredSelectors.some((ignoredSelector) =>
                                  target.matches(ignoredSelector)
                                 );

            if (trigger === 'click') {
                el.addEventListener("click", () => {
                    if (isIgnoredSelector(event.target)) return;
                    el.style.filter = el.style.filter.includes("blur")
                        ? "none"
                    : "blur(5px)";
                });
            } else {
                el.addEventListener("mouseover", () => {
                    if (isIgnoredSelector(event.target)) return;
                    el.style.filter = "none";
                });
                el.addEventListener("mouseout", () => {
                    if (isIgnoredSelector(event.target)) return;
                    el.style.filter = "blur(5px)";
                });
            }
        });
    };

    function applyBlurIfMatchesUrl(url, selector, trigger) {
        if (window.location.href.startsWith(url)) {
            applyBlur(selector, trigger);
        }
    }

    function changeInputType(selector) {
        var inputElements = document.querySelectorAll(selector);
        for (var i = 0; i < inputElements.length; i++) {
            inputElements[i].type = 'password';
        }
    }

    function applyBlurToBBCodeHide(selector, trigger) {
        const elements = document.querySelectorAll(selector);

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

            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");

                if (trigger === 'click') {
                    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 {
                    quoteContainer.addEventListener("mouseenter", () => { quote.style.filter = "none"; });
                    quoteContainer.addEventListener("mouseleave", () => { quote.style.filter = "blur(5px)"; });
                }
            }
        });
    }

    const applyBlurToAllSelectors = () =>
    selectors.forEach((selector) => {
        if (selector === ".bbCodeHide") {
            applyBlurToBBCodeHide(selector, "click");
        } else {
            applyBlur(selector);
        }
    });

    applyBlurToAllSelectors(); // блюрим элементы из указанных селекторов при загрузке страницы
    applyBlurIfMatchesUrl("https://zelenka.guru/account/security", "#ctrl_email", "click"); // блюрим почту
    applyBlurIfMatchesUrl("https://zelenka.guru/account/alerts", ".alertGroup ol", "hover"); // блюрим уведомления на странице /account/alerts

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                changeInputType('input[name="secret_answer"]'); // превращаем текст в пароль, секретные вопросы
                applyBlurToBBCodeHide('.bbCodeHide', "click"); // ищем новые элементы с хайдом
                applyBlur('[id^="imn-XenForoUniq"] span.message'); // блюрим live сообщения
                applyBlur('.liveAlert.listItemText li[id^="alert"]'); // блюрим live уведомления
                applyBlur('.scrollable.scrollable-vertical.lztng-lgi902', "click", [".chat2-tag.lztng-1hpx4rn", ".scrollable-y.lztng-lgi902"]); // блюрим сообщения в ламповом чатике
                applyBlur('#ConversationsMenu > div.scroll-wrapper.listPlaceholder.Scrollbar.scrollbar-macosx.scrollbar-dynamic'); // блюрим сообщения
            }

        });
    });

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