Created
March 14, 2012 15:10
-
-
Save tyoro/2037119 to your computer and use it in GitHub Desktop.
LDR Ad-Entry Blocker for Chrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
location.href= "javascript:function $x(x,c){c=c||document;var res=document.evaluate(x,c,null,4,null);for(var i,nodes=[];i=res.iterateNext();nodes.push(i));return nodes;}; var cfg = { patterns: [/^[\s【]*(AD|PR|AD|PR)[\s】]*[::]/i],style: {color: '#aaa', fontSize: '12px' }, interval: 1000, skip: true}; LDR.register_hook('AFTER_PRINTFEED', function() { var hist = []; var isComp = function(){ var len = hist.length; if(len < 3) return false; return hist[len-1] == hist[len-2] && hist[len-2] == hist[len-3]; }; var blocker = function(){ var titles = $x('//h2[@class=\"item_title\"]/a'); hist.push(titles.length); for(var i = 0; i < titles.length; i++){ var title = titles[i]; for(var j = 0; j < cfg.patterns.length; j++){ if((new RegExp(cfg.patterns[j])).test(title.innerHTML)){ setStyle(title, cfg.style); addClass(title.parentNode, 'laeb_blocked'); var childs = title.parentNode.parentNode.parentNode.childNodes; for(var k = 0; k < childs.length; k++){ if(childs[k].nodeType !== 1 || hasClass(childs[k], 'item_header')) continue; DOM.hide(childs[k]); } break; }; }; }; isComp() || setTimeout(blocker, cfg.interval); }; setTimeout(blocker, cfg.interval); }); if(cfg.skip){ var isEnd = function(dir){ var pos = get_active_item(); return dir ? pos == get_active_feed().items.length - 1 : pos == 0 }; var j_func = Keybind._keyfunc['j']; Keybind.add('j|enter', function(){ do{ j_func(); }while(!isEnd(true) && hasClass(get_active_item(true).element, 'laeb_blocked')); }); var k_func = Keybind._keyfunc['k']; Keybind.add('k|shift+enter', function(){ do{ k_func(); }while(!isEnd(false) && hasClass(get_active_item(true).element, 'laeb_blocked')); }); };"; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment