Instapaper bookmarklet, updated to close the tab every time

June 07, 2009

A few months ago I modified the bookmarklet provided by Instapaper so that it would automatically close the tab I was "instapapering," thereby obviating an extra step that I otherwise would have to take 100% of the time.

While I didn't mention it in the earlier post, I knew that some sites would just ignore the window.close() method. I'm aware that some browsers generally won't allow JavaScript to close a tab/window if that tab/window wasn't itself opened via JavaScript, but that didn't seem to explain why some sites — whose URIs were typed in manually — would let me close them with JavaScript and others wouldn't.

After tiring of trying to determine why this was the case, I decided to route around the issue entirely by "re-opening" the to-be-instapapered site via JavaScript, and then calling the window.close() method. With that order of events, the tab gets closed every time, and to the user the re-load is completely transparent: click the bookmarklet and the tab closes immediately, followed by the closing of the status pop-up.

The same caveats remain for this version of the bookmarklet as for the last: 1) I've tested it only with Safari 4/Mac and 2) you still will need to modify it to add your unique user key (as explained in the previous post).

To get/use the bookmarklet, drag this link to your bookmarks bar.

You should follow me on Twitter here