Change the background colour of article headers if they are popularity red or orange, or if the score is >100.
当前为
// ==UserScript==
// @name Inoreader Article Highlighter
// @version 20240524
// @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 => {
if (header.querySelector('.popularity_icon_red')) {
header.style.backgroundColor = '#F08080';
}
if (header.querySelector('.popularity_icon_orange')) {
header.style.backgroundColor = '#FFDAB9';
}
var scoreSpan = header.querySelector('.popularity_score_span');
if (scoreSpan) {
var scoreText = scoreSpan.innerText;
var score = parseScore(scoreText);
if (score > 100) {
header.style.backgroundColor = 'lightblue';
}
}
});
}
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
})();