// ==UserScript== // @name User Highlighting // @namespace http://tampermonkey.net/ // @version 0.2 // @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 // @downloadURL none // ==/UserScript== // Text and background colors for highlighted users. // Use null for default. const BACKGROUND_COLOR = "lightblue"; const TEXT_COLOR = null; (function() { 'use strict'; // Executed on DOM changes and limit the update rate. function onDomChange() { highlightYourself(); } 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 = BACKGROUND_COLOR; element.style.color = TEXT_COLOR; } } })();