Friday, November 23, 2007

Wikipedia Gears Cache Script

The concept:
Combine Google Gears, Greasemonkey, and Wikipedia to make something very cool. It adds a box to the side of every Wikipedia page with a link to cache it, so you can then revisit it when you're not connected to the internet.

Google Gears:
Google Gears is a toolbox Google made to let you access websites offline. The first use I know of was the Google RSS reader, where you download all the news, then read it offline and sync back up the next time you're connected.

Greasemonkey:
This is a firefox plugin which lets you install scripts to change how web pages look. You can install one script that censors words, or changes the color of some outline of a website, or inserts extra useful links into websites (which is what this script does)


So all of this together comes together into the dream of every wikipedia junky like myself. Unfortunately there is one problem with the script. It lists every page you have cached, which is no good. I want to be caching like a fiend, without putting a huge ugly box on the side of every en.wikipedia.com page I visit. Thus, I edited it.

I think it's very impressive work, since I've never done anything with javascript before, and I did all of this sitting in a motel room near Fresno with no internet or reference material. There is still one problem:
  • The [ Cache Page ] and [ Show Cache ] links render next to each other. This problem isn't there when it's [ Page Cached ] and [ Show Cache ]
So to get started:
Get Firefox
Install Greasemonkey
Install Google Gears
Install WikipediaOffline script
Read the original project page
Apply my patch. There is a program to do it in unix, but most people will need to do it manually. If you're really interested, just email me and I'll send it to you.

My patch:
(edit: looks like blogger mangles all the whitespace, sorry guys. Just ask me to email it to you.)

[Code patch deleted by Kenneth]
I'm not going to claim any copyright on this since it's just moving stuff around. If you do want to repost it or use it in any way, just let me know in a comment, and link back here if appropriate.

Mad props to Ben Lisbakken for a great script to start with.

No comments:

Post a Comment