You can modify your qa-theme.php this way:
function doctype() {
qa_html_theme_base::doctype();
$script = <<<JS
<script>
alert("hello");
</script>
JS;
$this->content['body_footer'] = (isset($this->content['body_footer']) ? $this->content['body_footer'] : '') . $script;
}
Respect the spacing in <<<JS and JS;.
If this shows the alert then this is working. You should now replace alert("hello"); with the given JS code. After that, it is a matter of making your JS code work :)