maildev@lists.thunderbird.net

Thunderbird email developers

View all threads

XUL overlay injection for restartless Add-Ons (PoC)

JB
John Bieling
Wed, May 23, 2018 8:05 AM

Hi,

the standard XUL overlay method does no longer work in restartless
bootstraped Add-Ons. However, it is a lot of work to actually convert a
XUL overlay file to JS using

element = document.createElement()

and one of these:

hookElement.appendChild(element); //append to parent
hookElement.parentNode.insertBefore(element, hookElement); //insert before
hookElement.parentNode.insertBefore(element, hookElement.nextSibling);
//insert after

I tried to automate this:

  • load XUL file from XPI via NetUtil.asyncFetch() during addon start
  • parse XUL file via nsIDOMParser (even dtd files work!) during addon
    start and store the DOM structure in an overlay object
  • each time a window is opened, run thru the overlay object and do the
    document.create() stuff.

This works very nice! It is in place here:

fetchFile():
https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676
used during addon start:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27

DOMParser:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27

inject during windowload:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66
injector:
https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136

Is that a bad idea?*
If not, is it worth publishing somewhere, so other AddOn devs can use
it to convert their AddOns faster to restartless bootstraped?

*
The XUL overlay file does need a few adjustmenst: it is purely ID based,
all the toplevel elemenst need a hook (insertbefore, insertafter, appendto).
Example:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul

John

Hi, the standard XUL overlay method does no longer work in restartless bootstraped Add-Ons. However, it is a lot of work to actually convert a XUL overlay file to JS using element = document.createElement() and one of these: hookElement.appendChild(element); //append to parent hookElement.parentNode.insertBefore(element, hookElement); //insert before hookElement.parentNode.insertBefore(element, hookElement.nextSibling); //insert after I tried to automate this: - load XUL file from XPI via NetUtil.asyncFetch() during addon start - parse XUL file via nsIDOMParser (even dtd files work!) during addon start and store the DOM structure in an overlay object - each time a window is opened, run thru the overlay object and do the document.create() stuff. This works very nice! It is in place here: fetchFile(): https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676 used during addon start: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27 DOMParser: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27 inject during windowload: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66 injector: https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136 *Is that a bad idea?** **If not, is it worth publishing somewhere, so other AddOn devs can use it to convert their AddOns faster to restartless bootstraped?** * The XUL overlay file does need a few adjustmenst: it is purely ID based, all the toplevel elemenst need a hook (insertbefore, insertafter, appendto). Example: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul John
JB
John Bieling
Wed, May 23, 2018 8:29 AM

Link to DOMParser was wrong
https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37

Am 23.05.2018 um 10:05 schrieb John Bieling:

Hi,

the standard XUL overlay method does no longer work in restartless
bootstraped Add-Ons. However, it is a lot of work to actually convert
a XUL overlay file to JS using

element = document.createElement()

and one of these:

hookElement.appendChild(element); //append to parent
hookElement.parentNode.insertBefore(element, hookElement); //insert
before
hookElement.parentNode.insertBefore(element, hookElement.nextSibling);
//insert after

I tried to automate this:

  • load XUL file from XPI via NetUtil.asyncFetch() during addon start
  • parse XUL file via nsIDOMParser (even dtd files work!) during addon
    start and store the DOM structure in an overlay object
  • each time a window is opened, run thru the overlay object and do the
    document.create() stuff.

This works very nice! It is in place here:

fetchFile():
https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676
used during addon start:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27

DOMParser:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27

inject during windowload:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66
injector:
https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136

Is that a bad idea?*
If not, is it worth publishing somewhere, so other AddOn devs can
use it to convert their AddOns faster to restartless bootstraped?

*
The XUL overlay file does need a few adjustmenst: it is purely ID
based, all the toplevel elemenst need a hook (insertbefore,
insertafter, appendto).
Example:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul

John


Maildev mailing list
Maildev@lists.thunderbird.net
http://lists.thunderbird.net/mailman/listinfo/maildev_lists.thunderbird.net

Link to DOMParser was wrong https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37 Am 23.05.2018 um 10:05 schrieb John Bieling: > Hi, > > the standard XUL overlay method does no longer work in restartless > bootstraped Add-Ons. However, it is a lot of work to actually convert > a XUL overlay file to JS using > > element = document.createElement() > > and one of these: > > hookElement.appendChild(element); //append to parent > hookElement.parentNode.insertBefore(element, hookElement); //insert > before > hookElement.parentNode.insertBefore(element, hookElement.nextSibling); > //insert after > > I tried to automate this: > > - load XUL file from XPI via NetUtil.asyncFetch() during addon start > - parse XUL file via nsIDOMParser (even dtd files work!) during addon > start and store the DOM structure in an overlay object > - each time a window is opened, run thru the overlay object and do the > document.create() stuff. > > This works very nice! It is in place here: > > fetchFile(): > https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676 > used during addon start: > https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27 > > DOMParser: > https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27 > > inject during windowload: > https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66 > injector: > https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136 > > > *Is that a bad idea?** > **If not, is it worth publishing somewhere, so other AddOn devs can > use it to convert their AddOns faster to restartless bootstraped?** > * > The XUL overlay file does need a few adjustmenst: it is purely ID > based, all the toplevel elemenst need a hook (insertbefore, > insertafter, appendto). > Example: > https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul > > > John > > > > > _______________________________________________ > Maildev mailing list > Maildev@lists.thunderbird.net > http://lists.thunderbird.net/mailman/listinfo/maildev_lists.thunderbird.net
OE
Onno Ekker
Wed, May 23, 2018 8:40 AM

On Wed, May 23, 2018 at 10:29 AM, John Bieling john.bieling@gmx.de wrote:

Link to DOMParser was wrong
https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37

Am 23.05.2018 um 10:05 schrieb John Bieling:

Hi,

the standard XUL overlay method does no longer work in restartless
bootstraped Add-Ons. However, it is a lot of work to actually convert a XUL
overlay file to JS using

element = document.createElement()

and one of these:

hookElement.appendChild(element); //append to parent
hookElement.parentNode.insertBefore(element, hookElement); //insert
before
hookElement.parentNode.insertBefore(element, hookElement.nextSibling);
//insert after

I tried to automate this:

  • load XUL file from XPI via NetUtil.asyncFetch() during addon start
  • parse XUL file via nsIDOMParser (even dtd files work!) during addon
    start and store the DOM structure in an overlay object
  • each time a window is opened, run thru the overlay object and do the
    document.create() stuff.

This works very nice! It is in place here:

fetchFile(): https://github.com/jobisoft/TbSync/blob/master/content/
tbsync.jsm#L647-L676
used during addon start: https://github.com/jobisoft/
TbSync/blob/master/content/provider/eas/eas.js#L20-L27

DOMParser:  https://github.com/jobisoft/TbSync/blob/master/content/
provider/eas/eas.js#L20-L27

inject during windowload: https://github.com/jobisoft/
TbSync/blob/master/content/provider/eas/eas.js#L58-L66
injector: https://github.com/jobisoft/TbSync/blob/master/content/
xultools.js#L77-L136

Is that a bad idea?
If not, is it worth publishing somewhere, so other AddOn devs can use it
to convert their AddOns faster to restartless bootstraped?

The XUL overlay file does need a few adjustmenst: it is purely ID based,
all the toplevel elemenst need a hook (insertbefore, insertafter, appendto).
Example: https://github.com/jobisoft/TbSync/blob/master/content/
provider/eas/overlays/abCardWindow.xul

John

I think this is the standard way of converting a XUL Overlay extension and

think this method is also described on MDN.

It might also be the easiest way of creating a new bootstrapped extension,
but for this, you can also do it the hard way by adding all the elements to
the UI via JS.

I have done it via JS to see if this was feasible for my very simple
extension ThreadKey and had no problems in doing it that way. Apart from
adding elements to the UI, you also have to remove the elements again, if
the user decides to remove or disable your extension.

Onno

On Wed, May 23, 2018 at 10:29 AM, John Bieling <john.bieling@gmx.de> wrote: > Link to DOMParser was wrong > https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37 > > > Am 23.05.2018 um 10:05 schrieb John Bieling: > > Hi, > > the standard XUL overlay method does no longer work in restartless > bootstraped Add-Ons. However, it is a lot of work to actually convert a XUL > overlay file to JS using > > element = document.createElement() > > and one of these: > > hookElement.appendChild(element); //append to parent > hookElement.parentNode.insertBefore(element, hookElement); //insert > before > hookElement.parentNode.insertBefore(element, hookElement.nextSibling); > //insert after > > I tried to automate this: > > - load XUL file from XPI via NetUtil.asyncFetch() during addon start > - parse XUL file via nsIDOMParser (even dtd files work!) during addon > start and store the DOM structure in an overlay object > - each time a window is opened, run thru the overlay object and do the > document.create() stuff. > > This works very nice! It is in place here: > > fetchFile(): https://github.com/jobisoft/TbSync/blob/master/content/ > tbsync.jsm#L647-L676 > used during addon start: https://github.com/jobisoft/ > TbSync/blob/master/content/provider/eas/eas.js#L20-L27 > > DOMParser: https://github.com/jobisoft/TbSync/blob/master/content/ > provider/eas/eas.js#L20-L27 > > inject during windowload: https://github.com/jobisoft/ > TbSync/blob/master/content/provider/eas/eas.js#L58-L66 > injector: https://github.com/jobisoft/TbSync/blob/master/content/ > xultools.js#L77-L136 > > > *Is that a bad idea?* > *If not, is it worth publishing somewhere, so other AddOn devs can use it > to convert their AddOns faster to restartless bootstraped?* > > The XUL overlay file does need a few adjustmenst: it is purely ID based, > all the toplevel elemenst need a hook (insertbefore, insertafter, appendto). > Example: https://github.com/jobisoft/TbSync/blob/master/content/ > provider/eas/overlays/abCardWindow.xul > > > John > > I think this is the standard way of converting a XUL Overlay extension and think this method is also described on MDN. It might also be the easiest way of creating a new bootstrapped extension, but for this, you can also do it the hard way by adding all the elements to the UI via JS. I have done it via JS to see if this was feasible for my very simple extension ThreadKey and had no problems in doing it that way. Apart from adding elements to the UI, you also have to remove the elements again, if the user decides to remove or disable your extension. Onno
JB
John Bieling
Wed, May 23, 2018 9:44 AM

Am 23.05.2018 um 10:40 schrieb Onno Ekker:

On Wed, May 23, 2018 at 10:29 AM, John Bieling <john.bieling@gmx.de
mailto:john.bieling@gmx.de> wrote:

 Am 23.05.2018 um 10:05 schrieb John Bieling:
 Hi,

 the standard XUL overlay method does no longer work in
 restartless bootstraped Add-Ons. However, it is a lot of work to
 actually convert a XUL overlay file to JS using

 element = document.createElement()

 and one of these:

 hookElement.appendChild(element); //append to parent
 hookElement.parentNode.insertBefore(element, hookElement);
 //insert before
 hookElement.parentNode.insertBefore(element,
 hookElement.nextSibling); //insert after

 I tried to automate this:

 - load XUL file from XPI via NetUtil.asyncFetch() during addon start
 - parse XUL file via nsIDOMParser (even dtd files work!) during
 addon start and store the DOM structure in an overlay object
 - each time a window is opened, run thru the overlay object and
 do the document.create() stuff.

 This works very nice! It is in place here:

 fetchFile():
 https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676
 <https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676>
 used during addon start:
 https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27
 <https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27>

 DOMParser:
 https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37
 <https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37>

 inject during windowload:
 https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66
 <https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66>
 injector:
 https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136
 <https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136>


 *Is that a bad idea?**
 **If not, is it worth publishing somewhere, so other AddOn devs
 can use it to convert their AddOns faster to restartless
 bootstraped?**
 *
 The XUL overlay file does need a few adjustmenst: it is purely ID
 based, all the toplevel elemenst need a hook (insertbefore,
 insertafter, appendto).
 Example:
 https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul
 <https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul>


 John

I think this is the standard way of converting a XUL Overlay extension
and think this method is also described on MDN.

It might also be the easiest way of creating a new bootstrapped
extension, but for this, you can also do it the hard way by adding all
the elements to the UI via JS.

I have done it via JS to see if this was feasible for my very simple
extension ThreadKey and had no problems in doing it that way. Apart
from adding elements to the UI, you also have to remove the elements
again, if the user decides to remove or disable your extension.

Onno

I really searched MDN but I could not find working code, and it did take
me two days to get this done. I know from my self that having to "redo"
the UI was the most fearful aspect which stopped me from converting
earlier. So I think that working code might help others to convert there
AddOns. But is my code a good example? Where should it be published (if
at all)?

The PoC also contains a function to remove the injected elements, I
forgot to point that out.

John

Am 23.05.2018 um 10:40 schrieb Onno Ekker: > On Wed, May 23, 2018 at 10:29 AM, John Bieling <john.bieling@gmx.de > <mailto:john.bieling@gmx.de>> wrote: > > > Am 23.05.2018 um 10:05 schrieb John Bieling: >> Hi, >> >> the standard XUL overlay method does no longer work in >> restartless bootstraped Add-Ons. However, it is a lot of work to >> actually convert a XUL overlay file to JS using >> >> element = document.createElement() >> >> and one of these: >> >> hookElement.appendChild(element); //append to parent >> hookElement.parentNode.insertBefore(element, hookElement); >> //insert before >> hookElement.parentNode.insertBefore(element, >> hookElement.nextSibling); //insert after >> >> I tried to automate this: >> >> - load XUL file from XPI via NetUtil.asyncFetch() during addon start >> - parse XUL file via nsIDOMParser (even dtd files work!) during >> addon start and store the DOM structure in an overlay object >> - each time a window is opened, run thru the overlay object and >> do the document.create() stuff. >> >> This works very nice! It is in place here: >> >> fetchFile(): >> https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676 >> <https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676> >> used during addon start: >> https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27 >> <https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27> >> >> DOMParser: >> https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37 >> <https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37> >> >> inject during windowload: >> https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66 >> <https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66> >> injector: >> https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136 >> <https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136> >> >> >> *Is that a bad idea?** >> **If not, is it worth publishing somewhere, so other AddOn devs >> can use it to convert their AddOns faster to restartless >> bootstraped?** >> * >> The XUL overlay file does need a few adjustmenst: it is purely ID >> based, all the toplevel elemenst need a hook (insertbefore, >> insertafter, appendto). >> Example: >> https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul >> <https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul> >> >> >> John >> > I think this is the standard way of converting a XUL Overlay extension > and think this method is also described on MDN. > > It might also be the easiest way of creating a new bootstrapped > extension, but for this, you can also do it the hard way by adding all > the elements to the UI via JS. > > I have done it via JS to see if this was feasible for my very simple > extension ThreadKey and had no problems in doing it that way. Apart > from adding elements to the UI, you also have to remove the elements > again, if the user decides to remove or disable your extension. > > Onno I really searched MDN but I could not find working code, and it did take me two days to get this done. I know from my self that having to "redo" the UI was the most fearful aspect which stopped me from converting earlier. So I think that working code might help others to convert there AddOns. But is my code a good example? Where should it be published (if at all)? The PoC also contains a function to remove the injected elements, I forgot to point that out. John
PK
Philipp Kewisch
Wed, May 23, 2018 10:22 AM

Hi John,

it is a great idea, which is why we are working on https://bugzilla.mozilla.org/show_bug.cgi?id=1448808

Maybe you want to help us out there? I haven’t gotten around to completing the work there.

Philipp

On 23. May 2018, at 11:44 AM, John Bieling john.bieling@gmx.de wrote:

Am 23.05.2018 um 10:40 schrieb Onno Ekker:

On Wed, May 23, 2018 at 10:29 AM, John Bieling john.bieling@gmx.de wrote:

Am 23.05.2018 um 10:05 schrieb John Bieling:

Hi,

the standard XUL overlay method does no longer work in restartless bootstraped Add-Ons. However, it is a lot of work to actually convert a XUL overlay file to JS using

element = document.createElement()

and one of these:

hookElement.appendChild(element); //append to parent
hookElement.parentNode.insertBefore(element, hookElement); //insert before
hookElement.parentNode.insertBefore(element, hookElement.nextSibling); //insert after

I tried to automate this:

  • load XUL file from XPI via NetUtil.asyncFetch() during addon start
  • parse XUL file via nsIDOMParser (even dtd files work!) during addon start and store the DOM structure in an overlay object
  • each time a window is opened, run thru the overlay object and do the document.create() stuff.

This works very nice! It is in place here:

fetchFile(): https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676
used during addon start: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27

DOMParser:  https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37

inject during windowload: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66
injector: https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136

Is that a bad idea?
If not, is it worth publishing somewhere, so other AddOn devs can use it to convert their AddOns faster to restartless bootstraped?

The XUL overlay file does need a few adjustmenst: it is purely ID based, all the toplevel elemenst need a hook (insertbefore, insertafter, appendto).
Example: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul

John

I think this is the standard way of converting a XUL Overlay extension and think this method is also described on MDN.

It might also be the easiest way of creating a new bootstrapped extension, but for this, you can also do it the hard way by adding all the elements to the UI via JS.

I have done it via JS to see if this was feasible for my very simple extension ThreadKey and had no problems in doing it that way. Apart from adding elements to the UI, you also have to remove the elements again, if the user decides to remove or disable your extension.

Onno

I really searched MDN but I could not find working code, and it did take me two days to get this done. I know from my self that having to "redo" the UI was the most fearful aspect which stopped me from converting earlier. So I think that working code might help others to convert there AddOns. But is my code a good example? Where should it be published (if at all)?

The PoC also contains a function to remove the injected elements, I forgot to point that out.

John


Maildev mailing list
Maildev@lists.thunderbird.net
http://lists.thunderbird.net/mailman/listinfo/maildev_lists.thunderbird.net

Hi John, it is a great idea, which is why we are working on https://bugzilla.mozilla.org/show_bug.cgi?id=1448808 Maybe you want to help us out there? I haven’t gotten around to completing the work there. Philipp > On 23. May 2018, at 11:44 AM, John Bieling <john.bieling@gmx.de> wrote: > > > >> Am 23.05.2018 um 10:40 schrieb Onno Ekker: >>> On Wed, May 23, 2018 at 10:29 AM, John Bieling <john.bieling@gmx.de> wrote: >>> >>> Am 23.05.2018 um 10:05 schrieb John Bieling: >>>> Hi, >>>> >>>> the standard XUL overlay method does no longer work in restartless bootstraped Add-Ons. However, it is a lot of work to actually convert a XUL overlay file to JS using >>>> >>>> element = document.createElement() >>>> >>>> and one of these: >>>> >>>> hookElement.appendChild(element); //append to parent >>>> hookElement.parentNode.insertBefore(element, hookElement); //insert before >>>> hookElement.parentNode.insertBefore(element, hookElement.nextSibling); //insert after >>>> >>>> I tried to automate this: >>>> >>>> - load XUL file from XPI via NetUtil.asyncFetch() during addon start >>>> - parse XUL file via nsIDOMParser (even dtd files work!) during addon start and store the DOM structure in an overlay object >>>> - each time a window is opened, run thru the overlay object and do the document.create() stuff. >>>> >>>> This works very nice! It is in place here: >>>> >>>> fetchFile(): https://github.com/jobisoft/TbSync/blob/master/content/tbsync.jsm#L647-L676 >>>> used during addon start: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L20-L27 >>>> >>>> DOMParser: https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L5-L37 >>>> >>>> inject during windowload: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66 >>>> injector: https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136 >>>> >>>> >>>> Is that a bad idea? >>>> If not, is it worth publishing somewhere, so other AddOn devs can use it to convert their AddOns faster to restartless bootstraped? >>>> >>>> The XUL overlay file does need a few adjustmenst: it is purely ID based, all the toplevel elemenst need a hook (insertbefore, insertafter, appendto). >>>> Example: https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/overlays/abCardWindow.xul >>>> >>>> >>>> John >>>> >> I think this is the standard way of converting a XUL Overlay extension and think this method is also described on MDN. >> >> It might also be the easiest way of creating a new bootstrapped extension, but for this, you can also do it the hard way by adding all the elements to the UI via JS. >> >> I have done it via JS to see if this was feasible for my very simple extension ThreadKey and had no problems in doing it that way. Apart from adding elements to the UI, you also have to remove the elements again, if the user decides to remove or disable your extension. >> >> Onno > > I really searched MDN but I could not find working code, and it did take me two days to get this done. I know from my self that having to "redo" the UI was the most fearful aspect which stopped me from converting earlier. So I think that working code might help others to convert there AddOns. But is my code a good example? Where should it be published (if at all)? > > The PoC also contains a function to remove the injected elements, I forgot to point that out. > > John > > _______________________________________________ > Maildev mailing list > Maildev@lists.thunderbird.net > http://lists.thunderbird.net/mailman/listinfo/maildev_lists.thunderbird.net
A
ace
Wed, May 23, 2018 9:20 PM

----- Pôvodná správa -----
Predmet: [Maildev] XUL overlay injection for restartless Add-Ons (PoC)
Od: John Bieling john.bieling@gmx.de
Pre: maildev@lists.thunderbird.net
Dátum: Wed, 23 May 2018 10:05:50 +0200

Hi,

the standard XUL overlay method does no longer work in restartless
bootstraped Add-Ons. However, it is a lot of work to actually convert a
XUL overlay file to JS using
I tried to automate this:
inject during windowload:
https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66
injector:
https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136

----- Pôvodná správa ----- Predmet: [Maildev] XUL overlay injection for restartless Add-Ons (PoC) Od: John Bieling <john.bieling@gmx.de> Pre: maildev@lists.thunderbird.net Dátum: Wed, 23 May 2018 10:05:50 +0200 > Hi, > > the standard XUL overlay method does no longer work in restartless > bootstraped Add-Ons. However, it is a lot of work to actually convert a > XUL overlay file to JS using > I tried to automate this: > inject during windowload: > https://github.com/jobisoft/TbSync/blob/master/content/provider/eas/eas.js#L58-L66 > injector: > https://github.com/jobisoft/TbSync/blob/master/content/xultools.js#L77-L136 Hi, for listening for new windows and then running your injection code you can also use the TB internal mechanism for this, see: https://dxr.mozilla.org/comm-central/rev/18881dd127e3b0c0d3f97390c9094e309d4dd9c1/mail/test/resources/jsbridge/jsbridge/extension/bootstrap.js#17 https://dxr.mozilla.org/comm-central/rev/18881dd127e3b0c0d3f97390c9094e309d4dd9c1/common/src/extensionSupport.jsm#151