Mahalo Follow Link Submission Via Safari
Note: If you don’t want to read all the geeky details, just skip down to the bottom paragraph with the link in order to use it.
Mahalo Follow has a toolbars for Firefox and IE but nothing yet for Safari. I decided to try and remedy that, al least for the function of submitting a link to Mahalo Follow. The toolbars do several other functions that I have not attempted to implement. Because I am lazy, I did not want to try and implement a full toolbar. I’m not even sure if that’s really possible with Safari/WebKit. It probably is, I just haven’t looked into it yet. But I wanted instant gratification. I figured I could create a bookmarklet fairly easily that would allow a link submission to Mahalo Follow. A bookmarklet is a regular bookmark that contains, instead of a normal URL, a snippet of javascript. Any javascript can be contained therein, but it must be all on one long line. No line-breaks. This makes it hard to read and edit and understand without expanding it back out to multiple lines, doing whatever you want with it, and squeezing it all back onto a single long line. Nevertheless, I had several hours to kill, so I began.
I delved into the javascript contained within the Mahalo Follow Firefox extension and figured out how to make the submission. Then I crafted the bookmarklet that would do it. It was actually very quick and easy to accomplish. Except that it didn’t work. It turns out that the javascript engine in Safari doesn’t support the btoa() method in the Window object (or any other object as far as I could tell). btoa() takes a string of binary data and returns a base64 encoded ASCII string. Both the title of the page and the URL to be submitted are base64 encoded. This is a nice way of avoiding odd characters in the URL or title being munged by the web server or anything else on its way into the code that actually decodes it and submits it. Since Safari didn’t implement this btoa() method, which is apparently non-standard but widely implemented by other javascript engines, I would have to implement or include someone else’s btoa() implementation in the bookmarklet. That’s going to be a heckuva long line of javascript in that bookmark. Luckily, again because I am lazy and I firmly believe in not reinventing the wheel, I found an implementation by Masanao Izumo that is freely available at Snippler. With this addition, the bookmarklet works… mostly.
The bookmarklet brings up the Mahalo Follow link submission page, and after filling it out, the “Recommend Link And Stay Here” button works perfectly. The button entitled, “Recommend Link And Go To Mahalo” submits the link, but it does not go to Mahalo… it stays on the page you submitted. I haven’t looked into why that is yet. Also, the Firefox tool pops the link submission page up in a new pop-up window that’s sized and centered nicely, with no address bar visible, etc. I don’t have any sizing specified in the bookmarklet because I have Safari, via Saft, forced into a mode where everything is opened up in a tab. Specifying sizes for the link submission page resizes my main Safari window because the page is opened as a tab in my window rather than a pop-up. So I have to add some javascript to detect how the window will be opened and specify a size if it will be a pop-up window and not specify a size if its going to be a tab. I hope its possible to detect this from within javascript before actually opening the window. I don’t yet know.
There may be other bits of Mahalo Follow link submission mechanics that I’m not implementing properly (or at all) because I really didn’t spend a whole lot of time studying their Firefox extension. But it *does* seem to submit the link, and nobody from Mahalo has yelled at me so far, and Jason Calacanis twittered about the existence of my bookmarklet. So I guess its not doing them any damage.
So here’s the bookmarklet. Just drag the link below into your Safari bookmark toolbar. Then whenever you’re on a page you’d like to submit just click on that bookmark. Up will pop the link submission page just as in Firefox.
This bookmarklet may even work with Firefox, but I have not tested that yet. I’ll do that tomorrow and update this page. Enjoy.
Update: The bookmarklet does not, in fact, work on Firefox… at least, not on the Mac. Oh well. Mahalo has a good toolbar extension for you folks on Firefox. Use that.
December 19th, 2007 at 1:57 pm
Thanks so much for this – I’ve needed a Safari bookmark (I’ve been using FireFox again, but I love having a choice!).
December 19th, 2007 at 5:45 pm
Thanks so much for doing this!!! Our devs are so bogged down they can’t even look up…. so, you saved us a lot of time!!!
December 19th, 2007 at 6:04 pm
Very interessant article.
When I read it, I remember that twitThis propose a similar bookmark module. I don’t know which script do they use, but it work fine on Safari.
Martin
December 19th, 2007 at 7:43 pm
Thanks for the kind words. I’m glad you’re all liking it. I still have to improve it a bit. Hopefully I can get around to that tomorrow or Friday, but its a busy next week or 10 days for me. Not work-wise… just fun-wise.