Hacker News new | past | comments | ask | show | jobs | submit login

For anyone interested, I reproduced the bookmarklet in question:

    javascript:(function() {var num = null;var found = window.location.toString().match(/(\d+)(?!.*\d)/);if (found != null) {num = parseInt(found[0])+1};if (num != null) {window.location=(window.location.toString().replace(/(\d+)(?!.*\d)/,num))};})()
I'm not a Javascript person, so I'm not sure if there is a better way but it seems to work.



I think mine came from here many years ago: https://www.squarefree.com/bookmarklets/misc.html#increment

The "works in" browser icons gives some idea of the date on that. IE, Phoenix, Netscape 4, and Opera. Probably some of the oldest still-in-use javascript in the world :P

Ran it through prettier.io:

    javascript: (function() {
        var e, s;
        IB = 1;
        function isDigit(c) {
            return "0" <= c && c <= "9";
        }
        L = location.href;
        LL = L.length;
        for (e = LL - 1; e >= 0; --e)
            if (isDigit(L.charAt(e))) {
            for (s = e - 1; s >= 0; --s) if (!isDigit(L.charAt(s))) break;
            break;
            }
        ++s;
        if (e < 0) return;
        oldNum = L.substring(s, e + 1);
        newNum = "" + (parseInt(oldNum, 10) + IB);
        while (newNum.length < oldNum.length) newNum = "0" + newNum;
        location.href = L.substring(0, s) + newNum + L.slice(e + 1);
    })();




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: