Skip to content

Facebook Psychic Mode

One thing that I’ve always enjoyed about the Pidgin chat client is the Psychic Mode plugin. This plugin basically detects when you receive an event from a given chat network that another user is typing a message to you. If you do not have a chat window open with that user, one will suddenly appear when plugin is triggered with the message “You feel a disturbance in the force…”.

After a little poking around on Facebook, I realized it’s pretty easy to add the same functionality into Facebook chat. I decided to write a simple Chrome extension to prototype the idea. You need to enable experimental extensions for any of the following code to work.

  if (resource.request.url.match(/channel\.facebook\.com/)) {
    resource.getContent(function(content, encoding){
      if (content == null) return;

      if (content.match(/"type":"typ"/) && content.match(/"st":1/)) {
        var from = content.match(/"from":\d+/);

        experimental.webInspector.log('You sense a disturbance in the force from... ' + /\d+/.exec(from)[0]));



When someone is typing a message to you, their browser will make a POST to ‘ajax/messaging/typ.php’. Facebook will then send your browser a message that contains an object with a ‘type’ property of ‘typ’ and ‘st’ property of 1. This extension simply looks for requests made to Facebook and attempts to find responses that meet said criteria.

This idea could perhaps be further flushed out via Firefox extensions. Chrome’s extension design and APIs make such a thing difficult (actively viewing requests and responses made by the browser). Such things are easier with Firefox where less restrictions and sandboxing for extensions are in place. Such an extension should likely even open the the chat tab with the target user (and of course display the ‘You sense a disturbance in the force from…’ message).

Post a Comment

Your email is never published nor shared. Required fields are marked *