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')

2 comments:

carolina said...
This comment has been removed by a blog administrator.
Bruce Fredman said...

Hi,
We at Chessboss.com strongly believe in necessity of chess to increase both knowledge and understanding. It is unfortunate that the oldest game in the world (Chess) has a very little fan base, ChessBoss.com aims to change that. We understand the importance of blogs and the information made available on them. We are working towards building a strong fan base around our FREE chess server to better increase the use of Chess online. Your blog seems to have a large viewing public and seems to hold great information which I would love to make available to my viewing public.

I have included the code for the ChessBoss.com banner within the body of this email along with textual link information. I would be pleased to offer you the ChessBoss.com featured blogger badge to post on your site, recognizeing your blog as a leading contributor to the Chess community. Thank you for your great work and dedication, we look forward to your response!Please reply me back with subject line of your Url to avoid spam and to make sure YOU get the Award.

Thank you.