Inoreader Article Highlighter

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

  1. // ==UserScript==
  2. // @name Inoreader Article Highlighter
  3. // @version 20241028
  4. // @description Change the background colour of article headers if they are popularity red or orange, or if the score is >100.
  5. // @author jamesdeluk
  6. // @match https://www.inoreader.com/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/242246
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function changeHeaderBackground() {
  15. var articleHeaders = document.querySelectorAll('.article_header');
  16. articleHeaders.forEach(header => {
  17. var scoreSpan = header.querySelector('.popularity_score_span');
  18. if (scoreSpan) {
  19. var scoreText = scoreSpan.innerText;
  20. var score = parseScore(scoreText);
  21. if (score > 99) {
  22. header.style.backgroundColor = 'lightblue';
  23. }
  24. }
  25. if (header.querySelector('.text-orange')) {
  26. header.style.backgroundColor = '#FFDAB9';
  27. }
  28. if (header.querySelector('.text-error-color')) {
  29. header.style.backgroundColor = '#F08080';
  30. }
  31. });
  32. }
  33.  
  34. function parseScore(scoreText) {
  35. var multiplier = 1;
  36. var score = parseFloat(scoreText);
  37. if (scoreText.toLowerCase().includes('k')) {
  38. multiplier = 1000;
  39. } else if (scoreText.toLowerCase().includes('m')) {
  40. multiplier = 1000000;
  41. }
  42. return score * multiplier;
  43. }
  44.  
  45. window.addEventListener('load', changeHeaderBackground);
  46.  
  47. setInterval(changeHeaderBackground, 5000); // Checks every 5 seconds for newly-loaded articles
  48. })();