Feedly Engagement based Color

color a Feedly list based on the engagement

Fra og med 27.11.2020. Se den nyeste version.

// ==UserScript==
// @name           Feedly Engagement based Color
// @namespace      https://openuserjs.org/users/burn
// @version        0.1.2
// @description    color a Feedly list based on the engagement
// @license        MIT
// @include        http://feedly.com/*
// @include        https://feedly.com/*
// @match          https://feedly.com/*
// @run-at         document-end
// @grant          GM_addStyle
// ==/UserScript==

// ==OpenUserJS==
// @author burn
// ==/OpenUserJS==

/* PLEASE READ HERE

This userscript was originally written by modalblue and published on userscripts.org:
https://userscripts-mirror.org/scripts/show/178751
I was using it years ago and recently I've decided to fork his code and continue maintaining it, just because I needed it working again.

*/

(function() {
    'use strict';

    var mo = null;
    var colors = {};
    var css = {
        entry:"div.entry"
        ,nbrRecommendations:"span.EntryEngagement"
    };
    function MakeColor(str) {
        if (str > 1000) str = 1000;
        return str / 1000;
    }
    function Colored() {
        var recommend = 0;
        var items = Array.prototype.slice.call(document.querySelectorAll(css.entry));
        if (items.length!=0) {
            items.forEach(function (item) {
                if (item.querySelector(css.nbrRecommendations)) {
                    recommend = item.querySelector(css.nbrRecommendations).textContent.replace(/[\s\+]/g, "").replace(/^([0-9]+)[A-Z]$/, "$1" + "000");
                    if (recommend > 0) {
                        item.setAttribute("colored", "engagement-color"+recommend);
                        if (colors[recommend] == undefined) {
                            colors[recommend] = MakeColor(recommend);
                            GM_addStyle(
                                "div[colored='" + "engagement-color"+recommend + "'] {background:rgba(0,204,0," + colors[recommend] + ") !important;}"
                                + "div[colored='" + "engagement-color"+recommend + "']:hover {background:rgba(0,204,0," + colors[recommend] + ") !important;}"
                            );
                        }
                    }
                }
            })
        }
    };
    mo = new MutationObserver(Colored);
    mo.observe(document.getElementById("box"), {childList:true, subtree : true});
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。