Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you're looking for something quick and dirty to filter jobs or get statistics, this is what I paste in browser console:

    function hideAllExcept(searchRegex) {
        var allComments = Array.from(document.querySelectorAll('.comment-tree .comtr'))
            .map(function(e){e.style.display='none';return e});
        var topLevelComments = allComments.filter(e=> e.querySelector('img[width="0"]'));
        var matchedComments = topLevelComments.filter(e=> 
            (e.style.display = searchRegex.test(e.querySelector('.comment').innerText) ? 'table-row' : 'none')=='table-row');
        console.log('Showing '+matchedComments.length+' out of '+topLevelComments.length+' jobs for '+searchRegex);
    }
    // Examples. The last one to execute determines what posts are shown.
    hideAllExcept(/\b(Rust)\b/i);
    hideAllExcept(/\b(Java)\b/i);
    hideAllExcept(/\b(Scala)\b/i);
    hideAllExcept(/\b(Kotlin)\b/i);
    hideAllExcept(/\b(Swift)\b/i);
    hideAllExcept(/\b(Ruby)\b/i);
    hideAllExcept(/\b(Python)\b/i);
    hideAllExcept(/\b(PHP|PHP5|PHP7)\b/i);
    hideAllExcept(/\b(JS|JavaScript)\b/i);
    hideAllExcept(/\b(React|ReactJS)\b/i);
    hideAllExcept(/\b(Angular|Angular5|Angular6)\b/i);
    hideAllExcept(/\b(Vue|VueJS)\b/i);
    hideAllExcept(/\b(Node|NodeJS)\b/i);
    hideAllExcept(/\b(Go|GO|Golang|golang|GOLANG)\b/);
    hideAllExcept(/C#/i);
    hideAllExcept(/\bC\b|C\+\+/i);
    hideAllExcept(/\bHaskell\b/i);
    hideAllExcept(/\bErlang\b/i);
    // Remember to also search other pages. Sorry if I missed some stacks in the examples.



Output for first page:

    Showing 8 out of 233 jobs for /\b(Rust)\b/i
    Showing 22 out of 233 jobs for /\b(Java)\b/i
    Showing 13 out of 233 jobs for /\b(Scala)\b/i
    Showing 5 out of 233 jobs for /\b(Kotlin)\b/i
    Showing 9 out of 233 jobs for /\b(Swift)\b/i
    Showing 33 out of 233 jobs for /\b(Ruby)\b/i
    Showing 75 out of 233 jobs for /\b(Python)\b/i
    Showing 7 out of 233 jobs for /\b(PHP|PHP5|PHP7)\b/i
    Showing 56 out of 233 jobs for /\b(JS|JavaScript)\b/i
    Showing 89 out of 233 jobs for /\b(React|ReactJS)\b/i
    Showing 11 out of 233 jobs for /\b(Angular|Angular5|Angular6)\b/i
    Showing 9 out of 233 jobs for /\b(Vue|VueJS)\b/i
    Showing 34 out of 233 jobs for /\b(Node|NodeJS)\b/i
    Showing 31 out of 233 jobs for /\b(Go|GO|Golang|golang|GOLANG)\b/
    Showing 5 out of 233 jobs for /C#/i
    Showing 34 out of 233 jobs for /\bC\b|C\+\+/i
    Showing 4 out of 233 jobs for /\bHaskell\b/i
    Showing 2 out of 233 jobs for /\bErlang\b/i
Suggestions for more regexes and improvements are welcome.


Nice one! I might say hideAllExcept(/(C#|\.NET)/i); although I'm sure that'll pull in a few false-positives...


How about sorting top to bottom?


Good idea. This prints jobs sorted:

    function hideAllExcept(searchRegex) {
        var allComments = Array.from(document.querySelectorAll('.comment-tree .comtr'))
            .map(function(e){e.style.display='none';return e});
        var topLevelComments = allComments.filter(e=> e.querySelector('img[width="0"]'));
        var matchedComments = topLevelComments.filter(e=> 
            (e.style.display = searchRegex.test(e.querySelector('.comment').innerText) ? 'table-row' : 'none')=='table-row');
        return 'Showing '+(matchedComments.length+'').padStart(3, ' ')+' out of '+topLevelComments.length+' jobs for '+searchRegex;
    }

    [
    /\b(Rust)\b/i,
    /\b(Java)\b/i,
    /\b(Scala)\b/i,
    /\b(Kotlin)\b/i,
    /\b(Swift)\b/i,
    /\b(Ruby)\b/i,
    /\b(Python)\b/i,
    /\b(PHP|PHP5|PHP7)\b/i,
    /\b(JS|JavaScript)\b/i,
    /\b(React|ReactJS)\b/i,
    /\b(Angular|Angular5|Angular6)\b/i,
    /\b(Vue|VueJS)\b/i,
    /\b(Node|NodeJS)\b/i,
    /\b(Go|GO|Golang|golang|GOLANG)\b/,
    /C#/i,
    /\bC\b|C\+\+/i,
    /\bHaskell\b/i,
    /\bErlang\b/i,
    ].map(hideAllExcept).sort().join('\n');


Thanks that's great I just put .reverse() after sort() to have it in descending order probably didn't say that in my original comment. Also if you're interested though I don't know how you'd apply it in this case, there is a chrome extension(cjs) where you can run javascript per page. Not sure how you'd apply it here though, maybe make a popup dialogue but mostly the url matching part as the urls don't exactly make sense eg. just numbers.

Anyway thanks pretty useful function


Ugly is in the eye of the beholder :) I think a lot of people don't realize what is so immediately available with a cut and paste. Though search works pretty well too ;)

inb4 "how do I make it work with webpack?"




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: