Custom about: URLs

  • Revision slug: Custom_about:_URLs
  • Revision title: Custom about: URLs
  • Revision id: 55534
  • Created:
  • Creator: MichaelKohler
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

For creating an own about: URL, you have to use the following template to create aboutSITENAME.js . You have to replace SITENAME with your chosen name for the URL. You're URL will be "about:SITENAME". Also you'll have to generate an own UUID for your page and replace YOUR-UUID with it.

const Cc = Components.classes;
const Ci = Components.interfaces;

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function AboutSITENAME() { }
AboutSITENAME.prototype = {
  classDescription: "about:SITENAME",
  contractID: "@mozilla.org/network/protocol/about;1?what=SITENAME",
  classID: Components.ID("{YOUR-UUID}"),
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
  
  getURIFlags: function(aURI) {
    return Ci.nsIAboutModule.ALLOW_SCRIPT;
  },
  
  newChannel: function(aURI) {
    let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    let channel = ios.newChannel("chrome://browser/content/aboutSITENAME.xhtml",
                                 null, null);
    channel.originalURI = aURI;
    return channel;
  }
};

function NSGetModule(compMgr, fileSpec)
  XPCOMUtils.generateModule([AboutSITENAME]);

After that, you should edit the Manifest file and add:

EXTRA_PP_COMPONENTS = \
      aboutSITENAME.js \
    $(NULL)

 

Revision Source

<p>For creating an own about: URL, you have to use the following template to create aboutSITENAME.js . You have to replace SITENAME with your chosen name for the URL. You're URL will be "about:SITENAME". Also you'll have to generate an own UUID for your page and replace YOUR-UUID with it.</p>
<pre>const Cc = Components.classes;
const Ci = Components.interfaces;

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

function AboutSITENAME() { }
AboutSITENAME.prototype = {
  classDescription: "about:SITENAME",
  contractID: "@mozilla.org/network/protocol/about;1?what=SITENAME",
  classID: Components.ID("{YOUR-UUID}"),
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
  
  getURIFlags: function(aURI) {
    return Ci.nsIAboutModule.ALLOW_SCRIPT;
  },
  
  newChannel: function(aURI) {
    let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
    let channel = ios.newChannel("chrome://browser/content/aboutSITENAME.xhtml",
                                 null, null);
    channel.originalURI = aURI;
    return channel;
  }
};

function NSGetModule(compMgr, fileSpec)
  XPCOMUtils.generateModule([AboutSITENAME]);
</pre>
<p>After that, you should edit the Manifest file and add:</p>
<pre>EXTRA_PP_COMPONENTS = \
      aboutSITENAME.js \
    $(NULL)
</pre>
<p> </p>
Revert to this revision