0
votes

Let's say a person clicks an XUL element (toolbar button) and I want to make a function and injects and runs javascript on the HTML document. How would I do this? Thanks.

1

1 Answers

0
votes

Yes you can. If you want to do inline javascript or attach a javascript function that is in your addon you can do that all inline.

However if you want to inject a .js file thats in your addon folder you have to add a chrome.manifest and give it contentaccessible=true.

Here is a demo addon, ready to go, just install. It shows how to inject html and addEventListener and stuff: _ff-addon-template-BootstrapWatchHostEventListener

The important function is addDiv look at that one.

Read the comments at the bottom. Feel free to add comments and share code.