How to execute javascript iframe in custom module?
The $form var in chat_with_librarian_get_html()is rather useless, just return the $html var instead and it should work.

function chat_with_librarian_get_html() {
  $html = '&lt;div id="parent"&gt;&lt;div id="qpchatwidget" &gt;&lt;/div&gt;' .
    '&lt;script ...call site in question with appropriate parameters...&gt;' .
    '&lt;noscript&gt;Please enable javascript to chat with librarians online&lt;/noscript&gt;&lt;/script&gt;&lt;/div&gt;';
  return $html;
}