Closed Bug 694617 Opened 13 years ago Closed 7 years ago

Write a greasemonkey porting guide

Categories

(Add-on SDK Graveyard :: Documentation, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: wbamberg, Assigned: wbamberg)

Details

We should have a guide for people who want to port user scripts to SDK add-ons.

It should cover:
- how page-mod is the equivalent of the GM framework for injecting user scripts
- how the GM_* APIs map on to SDK APIs
- any differences in the objects available to content scripts versus user scripts
- a worked example
FWIW there is a 3rd party addon sdk package that can be used to convert 1 or more userscripts into a addon with the addon sdk. 

https://github.com/scriptish/userscripts-jetpack-package

I will make sure that it is tightly integrated with page-mods code in the future too.
Status: NEW → ASSIGNED
Hardware: x86 → All
(In reply to Erik Vold from comment #1)
> FWIW there is a 3rd party addon sdk package that can be used to convert 1 or
> more userscripts into a addon with the addon sdk. 
> 
> https://github.com/scriptish/userscripts-jetpack-package
> 
> I will make sure that it is tightly integrated with page-mods code in the
> future too.

Yes, I'd seen this, and meant to talk about it in this guide, so thanks for pointing it out. I think it's an incredibly valuable package. I guess it's still somewhat worthwhile porting a user script to the SDK, because:
- you get to use the other SDK APIs
- you get streamlined AMO review (if you use only addon-kit APIs)

What do you think?
> I guess it's
> still somewhat worthwhile porting a user script to the SDK, because:
> - you get to use the other SDK APIs
> - you get streamlined AMO review (if you use only addon-kit APIs)
> 
> What do you think?

It would not be hard to give user scripts access to more features (including a message manager), and I do plan to build an API for injecting new features in to user script sandboxes so that 3rd part module devs can add new APIs; and the GM_* api is meant to provide a user friendly API that allows authors to do what they want quickly and easily.  So the point about using other SDK APIs is moot imo.

afaict the only advantage to porting to a page-mod would be for the streamlined AMO review, which would be a hard sell if there isn't some tool that would automate this process.

The disadvantages to porting to a page-mod is that a author has to do a bunch of work, and maintain two code bases.
(In reply to Will Bamberg [:wbamberg] from comment #0)
> We should have a guide for people who want to port user scripts to SDK
> add-ons.
> 
> It should cover:
> - how page-mod is the equivalent of the GM framework for injecting user
> scripts
> - how the GM_* APIs map on to SDK APIs
> - any differences in the objects available to content scripts versus user
> scripts
> - a worked example

page-mod is not equvlant because page-mod has no way of excluding urls like greasemonkey's @include / "@exclude" and specfiying regex seems to be broken and dosn't allow for not's.
Since Firefox 32 the exclude property has been added to Page-Mod.  Will do you have any work on this yet? I wouldn't mind helping make the doc.
Hi Jared

(In reply to Jared Null from comment #5)
> Since Firefox 32 the exclude property has been added to Page-Mod.  Will do
> you have any work on this yet? I wouldn't mind helping make the doc.

No, I've done nothing on this. From Erik's comment 3, it seemed like the motivation to port to the SDK from GM just wasn't there. But I'd be very happy for you to write up something for this if you wanted to, and I can review it if you'd like.
Great!  Ha, I haven't touched GM scripts in at least a year mainly because, i love writing add-ons now and i would never go back!  I have no problem writing something up. 

I think its a great idea for people to get more involved in development, it could really draw more people to building add-ons and maybe even Firefox development, maybe Erik is right about lack of interest, and the added AMO review process would deter people, ever since the Add-on Builder (Web Based) has been retired the learning curve does jump a bit higher. 

I'll compare to GM and see if i can't draft something up and would be grateful if you reviewed it.
(In reply to Will Bamberg [:wbamberg] from comment #6)
> Hi Jared
> 
> (In reply to Jared Null from comment #5)
> > Since Firefox 32 the exclude property has been added to Page-Mod.  Will do
> > you have any work on this yet? I wouldn't mind helping make the doc.
> 
> No, I've done nothing on this. From Erik's comment 3, it seemed like the
> motivation to port to the SDK from GM just wasn't there. 

There is motivation, GM is not available on Fennec while SDK is.
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.