Looking for a starting place to learn WebExtensions APIs

Discuss building things with or for the Mozilla Platform.
Post Reply
User avatar
Shadoefax
Posts: 465
Joined: April 29th, 2005, 2:59 pm
Location: Glendale, AZ
Contact:

Looking for a starting place to learn WebExtensions APIs

Post by Shadoefax »

I've been writing extensions for years using the XUL/Javascript platform. I want to find out if I can rewrite any of them using WebExtension APIs. Can anyone recommend a good tutorial? Is there any one place where all the current APIs are fully documented? Any "Hello World" type examples?

Specifically, can anyone answer these questions?

  1. Can I read/write files to disk?
  2. Can I create an icon that can be placed on the main browser toolbar (i.e., the toolbar that hold the location box, back/forward buttons, etc.)?
  3. Can I save preferences (about:config)?
  4. Can I open a preference window (or any window the user can interact with, including popups)?
  5. Can HTML completely replace XUL (and use attributes like 'oncommand', 'onselect', 'onclick', "flex', etc.)?
I've tried to search for a WebExtensions 101 type page, but haven't really found anything that is complete.
All my signatures are stolen from other people. Including this one.
Homepage
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: Looking for a starting place to learn WebExtensions APIs

Post by patrickjdempsey »

https://wiki.mozilla.org/WebExtensions

1. The only file access appears to be "storage" using the HTML5 localStorage API like any other web app.

2. "browserAction"

3. As it's based on web technology that would be a no-no. And it doesn't appear in the current list.

4. "browserAction" again?

5. Not to my knowledge. HTML is stupid limited in what attributes elements are allowed to have, especially compared to XUL where any element can have basically any attribute, including ones you make up. Flex is (going to be?) available via CSS. In fact, a great deal of basic layout stuff will have to be handled with cludgy CSS because HTML is a vertical document format, not a horizontal interface language.
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
avada
Posts: 1932
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: Looking for a starting place to learn WebExtensions APIs

Post by avada »

patrickjdempsey wrote: In fact, a great deal of basic layout stuff will have to be handled with cludgy CSS because HTML is a vertical document format, not a horizontal interface language.
Can you explain shortly, what does vertical/horizontal mean, in this context?
isaacschemm
Posts: 270
Joined: January 20th, 2015, 12:29 pm

Re: Looking for a starting place to learn WebExtensions APIs

Post by isaacschemm »

You might want to look into how Chrome extensions are made - if I recall, WebExtensions is very similar - missing some APIs at the moment, while possibly adding others.
It's not really comparable to traditional XUL extensions - those can do a lot more. (Although changes to the browser can make them stop working.)
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: Looking for a starting place to learn WebExtensions APIs

Post by patrickjdempsey »

avada wrote:
patrickjdempsey wrote: In fact, a great deal of basic layout stuff will have to be handled with cludgy CSS because HTML is a vertical document format, not a horizontal interface language.
Can you explain shortly, what does vertical/horizontal mean, in this context?
HTML is very closely related to document formats like those in a word processor like Word. It's really easy in Word to layout the page vertically by using the Enter button to make spaces between lines of text and images. But if you want to layout things horizontally... like have several columns of text or several images in one line, it's a whole lot more difficult. You can see what I mean if you disable CSS in a web page via the View menu. The entire layout of the page disappears and everything is just in a list, just like in a word processor document. If you were able to disable CSS in the XUL browser frame, the basic layout of the controls would still be the same, just missing images and pretty border surrounds. That's because XUL is really good at doing horizontal layout. It requires a whole heck of a lot of CSS gymnastics to force HTML to act like XUL does just natively.
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
avada
Posts: 1932
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: Looking for a starting place to learn WebExtensions APIs

Post by avada »

I see what you mean now. Well, more "fun" for addon devs... :) (for thos who stick around)

I would like to see all of them (html, css, xul, JS) trashed, and replaced with something that doesn't suck...
Post Reply