An Even Better Bookmarklet

March 8th, 2007

I’ve recently seen two bug reports about the behavior of the MarsEdit “Bookmarklet,” the little link that you can stick in your browser’s toolbar to easily “reblog” stuff that you find on the web. The gist of the problem is that special characters end up getting junked in transition so that they show up as useless parts of escape codes in MarsEdit. That’s no fun for anybody.

Following a lead from Takaaki, who reported one of the issues, I found what appears to be a sane workaround. The bookmarklet needs to use “encodeURIComponent” instead of “escape” to sanitize the input strings for the “magic URL” that sends the page to MarsEdit. (Read more about the various escaping mechanisms and when to use them).

The best part about these bugs is I can release a fix without updating MarsEdit itself. The behavior of MarsEdit seems to be perfect when the bookmarklet is altered to use the proper escaping function. So if you’ve run into this problem, please give the new bookmarklet a try:

Post with MarsEdit (drag link to bookmark bar)

And be sure to let me know if there are other issues which should be addressed in the bookmarklet for the next MarsEdit release.

6 Responses to “An Even Better Bookmarklet”

  1. Will Koffel Says:

    I’ve written a number of bookmarklets, and often another level of indirection is helpful too. The bookmarklet pulls down a JS snippet from the product site, and executes it. If you did that, no one would have to change to encodeURIComponent, as you could just make the change globally, and everyone would inherit the fix the next time they clicked on it.

    (Of course, then you have to keep the JS snippet location alive, which is not a problem except in an instance like the purchase of MarsEdit by RS!)

    This technique is also very useful for stats tracking on bookmarklet usage, etc. if you are into that kind of thing (most people in the commercial ad-supported web world are ; most indie-mac-devs are likely not)

  2. Daniel Jalkut Says:

    Interesting idea, Will. I’m satisified for the moment I think to “keep it simple,” but that is a technique to keep in mind.

    (See you at CocoaHeads tonight!)

  3. Takaaki Kato Says:

    I can release a fix without updating MarsEdit itself.

    You could do this even without releasing an update if you make a “Install bookmarklets” page on the web. Your users still have to wait for a new version.

    Most developers put the bookmarklets in the application bundle.

    Also, I wonder how you notitify this to users. Existing users have no way to notice this unless they read release notes.

    Anyways, thanks for fixing the issue. ^_^

  4. Michael J. Says:

    How do I use the &weblog=BlogName feature? I have two blogs, and want to have two bookmarklets – one for each blog. Thanks!

  5. Daniel Jalkut Says:

    Hi Michael – I’m hoping to enhance the “Install Bookmarklet” page inside MarsEdit to make this easier, but for the time being you have to edit the source for the bookmarklet (by editing the “address” in your browser).

    This is probably best explained by example … but pasting the whole example is ugly. You want to add the parameter to the source of the javascript, near the very end of the “address.” You’ll see that the bookmark currently ends in:


    And you want to sneak your “weblog” parameter in just before that, so that the end looks like this:


    Substitute whatever blog name you like from your list of Weblogs in MarsEdit.

    I know this is still kind of complex but hopefully it helps you figure it out!


  6. Michael J. Says:

    Works like a charm – thanks for the quick feedback!

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.