Add element to website/tab from Safari extension

I am trying to create an extension for Safari that will add an element to the page/tab that I am currently on. In the example below I’d like to add the Send button to the page.

The issue for me is that the new element (button) will be added to the extensions html.

(Sorry the bad format of code below, copy pasted with my phone)

<script type=“text/javascript”>

function sendMessage() {
document.getElementById(“textField”).innerHTML=“Sending message…”;“hey”, “there”);

function respondToMessage(messageEvent) {
if( === “gotIt”)



<BODY> Message Sender Bar   
<INPUT type=“button” value=“Send” onclick=“sendMessage()” />
<SPAN id=“textField”>…waiting… </SPAN>

var theBody = document.body;
var element = document.createElement(“p”); = “status”; = “float:right; color:red”;
element.textContent = “Waiting…”;
theBody.insertBefore(element, theBody.firstChild);

function replyToMessage(aMessageEvent) {
if ( === “hey”) {
document.getElementById(“status”).textContent=“Message received.”;“gotIt”,“Message acknowledged.”);
safari.self.addEventListener(“message”, replyToMessage, false);</BODY></HTML>