// ==UserScript== // @name 小説ランキングフィルター // @namespace https://greasyfork.org/en/users/1264733 // @version 2024-02-23 // @description なろう・カクヨムのランキングフィルタ // @author LE37 // @license MIT // @match https://yomou.syosetu.com/rank/* // @match https://kakuyomu.jp/rankings/* // @match https://kakuyomu.jp/*recent_works // @exclude https://yomou.syosetu.com/rank/top/ // @downloadURL none // ==/UserScript== (function() { 'use strict'; let a_re, a_lst, n_nc, n_ic, t_nc; // 表示設定: 0 滲み 1 隠す const s_type = 0; switch (location.host) { case "yomou.syosetu.com": a_re = /\d+/; // なろう作家IDリスト(完全一致) a_lst = [ // caviar https://mypage.syosetu.com/1/ "1", // バセンジー https://mypage.syosetu.com/4649/ "4649" ]; n_nc = "p-ranklist-item"; n_ic = "p-ranklist-item__synopsis"; t_nc = "p-ranklist-item__keyword"; break; case "kakuyomu.jp": a_re = /users\/(.*)$/; // カクヨム作家IDリスト(完全一致) a_lst = [ // test1 https://kakuyomu.jp/users/test1 "test1", // novel https://kakuyomu.jp/users/novel "novel" ]; n_nc = "widget-work"; n_ic = "widget-workCard-introduction"; t_nc = "widget-workCard-tags"; break; } // なろう・カクヨム小説タグリスト(部分一致) const t_lst = [ // https://yomou.syosetu.com/search.php?word=BL "BL", // https://kakuyomu.jp/tags/人外 "人外" ]; const no = document.getElementsByClassName(n_nc); let i = no.length; while (i--) { let dislike = false; const aid = no[i].getElementsByTagName("a")[1].href.match(a_re); if (a_lst.some(v => aid.includes(v))) { dislike = true; } else { const k_ele = no[i].getElementsByClassName(t_nc)[0]; if (k_ele !== undefined) { const kwd = k_ele.getElementsByTagName("a"); let k = kwd.length; while (k--) { const kdt = kwd[k].text; if (t_lst.some(v => kdt.includes(v))) { dislike = true; break; } } } } const ss = no[i].getElementsByClassName(n_ic)[0]; if (dislike === true) { switch (s_type) { case 0: no[i].style.filter = "opacity(50%)"; if (ss !== undefined) { ss.style.display = "none"; } break; case 1: no[i].style.display = "none"; break; } } else { //no[i].style.backgroundColor = "#0099FF"; if (ss !== undefined) { ss.style.maxHeight = "120px"; ss.style.overflow = "hidden"; } } } })();