はてブ一覧ページで各コメントへのブクマ数を表示するやつ(HatebuCommentCounter)

はてブ一覧ページで、各コメントのブクマ数(+はてブページのリンク)を表示して、大元のコメント自体を少しだけ赤く背景色を付けます。

// ==UserScript==
// @name      はてブ一覧ページで各コメントへのブクマ数を表示するやつ(HatebuCommentCounter)
// @name:en         HatebuCommentCounter
// @description はてブ一覧ページで、各コメントのブクマ数(+はてブページのリンク)を表示して、大元のコメント自体を少しだけ赤く背景色を付けます。
// @description:en  A tool/script that displays the number of bookmarks for each comment on the Hatena Bookmark list page.
// @namespace    HatebuCommentCounter
// @version      2025-06-21.3
// @author       iHok
// @match        https://b.hatena.ne.jp/entry/s/*/*
// @icon         https://b.hatena.ne.jp/favicon.ico
// @grant        GM_xmlhttpRequest
// @connect      bookmark.hatenaapis.com
// @license      MIT
// ==/UserScript==

//(function() {
setInterval(() => {
    'use strict';
    for (let i = 0,HatebuComments=document.querySelectorAll(".entry-comment-permalink [href^='/entry/'][href*='/comment/']:not(.commentCountChecked)"); i < HatebuComments.length / 50; i++) {
        GM_xmlhttpRequest({
            method: "GET",
            url: "https://bookmark.hatenaapis.com/count/entries?url=" + Array.from(HatebuComments).slice(i * 50, i * 50 + 50).join('&url='),
            headers: {
                "Content-Type": "application/json"
            },
            onload: function(response) {
                for (let item in JSON.parse(response.responseText)) {
                    if (JSON.parse(response.responseText)[item]) {
                        document.querySelector(".entry-comment-permalink [href^='" + item.replace(location.origin, "") + "']:not(.commentCountChecked)").closest("[data-user-name]").style.background = "#FF000011"
                        document.querySelector(".entry-comment-permalink [href^='" + item.replace(location.origin, "") + "']:not(.commentCountChecked)").insertAdjacentHTML('afterend', " <a style=\"color: red;\" href=\"//b.hatena.ne.jp/entry/" + item?.replace("https://", "s/") + "\" target=\"_blank\" class=\"commentCountChecked\">" + JSON.parse(response.responseText)[item] + "users(B!)</span>")
                        document.querySelector(".entry-comment-permalink [href^='" + item.replace(location.origin, "") + "']:not(.commentCountChecked)").classList.add("commentCountChecked");
                    } else{
                        document.querySelector(".entry-comment-permalink [href^='" + item.replace(location.origin, "") + "']:not(.commentCountChecked)").classList.add("commentCountChecked");
                    }
                }
            }
        });
    }
},1000)//新着ページの追加読み込み対策のため、1秒単位でチェックするようにしています。もっと早くしたい場合は、左記の1000を調整してください。
//})();
//もしページ表示時のみでよい場合は、最初の『(function(urls) {』とこの上の行のコメントアウトを削除+前後1行をコメントアウトしてください。