Inoreader Article Highlighter

Change the background colour of article headers if they are popularity red or orange, or if the score is >100.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Inoreader Article Highlighter
// @version      20241028
// @description  Change the background colour of article headers if they are popularity red or orange, or if the score is >100.
// @author       jamesdeluk
// @match        https://www.inoreader.com/*
// @grant        none
// @namespace https://greasyfork.org/users/242246
// ==/UserScript==

(function() {
    'use strict';

    function changeHeaderBackground() {
    var articleHeaders = document.querySelectorAll('.article_header');
    articleHeaders.forEach(header => {
        var scoreSpan = header.querySelector('.popularity_score_span');
        if (scoreSpan) {
            var scoreText = scoreSpan.innerText;
            var score = parseScore(scoreText);
            if (score > 99) {
                header.style.backgroundColor = 'lightblue';
            }
        }
        if (header.querySelector('.text-orange')) {
            header.style.backgroundColor = '#FFDAB9';
        }
        if (header.querySelector('.text-error-color')) {
            header.style.backgroundColor = '#F08080';
        }
    });
    }

    function parseScore(scoreText) {
        var multiplier = 1;
        var score = parseFloat(scoreText);
        if (scoreText.toLowerCase().includes('k')) {
            multiplier = 1000;
        } else if (scoreText.toLowerCase().includes('m')) {
            multiplier = 1000000;
        }
        return score * multiplier;
    }

    window.addEventListener('load', changeHeaderBackground);

    setInterval(changeHeaderBackground, 5000); // Checks every 5 seconds for newly-loaded articles
})();