
Show HN: Chrome Extension to Filter HN Stories by Keyword - alistproducer2
https://github.com/ShamariFeaster/chrome-extension-hn-filter
======
alistproducer2
Dev Here:

I made this because I'm tired of seeing political flame-stories on here and I
hate flagging them or, even worse, going in the threads to complain about
them.

With this extension you can make a comma-separated list of words that when
matched within a headline, the link is removed from the page before you ever
see it.

You can check the console to see what stories are being removed. It's open
source so feel free to fork, customize, contribute or whatever.

It can be used to filter anything, so if you can't stand to see another
"JavaScript" or "Python" story, you can block those too.

~~~
detaro
Good idea, thanks for making it!

> _It 's open source so feel free to fork, customize, contribute or whatever._

Could you add a license to the repo then?

~~~
alistproducer2
added a GPL. thanks for reminding me.

------
kasbah
I thought about making something like this to filter out Apple stories
actually. I use Firefox, might try and load this as a web extension.

~~~
mp3geek
Loaded, but didnt show the icon in the bar.

~~~
detaro
it uses an API that doesn't exist in Firefox to only trigger on
news.ycombinator.com

~~~
alistproducer2
if you don't mind, could you add that as an issue to the repo. I already have
a contributor so maybe someone could pitch in and make it proper cross
platform.

------
nailer
Rad! You might be able to save a little time/logic by updating the JavaScript
from ES3. Instead of:

    
    
      if(thisText.indexOf(thisWord) > -1)
    

You can just do:

    
    
      if ( thisText.includes(thisWord) )
    

Likewise...

    
    
      for(let i = 0; i < entries.length; i++){
    

Can be replaced with:

    
    
      entries.forEach(function(entry, index){ 
    

Chrome supports both the relevant parts of ES6 and ES5 out of the box.

~~~
alistproducer2
thanks for the suggestions. I tend to avoid forEach because of the memory
overhead (adds function calls where not really necessary). I guess I'm old
school, but never got around to using includes. It's been on my radar for a
while. I've always tried to write code that is as portable as possible, even
though now, with evergreen browsers in the lead, it doesn't really matter as
much.

~~~
nailer
Yeah, .forEach() is a new scope. But the better readability is worth the minor
performance impact for everything but the most performance-intensive code.

~~~
drenvuk
It's that kind of thinking that gets us really slow software.

~~~
nailer
"premature optimization is the root of all evil" \- Don Knuth

Also old-style for loops in JS fall victim to the last entry effect since
people often use them to set up event handlers and wonder why they don't work.

------
cpeterso
I'd love to see an extension like this for Twitter.

~~~
keyle
And Facebook!

~~~
cpeterso
Or an extension that understands how to parse many different news sites and
can filter out stories on all of them. Add one keyword (pick your own example
;) and see _no_ headlines containing that keyword on any news site. It
wouldn't be that hard, though it would reinforce one's own news bubble.

~~~
alistproducer2
I actually thought about something similar last night. Have a project that had
a plugable DOM parser so people could build plug ins for various sites.

------
aryamaan
I would like to make an extension which sorts the stories based upon numbers
of comments. How do I start? I have been working as a backend developer and
completely agnostic about this stuff. TIA.

~~~
alistproducer2
If you check the code, contentScript.js:28 that line removes the meta data
line, which contains the number of comments. One could easily parse the
comment line and use it to rearrange the some, as opposed to deleting it. Fork
the code and give it a try!

------
elcapitan
Did it work for you? Filtering by title keywords only seems to be rather hard,
especially for political stuff, which often uses rather non-descriptive
headlines.

Example: "New CIA Chief to Gladly Spy on Americans, Even If Using Info Hacked
by Russians" looks like opinionism that I could pretty well live without, but
it doesn't contain any keywords I would blacklist.

For technical stuff it's probably a lot easier (just name the
language/framework/etc).

~~~
alistproducer2
Yeah, I ran into something similar. I had "president" on my list and it
blocked a story on the president of a company. It's kind of trial and error.
That's why I find it useful to see what stories are blocked so you can get a
sense for how well your filter is working.

------
Shad0w59
Great, now I can de-Trump my feed.

------
alistproducer2
Version < 0.4 have a bug that filters comments containing words on naughty
list. 0.4 has been pushed to webstore but it will take a minute to propagate.
If you want fixed version now, pull it from github.

Although filtering out comments could be a feature and not a bug, amiright?

