// ==UserScript== // @name NarouRankingFilter // @namespace drownia.narourankingfilter // @version 0.1 // @description なろうのランキングにフィルター機能を追加 // @author Drownia // @match https://yomou.syosetu.com/rank/list/type/* // @match https://yomou.syosetu.com/rank/isekailist/type/* // @match https://yomou.syosetu.com/rank/genrelist/type/* // @require https://openuserjs.org/src/libs/sizzle/GM_config.js // @grant GM_getValue // @grant GM_setValue // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js // @require https://www.gitcdn.xyz/cdn/polygonplanet/encoding.js/152b576cb234c24c4cdf4b54fa051da843a8b593/encoding.js // @downloadURL none // ==/UserScript== GM_config.init({ 'id': 'NarouRankingFilter', 'title': '小説家になろう ランキングフィルター', 'fields': { 'whitelist_em': { 'label': 'ホワイトリスト(完全一致)', 'type': 'textarea', 'default': '' }, 'blacklist_em': { 'label': 'ブラックリスト(完全一致)', 'type': 'textarea', 'default': '' }, 'whitelist_pm': { 'label': 'ホワイトリスト(部分一致)', 'type': 'textarea', 'default': '' }, 'blacklist_pm': { 'label': 'ブラックリスト(部分一致)', 'type': 'textarea', 'default': '' } }, 'events': { 'save': function(forgotten) { location.reload(); } } }); $(function() { $('#header').append('
  • ⚙️ランキングのフィルター設定を開く
  • ') jQuery(document).on('click', '#open_config', function(){ GM_config.open(); }); var white_tag_em = GM_config.get('whitelist_em').replace('\n', '|'); var black_tag_em = GM_config.get('blacklist_em').replace('\n', '|'); var white_tag_pm = GM_config.get('whitelist_pm').replace('\n', '|'); var black_tag_pm = GM_config.get('blacklist_pm').replace('\n', '|'); if (black_tag_em == '') {black_tag_em = 'DUMMYTAG'} if (black_tag_pm == '') {black_tag_pm = 'DUMMYTAG'} var reg_white_em = new RegExp('(?<=)'); var reg_black_em = new RegExp('(?<=)'); var reg_white_pm = new RegExp('(?<=)'); var reg_black_pm = new RegExp('(?<=)'); var rank = $('div.rank_h').map(function(i, obj) { return [[obj, $('table.rank_table')[i]]]; }); var filtered_rank = rank.filter(function(i) { return (reg_white_em.test(Encoding.convert($($('tr:nth-child(4)')[i]).prop('outerHTML'), 'UNICODE', 'AUTO')) && !reg_black_em.test(Encoding.convert($($('tr:nth-child(4)')[i]).prop('outerHTML'), 'UNICODE', 'AUTO')) && reg_white_pm.test(Encoding.convert($($('tr:nth-child(4)')[i]).prop('outerHTML'), 'UNICODE', 'AUTO')) && !reg_black_pm.test(Encoding.convert($($('tr:nth-child(4)')[i]).prop('outerHTML'), 'UNICODE', 'AUTO'))); }).map( function(i, obj) { return [[obj[0], obj[1]]]; } ); var url_reg = /\/rank\/list\/type\/.*/; var modify_num = 1; if (url_reg.test(location.pathname)) { modify_num = 2 } for (var i = 0; i <= 100; i++) { $('.ranking_list:nth-child(' + (i+modify_num) + ')').html($(filtered_rank[i])); } })