Skip to content

Instantly share code, notes, and snippets.

@ivmirx
Last active May 7, 2025 23:17
Show Gist options
  • Save ivmirx/66a0015884d44297ea05a8c54d93566d to your computer and use it in GitHub Desktop.
Save ivmirx/66a0015884d44297ea05a8c54d93566d to your computer and use it in GitHub Desktop.
Filter for hckrnews.com (Chromium and Firefox extension)
var words = [
'php', 'js', 'css', 'html', 'webgl', 'java', 'ruby', 'golang', 'kotlin', 'perl', 'zig', 'gcc', 'c++',
'elixir', 'elm ', 'erlang', 'clojure', 'lisp', 'racket', 'scala', 'haskell',
'mozilla', 'firefox', 'wordpress', 'kagi ', 'sql', 'mongo', 'latex',
'kubernetes', 'docker', 'tensor', 'graphql', ' ml ', 'machine learning',
'alphabet', 'facebook', 'amazon', 'aws ', 'dell', 'amd', 'verizon', 'airbnb', 'uber', 'tesla', 'spacex', 'self-driving', 'waymo',
'fundraising', 'investor', 'venture', 'unicorn',
'bitcoin', 'btc', 'ethereum', 'blockchain', 'cryptocurrenc', 'nft',
'gpl', 'drm', 'court', 'legal', 'tiktok',
'francisco', 'new york', 'california', 'bay area', 'texas', 'florida', 'wall street', 'el salvador', 'canad', 'austral',
'billionaire', 'musk', 'bezos', 'bill gates', 'zuckerberg', 'trump', 'rfk', 'j.d.', 'waltz', 'doge '
'politics', 'u.s.', 'white house', 'federal', 'president', 'congress', 'senate', 'scotus', 'court', 'police', 'military', 'fbi', 'cia ', 'nsa', 'immigration', 'democracy', 'election', 'mayor', 'liberal', 'republican', 'democrat',
'nato', 'russia', 'ukrain', 'china', 'chinese', 'norw', 'german', 'gaza', 'palestin', 'israel', 'idf', 'nazi', 'terrorist',
'guardian', 'vox', 'forbes', 'bbc', 'cnn', 'fox news', 'new york times', 'nyt', 'reuters'];
function filter(list) {
var entries = list.getElementsByClassName('entry row');
var filteredEntries = [];
for (var i = entries.length - 1; i >= 0; i--) {
var link = entries[i].getElementsByClassName('link span15 story')[0];
if (link == null)
continue;
var text = link.innerText.toLowerCase();
for (var j = words.length - 1; j >= 0; j--) {
if (text.indexOf(words[j]) != -1) {
logEntry(entries[i], link);
filteredEntries.push(entries[i]);
break;
}
}
}
for (var i = filteredEntries.length - 1; i >= 0; i--) {
filteredEntries[i].parentNode.removeChild(filteredEntries[i]);
}
}
function logEntry(entry, link) {
var points = entry.getElementsByClassName('points')[0].innerText;
if (points < 100) {
return;
}
var commentsCount = entry.getElementsByClassName('comments')[0].innerText;
console.log(commentsCount + '/' + points + ' ' + link.innerText);
var commentsLink = entry.getElementsByClassName('hn span3 story ')[0].href;
console.log(commentsLink);
}
var entryLists = document.getElementsByClassName('entries unstyled');
for (var i = entryLists.length - 1; i >= 0; i--) {
filter(entryLists[i]);
}
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(item) {
item.addedNodes.forEach(function(node) {
filter(node);
});
});
});
var div = document.querySelector('#entries');
observer.observe(div, { childList: true });
{
"manifest_version": 3,
"name": "hckrnews.com filter",
"version": "1.0",
"description": "Filter out submissions on hckrnews.com based on keywords",
"permissions": [
"tabs"
],
"host_permissions": [
"https://hckrnews.com/"
],
"content_scripts": [
{
"matches": ["https://hckrnews.com/"],
"js": ["filter.js"]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment