Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a semi-documented way of getting the URLs of the SDK code modules. This involves low-level modules which aren't guaranteed to stay stable. In fact, it is very likely that this part of the SDK will change and this solution won't work any more (like the solution originally presented here).</p> <p>That said, the SDK allows you to access the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/_loader" rel="nofollow"><code>loader</code> module</a>. So first you need to <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/_loader" rel="nofollow">construct a loader with the same options as the one used by the SDK</a>. Then you need to use the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/_loader" rel="nofollow"><code>resolveURI</code> utility function</a> to resolve the module name using the mapping of this loader:</p> <pre class="lang-js prettyprint-override"><code>var {Loader, resolveURI} = require('toolkit/loader'); var options = require('@loader/options'); var loader = Loader(options); var fooURI = resolveURI("./foo", loader.mapping); </code></pre> <p>The code above generates the URL for the module <code>foo</code>. Note that you need to use the module <code>foo</code> somewhere, otherwise it won't be included in your extension. If you don't use it yet then a dummy function will be sufficient:</p> <pre class="lang-js prettyprint-override"><code>function dummy() { require("foo"); } </code></pre> <p>Using the resulting URL as content script works just fine:</p> <pre class="lang-js prettyprint-override"><code>var pageMod = require("page-mod"); pageMod.PageMod({ include: "*.google.com", contentScriptWhen: 'end', contentScriptFile: [fooURI, ...] }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload