NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name GoogleNewsFilter // @include *news.google.com/* // @description Top News isn't what I care about, you can add your own filters to the whitelist, ex. 'Entertainment' or 'Technology' // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js // @grant GM_addStyle // @license MIT // ==/UserScript== $(document).ready(runcode); $('main').css('visibility','hidden'); function runcode(){ setTimeout(delayedstart,0); } itermax=10; iter=0; function delayedstart(){ iter++; if(iter>=itermax) return; whitelist = ['Science']; search2 = $("main div h2"); search2.addClass('filterh2'); console.log(search2); search2.each(function(){ p = $(this).parent().parent(); p.addClass('filterh2start'); console.log(p); }); console.log(search2); $("main div div").each(function(){ if($(this).hasClass('filterh2start')){ s = $(this).find('h2').html(); wl = false; for(i in whitelist){ name = whitelist[i]; if(s.indexOf(name) !== -1){ wl=true; } } } if(!wl){ $(this).hide(); } }); $('main').css('visibility','visible'); setTimeout(delayedstart,100); }