Greasy Fork is available in English.
blacklist the links from certain boards in the main page.
当前为
// ==UserScript==
// @name bdwmBlacklist
// @namespace bdwmBlacklist
// @description blacklist the links from certain boards in the main page.
// @include http://bdwm.net/bbs/main0.php
// @version 0.1b
// @grant none
// ==/UserScript==
function rmNodeWithClass(node, classKey) {
// remove a node together with its ancestor node
// whose class name contains classKey
var myNode = node;
while (node.className!=null && node.className.indexOf(classKey)<0) {
node = node.parentNode;
}
if (node.className==null) {
console.log('error finding class.');
return;
}
console.log('removing class: '+node.className);
node.parentNode.removeChild(node);
}
function blacklistBoard(boardlist) {
console.log('Going to block '+boardlist.length+' boards.');
var keyStr = boardlist.map(function(s){return 'board='+s;});
var links = document.getElementsByTagName('a');
console.log(links.length+' links detected.');
for (var i in links) {
console.log('Link: '+links[i].href);
for (var j in keyStr) {
if (links[i].href.indexOf(keyStr[j])>=0) {
console.log('To remove '+links[i].href);
rmNodeWithClass(links[i], 'Rank');
break;
}
}
}
}
blacklistBoard(['Boy', 'SecretGarden', 'PieBridge', 'Triangle', "Joke"]);