// ==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.1a // @grant none // @downloadURL none // ==/UserScript== var boardList = ['Boy', 'SecretGarden', 'PieBridge']; function rmNodeWithClass(node, classKey) { // remove a node together with its ancestor node // whose class name contains classKey var myNode = node; while (node.className.indexOf(classKey)<0) { node = node.parentNode; } 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(boardList);