Greasy Fork

Greasy Fork is available in English.

User Highlighting

Highlight users in tickers.

当前为 2024-08-27 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         User Highlighting
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Highlight users in tickers.
// @author       Winston Smith
// @license      MIT
// @match        https://www.derstandard.at/jetzt/livebericht/*
// @icon         https://www.google.com/s2/favicons?domain=derstandard.at
// @grant        none
// ==/UserScript==

// Background color for highlighted users.
const COLOR = "lightblue";

(function() {
    'use strict';

    let isDelayed = false;

    // Executed on DOM changes and limit the update rate.
    function onDomChange() {
        if (!isDelayed) {
            highlightYourself();

            isDelayed = true;
            setTimeout(() => {
                isDelayed = false;
            }, 2500);

        }
    }

    const observer = new MutationObserver(onDomChange);
    const targetNode = document.body;
    const config = { childList: true, subtree: true };
    observer.observe(targetNode, config);

    function highlightYourself() {
        let legacyID = JSON.parse(localStorage.userdata).value.communityIdentityId;
        let xpath = `//a[contains(@href, '/legacy/${legacyID}') and contains(@class, 'upost-usercontainer')]/..`;
        let nodes = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

        for (let i = 0; i < nodes.snapshotLength; i++) {
            const element = nodes.snapshotItem(i);
            element.style.backgroundColor = COLOR;
        }
    }
})();