## Thursday, February 28, 2008

### Zeit Sudoku Bookmarklet

As you know, I am a Sudoku addict. For a nice ten minute break I often download the daily sudoku from Die Zeit. Until recently, from this bookmarked page, I had to change the level from "leicht" to "schwer" and then press the button for the PDF version to print out.

But now, they introduced even another page before that (where you have to choose between the Flash version and the puzzle from the printed (only weekly) newspaper or the oldstyle version that allows the download. You could no longer bookmark the next page as there the URL already contained some sort of session ID.

Of course, they want me to go through all these pages to make sure I do not miss any of the ads they want to present me. But I think that this new version requires a few mouse clicks too much and so I decided to have a look at the page's source code.

It turns out that the URL for the PDF no longer contains a session ID but instead contains today's date, slightly more than you can do with a static bookmark. But that got me thinking that one might be able to solve this problem with a bookmarklet, a bookmark that makes use of the fact you can have JavaScript in a URL and in a bookmark.

Last time I looked into JavaScript was roughly ten years ago and at that time it seemed like a very stupid idea to have some crippled language where you have to transmit all of the source code to the browser which then slowly interprets it if you can do much much more powerful things on the server side with CGI scripts.

Since then, a lot of time has passed and I have heard many interesting things (let me mention only AJAX) suggesting I should maybe reconsider my old dismissal of JavaScript. I had a look though a number of reference sheets and here it is: My first own JavaScript sniplet: A sudoku download bookmarklet. Clicking on this link (or bookmarking it and retrieving the bookmark) brings you directly to the PDF version on the latest "schweres" sudoku! Here is the source:

javascript:var d=new Date();  var m=d.getMonth()+1;  if(m<10){m="0"+m};  var t=d.getDate();  if(t<10){t="0"+t}; open('http://sudoku.zeit.de/sudoku/kunden/die_zeit/pdf/sudoku_' +        d.getFullYear()+'-'+m+'-'+t+'_schwer.pdf')