views:

376

answers:

5

I've been working on a Firefox extension extension, but it's been slow going (in part because I have no time to work on it). I've got a basic skeleton, verified that I can talk to an external JSON API, modify any webpage when loaded, and show a preferences box. These are all necessary HelloWorlds for the extension I am writing (maybe I don't need the preferences box).

Suddenly it occurred to me that I may be ignoring a much easier way to do it. Since Greasmonkey scripts may be compiled into Firefox Extensions, Greasemonkey might be a better way to go:

  1. It could be easier (not sure)?
  2. It could be cross-browser (at least Safari and Firefox)?
  3. Are there limits to Greasemonkey scripts vs. 'native' FF extensions? Can chrome UIs be written? Normal DIVs be popped up? Preferences be stored (I think they can be)?

I'm looking for a comparison of Greasemonkey vs. "native" FF extensions. Also, has anyone worked with "compiling" a Greasemonkey script into an FF extension (experiences, problems)?

A: 

One think greasemonkey scripts can't invoke UniversalXPConnect. I run into some problems due to this, not sure whether this can be solved with a Firefox extension. But I feel pretty much constrained as not able to call the UniversalXPConnect and do something big.

Priyank Bolia
Thanks Priyank, I see that from your other question here http://stackoverflow.com/questions/1284187/universalxpconnect-in-greasemonkey-script
Yar
+2  A: 

I would say, in general, if your purpose is to modify the way a webpage is displayed/functions, then Greasemonkey is the way to go. If you have a bunch of window/UI to display and you are really going beyond the core intention of Greasemonkey then it's probably best to stick with a more traditional extension.

philfreo
Thanks Philfreo, that seems to be my understanding too. At the same time I want to get into the more technical aspect of this, especially compiling Greasemonkey extensions (otherwise users need Greasemonkey, right?).
Yar
Correct... but if you want to support Safari you're still going to have to provide instructions on how to install GreaseKit first... and the people who do use Greasemonkey would probably rather not install an extension for Firefox
philfreo
+1  A: 

Now Google Chrome is gaining popularity. And it also has its own Extension API. Most simple Greasemonkey scripts would install on Google Chrome as it is without any tweaks. If you are using XHR then you might have to create a Chrome Extension.

I believe now Mozilla has realized that the Firefox Extension needs an overhaul. At the moment they are pushing for Jetpack. They should have improved Extension mechanism long time ago taking cue from the success of Greasemonkey.

I'm just adding to your question that there are more options then just Greasemonkey and Firefox Extension. You want a solution that would be easy to install/run on multiple browsers.

I would think out what 'features' I'm going to implement in browser extension and then see which extension mechanism (GM, Jetpack, FF extension, Google Chrome Extension) supports all the features.

tech4computer
Point taken, thank you.
Yar
+1  A: 

Since asking this, I've started working with compiling Greasemonkey scripts in Firefox. Works like a charm.

The limitations are all things that you cannot do with a Greasemonkey extension. You cannot do a real Firefox Add-on Preferences box, nor much serious "Chrome" stuff. The only thing you can modify in the browser is the chrome.css that comes up sometime before page load.

There are probably other limits (see Priyank's answer, which has to do with accessing the local filesystem).

As philfreo says, if your intention is to modify a webpage, Greasemonkey is a fine way to go. I have seen NO problems in compiling Greasemonkey extensions (amazingly) and getting them to work as they do in Greasemonkey.

Yar
A: 

the skipscreen extension is an example of your goal

(however, please do not subjugate users to malware. Yes, naysayers, surfcanyon is malware when it defaults to "opt"-in "preference")

normal user