Monday, September 7, 2009

Facebook Chat's Bold and Underline Text and Prodding Facebook Chat on a mission

I never noticed this before, but by placing asterisks around a word in Facebook Chat will bold the word, and placing underscores around one will underline the word. My first instinct was to figure out how to type italic text. Well a few Google searches showed that other people were looking for it as well; so I decided to go "straight to the horse's mouth," so to speak.

Figured the first place to start the search was in the messages that relay chat and see if the HTML conversion takes place there. Now mind you I've already poked and prodded Facebook Chat's message relay server before. Its a MochiWeb server, which you can see in the HTTP headers for chat packets. For more background specifics on the setup that is Facebook chat, see Facebook's engineering blog.

Server: MochiWeb/1.0 (I'm not even supposed to be here today.)

Anyhow, by reading the HTTP packet flow, I can get the "raw" information that the webpage uses to talk to the server. These I believe are in JSON although don't quote me on that, suffice to say I can at least read enough of the raw information they contain to see the message I just received. And sure enough these contain the text just as they would have been typed, that is, asterisks instead of HTML bold tags and underscores instead of HTML underline tags.

So, then this tells me that the replacement of "Facebook Chat style markup" takes place in the user's web browser. Problem is, there's a bunch of JavaScript files attached to any Facebook page. Fortunately for me though with Firefox with the FireBug extension the process of analyzing a web page's code is fairly streamlined.

Going straight to the code generated for a chat window, I noticed that the "pic_padding" class is on each message's node (which happen to be paragraph elements). So I searched for this class in the JavaScript given that is was the best lead I had. Fortunately this lead turned out results.

if(pendingMsgID||errorMarkup){
var pendingElementID=pendingMsgID?' id="pending_'+this.id+'_'+pendingMsgID+'"':'';markup+=''+
299(errorMarkup?errorMarkup:'')+'
';}

And just a couple lines below that, ta-da!

_processStyledText:function(textProcessor,str){return textProcessor(str).replace(/\b_([^_\*]+)_\b/g,'<u>$1</u>').replace(/(\s|^)\*([^_\*]+)\*(?=$|\s)/g,'$1<b>$2</b>');}

Yep, regular expressions. Just what I was expecting. No sign of a regex that replaces something with <i>..</i>. That's right, there is no way to type in italics.

So Facebook, why no italics?

17 comments:

redacted said...

Thanks so much for the instructions - very helpful and sincerely appreciated.

I was hoping that these same tricks might also apply to facebook messages, but it appears they do not. Can you please tell me if bold/italic/underline are even possible with the facebook message system?

Thanks very much for your time and help :)

Anonymous said...

Certainly. So happens.

Anonymous said...

Amiable brief and this mail helped me alot in my college assignement. Say thank you you on your information.

Anonymous said...

What phrase... super

Anonymous said...

Genial post and this post helped me alot in my college assignement. Thank you for your information.

Anonymous said...

i'm new... expectancy to despatch around more regularly!

Anonymous said...

using the GV 81. The same procedure applies for a haulier wanting to use a new operating centre. The FTA Yearbook 1986 has a very useful summary of procedures http://buyviagraonlineauviagra-au.com#6,2688E+67 buy Viagra au gene (oligonucleotide C) and a motif differing by a change from T to G converting the HSV ICP0 site to a perfect TAATGARAT motif (oligonucleotide A). http://buyviagra100mgcostviagraonline.co.uk#3,12341E+24451 Viagra cost uk Polysaturated fats are also from vegetables but could remain liquid in both cold and room temperature

Anonymous said...

plant modification (b) due to staff turnover there was not appropriately qualified engineer ( c ) there was a large quantity of hot flammable material. (a) raised http://buyviagraonlineauviagra-au.com#7,2389E+37 buy Viagra au Award Ref No: RC/00/23/2400 Old Ref No: C/00/23/2400 Award Holder: Dr B G Salter; Dr E R Tapper Department: UNKNOWN Institution: Sussex University Amount: http://buyviagra100mgcostviagraonline.co.uk#5868 viagra online 438 Besides, sudden bursts of emotions also lead us to doing things we might regret later on

Anonymous said...

resort '') the Bank of England will always step in and lend to the discount houses, or purchase bills of exchange from them before the bills have reached maturity http://buyviagraonlineauviagra-au.com#9489 viagra in first place dey know it's wrong (.) Brenda's brother ( L ) is Jamaican-born and has a strong Caribbean accent. His turn here is also http://buyviagra100mgcostviagraonline.co.uk#1,81522E+78751 Viagra cost uk You can take a look at the high end and the prestigious makeup companies and try the expensive creams and lotions

Anonymous said...

You need to concentrate on overall body fat reduction buy lumigan uk I don't care if those pounds are marble or body fat
Our bodies crave these foods and so the vitamins that you need must contain these elements buy cymbalta cost Life is full of surprises and not all of them are pleasant! So you’d better be ready to fight!
Place your elbows firmly by your sides and let the dumbbells hang down from fully stretched hands viagra for women au The problem is that the major cosmetics companies are seeking to widen their profit margins by only including the lowest priced ingredients they possibly can
Fish is a good idea too, as it contains vitamins, a good amount of protein and omega 3 oils, all of which can help strengthen your immune system against infection buy iressa Ashwagandha ( part of Madhura gana)
This is very important if are going to live your life in the real world No rx Astelin The makers of some of the best hair removal creams are so confident in their product that they are willing to let you try them for free

Anonymous said...

They also noticed that they could walk further and were able to stay on their feet for much longer periods of time cheap lumigan Panic and anxiety attacks are only triggered and sustained if you let it overcome you
This normally happens when the back problem is related to the bone damaged or fracture buy cymbalta cost Post-natal depression may turn out to be a catastrophe for a young family
The self-confidence which you would certainly obtain and also the improvement in your sexual life will be incredible generic Viagra for women Infrared saunas present a new age approach to sauna baths or treatments
As men grow older their sperm count decreases and an overall decline in the genetic quality of the sperm releases are compromised cheap iressa However, the curling process and taking extra care to maintain the beautiful strands in ringlets is not very easy
Vitamins like A, C, E, biotin, and riboflavin (or B2) are very important in maintaining the health of your skin too SALE Orlistat Water

Anonymous said...

Hello there! This post could not be written much better!
Reading through this post reminds me of my previous
roommate! He always kept talking about this. I most certainly will
send this information to him. Pretty sure
he will have a very good read. I appreciate you for sharing!


Have a look at my homepage ... cedar finance contact info

Anonymous said...

It is remarkable, very useful message
And how it to paraphrase?
It is remarkable, this amusing message
It is not necessary to try all successively
You are absolutely right. In it something is also thought good, I support.

[url=http://208.81.166.240/forum.php?mod=viewthread&tid=2015996][b]Cheap NHL Jerseys[/b][/url]
[url=http://www.ncsmed.org.fj/index.php?option=com_blog&view=comments&pid=1139536&Itemid=0][b]Cheap NHL Jerseys[/b][/url]
[url=http://loudinfo.com/forum.php?mod=viewthread&tid=374422][b]Cheap NHL Jerseys[/b][/url]
[url=http://www.cn-stny.com/plus/view.php?aid=60871][b]Cheap NHL Jerseys[/b][/url]
[url=http://www.802.11abgn.com/activity/p/358248/][b]Cheap NHL Jerseys[/b][/url]

Anonymous said...

Prix http://viagraprixenligne.com#1438 - viagra generique faits http://viagrasildenafilprix.com#145 - viagra sildenafil sans prescrire Viagra Pas cher http://viagrageneriqueprix.com#904 - viagra prix pour les femmes Évidemment, vous aurez envie d'éviter tout produit qui a un effet pervers comme ça http://levitra-generique.eu#127 - levitra en ligne cher

Anonymous said...

Keep on writing, great job!

Here is my web-site ... http://dotegypt.net/home/blog/view/1170723/a-complete-one-hundred-organic-male-enhancement-complement

Anonymous said...

у нас на интернет-блоге подобран большой набор [url=http://www.filmkpktut.ru/]скачать бесплатное видео[/url].

Anonymous said...

Hello to every , as I am really keen of reading this
weblog's post to be updated on a regular basis. It carries good stuff.

Feel free to surf to my web site - account forex trading

hit counter