Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Starting with Firefox 4 you should be using the <a href="https://developer.mozilla.org/en/Addons/Add-on_Manager/AddonManager" rel="nofollow">Add-on Manager API</a>:</p> <pre class="lang-js prettyprint-override"><code>Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAddonByID(id, function(addon) { var uri = addon.getResourceURI("config.json"); if (uri instanceof Components.interfaces.nsIFileURL) writeToFile(uri.file); }); </code></pre> <p>Note that the new API is asynchronous, fetching the data about an extension can take time. Also, you would need to specify <a href="https://developer.mozilla.org/en/Install_Manifests#unpack" rel="nofollow"><code>&lt;em:unpack&gt;true&lt;/em:unpack&gt;</code> flag</a> in your <code>install.rdf</code>, otherwise your extension will not be unpacked upon installation (for performance reasons) and there will be no file on disk corresponding to <code>config.json</code> (it will rather be a location inside the packed XPI file). There is another issue with writing to the extension directory: all the files there will be replaced when the extension is updated. A better idea might be writing to a file in the profile directory, then you won't need to sacrifice performance.</p> <p>Writing to a file can be simplified using <a href="https://developer.mozilla.org/en/JavaScript_code_modules/FileUtils.jsm" rel="nofollow">FileUtils.jsm</a>:</p> <pre class="lang-js prettyprint-override"><code>Components.utils.import("resource://gre/modules/FileUtils.jsm"); var stream = FileOutputStream.openFileOutputStream(file, FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE); stream.write(data, data.length); stream.close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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