views:

695

answers:

5

I want to insert some script into every page, which have some functions that will be called by the modified HTML of that page, using a Firefox extension. I am able to insert the JavaScript into the head of the HTML, and also modify the page, but the java script functions are not called by the onmouseover event. Does someone has any pointer on how to do that, using java script in local extension or as a online resource.

No GreaseMonkey, I need to do it with my plugin and not ask user to install greasemonkey, my plugin and the scripts.

+1  A: 

Greasemonkey does this. It's excellent!

Galwegian
+1  A: 

Make a Greasemonkey script. See Userscripts.org for lots of example ones to work off.

ceejayoz
A: 

Why not use Greasemonkey? It allows you to execute javascript on any page on Firefox, and if executing the code you enter isn't good enough you could dynamically add links to the head, too.

Daniel Lew
I think the question made this pretty clear -- asking the user to install two extensions is awkward. The poster wants one extension with this functionality.
Michael Paulukonis
A: 

you can modify the DOM using Firebug. I am not sure if you can load files locally.. sounds malicious. Also, you can just run arbitrary javascript commands in the Firebug console (a la python/ruby console)

firebug shows me that the javascript is already there, but it not called, that's what the question is!
Priyank Bolia
A: 

There are some Greasemonkey-to-extension "compilers" (or extension-wrappers) out there:

Arantius's GM compiler Gina Trapani's multiple-GM-script compiler

I've used the first one with extensive internal tweaking over time. However, I don't believe the compiler is actively maintained (default max-version is only 3.0), so may not be up-to-date with the latest GreaseMonkey, or FireFox.

I think Gina Trapani's is more designed for multiple scripts targetting the same domain, but I haven't used it.

Neither of these is a "GreaseMonkey solution" per se, as the end-user never has to install GreaseMonkey. They get a real-live FireFox extension. The core is very similar to GM, but you can change or add as much as you like.

Michael Paulukonis