Priyank Bolia
Priyank Bolia

Reputation: 14449

Firefox extension: Embed javascript in a webpage

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.

Upvotes: 4

Views: 3035

Answers (5)

Michael Paulukonis
Michael Paulukonis

Reputation: 9100

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.

Upvotes: 0

theman_on_vista
theman_on_vista

Reputation:

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)

Upvotes: 0

Dan Lew
Dan Lew

Reputation: 87430

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.

Upvotes: 0

ceejayoz
ceejayoz

Reputation: 180147

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

Upvotes: 1

Galwegian
Galwegian

Reputation: 42257

Greasemonkey does this. It's excellent!

Upvotes: 1

Related Questions