Available in userscripts ✔️
Available in popup scripts ✔️
Required manifest permissions None


Allows addons to get information about themselves or the browser.


Using addon.self.dir

With addon.self.dir, we can get the URL to an image inside the addon’s directory.

  const img = document.createElement("img");
  img.src = addon.self.dir + "/image.svg"; 
  // Will be something like `chrome-extension://aeepldbjfoihffgcaejikpoeppffnlbd/addons/addon-id/image.svg`

Using addon.self.disabled and events (dynamicDisable)

We use the disabled and reenabled events to hide the image when the addon is disabled, without requiring the user to refresh the page.
We also use addon.self.disabled inside an event listener to avoid running code while the addon is disabled.
This example requires {"dynamicDisable": true} in the manifest.

  addon.self.addEventListener("disabled", () => = "visible");
  addon.self.addEventListener("reenabled", () => = "hidden");

  img.onclick = () => {
    if (addon.self.disabled) return;
    // Code starting here will only run if the image is visible


Type String
Nullable No

The addon ID for this addon.
The addon ID is the name of the directory inside /addons that identifies the addon.


Type String
Nullable No

Path to the addon’s directory, without trailing slash.
Should be used instead of hardcoding URLs. Locally, using a hardcoded URL like chrome-extension://aeepldbjfoihffgcaejikpoeppffnlbd/addons/full-signature/happen.js might appear to work properly, but the extension ID can change and it will not work in Firefox.


Type String
Nullable No

Path to the /libraries directory, without trailing slash.


Value "chrome" | "firefox"
Nullable No

The browser Scratch Addons is running on.


Type Boolean
Nullable No

Whether the addon is currently disabled or not.
Useful for returning early in event listeners for addons that support dynamicDisable.


Type Boolean
Nullable No

Whether the running userscript was injected dynamically in response to the user enabling the addon.
Can only be true if the addon supports dynamicEnable.
If the addon was enabled when the page loaded, then was disabled and reenabled, this will still be false. In that case, the reenabled event will fire.



Parameter Type Required Description
tag String No The tag for filtering.
Return value Promise<string[]>

Gets a list of addon IDs enabled, optionally filtered using tags.



Fires when the addon gets disabled.
Requires the dynamicDisable manifest property.


Fires when the addon gets reenabled, after being disabled.

Last updated at 16 January 2022 by lisa-wolfgang on commit 9df7a19. Improve this page.