Skip to content

Instantly share code, notes, and snippets.

@JasonGhent
Created December 11, 2014 15:46
Show Gist options
  • Save JasonGhent/8b04fffbacb006cb870b to your computer and use it in GitHub Desktop.
Save JasonGhent/8b04fffbacb006cb870b to your computer and use it in GitHub Desktop.
HN Who Is Hiring Filter
/* Removes all non-toplevel comments and toplevel comments older than 24H */
var rows = document.querySelectorAll('table:nth-child(1) tr:nth-child(3) table:nth-child(4) > tbody > tr');
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var margin = row.querySelectorAll('img')[0];
var width = margin ? margin.getAttribute('width') : '';
width = width ? parseInt(width,10) : '';
if (width === 0) {
var head = row.querySelector('.comhead');
head = head.innerText;
head = head.split('|');
head.pop();
head = head.join();
var first = head.split(' ')[0];
if (!/^\d+$/.test(first) || isNaN(parseInt(first,10))) {
head = head.split(' ');
head.splice(0,1);
head = head.join(' ');
}
var num = head.split(' ')[0];
var measure = head.split(' ')[1];
measure = measure.slice(-1)==='s' ? measure.substring(0, measure.length-1) : measure;
if (measure!=='day') {
console.log(num + ' ' + measure, row);
}
else { row.remove(); }
}
else { row.remove(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment