Inoreader Article Highlighter

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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
})();