您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
过滤页面中黑名单用户的主题和回复
当前为
// ==UserScript== // @name SCBOY论坛增强黑名单 // @namespace *://www.scboy.cc/ // @version 1.1 // @description 过滤页面中黑名单用户的主题和回复 // @author RustyHare // @match *://*.scboy.cc/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @license MIT // ==/UserScript== var mode = GM_getValue("mode"); var menu = "" var usr=GM_getValue("blusr"); var kwd=GM_getValue("blkwd"); function forumCleaning() { var threads = $("a.xs-thread-a"); for (var i = 0; i < threads.length; i++) { for (var j = 0; j < kwd.length; j++) { if (threads[i].innerText.indexOf(kwd[j]) != -1) { if (mode == "remove") { threads[i].parentElement.parentElement.parentElement.remove(); } else { threads[i].parentElement.parentElement.parentElement.style.backgroundColor = "yellow"; } } } } var sps = $("span.username.hidden-sm"); for (var i = 0; i < sps.length; i++) { if (usr.indexOf(sps[i].innerText) != -1) { if (mode == "remove") { sps[i].parentElement.parentElement.parentElement.parentElement.remove(); } else { sps[i].parentElement.parentElement.parentElement.parentElement.style.backgroundColor = "yellow"; } } } } function threadCleaning() { var ats = $("a.text-muted.font-weight-bold"); for (var i = 0; i < ats.length; i++) { if (usr.indexOf(ats[i].innerText) != -1 || kwd.indexOf(ats[i].innerText) != -1) { if (ats[i].parentElement.parentElement.parentElement.nodeName == "DD") { if (mode == "remove") { ats[i].parentElement.parentElement.parentElement.remove(); } else { ats[i].parentElement.parentElement.parentElement.style.backgroundColor = "yellow"; } } else if (ats[i].parentElement.parentElement.parentElement.parentElement.parentElement.nodeName == "LI") { if (mode == "remove") { ats[i].parentElement.parentElement.parentElement.parentElement.parentElement.remove(); } else { ats[i].parentElement.parentElement.parentElement.parentElement.parentElement.style .backgroundColor = "yellow"; } } } } } function main() { if (mode == "remove") { menu = "切换到高亮模式"; } else { menu = "切换到屏蔽模式"; } const oSwitchModeCMD = GM_registerMenuCommand(menu, function(e) { if (mode == "remove") { GM_setValue("mode", "highlight") } else { GM_setValue("mode", "remove") } window.location.reload() }, "a"); const oMenuCMD = GM_registerMenuCommand('管理屏蔽', function(e) { unsafeWindow.shusr=function(){ let blusr=GM_getValue("blusr"); if(typeof(blusr)=="undefined"){ blusr=[]; GM_setValue("blusr",blusr); } let tbody=document.getElementById("RHBlackListTBody"); tbody.innerHTML=` <tr> <th><input id="RHBlackListInput"></th> <th><button id="RHBlackListButtonAdd" class="btn" onclick="addusr()">添加</button></th> </tr> `; blusr.forEach(function(e){ let tr=document.createElement("TR"); let thn=document.createElement("TH"); thn.innerText=e; let thb=document.createElement("TH"); thb.innerHTML=`<button class="close" onclick="delusr(event)">×</button>`; tr.appendChild(thn); tr.appendChild(thb); tbody.appendChild(tr); }) document.getElementById("RHshusr").classList.remove("disabled"); document.getElementById("RHshkwd").classList.add("disabled"); } unsafeWindow.shkwd=function(){ let blkwd=GM_getValue("blkwd"); if(typeof(blkwd)=="undefined"){ blkwd=[]; GM_setValue("blkwd",blkwd); } let tbody=document.getElementById("RHBlackListTBody"); tbody.innerHTML=` <tr> <th><input id="RHBlackListInput"></th> <th><button id="RHBlackListButtonAdd" class="btn" onclick="addkwd()">添加</button></th> </tr> `; blkwd.forEach(function(e){ let tr=document.createElement("TR"); let thn=document.createElement("TH"); thn.innerText=e; let thb=document.createElement("TH"); thb.innerHTML=`<button class="close" onclick="delkwd(event)">×</button>`; tr.appendChild(thn); tr.appendChild(thb); tbody.appendChild(tr); }) document.getElementById("RHshusr").classList.add("disabled"); document.getElementById("RHshkwd").classList.remove("disabled"); } unsafeWindow.addusr=function(){ let rhinput=document.getElementById("RHBlackListInput"); let blusr=GM_getValue("blusr"); if(typeof(blusr)=="undefined"){ blusr=[]; GM_setValue("blkwd",blusr); } if(blusr.indexOf(rhinput.value)==-1 && rhinput.value.length>0){ blusr.push(rhinput.value.toString()) } GM_setValue("blusr",blusr) shusr(); } unsafeWindow.delusr=function(e){ let blusr=GM_getValue("blusr"); let i=blusr.indexOf(e.target.parentElement.parentElement.children[0].innerText) if(i>-1){ blusr.splice(i,1); GM_setValue("blusr",blusr); } shusr(); } unsafeWindow.addkwd=function(){ let rhinput=document.getElementById("RHBlackListInput"); let blkwd=GM_getValue("blkwd"); if(typeof(blkwd)=="undefined"){ blkwd=[]; GM_setValue("blkwd",blkwd); } if(blkwd.indexOf(rhinput.value)==-1 && rhinput.value.length>0){ blkwd.push(rhinput.value.toString()) } GM_setValue("blkwd",blkwd) shkwd(); } unsafeWindow.delkwd=function(e){ let blkwd=GM_getValue("blkwd"); let i=blkwd.indexOf(e.target.parentElement.parentElement.children[0].innerText) if(i>-1){ blkwd.splice(i,1); GM_setValue("blkwd",blkwd); } shkwd(); } var dModalFrame=document.createElement("DIV"); dModalFrame.className="modal fade" dModalFrame.style.display="none"; dModalFrame.id="RHBlackListModalFrame"; dModalFrame.innerHTML=` <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <span>编辑黑名单</span> <span>(直接关掉这个窗口就好awa改动是自动保存的)</span> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> </div> <div class="modal-body"> <div class="btn-group"> <button type="button" class="btn btn-default" id="RHshusr" onclick="shusr()">屏蔽用户名</button> <button type="button" class="btn btn-default" id="RHshkwd" onclick="shkwd()">屏蔽关键词</button> </div> <div id="RHBlackListTable" style="max-height:300px;overflow-y:scroll;"> <table class="table"> <thead> <tr> <th style="width:80%"></th> <th style="width:20%"></th> </tr> </thead> <tbody id="RHBlackListTBody"> </tbody> </table> </div> </div> </div> </div> ` document.body.appendChild(dModalFrame); shusr(); $("#RHBlackListModalFrame").modal() }, "c"); window.blackList = GM_getValue("blackList") if (window.location.href.search("forum") > -1) { forumCleaning() } else if (window.location.href.search("thread") > -1) { threadCleaning() } } if (window.addEventListener != null) { window.addEventListener("load", main, false); } else if (window.attachEvent != null) { window.attachEvent("onload", main); }