I need to inteface to a few websites that use Socket.IO for data transport between their backend Node.JS server and the client's browser. I need to log all chat messages and sometimes send responses to the server. The websites use SSL so I can't use a proxy to intercept the messages, and they also don't permit multiple logins, so I can't use a separate program to do the automation if I want to interact with the website with my browser at the same time.

This is a much simpler Socket.IO chat example similar to the the websites which I have to interface to: https://node-yapp.rhcloud.com/. So for this example I'd want to capture the data argument from the addMessage function.

I'm looking for a way to use WWW::Mechanize::Firefox to automate this, but none of the available examples resemble this use case. There is an example that listens for progress events, but I don't think I can use that here.

The only other solution I can figure out is to use Greasemonkey to wrap the target javascript function inside my own function that would then post the data with GM_xmlhttpRequest to a local webserver which would write it to the logfile and return any data that should be sent back to the website's server. This seems like a more complicated solution so I am hoping somebody can suggest a simpler solution with WWW::Mechanize::Firefox, MozRepl::RemoteObject, or something I haven't even thought of.


In reply to Listening for Socket.IO events with WWW::Mechanize::Firefox by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.