// ==UserScript== // @name Novel Comments Filter // @name:ja 小説コメントフィルター // @namespace https://greasyfork.org/en/users/1264733 // @version 2024-05-05 // @description Filtering comment by userID on Alphapolis Hameln Kakuyomu Narou novel's comments page // @description:ja アルファポリス・ハーメルン・カクヨム・なろう 小説のコメントページで特定ユーザによる感想を非表示にする // @author LE37 // @license MIT // @include https://kakuyomu.jp/works/*/comments* // @include https://kakuyomu.jp/works/*/episodes/* // @include https://novelcom.syosetu.com/impression/* // @include https://syosetu.org/?mode=review* // @include https://www.alphapolis.co.jp/novel/*/comment* // @grant GM_setValue // @grant GM_getValue // @downloadURL none // ==/UserScript== (()=>{ 'use strict'; let sK, cN, uId; // Mobile const M = navigator.userAgent.includes("Mobile"); switch (location.host) { case "kakuyomu.jp": sK = "NCF_K"; if (!location.pathname.includes("comments")) { cN = "ul.widget-cheerCommentList li"; } else { cN = M ? 'div[class^="NewBox_box__"]>ul>li' : 'ul:nth-child(1) li'; } uId = /users\/(.*)$/; break; case "novelcom.syosetu.com": sK = "NCF_N"; cN = M ? "div.impression" : "div.waku"; uId = /\/(\d+)/; break; case "syosetu.org": sK = "NCF_H"; cN = M ? "div.search_box" : "div.section3"; uId = /((?<=uid=).*|(\d+)(?=\/))/; break; case "www.alphapolis.co.jp": sK = "NCF_A"; cN = "div.comment"; uId = /detail\/(\d+)$/; break; } // Read List const G = GM_getValue(sK); const tbl = G ? G.BL : []; // Save List function S() { const O = { BL:tbl }; GM_setValue(sK, O); } // Kakuyomu Comment if (sK === "NCF_K") { let oN; if (cN === "ul.widget-cheerCommentList li") { oN = "#episodeFooter-cheerComments-panel-mainContents"; } else { oN = "#__next"; } const obs = new MutationObserver(() => { obs.disconnect(); R(); }); obs.observe(document.querySelector(oN), { childList: true, subtree: true }); } else { R(); } function R() { const no = document.querySelectorAll(cN); for (let i = 0; i < no.length; i++) { const uL = no[i].querySelector("a").href.match(uId); // Narou Nologin User const userId = uL ? uL[1] : no[i].querySelector("div.comment_authorbox>div").textContent.split("\n")[2]; //console.log(userId); const B = tbl.some((v) => userId === v); let bTn = no[i].querySelector(".cbt"); if (!bTn) { no[i].innerHTML = '