Next Number Bookmarklet

Many times, you'll want to browse to a bunch of pages in order: e.g., www.mysite.com/article01.html, article02.html, article03.html ...

It's kind of a pain to keep selecting the number, replacing it with the next number, remembering to pad with leading zeroes, etc. So here's a BookMarklet that does all that:

 javascript:x=location.href;c="";n="";i=x.length-1;while(i>=0&&"0123456789".indexOf(x.charAt(i))==-1){c=x.charAt(i)+c;--i;}x=x.substr(0,i+1);while(i>=0&&"0123456789".indexOf(x.charAt(i))!=-1){n=x.charAt(i)+n;--i;}x=x.substr(0,i+1);w=n.length;n=""+(parseInt(n,10)+1);while(n.length<w)n="0"+n;location.href=(x+(n)+c);

It can deal with trailing numbers (e.g. www.mysite.com/directories/001), as well as any extension or suffix (e.g. www.mysite.com/thing1.php, www.mysite.com/thing01/index.php).


EditText of this page (last edited November 1, 2011) or FindPage with title or text search