logoalt Hacker News

mgtoday at 10:23 AM0 repliesview on HN

I use the bookmarklet below.

It jumps to the newest story on the frontpage. And when I click the bookmarklet again (or press "n") it jumps to the next. So I just click it until I land on a story I have already seen and know I have seen them all.

If you want to use it, you can convert the code into a bookmarklet with my bookmarklet editor:

https://www.gibney.org/bookmarklet_editor

The bookmarklet:

    if (!location.href.match('ycom'))
        location.href='https://news.ycombinator.com';

    doTheMagic = function() {
        if (typeof e!=='undefined')
            e.style.background='#c0c0c0';
        e=Array.from(
            document.querySelectorAll(
                '.age a:not(.seen)')
        ).sort().at(-1);
        e.style.background='#ff0';
        e.classList.add('seen');
        e.scrollIntoView({
            behavior:"smooth",
            block:"center",
            inline:"nearest"
        });
    }

    function addShortcuts() {
        document.addEventListener("keydown", function(evnt) {
            if (evnt.key === "n") doTheMagic();
        });
    }

    function addStyle() {
       let style = document.createElement('style');
        style.type = 'text/css';
        style.textContent = `
            .noshow {
                display: initial;
            }
        `;
        document.head.appendChild(style);
    }

    if (typeof theMagicIsActive=='undefined') {
        addShortcuts();
        addStyle();
        theMagicIsActive = true;
    }

    doTheMagic();