Tag Archives: chat

Google Talk chatback badge – auto open chat

Just recently I needed to make a Google Talk chatback session start automatically, that a website could offer assistance after x amount of idletime and start the chat upon request. Far cleaner than asking them to click a link, I wanted the session to initiate once a user click “Yes, start live chat!” (or something to that effect).

The problem, was the Google Talk chatback badge uses an iFrame. I wanted to use jQuery to click the “open” link, but because of cross-domain scripting security within browsers this wasn’t possible.

My solution was quite simple. First of all I realised that I could easily grab the source to my chatback badge.

$ wget "http://www.google.com/talk/service/badge/Show?tk=...&w=200&h=60" -O talkBadge.html

Then I modified the talkBadge.html file to fix the broken resources. I did this with vim, since I already had it open, but you can do it with any tool using a simple search and replace.

:%s/"\/talk\//"http:\/\/www.google.com\/talk\//g

This replaces “/talk/ with “http://www.google.com/talk/. Finally I modified line 56 to give the a tag id=”talkLink”.

Now it was as easy as including the iFrame to my page as usual, but with the new talkBadge.html.

<iframe id="talkBadge" src="talkBadge.html" frameborder="0" allowtransparency="true" width="200" height="60"></iframe>

And then you can open the chatbox with the following line of Javascript (using jQuery).

$('#talkBox').contents().find('#talkLink').click();

I used the setTimeout function and a jQuery UI Dialog box to build a quick “Do you require assistance?” alert. Works a treat.

Facebook XMPP

I’ve been meaning to post this for a while. About a month and a bit ago Facebook finally added support for XMPP. What does this mean? It means you can use Faceook Chat with any XMPP capable chat client.

I am using bitlbee, it was very easy to set up. Once you have a working bitlbee server (I will not discuss this here, it’s very easy!) this addline will add your Facebook account:

account add jabber USERNAME@chat.facebook.com PASSWORD

One problem is that all your friends will have nicknames similar to “u231523234″ where 231523234 is their unique ID. Assuming you are using irssi one way to get around this is t use this script.

wget -O ~/.irssi/scripts/bitlbee_rename.pl http://browsingtheinternet.com/temp/bitlbee_rename.txt
ln -s ~/.irssi/scripts/bitlbee_rename.pl ~/.irssi/scripts/autorun/bitlbee_rename.pl

And then load it into irssi:

/script load bitlbee_rename.pl

Your contacts will be renamed when the join. Leave it for a few hours and eventually it will get everyone. Some names will not be accepted (if they are stupidly long for example). You can rename these people manually. Also, it won’t handle people with the same names.

Enjoy.