Greasy Fork is available in English.
Filtering comment by userID on Alphapolis Hameln Kakuyomu Narou novel's comments page
当前为
// ==UserScript==
// @name Novel Comments Filter
// @name:ja 小説コメントフィルター
// @namespace http://greasyfork.icu/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
// ==/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 = '<div class="uct">' + no[i].innerHTML + '</div>';
bTn = document.createElement("div");
bTn.classList = "cbt";
no[i].firstChild.before(bTn);
bTn.innerHTML = '<button class="bbtn" type="button">' + userId + '</button>';
}
no[i].querySelector(".bbtn").style.color = B ? "fuchsia" : "dodgerblue";
no[i].querySelector(".uct").style.visibility = B ? "hidden" : "visible";
}
}
document.addEventListener("click", H);
function H(e) {
//console.log(e.target);
if(e.target.className === "bbtn") {
const tid = e.target.textContent;
const li = tbl.findIndex((v) => v === tid);
if (li !== -1) {
tbl.splice(li,1);
} else {
tbl.push(tid);
}
R();
S();
}
}
})();