The License Shit in TwitterFox 1.8+
Last weekend TwitterF0x was upgraded to version 1.8.x . As they have not yet integrate translate functions, or take/endorse my code, I plan to redo the hacking again.
Guess what ? A new license file added since veriosn 1.8.0 make TwitterF0x Proprietary. Thus I am not legally accepted to do any tenhancement nor investigate at the software.
That shits! NaanStudi0 used to place LGPL inside the scripts of TwitterF0x 1.7.x or earlier, what have changed their mind ?
As far as I know, TwitterF0x was not for profit. Are the NaanStudi0 guys going to inject AdM0d into the Firefox plugin, like what they do last month in TwitterF0n for the i-Phone ?
I would say that last month TwitterF0n was degraded into crap. Not because of having Ads, I am not that mean, but because of broken layout. Naan Studio has released two updates after the crap version, non of them addressed the layout problem. Do they care about users ?
Another possibility is they hate Fanfox, they don’t want to be cloned by the Chinese copycat any more. I can understand if this is their real cause, yet not a good / appreciable one.
So, if I have to continue the hack, I have two choice:
1. Fork from twitterf0x 1.7.x
2. Hack Fanfox and contribute to fanfox instead
Any idea ? Please throw to twitter.com/bencrox
( P.S. According to the new SLA, twitterF0x , twitterF0n and NaanStudi0 are their 0wn trademarks. Yeah! I am not affiliated with these traders. Would be happy to misspell all TM shit. )
Mash TwitterFox with Google Translate
If you don’t care about the story, here is the file, eat your own dog food to install. ( some screen shots here
)
—-
After attending Barcamp Bangkok #3 , I have added some new twitter friends all over South East Asia.
In order to read their tweet, which may be in Thai, Vietnamese or whatsoever language I don’t know or that I am not quite familiar with ( such as Japanese … ) , I use the build-in translation function in Tweetdeck / Nambu in MacOS.
Problem arise when I switch to a PC, in which I am used to tweet with Twitterfox. Twitterfox does not yet have embedded translation function. Although Tweetdeck can be installed into Windows, windows itself sucks enough. I don’t what to open one more app and kick start the AIR runtime. Another reason is that Twitterfox is a firefox plug-in, I can use it in Windows, MacOS, Linux and even BSD desktop and keep similar ( err…. ) working experience.
So I decided to h… Hey! I decided to look at the change-log first .
Don’t reinvent the wheel before you hack things, that sucks.
But what I had found is the Naan Studio guys in behind, are shifting their focus on TwitterFon, another piece of software, or an iPhone App, that I use a lot. Peer comments also reveals that TwitterFox is not to be made complicated.
OK, time to hack.
First, most firefox plug-ins are just javascript and XUL files in a zipped archive. Just find out the directory path and unzip files in chrome, most likely you can read and edit the source. For my TwitterFon, the file path is somewhat like:
W:\Document and Settings\%USER%\Application Data\Mozilla\Firefox\Profiles\%your.default%\extensions\twitternotifier@naan.net\chrome
I just use Windows search to find TwitterFox.jar , and that is it.
If you have installed firefox and twitterfox, just want and dare to test my crap hack, just download my file and replace the original one. Needless to say, you don’t back up, you bare your own blame.
For me, I unzip it with 7zip , and check out what can I do.
Obviously, “content\twitternotifier.js” should be the main file for fun.
What I want to do is to
1. Add a new item to the context menu ( right click ) , like the retweet stuff.
2. Use Google translate API ( RESTful part ) to do the job.
3. make the translated result usable for retweet
4. auto detect original language ( google api takes care about it ) and user preferred language ( as set in browser )
It turns out more files are involved, including i18n thingies, for point 1, which I spend most of the time to clean up tonight.
For point 2, just read Google’s document. It is by far easier than what I used to work with ( babelfish… ) 6 years ago. I add this follow code within 30 minutes, most time are wasted for my many many bugs and typos and thus firefox restarts.
( this is added just after the retweet function )
translate: function(target) {
var tweet = target.parentNode.node;
/*I don't care what "target" is, the code in above tells me how to get the "tweet". */
var req = new XMLHttpRequest;
/* Ajax translation kind of stuff */
req.open('GET', GTranslateAPI + tweet.getAttribute('text') ,true);
/* constants have be defined in the header */
req.onreadystatechange = function(){
if(req.readyState == 1)
req.setRequestHeader('Referer', Referrer);
/* google requires developers to state the referrer, although the function would work without it*/
if(req.readyState != 4) return;
result=eval('('+req.responseText+')');
/* json stuff */
r=result.responseData.translatedText;
/* fixit: yeah I am super lazy, even there are some available functions to normalize the result, I do nothing */
t=document.createTextNode(r);
p=document.createElement('description');
p.className = "twitternotifier-message-translate";
/* add some styling, thus the CSS file is also changed */
p.appendChild(t);
tweet.appendChild(p);
/* fixit: this part is definitely sick, may be CSS problem exists */
tweet.setAttribute('text',r);
/* How DIRTY ! :DDD , translate and retweet result is that easy (3) */
};
req.send('');
},
For point 4, just read the setting of the browser is not enough. Google translate does not know ALL languages.
Even worse, it takes only first two letter in locale for most langauge. Chinese is the only exception. The worst thing ture out to be zh-HK, which I am suppose to support even though I don’t like to use, is not supported by Google Translate. Thus this is the REAL Hack, if anything in this post means to be a hack :
( in the header )
var tolang;
switch(navigator.language) {
case 'zh-TW':
case 'zh-HK':
tolang='zh-tw';
break;
default:
tolang=navigator.language.substr(0,2);
}
const GTranslateAPI = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=%7C'
+ tolang + '&q=';
const Referrer = 'http://twitterfox.net/';
And that’s it .
Wait, I have also changed the behavior of Retweet , from
RT: @someone:
to
RT @someone
What is the point for adding two colons ? Funny ? Waste two more precious digit space ?
Moreover, I add a “zh-HK” locale.
Otherwise, HK users ( not me ) will be depreciated to be broken Chinese (破體中文) readers.
( Doh!)
—
By the way, I know there are many many bugs as you can see in the above code snippets ( at least look at the Fixits ).
I don’t care too much, but I may update if have time.
Hope that the Naan studio guys will read this post, throw away my crap, and implement something really works.
Before that, my dog food might be good enough for you darn lazy geeks.
You can always hack it better. I hope you will notice me after tasting your own shit.
The above code is a damned deviate (dd). Never attribute me if you copy and distribute. Yet I don’t care if you make it even more horrible and throw me some tipjoy to fix it. I will NOT fix it for you. I will fix it perhaps for my own pleasure.
If your firefox is corrupted by my file, please feel free to shout out your foul words to @bencrox.
Booklet for June 4 20th anniversay candlelight vigil
I heard that the googlesite hosting 六四二十周年紀念晚會場刊 ( 8964 - 20th Candlelight Vigil booklet ) has exceed limits.
Here please find my recompiled version ( best for iphone Discover / other pdf reader ) host on Scribd.com
8964 - 20th Candlelight Vigil booklet
我們一生都很快樂
熱愛中華人民共和國
滿目良辰美景
繁榮安定
社會最需要保和諧
飲食娛樂場所開滿街
十三億個共鳴
喜不自勝
I submit the an inquiry from in Air Asia dot com ’s website. Hey! It is 2009 now ! WTH is there, no confirmation after submission ?
If there is something wrong, please make good indication !
Hi there,
This is my first time buying ticket from AirAsia. I am quite confused about departure arrangement.
Am I supposed to receive nothing physical, just to bring the Booking Number to Hong Kong International Airport, and look around for some AirAsia counter?
I don’t find any paper mail from AirAsia in my box since purchasing two weeks ago. That makes me nervous.
I don’t know where, or not, to find AirAsia’s counter in the Airport. What document should I bring in order to check out and proof my identity ? What else should I do with my luggage ?
I guess there are some hints lay in the super small hidden words :
# 我們的登機櫃檯在航班計劃起飛時間之前2小時開放。在計劃起飛時間之前45分鐘關閉。在登機櫃檯關閉之前,您必須領取到登機牌,否則您將無法登機
# 您有責任確保遵守所前往國家的入境、海關或者其他方面的法律要求。如果是國際旅行,請您確保持有一份有效期至少還有6個月的有效護照,以及有效簽證。您還應該持有一份回航的行程安排或者繼續旅行的機票;
And I believe if these line tells all I should do, PLEASE present it BOLD and well posited for first timer.
I hope my inquiry sound not too silly, as every first timer at large will have the same feeling.
Last but not the least, please consider to have a Hong Kong hotline number. You can easily buy a number and route through VoIP to your call center outside HK. That is cheap and fast to proceed.
Looking forward to seeing your reply.
With Faith,
Ben
Sat 2 May: HK International Design and Innovation Forum
Hong Kong International Design and Innovation Forum will be held at the Jockey Club Creative Arts Centre, on the L2 Terrace in front of G.O.D. Street Culture Museum.
Address: 30 pak tin street, shek kip mei
http://jccac.org.hk/index.php/English/contactandvisit
23 ~ 24 May: BarCamp Bangkok !

I bet #gmail will sky rocket in twitter today ( 2009 Feb 24 )
( the above is a dynamic graph, if you are reading RSS, try to look at this link instead )
No brainer short url for my own site
Here is a story of a lazy man.
1. 2 min b4, I want to make a short url service for my own.
2. 1 min b4, I surf for solution, and someone suggested you may not have a database.
3. I have a (few) database(s), but I am willing to pump it, what then ?
4. I don’t even want to setup accounts, what then ?
5. 30sec later, I add this line to my dot-htaccess:
RewriteRule ^is\.gd/(.*) http://is.gd/$1 [QSA,L]
( of course I have deleted it after trial… and, you can replace the first clause with something like ^\.(.*) and any other capable service in the second clause )
6. What then? Before I delete the RewriteRule, http://bencrox.info/is.gd/evil is equivalent to http://is.gd/evil . And that works
Yes I know, it maybe fairly simple to setup something like http://bencrox.is.bad/blah , and get rid of all those spam urls others pump in and taint your DN ( because of yours own evil/unauthorized endorsement… ). But if you are lazy enough and being a console man, a one liner RewriteRule is always your candy.
–
What’s more ?
Hmm… say you know how to play with curl ( and any cgi stuff ) , you can redirect the short url to your cgi and RegEx match / show preview(s) / do any evil restructuring ( perhaps by … jQuery ? ) to check and claim others resources.
Conclusion ? You don’t need to learn any API to play with, in order to add functionality with your DN. ModRewrite is the ultimate answer.
This is how I learn my i-phone by accident.
Just type in some note, and wonder why the font is changing.
What then ? Search Google . So I can also get rid of the “handwritten” style font in i-phone.
OK, by reading the above, I want to know how other do Screen Cap.
1. Ready ?
2. Search !
3. Go through results until getting things done.
Here is one entry about how to do screen cap in iphone.