Highlight Joined Subs differently in search results on New Reddit

Using New Reddit Search is handy, but doesn't show already joined subs as any differently to non-joined subs, which I want to more easily distinguish, hence this script.

目前为 2024-03-02 提交的版本。查看 最新版本

// ==UserScript==
// @name         Highlight Joined Subs differently in search results on New Reddit
// @namespace    http://tampermonkey.net/
// @version      2024-03-03
// @description  Using New Reddit Search is handy, but doesn't show already joined subs as any differently to non-joined subs, which I want to more easily distinguish, hence this script.
// @author       You
// @match        https://new.reddit.com/search/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant        none
// ==/UserScript==

var entryCount = 0;

function applyHighlighting() {
    var entries = document.querySelectorAll('div[data-testid*="communities-list"]>div>div');
    if(entryCount != entries.length){
        entryCount = entries.length;

        for(var entry of entries) {
            if(entry.querySelector('button').innerText == "Joined") {
                entry.style.backgroundColor="maroon";
            }
        }
    }
}

(function() {
    'use strict';

    setInterval(applyHighlighting,1000);
})();