On a whim tonight, I whipped up my first Google Chrome extension in about 2 hours. A non-trivial amount of time was spent writing it up and making the icons. It’s obviously very simple, but it replicates one of my favorite features of Safari 3: SnapBack (the feature got eviscerated in Safari 4).
Basically all this extension does is add a button to the Chrome toolbar that you can click to jump back to the first page in a tab’s history. I realize the button and icons are ugly; I am not a design-type person.
As Chrome rolls out the Extensions Gallery, I’ll deploy the extension out there. It could probably use some better options, and some smarter heuristics for determining where the beginning is, but for my purposes it gives me the magic button I want.
You can install the BackSnapper extension from the .zip file more or less by following Step 4 in these instructions. Note that at present this only works for the dev channel (version 4) of Google Chrome.
- Download and unpack the .zip file
- Select Extensions from the Tools menu.
- Click “Developer Mode” on the right in the Extensions display.
- Click “Load unpacked extension…” and select the unpacked BackSnapper folder
There were a few things I learned getting this working that weren’t immediately obvious from the documentation:
- The debug console is per tab
- For simple calls into content scripts, chrome.tabs.sendRequest() is sufficient, you don’t need to use the more complicated connect() message passing calls.
There were also a few things I couldn’t figure out:
- Why won’t the current developers-only Extensions Gallery accept my unsigned zip file?
- Why can’t I determine the current URL in the history after having called history.go()? location.href remains unchanged, and history.current is undefined.