25 June 2007

Hacking the Apple Weather Widget


I use a Mac. I use Dashboard. As a biker I use the weather widget every morning to prepare myself for weather conditions I will encounter on my ride to work. If rain is in the forecast I will check the radar page to see if the precipitation is eminent. This involves three clicks with associated wait time for the web page to load (1. Click on weather widget to open accuweather.com, 2. Click on "Radar," 3. Click on Large, animated radar). It also bothers me that the default page the widget is linked to displays all of the same info listed in the widget. Most mornings I am running late and would like to speed up this process.



I want a one click solution from widget to radar.

Since widgets are just html and javascript I figured that somewhere there is a link to a accuweather.com page. After poking around in the weather widget I found the link and changed it. After a quick logout-login I have one click access to my preferred radar web page.


How to:

1. In the Finder select Go to Folder... from the Go menu.
2. Type "/name of your OS X volume/System/Library/WidgetResources/.parsers/" and hit return.
3. Drag the file "weatherParser.js" to the desktop and create a duplicate of it named "weatherParserOrig.js. This is important because if you mangle something in the script you will need a backup.
4. Open the "weatherParser.js" file on the desktop in TextEdit.
4. Scroll all the way down to the bottom to find the text:
"return 'http://apple.accuweather.com/adcbin/apple/Apple_weather.asp?location=' + location;"
This is the bit that needs to be changed.
5. Change that bit to:
"return 'http://www.accuweather.com/radar-large.asp?partner=apple&traveler=0&zipChg=1&site=Enter State Here_&type=SIR&anim=1&level=state&large=1'"
Where noted enter the two letter abbreviation for the state you are in (NY, IL, OR, etc.)
6. Save this file.
7. Drag the "weatherParser.js" file from the desktop back to the .parsers folder. A window will pop up, click on authenticate and enter you password. You will also have to click on "replace" when prompted.
8. Now log out/log in and confirm that clicking on the weather widget brings you directly to the radar page.

Note: I am not a programmer and used the trial and error method to hack the widget. To change which state radar is displayed you will need to manually make the change to the weatherParser.js file. I tried to use a variable to get the state abbreviation to be automatically placed in the correct spot but could only find a variable which returned the zipcode. If you are an expert programmer and have a more elegant solution to this please post in the comments.

1 comment:

Da' Square Wheelman, said...

this is way toooooo kool! Thanks and have a great trip to Cali %)

Free Hit Counter
Free Hit Counter