Page 1 of 1

Extension development - can I overlay a vbox?

Posted: 2019-09-07, 04:00
by moonbat
First attempt at extension development.
I want to extend the about:permissions window with an additional section for site specific user-agent overrides. I opened it up in DOM inspector, and found that there is a hbox entry for each type of permission, all inside a vbox named 'permissions-box'. I tried to overlay this by adding another hbox block like so:

Code: Select all

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin/"?>
<?xml-stylesheet type="text/css" href="chrome://PermissionsPlus/skin/browserOverlay.css"?>
<overlay id="permissionsplus-browser-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  <stringbundleset id="stringbundleset">
    <stringbundle id="permissionsplus-string-bundle" src="chrome://permissionsplus/locale/browserOverlay.properties" />
  </stringbundleset>
  <vbox id="permissions-box" flex="1">
    <hbox id="permissionplus-user-agent-override" align="center">
      <label id="permissionsbox.section.useragent.label" value="&permissionsbox.section.useragent.label"/>
      <textbox id="permissionsbox.section.useragent.value" value="Add user agent override here."/>
    </hbox>
  </vbox>
</overlay>
and I have the relevant entry in chrome.manifest as well -

Code: Select all

overlay	chrome://browser/content/browser.xul chrome://permissionsplus/content/browserOverlay.xul
but when I install it on a fresh profile and restart, there's nothing to be seen (not in DOM inspector either).
Is it possible to overlay at the vbox level, or am I missing something here?
The only example of an overlay I could find when searching was for the main menu, in the XUL School tutorial.

Re: Extension development - can I overlay a vbox?

Posted: 2019-09-07, 05:31
by FranklinDM
  • You're applying the overlay at the wrong location. Since we want to overlay at the Permissions Manager (about:permissions), it should be:

    Code: Select all

    overlay	about:permissions chrome://permissionsplus/content/browserOverlay.xul
  • The parent element of permissions-box is missing:

    Code: Select all

    <hbox flex="1" id="permissions-content" class="main-content">
          <vbox id="permissions-box" flex="1">
            <hbox id="permissionplus-user-agent-override" align="center" insertafter="plugins-pref-item">
              <label id="permissionsbox.section.useragent.label" value="&permissionsbox.section.useragent.label;"/>
              <textbox id="permissionsbox.section.useragent.value" value="Add user agent override here."/>
            </hbox>
          </vbox>
    </hbox>
    
  • Avoid & and ; unless the string is defined in your extension's locale file.

    Code: Select all

    XML Parsing Error: not well-formed
    Location: chrome://permissionsplus/content/overlay.xul
    Line Number 8, Column 108:
    <label id="permissionsbox.section.useragent.label" value="&permissionsbox.section.useragent.label"/>
    
You might want to add an icon to make it match the rest of the content:
Snap
Snap
{29B1A65B-4080-4416-AAB3-1E3EAC4D0E69}.png.jpg (7.58 KiB) Viewed 375 times

Re: Extension development - can I overlay a vbox?

Posted: 2019-09-07, 05:42
by moonbat
Thank you so much! :thumbup:
I should be able to get started with this now.