World Line

Archive for April 2010

Twanslate!

with 10 comments

Last night I wrote another quick-and-dirty Firefox extension; or rather, I wrote a quick-and-dirty Greasemonkey script based on Jack Hsu’s script which I then used Rochak Chauhan‘s User Script Compiler on to generate a skeleton extension to flesh out. Isn’t involuntary collaboration awesome? 🙂

The script is very simple; it adds a stylish globe icon underneath the “Star” in each tweet on the Twitter timeline. Clicking it makes an API call to Google Translate and adds an overlay containing the translation to English, from whatever language it happens to be in.

Unfortunately, my extension can't make Google Translate suck any less...

I’ve found it very useful, and not just for understanding certain Japanese AV stars. Hopefully someone else shares my passion for Sora — I mean, international culture — and can give it enough feedback on the official add-on site to be able to nominate it for public release. If Send to EidoGo managed to be selected, despite being thoroughly niche, I’m sure Twanslate has nothing to worry about 🙂

Of course, as the product of an evening’s worth of work, it’s not perfect yet. In the interest of full disclosure, here are the outstanding issues.

  • You may have heard that Greasemonkey-based scripts work automagically in Google Chrome. This has some truth to it, but like most things, it’s not that simple. Chrome’s security model is stricter than Greasemonkey’s, so things like hijacking the unsafeWindow.onPageChange() call don’t automatically work. I think I can tweak it to make it work, if it turns out anyone wants it.
  • New tweets that come in with the “X new tweets” notification at the top do not get the translate button, even though they do when you click the “More tweets…” button at the bottom. This is a Twitter weirdness — for some reason their Javascript does call the window.onPageChange() when it’s done adding tweets to the bottom of the timeline, but does not call it when adding tweets to the top, even though the change to the DOM is indistinguishable. Thus it’s much harder to hijack that page event. I’ll figure it out one day. For now, just refresh the page to get it.
  • The output language is not configurable, it’s always English for now. Will be fixed in a subsequent release.

That’s about it. I hope somebody else finds this useful.

Advertisements

Written by Adrian Petrescu

April 20, 2010 at 9:49 pm

Posted in Development

Tagged with

%d bloggers like this: