arrow-left arrow-right brightness-2 chevron-left chevron-right facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
Instapaper bookmarklet, updated to close the tab every time
1 min read

Instapaper bookmarklet, updated to close the tab every time

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've successfully subscribed to P O L Y M A T H.
Success! Your account is fully activated, you now have access to all content.