// ==UserScript== // @name 抽屉眼不见为净 // @require http://cdn.staticfile.org/jquery/3.3.1/jquery.slim.min.js // @require http://cdn.staticfile.org/arrive/2.4.1/arrive.min.js // @require http://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js // @resource jqueryModalCss http://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css // @resource pureCss http://cdn.staticfile.org/pure/1.0.0/pure-min.css // @version 1.0 // @description 可以按照发布者,标题和tag过滤热榜内容或评论 // @include https://dig.chouti.com/* // @exclude https://dig.chouti.com/link/* // @exclude https://dig.chouti.com/user/link/* // @icon https://dig.chouti.com/images/favicon-d38b877458.png // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_addStyle // @grant GM_getResourceText // @run-at document-start // @namespace https://greasyfork.org/users/96951 // @downloadURL none // ==/UserScript== // 载入两个简单的css GM_addStyle(GM_getResourceText('jqueryModalCss')); GM_addStyle(GM_getResourceText('pureCss')); // 主信息流过滤设置 let titleList = JSON.parse(GM_getValue('titleList', '[]')) || []; let authorList = JSON.parse(GM_getValue('authorList', '[]')) || []; let tagList = JSON.parse(GM_getValue('tagList', '[]')) || []; let commentAuthorList = JSON.parse(GM_getValue('commentAuthorList', '[]')) || []; function filterFeed(feedElement) { let feed = $(feedElement); let title = feed.find('.link-title').text(); if (titleList.some(ele => title.indexOf(ele) >= 0)) { feed.remove(); return; } let author = feed.find('.author-name').text(); if (authorList.indexOf(author) >= 0) { feed.remove(); return; } let tag = feed.find('.link-mark').find('span.left').text(); if (tag && tagList.indexOf(tag) >= 0) { feed.remove(); return; } } function filterComment(commentElement) { let comment = $(commentElement); let author = comment.find('.comment-author').text(); if (author && commentAuthorList.some(ele => ele === author)) { comment.remove(); return; } } // 过滤元素 function monitor(cssSelector, callback) { $(document).arrive(cssSelector, callback); $(cssSelector).each((index,element) => callback(element)); } // 开始过滤过滤代码 monitor('.link-item', filterFeed); monitor('.comment-li', filterComment); // 设置窗口 let settingDialog = $(`