From c7b25854a4b39c23004bae675cc557c62d0d9d86 Mon Sep 17 00:00:00 2001 From: shinemoon Date: Fri, 24 Nov 2023 11:17:22 +0800 Subject: [PATCH] fix for issue 183 --- xExtension-ColorfulList/static/script.js | 36 ++++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/xExtension-ColorfulList/static/script.js b/xExtension-ColorfulList/static/script.js index 0363fcf..199d3df 100644 --- a/xExtension-ColorfulList/static/script.js +++ b/xExtension-ColorfulList/static/script.js @@ -1,23 +1,29 @@ + + document.addEventListener('DOMContentLoaded', function(){ - function monitorEntry(monitorCallback) { - const targetNode = document.getElementById('stream'); - const config = { attributes: false, childList: true, subtree: false}; - const callback = function(mutationsList, observer) { - for(let mutation of mutationsList) { - if (mutation.type === 'childList') { - monitorCallback(mutationsList); - } - } - }; - const observer = new MutationObserver(callback); - observer.observe(targetNode, config); - //observer.disconnect(); - }; + //Initial Colorize for situation where 'no new item changes triggered later' (https://github.com/FreshRSS/Extensions/issues/183) + colorize(); + + //Insert entry monitor monitorEntry(colorize); }); +function monitorEntry(monitorCallback) { + const targetNode = document.getElementById('stream'); + const config = { attributes: false, childList: true, subtree: false}; + const callback = function(mutationsList, observer) { + for(let mutation of mutationsList) { + if (mutation.type === 'childList') { + monitorCallback(mutationsList); + } + } + }; + const observer = new MutationObserver(callback); + observer.observe(targetNode, config); + //observer.disconnect(); +}; -function colorize(entries){ +function colorize(){ let entry = document.querySelectorAll('.flux_header'); entry.forEach((e,i)=>{ let cl = stringToColour(e.querySelector('.website').textContent)+'12';