|
|
|
Show HN: Bookmarklet to filter HN by regex-enabled keywords.
|
|
3 points
by CodeFoo
4757 days ago
|
|
This is a small bookmarklet that adds a background color to articles matching keywords, making it easier to distinguish links important to you. Tested in Chrome 27, Firefox 21 and Safari 6.0.5. Preview: http://i.imgur.com/6A3CU6T.png 1. Modify the OPTIONS.color and OPTIONS.keywords properties to your liking. You may use regex in the keywords. Keywords are case-insensitive. 2. Paste the bookmarklet below as the URL to a bookmark. You have to click this bookmark on every refresh, therefore you may want to place it on your "Bookmarks Bar" for quick access. javascript:(function(){var OPTIONS={keywords:["surveillance","nsa","prism","privacy","government"],color:"#f4c3c3"};NodeList.prototype.forEach=Array.prototype.forEach;document.querySelectorAll('.title>a').forEach(function(e){if(e.firstChild.nodeValue=='More')return;if(new RegExp(OPTIONS.keywords.join('|'), 'i').test(e.firstChild.nodeValue)){e.parentNode.parentNode.style.backgroundColor=OPTIONS.color;e.parentNode.parentNode.nextSibling.style.backgroundColor=OPTIONS.color}})})() |
|