From 3ad5590d902b46eb1db6c884c3f9f10f866117e4 Mon Sep 17 00:00:00 2001 From: Peter Harpending Date: Tue, 7 Feb 2023 21:50:28 -0700 Subject: [PATCH] [wip] jr model --- jrx/dist/popup.js | 4 - jrx/dist/popup.js.map | 2 +- jrx/dist/storage/impure.d.ts | 10 + jrx/dist/storage/impure.js | 16 + jrx/dist/storage/impure.js.map | 1 + jrx/dist/storage/model.d.ts | 0 jrx/dist/storage/model.js | 41 + jrx/dist/storage/model.js.map | 1 + jrx/notes.txt | 19 + jrx/src/background.ts | 7 + jrx/src/content.ts | 22 +- jrx/src/model/model.ts | 40 - jrx/src/popup.ts | 4 - jrx/src/types/firefox-webext-browser.d.ts | 9264 +++++++++++++++++++++ jrx/src/types/nacl.d.ts | 98 + 15 files changed, 9469 insertions(+), 60 deletions(-) create mode 100644 jrx/dist/storage/impure.d.ts create mode 100644 jrx/dist/storage/impure.js create mode 100644 jrx/dist/storage/impure.js.map create mode 100644 jrx/dist/storage/model.d.ts create mode 100644 jrx/dist/storage/model.js create mode 100644 jrx/dist/storage/model.js.map create mode 100644 jrx/src/background.ts delete mode 100644 jrx/src/model/model.ts create mode 100644 jrx/src/types/firefox-webext-browser.d.ts create mode 100644 jrx/src/types/nacl.d.ts diff --git a/jrx/dist/popup.js b/jrx/dist/popup.js index 475dd7e..88e12c9 100644 --- a/jrx/dist/popup.js +++ b/jrx/dist/popup.js @@ -20,7 +20,6 @@ async function main() { */ async function detuctable() { let ati = await active_tab_id(); - // @ts-ignore browser api unknown browser.tabs.sendMessage(ati, // active tab 'mk-detectable'); // message // @ts-ignore disabled exists on this @@ -31,7 +30,6 @@ async function detuctable() { * gets the id of the current tab */ async function active_tab_id() { - // @ts-ignore browser api unkown let active_tabs = await browser.tabs.query({ active: true, currentWindow: true }); return active_tabs[0].id; } @@ -44,7 +42,6 @@ async function relist_keypairs() { // delete all list items pfizer(document.getElementById('keypairs')); // look for keypairs then relist - // @ts-ignore browser api let obj = await browser.storage.local.get('keypairs'); await handle_keypairs(obj); } @@ -117,7 +114,6 @@ function no_keypairs() { */ async function generate_keypair() { logln('generating a keypair'); - // @ts-ignore namespace nacl let keypair = nacl.sign.keyPair(); // @ts-ignore changing type keypair.name = "Untitled Keypair 1"; diff --git a/jrx/dist/popup.js.map b/jrx/dist/popup.js.map index 71a2985..a10ef86 100644 --- a/jrx/dist/popup.js.map +++ b/jrx/dist/popup.js.map @@ -1 +1 @@ -{"version":3,"file":"popup.js","sourceRoot":"","sources":["../src/popup.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,4CAA4C;AAE5C,IAAI,EAAE,CAAC;AAEP;;GAEG;AACH,KAAK,UACL,IAAI;IAIA,uBAAuB;IACvB,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAE,CAAC,OAAO,GAAG,UAAU,CAAC;IAC/D,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAE,CAAC,OAAO,GAAG,gBAAgB,CAAC;IAEhE,kBAAkB;IAClB,iCAAiC;IACjC,MAAM,eAAe,EAAE,CAAC;AAC5B,CAAC;AAID;;GAEG;AACH,KAAK,UACL,UAAU;IAIN,IAAI,GAAG,GAAG,MAAM,aAAa,EAAE,CAAC;IAChC,iCAAiC;IACjC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAgB,aAAa;IAChC,eAAe,CAAC,CAAC,CAAE,UAAU;IACtD,qCAAqC;IACrC,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzD,wCAAwC;AAC5C,CAAC;AAGD;;GAEG;AACH,KAAK,UACL,aAAa;IAIT,gCAAgC;IAChC,IAAI,WAAW,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC;IAChF,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7B,CAAC;AAGD;;;;GAIG;AAC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storage/impure.d.ts new file mode 100644 index 0000000..2f33f4a --- /dev/null +++ b/jrx/dist/storage/impure.d.ts @@ -0,0 +1,10 @@ +/** + * Impure storage API + * + * This code is responsible for + * + * - fetching the program state from storage + * - putting the program state into storage + * + * @module + */ diff --git a/jrx/dist/storage/impure.js b/jrx/dist/storage/impure.js new file mode 100644 index 0000000..b509c71 --- /dev/null +++ b/jrx/dist/storage/impure.js @@ -0,0 +1,16 @@ +"use strict"; +/** + * Impure storage API + * + * This code is responsible for + * + * - fetching the program state from storage + * - putting the program state into storage + * + * @module + */ +//export { +// fetch_, +// fetch_migrate +//}; +//# sourceMappingURL=impure.js.map \ No newline at end of file diff --git a/jrx/dist/storage/impure.js.map b/jrx/dist/storage/impure.js.map new file mode 100644 index 0000000..492067e --- /dev/null +++ b/jrx/dist/storage/impure.js.map @@ -0,0 +1 @@ +{"version":3,"file":"impure.js","sourceRoot":"","sources":["../../src/storage/impure.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,UAAU;AACV,aAAa;AACb,mBAAmB;AACnB,IAAI"} \ No newline at end of file diff --git a/jrx/dist/storage/model.d.ts b/jrx/dist/storage/model.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/jrx/dist/storage/model.js b/jrx/dist/storage/model.js new file mode 100644 index 0000000..bbeeaff --- /dev/null +++ b/jrx/dist/storage/model.js @@ -0,0 +1,41 @@ +"use strict"; +/* idea: versioned state + * + * there is a version 0 state + * + * each state migration contains a migration from the previous version to the + * new version + * + * laws: + * + * - all version N states must map to valid version N+1 states + * + */ +//export { +// jr_version, +// jr_state +//}; +// +//let jr_version = 0; +// +///** +// * current state type for current version +// */ +//type jr_state = jr_0_state; +// +///** +// * All jr state types, historically +// */ +//type jr_n_state +// = jr_0_state; +// +///** +// * This is the version 0 state +// */ +//type jr_0_state +// = {version : 0, +// keypair : keypair}; +// +//type keypair +// = {secretKey: Uint8Array +//# sourceMappingURL=model.js.map \ No newline at end of file diff --git a/jrx/dist/storage/model.js.map b/jrx/dist/storage/model.js.map new file mode 100644 index 0000000..ea992fe --- /dev/null +++ b/jrx/dist/storage/model.js.map @@ -0,0 +1 @@ +{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/storage/model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;AAEH,UAAU;AACV,iBAAiB;AACjB,cAAc;AACd,IAAI;AACJ,EAAE;AACF,qBAAqB;AACrB,EAAE;AACF,KAAK;AACL,2CAA2C;AAC3C,KAAK;AACL,6BAA6B;AAC7B,EAAE;AACF,KAAK;AACL,qCAAqC;AACrC,KAAK;AACL,iBAAiB;AACjB,mBAAmB;AACnB,EAAE;AACF,KAAK;AACL,gCAAgC;AAChC,KAAK;AACL,iBAAiB;AACjB,qBAAqB;AACrB,4BAA4B;AAC5B,EAAE;AACF,cAAc;AACd,8BAA8B"} \ No newline at end of file diff --git a/jrx/notes.txt b/jrx/notes.txt index 8bfddf7..e2fd419 100644 --- a/jrx/notes.txt +++ b/jrx/notes.txt @@ -10,3 +10,22 @@ content.js - this is basically a process that background script + + +------------------------------------------------ + +-> background + -> controller + -> "impure component" + -> fetching data + -> writing to disk + -> "pure component" + -> business logic + -> migrating data from version N to version N+1 + -> all allowable mutations to the data within a specific version +-> content script + - talking to page scripts + - intermediary between the background script and a page script + - raseev requests + - send responses back to page +- diff --git a/jrx/src/background.ts b/jrx/src/background.ts new file mode 100644 index 0000000..5ffe9f9 --- /dev/null +++ b/jrx/src/background.ts @@ -0,0 +1,7 @@ +/** + * JR Controller + * + * @module + */ + + diff --git a/jrx/src/content.ts b/jrx/src/content.ts index 199318c..73431e1 100644 --- a/jrx/src/content.ts +++ b/jrx/src/content.ts @@ -1,15 +1,15 @@ -let detect_msg = - {id : "urmom", - name : "JR", - networkId : "ae_uat", - origin : "ur dads balls", - type : "extension"}; +let detect_msg + = {id : "urmom", + name : "JR", + networkId : "ae_uat", + origin : "ur dads balls", + type : "extension"}; -let detect_awcp_msg = - {type: "to_aepp", - data: {jsonrpc: "2.0", - method: "connection.announcePresence", - params: detect_msg}}; +let detect_awcp_msg + = {type : "to_aepp", + data : {jsonrpc : "2.0", + method : "connection.announcePresence", + params : detect_msg}}; diff --git a/jrx/src/model/model.ts b/jrx/src/model/model.ts deleted file mode 100644 index 8a1048f..0000000 --- a/jrx/src/model/model.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* idea: versioned state - * - * there is a version 0 state - * - * each state migration contains a migration from the previous version to the - * new version - * - * laws: - * - * - all version N states must map to valid version N+1 states - * - */ - -export { - jr_version, - jr_state -}; - -let jr_version = 0; - -/** - * current state type for current version - */ -type jr_state = jr_0_state; - -/** - * All jr state types, historically - */ -type jr_n_state - = jr_0_state; - -/** - * This is the version 0 state - */ -type jr_0_state - = {version : 0, - keypair : keypair}; - -type keypair - = {secretKey: Uint8Array diff --git a/jrx/src/popup.ts b/jrx/src/popup.ts index 89a305d..f56f4dc 100644 --- a/jrx/src/popup.ts +++ b/jrx/src/popup.ts @@ -34,7 +34,6 @@ detuctable : Promise { let ati = await active_tab_id(); - // @ts-ignore browser api unknown browser.tabs.sendMessage(ati, // active tab 'mk-detectable'); // message // @ts-ignore disabled exists on this @@ -51,7 +50,6 @@ active_tab_id () : Promise { - // @ts-ignore browser api unkown let active_tabs = await browser.tabs.query({active: true, currentWindow: true}); return active_tabs[0].id; } @@ -70,7 +68,6 @@ relist_keypairs // delete all list items pfizer(document.getElementById('keypairs')!); // look for keypairs then relist - // @ts-ignore browser api let obj = await browser.storage.local.get('keypairs'); await handle_keypairs(obj); } @@ -174,7 +171,6 @@ generate_keypair : Promise { logln('generating a keypair'); - // @ts-ignore namespace nacl let keypair : keypair = nacl.sign.keyPair(); // @ts-ignore changing type keypair.name = "Untitled Keypair 1"; diff --git a/jrx/src/types/firefox-webext-browser.d.ts b/jrx/src/types/firefox-webext-browser.d.ts new file mode 100644 index 0000000..bd9c402 --- /dev/null +++ b/jrx/src/types/firefox-webext-browser.d.ts @@ -0,0 +1,9264 @@ +// Type definitions for non-npm package WebExtension Development in FireFox 109.0 +// Project: https://developer.mozilla.org/en-US/Add-ons/WebExtensions +// Definitions by: Jasmin Bom +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.4 +// Generated using script at github.com/jsmnbom/definitelytyped-firefox-webext-browser + +interface WebExtEvent any> { + addListener(cb: TCallback): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; +} + +/** Not allowed in: Content scripts, Devtools pages */ +declare namespace browser._manifest { + /* _manifest types */ + type PermissionPrivileged = _PermissionPrivileged; + + interface ActionManifest { + default_title?: string | undefined; + default_icon?: IconPath | undefined; + /** Specifies icons to use for dark and light themes */ + theme_icons?: ThemeIcons[] | undefined; + default_popup?: string | undefined; + browser_style?: boolean | undefined; + /** Defines the location the browserAction will appear by default. The default location is navbar. */ + default_area?: _ActionManifestDefaultArea | undefined; + } + + /** Represents a WebExtension manifest.json file */ + interface WebExtensionManifest { + /** Needs at least manifest version 3. */ + action?: ActionManifest | undefined; + /** Not supported on manifest versions above 2. */ + browser_action?: ActionManifest | undefined; + /** Needs at least manifest version 3. */ + declarative_net_request?: _WebExtensionManifestDeclarativeNetRequest | undefined; + experiment_apis?: { [key: string]: experiments.ExperimentAPI } | undefined; + /** A list of protocol handler definitions. */ + protocol_handlers?: ProtocolHandler[] | undefined; + default_locale?: string | undefined; + l10n_resources?: string[] | undefined; + minimum_chrome_version?: string | undefined; + minimum_opera_version?: string | undefined; + icons?: _WebExtensionManifestIcons | undefined; + incognito?: _WebExtensionManifestIncognito | undefined; + background?: + | { + page: ExtensionURL; + /** Not supported on manifest versions above 2. */ + persistent?: boolean | undefined; + } + | { + scripts: ExtensionURL[]; + /** Not supported on manifest versions above 2. */ + persistent?: boolean | undefined; + } + | { + service_worker: ExtensionURL; + } + | undefined; + options_ui?: _WebExtensionManifestOptionsUi | undefined; + content_scripts?: ContentScript[] | undefined; + content_security_policy?: + | string + | { + /** The Content Security Policy used for extension pages. */ + extension_pages?: string | undefined; + } + | undefined; + permissions?: PermissionOrOrigin[] | Permission[] | undefined; + granted_host_permissions?: boolean | undefined; + /** Needs at least manifest version 3. */ + host_permissions?: MatchPattern[] | undefined; + optional_permissions?: OptionalPermissionOrOrigin[] | undefined; + web_accessible_resources?: + | string[] + | Array<{ + resources: string[]; + matches?: MatchPattern[] | undefined; + extension_ids?: Array | undefined; + }> + | undefined; + hidden?: boolean | undefined; + page_action?: _WebExtensionManifestPageAction | undefined; + telemetry?: _WebExtensionManifestTelemetry | undefined; + theme_experiment?: ThemeExperiment | undefined; + /** Not supported on manifest versions above 2. */ + user_scripts?: _WebExtensionManifestUserScripts | undefined; + chrome_settings_overrides?: _WebExtensionManifestChromeSettingsOverrides | undefined; + commands?: { [key: string]: _WebExtensionManifestCommands } | undefined; + devtools_page?: ExtensionURL | undefined; + omnibox?: _WebExtensionManifestOmnibox | undefined; + sidebar_action?: _WebExtensionManifestSidebarAction | undefined; + chrome_url_overrides?: _WebExtensionManifestChromeUrlOverrides | undefined; + manifest_version: number; + /** + * The applications property is deprecated, please use 'browser_specific_settings' + * Not supported on manifest versions above 2. + */ + applications?: BrowserSpecificSettings | undefined; + browser_specific_settings?: BrowserSpecificSettings | undefined; + name: string; + short_name?: string | undefined; + description?: string | undefined; + author?: string | undefined; + version: string; + homepage_url?: string | undefined; + install_origins?: string[] | undefined; + developer?: _WebExtensionManifestDeveloper | undefined; + } + + type OptionalPermission = OptionalPermissionNoPrompt | _OptionalPermission; + + type PermissionNoPrompt = OptionalPermissionNoPrompt | PermissionPrivileged | _PermissionNoPrompt; + + type OptionalPermissionNoPrompt = _OptionalPermissionNoPrompt; + + type Permission = string | PermissionNoPrompt | OptionalPermission | 'declarativeNetRequest'; + + /** Represents a protocol handler definition. */ + interface ProtocolHandler { + /** + * A user-readable title string for the protocol handler. This will be displayed to the user in interface objects as needed. + */ + name: string; + /** + * The protocol the site wishes to handle, specified as a string. For example, you can register to handle SMS text message links by registering to handle the "sms" scheme. + */ + protocol: string | _ProtocolHandlerProtocol; + /** + * The URL of the handler, as a string. This string should include "%s" as a placeholder which will be replaced with the escaped URL of the document to be handled. This URL might be a true URL, or it could be a phone number, email address, or so forth. + */ + uriTemplate: ExtensionURL | HttpURL; + } + + /** Common properties for all manifest.json files */ + interface ManifestBase { + manifest_version: number; + /** + * The applications property is deprecated, please use 'browser_specific_settings' + * Not supported on manifest versions above 2. + */ + applications?: BrowserSpecificSettings | undefined; + browser_specific_settings?: BrowserSpecificSettings | undefined; + name: string; + short_name?: string | undefined; + description?: string | undefined; + author?: string | undefined; + version: string; + homepage_url?: string | undefined; + install_origins?: string[] | undefined; + developer?: _ManifestBaseDeveloper | undefined; + } + + /** Represents a WebExtension language pack manifest.json file */ + interface WebExtensionLangpackManifest { + homepage_url?: string | undefined; + langpack_id: string; + languages: _WebExtensionLangpackManifestLanguages; + sources?: _WebExtensionLangpackManifestSources | undefined; + manifest_version: number; + /** + * The applications property is deprecated, please use 'browser_specific_settings' + * Not supported on manifest versions above 2. + */ + applications?: BrowserSpecificSettings | undefined; + browser_specific_settings?: BrowserSpecificSettings | undefined; + name: string; + short_name?: string | undefined; + description?: string | undefined; + author?: string | undefined; + version: string; + install_origins?: string[] | undefined; + developer?: _WebExtensionLangpackManifestDeveloper | undefined; + } + + /** Represents a WebExtension dictionary manifest.json file */ + interface WebExtensionDictionaryManifest { + homepage_url?: string | undefined; + dictionaries: _WebExtensionDictionaryManifestDictionaries; + manifest_version: number; + /** + * The applications property is deprecated, please use 'browser_specific_settings' + * Not supported on manifest versions above 2. + */ + applications?: BrowserSpecificSettings | undefined; + browser_specific_settings?: BrowserSpecificSettings | undefined; + name: string; + short_name?: string | undefined; + description?: string | undefined; + author?: string | undefined; + version: string; + install_origins?: string[] | undefined; + developer?: _WebExtensionDictionaryManifestDeveloper | undefined; + } + + /** Represents a WebExtension site permissions manifest.json file */ + interface WebExtensionSitePermissionsManifest { + site_permissions: SitePermission[]; + install_origins?: [string] | undefined; + manifest_version: number; + /** + * The applications property is deprecated, please use 'browser_specific_settings' + * Not supported on manifest versions above 2. + */ + applications?: BrowserSpecificSettings | undefined; + browser_specific_settings?: BrowserSpecificSettings | undefined; + name: string; + short_name?: string | undefined; + description?: string | undefined; + author?: string | undefined; + version: string; + homepage_url?: string | undefined; + developer?: _WebExtensionSitePermissionsManifestDeveloper | undefined; + } + + interface ThemeIcons { + /** A light icon to use for dark themes */ + light: ExtensionURL; + /** The dark icon to use for light themes */ + dark: ExtensionURL; + /** The size of the icons */ + size: number; + } + + type OptionalPermissionOrOrigin = OptionalPermission | MatchPattern; + + type PermissionOrOrigin = Permission | MatchPattern; + + type SitePermission = _SitePermission; + + type HttpURL = string; + + type ExtensionURL = string; + + type ExtensionFileUrl = string; + + type ImageDataOrExtensionURL = string; + + type ExtensionID = string; + + interface FirefoxSpecificProperties { + id?: ExtensionID | undefined; + update_url?: string | undefined; + strict_min_version?: string | undefined; + strict_max_version?: string | undefined; + } + + interface BrowserSpecificSettings { + gecko?: FirefoxSpecificProperties | undefined; + } + + type MatchPattern = MatchPatternRestricted | MatchPatternUnestricted | ''; + + /** Same as MatchPattern above, but excludes */ + type MatchPatternRestricted = string; + + /** + * Mostly unrestricted match patterns for privileged add-ons. This should technically be rejected for unprivileged add-ons, but, reasons. The MatchPattern class will still refuse privileged schemes for those extensions. + */ + type MatchPatternUnestricted = string; + + /** + * Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. Based on InjectDetails, but using underscore rather than camel case naming conventions. + */ + interface ContentScript { + matches: MatchPattern[]; + exclude_matches?: MatchPattern[] | undefined; + include_globs?: string[] | undefined; + exclude_globs?: string[] | undefined; + /** The list of CSS files to inject */ + css?: ExtensionURL[] | undefined; + /** The list of JS files to inject */ + js?: ExtensionURL[] | undefined; + /** + * If allFrames is `true`, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's `false` and is only injected into the top frame. + */ + all_frames?: boolean | undefined; + /** + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is `false`. + */ + match_about_blank?: boolean | undefined; + /** The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle". */ + run_at?: extensionTypes.RunAt | undefined; + } + + type IconPath = + | { + [key: number]: ExtensionFileUrl; + } + | ExtensionFileUrl; + + type IconImageData = + | { + [key: number]: ImageData; + } + | ImageData; + + type ImageData = any; + + /** @deprecated An unexpected property was found in the WebExtension manifest. */ + type UnrecognizedProperty = any; + + /** Represents a native manifest file */ + type NativeManifest = + | { + name: string; + description: string; + path: string; + type: 'pkcs11' | 'stdio'; + allowed_extensions: ExtensionID[]; + } + | { + name: ExtensionID; + description: string; + data: { [key: string]: any }; + type: 'storage'; + }; + + type ThemeColor = string | [number, number, number] | [number, number, number, number]; + + interface ThemeExperiment { + stylesheet?: ExtensionURL | undefined; + images?: { [key: string]: string } | undefined; + colors?: { [key: string]: string } | undefined; + properties?: { [key: string]: string } | undefined; + } + + interface ThemeType { + images?: _ThemeTypeImages | undefined; + colors?: _ThemeTypeColors | undefined; + properties?: _ThemeType | undefined; + } + + /** Contents of manifest.json for a static theme */ + interface ThemeManifest { + theme: ThemeType; + dark_theme?: ThemeType | undefined; + default_locale?: string | undefined; + theme_experiment?: ThemeExperiment | undefined; + icons?: _ThemeManifestIcons | undefined; + } + + type KeyName = string; + + type _PermissionPrivileged = + | 'activityLog' + | 'mozillaAddons' + | 'networkStatus' + | 'telemetry' + | 'normandyAddonStudy' + | 'urlbar'; + + /** Defines the location the browserAction will appear by default. The default location is navbar. */ + type _ActionManifestDefaultArea = 'navbar' | 'menupanel' | 'tabstrip' | 'personaltoolbar'; + + interface _WebExtensionManifestDeclarativeNetRequestRuleResources { + /** + * A non-empty string uniquely identifying the ruleset. IDs beginning with '_' are reserved for internal use. + */ + id: string; + /** Whether the ruleset is enabled by default. */ + enabled: boolean; + /** The path of the JSON ruleset relative to the extension directory. */ + path: ExtensionURL; + } + + /** Needs at least manifest version 3. */ + interface _WebExtensionManifestDeclarativeNetRequest { + rule_resources: _WebExtensionManifestDeclarativeNetRequestRuleResources[]; + } + + interface _WebExtensionManifestIcons { + [key: number]: ExtensionFileUrl; + } + + type _WebExtensionManifestIncognito = 'not_allowed' | 'spanning'; + + interface _WebExtensionManifestOptionsUi { + page: ExtensionURL; + browser_style?: boolean | undefined; + chrome_style?: boolean | undefined; + open_in_tab?: boolean | undefined; + } + + interface _WebExtensionManifestPageAction { + default_title?: string | undefined; + default_icon?: IconPath | undefined; + default_popup?: string | undefined; + browser_style?: boolean | undefined; + show_matches?: MatchPattern[] | undefined; + hide_matches?: MatchPatternRestricted[] | undefined; + pinned?: boolean | undefined; + } + + interface _WebExtensionManifestTelemetryPublicKeyKey { + crv?: string | undefined; + kty?: string | undefined; + x?: string | undefined; + y?: string | undefined; + } + + interface _WebExtensionManifestTelemetryPublicKey { + id: string; + key: _WebExtensionManifestTelemetryPublicKeyKey; + } + + interface _WebExtensionManifestTelemetry { + ping_type: string; + schemaNamespace: string; + public_key: _WebExtensionManifestTelemetryPublicKey; + study_name?: string | undefined; + pioneer_id?: boolean | undefined; + } + + /** Not supported on manifest versions above 2. */ + interface _WebExtensionManifestUserScripts { + api_script?: ExtensionURL | undefined; + } + + /** The type of param can be either "purpose" or "pref". */ + type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition = 'purpose' | 'pref'; + + /** The context that initiates a search, required if condition is "purpose". */ + type _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose = + | 'contextmenu' + | 'searchbar' + | 'homepage' + | 'keyword' + | 'newtab'; + + interface _WebExtensionManifestChromeSettingsOverridesSearchProviderParams { + /** A url parameter name */ + name: string; + /** The type of param can be either "purpose" or "pref". */ + condition?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsCondition | undefined; + /** The preference to retrieve the value from. */ + pref?: string | undefined; + /** The context that initiates a search, required if condition is "purpose". */ + purpose?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParamsPurpose | undefined; + /** A url parameter value. */ + value?: string | undefined; + } + + interface _WebExtensionManifestChromeSettingsOverridesSearchProvider { + name: string; + keyword?: string | string[] | undefined; + search_url: string; + favicon_url?: string | undefined; + suggest_url?: string | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + instant_url?: string | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + image_url?: string | undefined; + /** GET parameters to the search_url as a query string. */ + search_url_get_params?: string | undefined; + /** POST parameters to the search_url as a query string. */ + search_url_post_params?: string | undefined; + /** GET parameters to the suggest_url as a query string. */ + suggest_url_get_params?: string | undefined; + /** POST parameters to the suggest_url as a query string. */ + suggest_url_post_params?: string | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + instant_url_post_params?: string | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + image_url_post_params?: string | undefined; + search_form?: string | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + alternate_urls?: string[] | undefined; + /** @deprecated Unsupported on Firefox. */ + prepopulated_id?: number | undefined; + /** Encoding of the search term. */ + encoding?: string | undefined; + /** Sets the default engine to a built-in engine only. */ + is_default?: boolean | undefined; + /** + * A list of optional search url parameters. This allows the additon of search url parameters based on how the search is performed in Firefox. + */ + params?: _WebExtensionManifestChromeSettingsOverridesSearchProviderParams[] | undefined; + } + + interface _WebExtensionManifestChromeSettingsOverrides { + homepage?: string | undefined; + search_provider?: _WebExtensionManifestChromeSettingsOverridesSearchProvider | undefined; + } + + interface _WebExtensionManifestCommandsSuggestedKey { + default?: KeyName | undefined; + mac?: KeyName | undefined; + linux?: KeyName | undefined; + windows?: KeyName | undefined; + chromeos?: string | undefined; + android?: string | undefined; + ios?: string | undefined; + /** @deprecated Unknown platform name */ + additionalProperties?: string | undefined; + } + + interface _WebExtensionManifestCommands { + suggested_key?: _WebExtensionManifestCommandsSuggestedKey | undefined; + description?: string | undefined; + } + + interface _WebExtensionManifestOmnibox { + keyword: string; + } + + interface _WebExtensionManifestSidebarAction { + default_title?: string | undefined; + default_icon?: IconPath | undefined; + browser_style?: boolean | undefined; + default_panel: string; + /** Whether or not the sidebar is opened at install. Default is `true`. */ + open_at_install?: boolean | undefined; + } + + interface _WebExtensionManifestChromeUrlOverrides { + newtab?: ExtensionURL | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + bookmarks?: ExtensionURL | undefined; + /** @deprecated Unsupported on Firefox at this time. */ + history?: ExtensionURL | undefined; + } + + interface _WebExtensionManifestDeveloper { + name?: string | undefined; + url?: string | undefined; + } + + type _OptionalPermission = + | 'browserSettings' + | 'browsingData' + | 'downloads' + | 'downloads.open' + | 'management' + | 'clipboardRead' + | 'clipboardWrite' + | 'geolocation' + | 'notifications' + | 'privacy' + | 'proxy' + | 'nativeMessaging' + | 'webNavigation' + | 'bookmarks' + | 'devtools' + | 'find' + | 'history' + | 'pkcs11' + | 'sessions' + | 'tabs' + | 'tabHide' + | 'topSites'; + + type _PermissionNoPrompt = + | 'captivePortal' + | 'contextualIdentities' + | 'declarativeNetRequestFeedback' + | 'declarativeNetRequestWithHostAccess' + | 'dns' + | 'geckoProfiler' + | 'identity' + | 'alarms' + | 'storage' + | 'unlimitedStorage' + | 'theme' + | 'menus' + | 'contextMenus'; + + type _OptionalPermissionNoPrompt = + | 'cookies' + | 'idle' + | 'scripting' + | 'webRequest' + | 'webRequestBlocking' + | 'webRequestFilterResponse.serviceWorkerScript' + | 'menus.overrideContext' + | 'search' + | 'activeTab'; + + type _ProtocolHandlerProtocol = + | 'bitcoin' + | 'dat' + | 'dweb' + | 'ftp' + | 'geo' + | 'gopher' + | 'im' + | 'ipfs' + | 'ipns' + | 'irc' + | 'ircs' + | 'magnet' + | 'mailto' + | 'matrix' + | 'mms' + | 'news' + | 'nntp' + | 'sip' + | 'sms' + | 'smsto' + | 'ssb' + | 'ssh' + | 'tel' + | 'urn' + | 'webcal' + | 'wtai' + | 'xmpp'; + + interface _ManifestBaseDeveloper { + name?: string | undefined; + url?: string | undefined; + } + + interface _UndefinedChromeResources { + [key: string]: + | ExtensionURL + | { + [key: string]: ExtensionURL; + }; + } + + interface _WebExtensionLangpackManifestLanguages { + [key: string]: { + chrome_resources: _UndefinedChromeResources; + version: string; + }; + } + + interface _WebExtensionLangpackManifestSources { + [key: string]: { + base_path: ExtensionURL; + paths?: string[] | undefined; + }; + } + + interface _WebExtensionLangpackManifestDeveloper { + name?: string | undefined; + url?: string | undefined; + } + + interface _WebExtensionDictionaryManifestDictionaries { + [key: string]: string; + } + + interface _WebExtensionDictionaryManifestDeveloper { + name?: string | undefined; + url?: string | undefined; + } + + interface _WebExtensionSitePermissionsManifestDeveloper { + name?: string | undefined; + url?: string | undefined; + } + + type _SitePermission = 'midi' | 'midi-sysex'; + + interface _ThemeTypeImages { + additional_backgrounds?: ImageDataOrExtensionURL[] | undefined; + /** + * @deprecated Unsupported images property, use 'theme.images.theme_frame', this alias is ignored in Firefox >= 70. + */ + headerURL?: ImageDataOrExtensionURL | undefined; + theme_frame?: ImageDataOrExtensionURL | undefined; + } + + interface _ThemeTypeColors { + tab_selected?: ThemeColor | undefined; + /** + * @deprecated Unsupported colors property, use 'theme.colors.frame', this alias is ignored in Firefox >= 70. + */ + accentcolor?: ThemeColor | undefined; + frame?: ThemeColor | undefined; + frame_inactive?: ThemeColor | undefined; + /** + * @deprecated Unsupported color property, use 'theme.colors.tab_background_text', this alias is ignored in Firefox >= 70. + */ + textcolor?: ThemeColor | undefined; + tab_background_text?: ThemeColor | undefined; + tab_background_separator?: ThemeColor | undefined; + tab_loading?: ThemeColor | undefined; + tab_text?: ThemeColor | undefined; + tab_line?: ThemeColor | undefined; + toolbar?: ThemeColor | undefined; + /** This color property is an alias of 'bookmark_text'. */ + toolbar_text?: ThemeColor | undefined; + bookmark_text?: ThemeColor | undefined; + toolbar_field?: ThemeColor | undefined; + toolbar_field_text?: ThemeColor | undefined; + toolbar_field_border?: ThemeColor | undefined; + /** @deprecated This color property is ignored in Firefox >= 89. */ + toolbar_field_separator?: ThemeColor | undefined; + toolbar_top_separator?: ThemeColor | undefined; + toolbar_bottom_separator?: ThemeColor | undefined; + toolbar_vertical_separator?: ThemeColor | undefined; + icons?: ThemeColor | undefined; + icons_attention?: ThemeColor | undefined; + button_background_hover?: ThemeColor | undefined; + button_background_active?: ThemeColor | undefined; + popup?: ThemeColor | undefined; + popup_text?: ThemeColor | undefined; + popup_border?: ThemeColor | undefined; + toolbar_field_focus?: ThemeColor | undefined; + toolbar_field_text_focus?: ThemeColor | undefined; + toolbar_field_border_focus?: ThemeColor | undefined; + popup_highlight?: ThemeColor | undefined; + popup_highlight_text?: ThemeColor | undefined; + ntp_background?: ThemeColor | undefined; + ntp_card_background?: ThemeColor | undefined; + ntp_text?: ThemeColor | undefined; + sidebar?: ThemeColor | undefined; + sidebar_border?: ThemeColor | undefined; + sidebar_text?: ThemeColor | undefined; + sidebar_highlight?: ThemeColor | undefined; + sidebar_highlight_text?: ThemeColor | undefined; + toolbar_field_highlight?: ThemeColor | undefined; + toolbar_field_highlight_text?: ThemeColor | undefined; + } + + type _ThemeTypeAdditionalBackgroundsAlignment = + | 'bottom' + | 'center' + | 'left' + | 'right' + | 'top' + | 'center bottom' + | 'center center' + | 'center top' + | 'left bottom' + | 'left center' + | 'left top' + | 'right bottom' + | 'right center' + | 'right top'; + + type _ThemeTypeAdditionalBackgroundsTiling = 'no-repeat' | 'repeat' | 'repeat-x' | 'repeat-y'; + + type _ThemeTypeColorScheme = 'auto' | 'light' | 'dark' | 'system'; + + type _ThemeTypeContentColorScheme = 'auto' | 'light' | 'dark' | 'system'; + + interface _ThemeType { + additional_backgrounds_alignment?: _ThemeTypeAdditionalBackgroundsAlignment[] | undefined; + additional_backgrounds_tiling?: _ThemeTypeAdditionalBackgroundsTiling[] | undefined; + color_scheme?: _ThemeTypeColorScheme | undefined; + content_color_scheme?: _ThemeTypeContentColorScheme | undefined; + } + + interface _ThemeManifestIcons { + [key: number]: string; + } +} + +/** + * Monitor extension activity + * + * Permissions: `activityLog` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.activityLog { + /** + * The type of log entry. api_call is a function call made by the extension and api_event is an event callback to the extension. content_script is logged when a content script is injected. + */ + type _OnExtensionActivityDetailsType = 'api_call' | 'api_event' | 'content_script' | 'user_script'; + + /** The type of view where the activity occurred. Content scripts will not have a viewType. */ + type _OnExtensionActivityDetailsViewType = + | 'background' + | 'popup' + | 'sidebar' + | 'tab' + | 'devtools_page' + | 'devtools_panel'; + + interface _OnExtensionActivityDetailsData { + /** A list of arguments passed to the call. */ + args?: any[] | undefined; + /** The result of the call. */ + result?: object | undefined; + /** The tab associated with this event if it is a tab or content script. */ + tabId?: number | undefined; + /** If the type is content_script, this is the url of the script that was injected. */ + url?: string | undefined; + } + + interface _OnExtensionActivityDetails { + /** The date string when this call is triggered. */ + timeStamp: extensionTypes.Date; + /** + * The type of log entry. api_call is a function call made by the extension and api_event is an event callback to the extension. content_script is logged when a content script is injected. + */ + type: _OnExtensionActivityDetailsType; + /** The type of view where the activity occurred. Content scripts will not have a viewType. */ + viewType?: _OnExtensionActivityDetailsViewType | undefined; + /** The name of the api call or event, or the script url if this is a content or user script event. */ + name: string; + data: _OnExtensionActivityDetailsData; + } + + interface _ActivityLogOnExtensionActivityEvent void> { + addListener(cb: TCallback, id: string): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + /* activityLog events */ + /** Receives an activityItem for each logging event. */ + const onExtensionActivity: _ActivityLogOnExtensionActivityEvent; +} + +/** + * Permissions: `alarms` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.alarms { + /* alarms types */ + interface Alarm { + /** Name of this alarm. */ + name: string; + /** Time when the alarm is scheduled to fire, in milliseconds past the epoch. */ + scheduledTime: number; + /** When present, signals that the alarm triggers periodically after so many minutes. */ + periodInMinutes?: number | undefined; + } + + /** + * Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead), or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided). Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided, then the alarm recurs repeatedly after that many minutes. + */ + interface _CreateAlarmInfo { + /** Time when the alarm is scheduled to first fire, in milliseconds past the epoch. */ + when?: number | undefined; + /** Number of minutes from the current time after which the alarm should first fire. */ + delayInMinutes?: number | undefined; + /** Number of minutes after which the alarm should recur repeatedly. */ + periodInMinutes?: number | undefined; + } + + /* alarms functions */ + /** + * Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. + * @param alarmInfo Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead), or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided). Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided, then the alarm recurs repeatedly after that many minutes. + */ + function create(alarmInfo: _CreateAlarmInfo): void; + /** + * Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm. + * @param name Optional name to identify this alarm. Defaults to the empty string. + * @param alarmInfo Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead), or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided). Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided, then the alarm recurs repeatedly after that many minutes. + */ + function create(name: string, alarmInfo: _CreateAlarmInfo): void; + + /** + * Retrieves details about the specified alarm. + * @param [name] The name of the alarm to get. Defaults to the empty string. + */ + function get(name?: string): Promise; + + /** Gets an array of all the alarms. */ + function getAll(): Promise; + + /** + * Clears the alarm with the given name. + * @param [name] The name of the alarm to clear. Defaults to the empty string. + */ + function clear(name?: string): Promise; + + /** Clears all alarms. */ + function clearAll(): Promise; + + /* alarms events */ + /** + * Fired when an alarm has expired. Useful for transient background pages. + * @param name The alarm that has expired. + */ + const onAlarm: WebExtEvent<(name: Alarm) => void>; +} + +/** + * Use browser actions to put icons in the main browser toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup. + * + * Manifest keys: `action`, `browser_action` + * + * Needs at least manifest version 3. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.action { + /* action types */ + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface Details { + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + type ColorArray = [number, number, number, number]; + + /** Pixel data for an image. Must be an ImageData object (for example, from a `canvas` element). */ + type ImageDataType = ImageData; + + /** + * An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is `[255, 0, 0, 255]`. Can also be a string with a CSS value, with opaque red being `#FF0000` or `#F00`. + */ + type ColorValue = string | ColorArray | null; + + /** Information sent when a browser action is clicked. */ + interface OnClickData { + /** An array of keyboard modifiers that were held while the menu item was clicked. */ + modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number | undefined; + } + + type _OnClickDataModifiers = 'Shift' | 'Alt' | 'Command' | 'Ctrl' | 'MacCtrl'; + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetTitleDetails { + /** The string the browser action should display when moused over. */ + title: string | null; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetIconDetails { + /** + * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals `scale`, then image with size `scale` * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' + */ + imageData?: + | ImageDataType + | { + [key: number]: ImageDataType; + } + | undefined; + /** + * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals `scale`, then image with size `scale` * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' + */ + path?: + | string + | { + [key: number]: string; + } + | undefined; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetPopupDetails { + /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ + popup: string | null; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetBadgeTextDetails { + /** Any number of characters can be passed, but only about four can fit in the space. */ + text: string | null; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetBadgeBackgroundColorDetails { + color: ColorValue; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetBadgeTextColorDetails { + color: ColorValue; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** An object with information about the popup to open. */ + interface _OpenPopupOptions { + /** Defaults to the current window. */ + windowId?: number | undefined; + } + + /* action functions */ + /** + * Sets the title of the browser action. This shows up in the tooltip. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setTitle(details: _SetTitleDetails): Promise; + + /** Gets the title of the browser action. */ + function getTitle(details: Details): Promise; + + /** + * Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the **path** or the **imageData** property must be specified. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setIcon(details: _SetIconDetails): Promise; + + /** + * Sets the html document to be opened as a popup when the user clicks on the browser action's icon. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setPopup(details: _SetPopupDetails): Promise; + + /** Gets the html document set as the popup for this browser action. */ + function getPopup(details: Details): Promise; + + /** + * Sets the badge text for the browser action. The badge is displayed on top of the icon. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setBadgeText(details: _SetBadgeTextDetails): Promise; + + /** + * Gets the badge text of the browser action. If no tab nor window is specified is specified, the global badge text is returned. + */ + function getBadgeText(details: Details): Promise; + + /** + * Sets the background color for the badge. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setBadgeBackgroundColor(details: _SetBadgeBackgroundColorDetails): Promise; + + /** Gets the background color of the browser action badge. */ + function getBadgeBackgroundColor(details: Details): Promise; + + /** + * Sets the text color for the badge. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setBadgeTextColor(details: _SetBadgeTextColorDetails): Promise; + + /** Gets the text color of the browser action badge. */ + function getBadgeTextColor(details: Details): Promise; + + /** + * Enables the browser action for a tab. By default, browser actions are enabled. + * @param [tabId] The id of the tab for which you want to modify the browser action. + */ + function enable(tabId?: number): Promise; + + /** + * Disables the browser action for a tab. + * @param [tabId] The id of the tab for which you want to modify the browser action. + */ + function disable(tabId?: number): Promise; + + /** Checks whether the browser action is enabled. */ + function isEnabled(details: Details): Promise; + + /** + * Opens the extension popup window in the specified window. + * @param [options] An object with information about the popup to open. + */ + function openPopup(options?: _OpenPopupOptions): Promise; + + /* action events */ + /** + * Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. + */ + const onClicked: WebExtEvent<(tab: tabs.Tab, info?: OnClickData) => void>; +} + +/** + * Manifest keys: `action`, `browser_action` + * + * Not supported on manifest versions above 2. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.browserAction { + /* browserAction types */ + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface Details { + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + type ColorArray = [number, number, number, number]; + + /** Pixel data for an image. Must be an ImageData object (for example, from a `canvas` element). */ + type ImageDataType = ImageData; + + /** + * An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is `[255, 0, 0, 255]`. Can also be a string with a CSS value, with opaque red being `#FF0000` or `#F00`. + */ + type ColorValue = string | ColorArray | null; + + /** Information sent when a browser action is clicked. */ + interface OnClickData { + /** An array of keyboard modifiers that were held while the menu item was clicked. */ + modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number | undefined; + } + + type _OnClickDataModifiers = 'Shift' | 'Alt' | 'Command' | 'Ctrl' | 'MacCtrl'; + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetTitleDetails { + /** The string the browser action should display when moused over. */ + title: string | null; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetIconDetails { + /** + * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals `scale`, then image with size `scale` * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' + */ + imageData?: + | ImageDataType + | { + [key: number]: ImageDataType; + } + | undefined; + /** + * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals `scale`, then image with size `scale` * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' + */ + path?: + | string + | { + [key: number]: string; + } + | undefined; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetPopupDetails { + /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ + popup: string | null; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetBadgeTextDetails { + /** Any number of characters can be passed, but only about four can fit in the space. */ + text: string | null; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetBadgeBackgroundColorDetails { + color: ColorValue; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** + * Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + interface _SetBadgeTextColorDetails { + color: ColorValue; + /** + * When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited. + */ + tabId?: number | undefined; + /** + * When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited. + */ + windowId?: number | undefined; + } + + /** An object with information about the popup to open. */ + interface _OpenPopupOptions { + /** Defaults to the current window. */ + windowId?: number | undefined; + } + + /* browserAction functions */ + /** + * Sets the title of the browser action. This shows up in the tooltip. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setTitle(details: _SetTitleDetails): Promise; + + /** Gets the title of the browser action. */ + function getTitle(details: Details): Promise; + + /** + * Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the **path** or the **imageData** property must be specified. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setIcon(details: _SetIconDetails): Promise; + + /** + * Sets the html document to be opened as a popup when the user clicks on the browser action's icon. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setPopup(details: _SetPopupDetails): Promise; + + /** Gets the html document set as the popup for this browser action. */ + function getPopup(details: Details): Promise; + + /** + * Sets the badge text for the browser action. The badge is displayed on top of the icon. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setBadgeText(details: _SetBadgeTextDetails): Promise; + + /** + * Gets the badge text of the browser action. If no tab nor window is specified is specified, the global badge text is returned. + */ + function getBadgeText(details: Details): Promise; + + /** + * Sets the background color for the badge. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setBadgeBackgroundColor(details: _SetBadgeBackgroundColorDetails): Promise; + + /** Gets the background color of the browser action badge. */ + function getBadgeBackgroundColor(details: Details): Promise; + + /** + * Sets the text color for the badge. + * @param details Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved. + */ + function setBadgeTextColor(details: _SetBadgeTextColorDetails): Promise; + + /** Gets the text color of the browser action badge. */ + function getBadgeTextColor(details: Details): Promise; + + /** + * Enables the browser action for a tab. By default, browser actions are enabled. + * @param [tabId] The id of the tab for which you want to modify the browser action. + */ + function enable(tabId?: number): Promise; + + /** + * Disables the browser action for a tab. + * @param [tabId] The id of the tab for which you want to modify the browser action. + */ + function disable(tabId?: number): Promise; + + /** Checks whether the browser action is enabled. */ + function isEnabled(details: Details): Promise; + + /** + * Opens the extension popup window in the specified window. + * @param [options] An object with information about the popup to open. + */ + function openPopup(options?: _OpenPopupOptions): Promise; + + /* browserAction events */ + /** + * Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. + */ + const onClicked: WebExtEvent<(tab: tabs.Tab, info?: OnClickData) => void>; +} + +/** + * Use the `browser.browserSettings` API to control global settings of the browser. + * + * Permissions: `browserSettings` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.browserSettings { + /* browserSettings types */ + /** How images should be animated in the browser. */ + type ImageAnimationBehavior = 'normal' | 'none' | 'once'; + + /** After which mouse event context menus should popup. */ + type ContextMenuMouseEvent = 'mouseup' | 'mousedown'; + + /** Color management mode. */ + type ColorManagementMode = 'off' | 'full' | 'tagged_only'; + + /* browserSettings properties */ + /** Allows or disallows pop-up windows from opening in response to user events. */ + const allowPopupsForUserEvents: types.Setting; + + /** Enables or disables the browser cache. */ + const cacheEnabled: types.Setting; + + /** This boolean setting controls whether the selected tab can be closed with a double click. */ + const closeTabsByDoubleClick: types.Setting; + + /** + * Controls after which mouse event context menus popup. This setting's value is of type ContextMenuMouseEvent, which has possible values of `mouseup` and `mousedown`. + */ + const contextMenuShowEvent: types.Setting; + + /** + * Returns whether the FTP protocol is enabled. Read-only. + * @deprecated FTP support was removed from Firefox in bug 1574475 + */ + const ftpProtocolEnabled: types.Setting; + + /** Returns the value of the overridden home page. Read-only. */ + const homepageOverride: types.Setting; + + /** + * Controls the behaviour of image animation in the browser. This setting's value is of type ImageAnimationBehavior, defaulting to `normal`. + */ + const imageAnimationBehavior: types.Setting; + + /** Returns the value of the overridden new tab page. Read-only. */ + const newTabPageOverride: types.Setting; + + /** + * Controls where new tabs are opened. `afterCurrent` will open all new tabs next to the current tab, `relatedAfterCurrent` will open only related tabs next to the current tab, and `atEnd` will open all tabs at the end of the tab strip. The default is `relatedAfterCurrent`. + */ + const newTabPosition: types.Setting; + + /** This boolean setting controls whether bookmarks are opened in the current tab or in a new tab. */ + const openBookmarksInNewTabs: types.Setting; + + /** This boolean setting controls whether search results are opened in the current tab or in a new tab. */ + const openSearchResultsInNewTabs: types.Setting; + + /** This boolean setting controls whether urlbar results are opened in the current tab or in a new tab. */ + const openUrlbarResultsInNewTabs: types.Setting; + + /** Disables webAPI notifications. */ + const webNotificationsDisabled: types.Setting; + + /** This setting controls whether the user-chosen colors override the page's colors. */ + const overrideDocumentColors: types.Setting; + + /** + * This setting controls whether a light or dark color scheme overrides the page's preferred color scheme. + */ + const overrideContentColorScheme: types.Setting; + + /** This setting controls whether the document's fonts are used. */ + const useDocumentFonts: types.Setting; + + /** This boolean setting controls whether zoom is applied to the full page or to text only. */ + const zoomFullPage: types.Setting; + + /** + * This boolean setting controls whether zoom is applied on a per-site basis or to the current tab only. If privacy.resistFingerprinting is true, this setting has no effect and zoom is applied to the current tab only. + */ + const zoomSiteSpecific: types.Setting; +} + +/** + * Use the `browserSettings.colorManagement` API to query and set items related to color management. + * + * Permissions: `browserSettings` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.browserSettings.colorManagement { + /* browserSettings.colorManagement properties */ + /** + * This setting controls the mode used for color management and must be a string from `browserSettings.ColorManagementMode` + */ + const mode: types.Setting; + + /** This boolean setting controls whether or not native sRGB color management is used. */ + const useNativeSRGB: types.Setting; + + /** This boolean setting controls whether or not the WebRender compositor is used. */ + const useWebRenderCompositor: types.Setting; +} + +/** + * Use the `browser.browsingData` API to remove browsing data from a user's local profile. + * + * Permissions: `browsingData` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.browsingData { + /* browsingData types */ + /** Options that determine exactly what data will be removed. */ + interface RemovalOptions { + /** + * Remove data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the `getTime` method of the JavaScript `Date` object). If absent, defaults to 0 (which would remove all browsing data). + */ + since?: extensionTypes.Date | undefined; + /** Only remove data associated with these hostnames (only applies to cookies and localStorage). */ + hostnames?: string[] | undefined; + /** Only remove data associated with this specific cookieStoreId. */ + cookieStoreId?: string | undefined; + /** + * An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that you _really_ want to remove application data before adding 'protectedWeb' or 'extensions'. + */ + originTypes?: _RemovalOptionsOriginTypes | undefined; + } + + /** A set of data types. Missing data types are interpreted as `false`. */ + interface DataTypeSet { + /** + * The browser's cache. Note: when removing data, this clears the _entire_ cache: it is not limited to the range you specify. + */ + cache?: boolean | undefined; + /** The browser's cookies. */ + cookies?: boolean | undefined; + /** The browser's download list. */ + downloads?: boolean | undefined; + /** The browser's stored form data. */ + formData?: boolean | undefined; + /** The browser's history. */ + history?: boolean | undefined; + /** Websites' IndexedDB data. */ + indexedDB?: boolean | undefined; + /** Websites' local storage data. */ + localStorage?: boolean | undefined; + /** Server-bound certificates. */ + serverBoundCertificates?: boolean | undefined; + /** Stored passwords. */ + passwords?: boolean | undefined; + /** Plugins' data. */ + pluginData?: boolean | undefined; + /** Service Workers. */ + serviceWorkers?: boolean | undefined; + } + + /** + * An object whose properties specify which origin types ought to be cleared. If this object isn't specified, it defaults to clearing only "unprotected" origins. Please ensure that you _really_ want to remove application data before adding 'protectedWeb' or 'extensions'. + */ + interface _RemovalOptionsOriginTypes { + /** Normal websites. */ + unprotectedWeb?: boolean | undefined; + /** Websites that have been installed as hosted applications (be careful!). */ + protectedWeb?: boolean | undefined; + /** Extensions and packaged applications a user has installed (be _really_ careful!). */ + extension?: boolean | undefined; + } + + interface _SettingsReturnResult { + options: RemovalOptions; + /** + * All of the types will be present in the result, with values of `true` if they are both selected to be removed and permitted to be removed, otherwise `false`. + */ + dataToRemove: DataTypeSet; + /** + * All of the types will be present in the result, with values of `true` if they are permitted to be removed (e.g., by enterprise policy) and `false` if not. + */ + dataRemovalPermitted: DataTypeSet; + } + + /* browsingData functions */ + /** + * Reports which types of data are currently selected in the 'Clear browsing data' settings UI. Note: some of the data types included in this API are not available in the settings UI, and some UI settings control more than one data type listed here. + */ + function settings(): Promise<_SettingsReturnResult>; + + /** + * Clears various types of browsing data stored in a user's profile. + * @param dataToRemove The set of data types to remove. + */ + function remove(options: RemovalOptions, dataToRemove: DataTypeSet): Promise; + + /** + * Clears websites' appcache data. + * @deprecated Unsupported on Firefox at this time. + */ + function removeAppcache(options: RemovalOptions): Promise; + + /** Clears the browser's cache. */ + function removeCache(options: RemovalOptions): Promise; + + /** Clears the browser's cookies and server-bound certificates modified within a particular timeframe. */ + function removeCookies(options: RemovalOptions): Promise; + + /** Clears the browser's list of downloaded files (_not_ the downloaded files themselves). */ + function removeDownloads(options: RemovalOptions): Promise; + + /** + * Clears websites' file system data. + * @deprecated Unsupported on Firefox at this time. + */ + function removeFileSystems(options: RemovalOptions): Promise; + + /** Clears the browser's stored form data (autofill). */ + function removeFormData(options: RemovalOptions): Promise; + + /** Clears the browser's history. */ + function removeHistory(options: RemovalOptions): Promise; + + /** + * Clears websites' IndexedDB data. + * @deprecated Unsupported on Firefox at this time. + */ + function removeIndexedDB(options: RemovalOptions): Promise; + + /** Clears websites' local storage data. */ + function removeLocalStorage(options: RemovalOptions): Promise; + + /** Clears plugins' data. */ + function removePluginData(options: RemovalOptions): Promise; + + /** Clears the browser's stored passwords. */ + function removePasswords(options: RemovalOptions): Promise; + + /** + * Clears websites' WebSQL data. + * @deprecated Unsupported on Firefox at this time. + */ + function removeWebSQL(options: RemovalOptions): Promise; +} + +/** + * This API provides the ability detect the captive portal state of the users connection. + * + * Permissions: `captivePortal` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.captivePortal { + /** The current captive portal state. */ + type _OnStateChangedDetailsState = 'unknown' | 'not_captive' | 'unlocked_portal' | 'locked_portal'; + + interface _OnStateChangedDetails { + /** The current captive portal state. */ + state: _OnStateChangedDetailsState; + } + + type _OnConnectivityAvailableStatus = 'captive' | 'clear'; + + /* captivePortal properties */ + /** Return the canonical captive-portal detection URL. Read-only. */ + const canonicalURL: types.Setting; + + /* captivePortal functions */ + /** + * Returns the current portal state, one of `unknown`, `not_captive`, `unlocked_portal`, `locked_portal`. + */ + function getState(): Promise<_OnStateChangedDetailsState>; + + /** Returns the time difference between NOW and the last time a request was completed in milliseconds. */ + function getLastChecked(): Promise; + + /* captivePortal events */ + /** Fired when the captive portal state changes. */ + const onStateChanged: WebExtEvent<(details: _OnStateChangedDetails) => void>; + + /** + * This notification will be emitted when the captive portal service has determined that we can connect to the internet. The service will pass either `captive` if there is an unlocked captive portal present, or `clear` if no captive portal was detected. + */ + const onConnectivityAvailable: WebExtEvent<(status: _OnConnectivityAvailableStatus) => void>; +} + +/** + * Offers the ability to write to the clipboard. Reading is not supported because the clipboard can already be read through the standard web platform APIs. + * + * Permissions: `clipboardWrite` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.clipboard { + /** The type of imageData. */ + type _SetImageDataImageType = 'jpeg' | 'png'; + + /* clipboard functions */ + /** + * Copy an image to the clipboard. The image is re-encoded before it is written to the clipboard. If the image is invalid, the clipboard is not modified. + * @param imageData The image data to be copied. + * @param imageType The type of imageData. + */ + function setImageData(imageData: ArrayBuffer, imageType: _SetImageDataImageType): Promise; +} + +/** + * Not supported on manifest versions above 2. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.contentScripts { + /* contentScripts types */ + /** Details of a content script registered programmatically */ + interface RegisteredContentScriptOptions { + matches: _manifest.MatchPattern[]; + excludeMatches?: _manifest.MatchPattern[] | undefined; + includeGlobs?: string[] | undefined; + excludeGlobs?: string[] | undefined; + /** The list of CSS files to inject */ + css?: extensionTypes.ExtensionFileOrCode[] | undefined; + /** The list of JS files to inject */ + js?: extensionTypes.ExtensionFileOrCode[] | undefined; + /** + * If allFrames is `true`, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's `false` and is only injected into the top frame. + */ + allFrames?: boolean | undefined; + /** + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is `false`. + */ + matchAboutBlank?: boolean | undefined; + /** The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle". */ + runAt?: extensionTypes.RunAt | undefined; + /** limit the set of matched tabs to those that belong to the given cookie store id */ + cookieStoreId?: string[] | string | undefined; + } + + /** An object that represents a content script registered programmatically */ + interface RegisteredContentScript { + /** Unregister a content script registered programmatically */ + unregister(): Promise; + } + + /* contentScripts functions */ + /** Register a content script programmatically */ + function register(contentScriptOptions: RegisteredContentScriptOptions): Promise; +} + +/** + * Use the `browser.contextualIdentities` API to query and modify contextual identity, also called as containers. + * + * Permissions: `contextualIdentities` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.contextualIdentities { + /* contextualIdentities types */ + /** Represents information about a contextual identity. */ + interface ContextualIdentity { + /** The name of the contextual identity. */ + name: string; + /** The icon name of the contextual identity. */ + icon: string; + /** The icon url of the contextual identity. */ + iconUrl: string; + /** The color name of the contextual identity. */ + color: string; + /** The color hash of the contextual identity. */ + colorCode: string; + /** The cookie store ID of the contextual identity. */ + cookieStoreId: string; + } + + /** Information to filter the contextual identities being retrieved. */ + interface _QueryDetails { + /** Filters the contextual identity by name. */ + name?: string | undefined; + } + + /** Details about the contextual identity being created. */ + interface _CreateDetails { + /** The name of the contextual identity. */ + name: string; + /** The color of the contextual identity. */ + color: string; + /** The icon of the contextual identity. */ + icon: string; + } + + /** Details about the contextual identity being created. */ + interface _UpdateDetails { + /** The name of the contextual identity. */ + name?: string | undefined; + /** The color of the contextual identity. */ + color?: string | undefined; + /** The icon of the contextual identity. */ + icon?: string | undefined; + } + + interface _OnUpdatedChangeInfo { + /** Contextual identity that has been updated */ + contextualIdentity: ContextualIdentity; + } + + interface _OnCreatedChangeInfo { + /** Contextual identity that has been created */ + contextualIdentity: ContextualIdentity; + } + + interface _OnRemovedChangeInfo { + /** Contextual identity that has been removed */ + contextualIdentity: ContextualIdentity; + } + + /* contextualIdentities functions */ + /** + * Retrieves information about a single contextual identity. + * @param cookieStoreId The ID of the contextual identity cookie store. + */ + function get(cookieStoreId: string): Promise; + + /** + * Retrieves all contextual identities + * @param details Information to filter the contextual identities being retrieved. + */ + function query(details: _QueryDetails): Promise; + + /** + * Creates a contextual identity with the given data. + * @param details Details about the contextual identity being created. + */ + function create(details: _CreateDetails): Promise; + + /** + * Updates a contextual identity with the given data. + * @param cookieStoreId The ID of the contextual identity cookie store. + * @param details Details about the contextual identity being created. + */ + function update(cookieStoreId: string, details: _UpdateDetails): Promise; + + /** + * Deletes a contetual identity by its cookie Store ID. + * @param cookieStoreId The ID of the contextual identity cookie store. + */ + function remove(cookieStoreId: string): Promise; + + /* contextualIdentities events */ + /** Fired when a container is updated. */ + const onUpdated: WebExtEvent<(changeInfo: _OnUpdatedChangeInfo) => void>; + + /** Fired when a new container is created. */ + const onCreated: WebExtEvent<(changeInfo: _OnCreatedChangeInfo) => void>; + + /** Fired when a container is removed. */ + const onRemoved: WebExtEvent<(changeInfo: _OnRemovedChangeInfo) => void>; +} + +/** + * Use the `browser.cookies` API to query and modify cookies, and to be notified when they change. + * + * Permissions: `cookies` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.cookies { + /* cookies types */ + /** + * A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set without a 'SameSite' attribute, 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. + */ + type SameSiteStatus = 'no_restriction' | 'lax' | 'strict'; + + /** + * The description of the storage partition of a cookie. This object may be omitted (null) if a cookie is not partitioned. + */ + interface PartitionKey { + /** The first-party URL of the cookie, if the cookie is in storage partitioned by the top-level site. */ + topLevelSite?: string | undefined; + } + + /** Represents information about an HTTP cookie. */ + interface Cookie { + /** The name of the cookie. */ + name: string; + /** The value of the cookie. */ + value: string; + /** The domain of the cookie (e.g. "www.google.com", "example.com"). */ + domain: string; + /** + * True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie). + */ + hostOnly: boolean; + /** The path of the cookie. */ + path: string; + /** + * True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS). + */ + secure: boolean; + /** True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts). */ + httpOnly: boolean; + /** The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests). */ + sameSite: SameSiteStatus; + /** True if the cookie is a session cookie, as opposed to a persistent cookie with an expiration date. */ + session: boolean; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. + */ + expirationDate?: number | undefined; + /** The ID of the cookie store containing this cookie, as provided in getAllCookieStores(). */ + storeId: string; + /** The first-party domain of the cookie. */ + firstPartyDomain: string; + /** The cookie's storage partition, if any. null if not partitioned. */ + partitionKey?: PartitionKey | undefined; + } + + /** + * Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window. + */ + interface CookieStore { + /** The unique identifier for the cookie store. */ + id: string; + /** Identifiers of all the browser tabs that share this cookie store. */ + tabIds: number[]; + /** Indicates if this is an incognito cookie store */ + incognito: boolean; + } + + /** + * The underlying reason behind the cookie's change. If a cookie was inserted, or removed via an explicit call to `cookies.remove`, "cause" will be "explicit". If a cookie was automatically removed due to expiry, "cause" will be "expired". If a cookie was removed due to being overwritten with an already-expired expiration date, "cause" will be set to "expired_overwrite". If a cookie was automatically removed due to garbage collection, "cause" will be "evicted". If a cookie was automatically removed due to a "set" call that overwrote it, "cause" will be "overwrite". Plan your response accordingly. + */ + type OnChangedCause = 'evicted' | 'expired' | 'explicit' | 'expired_overwrite' | 'overwrite'; + + /** Details to identify the cookie being retrieved. */ + interface _GetDetails { + /** + * The URL with which the cookie to retrieve is associated. This argument may be a full URL, in which case any data following the URL path (e.g. the query string) is simply ignored. If host permissions for this URL are not specified in the manifest file, the API call will fail. + */ + url: string; + /** The name of the cookie to retrieve. */ + name: string; + /** + * The ID of the cookie store in which to look for the cookie. By default, the current execution context's cookie store will be used. + */ + storeId?: string | undefined; + /** + * The first-party domain which the cookie to retrieve is associated. This attribute is required if First-Party Isolation is enabled. + */ + firstPartyDomain?: string | undefined; + /** + * The storage partition, if the cookie is part of partitioned storage. By default, only non-partitioned cookies are returned. + */ + partitionKey?: PartitionKey | undefined; + } + + /** Information to filter the cookies being retrieved. */ + interface _GetAllDetails { + /** Restricts the retrieved cookies to those that would match the given URL. */ + url?: string | undefined; + /** Filters the cookies by name. */ + name?: string | undefined; + /** Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */ + domain?: string | undefined; + /** Restricts the retrieved cookies to those whose path exactly matches this string. */ + path?: string | undefined; + /** Filters the cookies by their Secure property. */ + secure?: boolean | undefined; + /** Filters out session vs. persistent cookies. */ + session?: boolean | undefined; + /** + * The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. + */ + storeId?: string | undefined; + /** + * Restricts the retrieved cookies to those whose first-party domains match this one. This attribute is required if First-Party Isolation is enabled. To not filter by a specific first-party domain, use `null` or `undefined`. + */ + firstPartyDomain?: string | undefined; + /** + * Selects a specific storage partition to look up cookies. Defaults to null, in which case only non-partitioned cookies are retrieved. If an object iis passed, partitioned cookies are also included, and filtered based on the keys present in the given PartitionKey description. An empty object ({}) returns all cookies (partitioned + unpartitioned), a non-empty object (e.g. {topLevelSite: '...'}) only returns cookies whose partition match all given attributes. + */ + partitionKey?: PartitionKey | undefined; + } + + /** Details about the cookie being set. */ + interface _SetDetails { + /** + * The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. + */ + url: string; + /** The name of the cookie. Empty by default if omitted. */ + name?: string | undefined; + /** The value of the cookie. Empty by default if omitted. */ + value?: string | undefined; + /** The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */ + domain?: string | undefined; + /** The path of the cookie. Defaults to the path portion of the url parameter. */ + path?: string | undefined; + /** Whether the cookie should be marked as Secure. Defaults to false. */ + secure?: boolean | undefined; + /** Whether the cookie should be marked as HttpOnly. Defaults to false. */ + httpOnly?: boolean | undefined; + /** The cookie's same-site status. */ + sameSite?: SameSiteStatus | undefined; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. + */ + expirationDate?: number | undefined; + /** + * The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. + */ + storeId?: string | undefined; + /** + * The first-party domain of the cookie. This attribute is required if First-Party Isolation is enabled. + */ + firstPartyDomain?: string | undefined; + /** + * The storage partition, if the cookie is part of partitioned storage. By default, non-partitioned storage is used. + */ + partitionKey?: PartitionKey | undefined; + } + + /** + * Contains details about the cookie that's been removed. If removal failed for any reason, this will be "null", and `runtime.lastError` will be set. + */ + interface _RemoveReturnDetails { + /** The URL associated with the cookie that's been removed. */ + url: string; + /** The name of the cookie that's been removed. */ + name: string; + /** The ID of the cookie store from which the cookie was removed. */ + storeId: string; + /** The first-party domain associated with the cookie that's been removed. */ + firstPartyDomain: string; + /** The storage partition, if the cookie is part of partitioned storage. null if not partitioned. */ + partitionKey?: PartitionKey | undefined; + } + + /** Information to identify the cookie to remove. */ + interface _RemoveDetails { + /** + * The URL associated with the cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. + */ + url: string; + /** The name of the cookie to remove. */ + name: string; + /** + * The ID of the cookie store to look in for the cookie. If unspecified, the cookie is looked for by default in the current execution context's cookie store. + */ + storeId?: string | undefined; + /** + * The first-party domain associated with the cookie. This attribute is required if First-Party Isolation is enabled. + */ + firstPartyDomain?: string | undefined; + /** + * The storage partition, if the cookie is part of partitioned storage. By default, non-partitioned storage is used. + */ + partitionKey?: PartitionKey | undefined; + } + + interface _OnChangedChangeInfo { + /** True if a cookie was removed. */ + removed: boolean; + /** Information about the cookie that was set or removed. */ + cookie: Cookie; + /** The underlying reason behind the cookie's change. */ + cause: OnChangedCause; + } + + /* cookies functions */ + /** + * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned. + * @param details Details to identify the cookie being retrieved. + */ + function get(details: _GetDetails): Promise; + + /** + * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. + * @param details Information to filter the cookies being retrieved. + */ + function getAll(details: _GetAllDetails): Promise; + + /** + * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. + * @param details Details about the cookie being set. + */ + function set(details: _SetDetails): Promise; + + /** + * Deletes a cookie by name. + * @param details Information to identify the cookie to remove. + */ + function remove(details: _RemoveDetails): Promise<_RemoveReturnDetails | null>; + + /** Lists all existing cookie stores. */ + function getAllCookieStores(): Promise; + + /* cookies events */ + /** + * Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit". + */ + const onChanged: WebExtEvent<(changeInfo: _OnChangedChangeInfo) => void>; +} + +/** + * Use the declarativeNetRequest API to block or modify network requests by specifying declarative rules. + * + * Permissions: `declarativeNetRequest`, `declarativeNetRequestWithHostAccess` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.declarativeNetRequest { + /* declarativeNetRequest types */ + /** How the requested resource will be used. Comparable to the webRequest.ResourceType type. */ + type ResourceType = + | 'main_frame' + | 'sub_frame' + | 'stylesheet' + | 'script' + | 'image' + | 'object' + | 'object_subrequest' + | 'xmlhttprequest' + | 'xslt' + | 'ping' + | 'beacon' + | 'xml_dtd' + | 'font' + | 'media' + | 'websocket' + | 'csp_report' + | 'imageset' + | 'web_manifest' + | 'speculative' + | 'other'; + + interface MatchedRule { + /** A matching rule's ID. */ + ruleId: number; + /** ID of the Ruleset this rule belongs to. */ + rulesetId: string; + /** ID of the extension, if this rule belongs to a different extension. */ + extensionId?: string | undefined; + } + + /** Describes the type of the Rule.action.redirect.transform property. */ + interface URLTransform { + /** The new scheme for the request. */ + scheme?: _URLTransformScheme | undefined; + /** The new username for the request. */ + username?: string | undefined; + /** The new password for the request. */ + password?: string | undefined; + /** The new host name for the request. */ + host?: string | undefined; + /** The new port for the request. If empty, the existing port is cleared. */ + port?: string | undefined; + /** The new path for the request. If empty, the existing path is cleared. */ + path?: string | undefined; + /** + * The new query for the request. Should be either empty, in which case the existing query is cleared; or should begin with '?'. Cannot be specified if 'queryTransform' is specified. + */ + query?: string | undefined; + /** Add, remove or replace query key-value pairs. Cannot be specified if 'query' is specified. */ + queryTransform?: _URLTransformQueryTransform | undefined; + /** + * The new fragment for the request. Should be either empty, in which case the existing fragment is cleared; or should begin with '#'. + */ + fragment?: string | undefined; + } + + interface Rule { + /** An id which uniquely identifies a rule. Mandatory and should be >= 1. */ + id: number; + /** Rule priority. Defaults to 1\. When specified, should be >= 1 */ + priority?: number | undefined; + /** The condition under which this rule is triggered. */ + condition: _RuleCondition; + /** The action to take if this rule is matched. */ + action: _RuleAction; + } + + /** The new scheme for the request. */ + type _URLTransformScheme = 'http' | 'https' | 'moz-extension'; + + interface _URLTransformQueryTransformAddOrReplaceParams { + key: string; + value: string; + /** + * If true, the query key is replaced only if it's already present. Otherwise, the key is also added if it's missing. + */ + replaceOnly?: boolean | undefined; + } + + /** Add, remove or replace query key-value pairs. Cannot be specified if 'query' is specified. */ + interface _URLTransformQueryTransform { + /** The list of query keys to be removed. */ + removeParams?: string[] | undefined; + /** The list of query key-value pairs to be added or replaced. */ + addOrReplaceParams?: _URLTransformQueryTransformAddOrReplaceParams[] | undefined; + } + + /** + * Specifies whether the network request is first-party or third-party to the domain from which it originated. If omitted, all requests are matched. + */ + type _RuleConditionDomainType = 'firstParty' | 'thirdParty'; + + /** The condition under which this rule is triggered. */ + interface _RuleCondition { + /** + * TODO: link to doc explaining supported pattern. The pattern which is matched against the network request url. Only one of 'urlFilter' or 'regexFilter' can be specified. + */ + urlFilter?: string | undefined; + /** + * Regular expression to match against the network request url. Only one of 'urlFilter' or 'regexFilter' can be specified. + */ + regexFilter?: string | undefined; + /** Whether 'urlFilter' or 'regexFilter' is case-sensitive. Defaults to true. */ + isUrlFilterCaseSensitive?: boolean | undefined; + /** + * The rule will only match network requests originating from the list of 'initiatorDomains'. If the list is omitted, the rule is applied to requests from all domains. + */ + initiatorDomains?: string[] | undefined; + /** + * The rule will not match network requests originating from the list of 'initiatorDomains'. If the list is empty or omitted, no domains are excluded. This takes precedence over 'initiatorDomains'. + */ + excludedInitiatorDomains?: string[] | undefined; + /** + * The rule will only match network requests when the domain matches one from the list of 'requestDomains'. If the list is omitted, the rule is applied to requests from all domains. + */ + requestDomains?: string[] | undefined; + /** + * The rule will not match network requests when the domains matches one from the list of 'excludedRequestDomains'. If the list is empty or omitted, no domains are excluded. This takes precedence over 'requestDomains'. + */ + excludedRequestDomains?: string[] | undefined; + /** + * List of resource types which the rule can match. When the rule action is 'allowAllRequests', this must be specified and may only contain 'main_frame' or 'sub_frame'. Cannot be specified if 'excludedResourceTypes' is specified. If neither of them is specified, all resource types except 'main_frame' are matched. + */ + resourceTypes?: ResourceType[] | undefined; + /** + * List of resource types which the rule won't match. Cannot be specified if 'resourceTypes' is specified. If neither of them is specified, all resource types except 'main_frame' are matched. + */ + excludedResourceTypes?: ResourceType[] | undefined; + /** + * List of HTTP request methods which the rule can match. Should be a lower-case method such as 'connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put'.' + */ + requestMethods?: string[] | undefined; + /** + * List of request methods which the rule won't match. Cannot be specified if 'requestMethods' is specified. If neither of them is specified, all request methods are matched. + */ + excludedRequestMethods?: string[] | undefined; + /** + * Specifies whether the network request is first-party or third-party to the domain from which it originated. If omitted, all requests are matched. + */ + domainType?: _RuleConditionDomainType | undefined; + /** + * List of tabIds which the rule should match. An ID of -1 matches requests which don't originate from a tab. Only supported for session-scoped rules. + */ + tabIds?: number[] | undefined; + /** + * List of tabIds which the rule should not match. An ID of -1 excludes requests which don't originate from a tab. Only supported for session-scoped rules. + */ + excludedTabIds?: number[] | undefined; + } + + type _RuleActionType = 'block' | 'redirect' | 'allow' | 'upgradeScheme' | 'modifyHeaders' | 'allowAllRequests'; + + /** Describes how the redirect should be performed. Only valid when type is 'redirect'. */ + interface _RuleActionRedirect { + /** Path relative to the extension directory. Should start with '/'. */ + extensionPath?: string | undefined; + /** Url transformations to perform. */ + transform?: URLTransform | undefined; + /** The redirect url. Redirects to JavaScript urls are not allowed. */ + url?: string | undefined; + /** TODO with regexFilter + Substitution pattern for rules which specify a 'regexFilter'. */ + regexSubstitution?: string | undefined; + } + + /** The operation to be performed on a header. */ + type _RuleActionRequestHeadersOperation = 'append' | 'set' | 'remove'; + + interface _RuleActionRequestHeaders { + /** The name of the request header to be modified. */ + header: string; + /** The operation to be performed on a header. */ + operation: _RuleActionRequestHeadersOperation; + /** The new value for the header. Must be specified for the 'append' and 'set' operations. */ + value?: string | undefined; + } + + /** The operation to be performed on a header. */ + type _RuleActionResponseHeadersOperation = 'append' | 'set' | 'remove'; + + interface _RuleActionResponseHeaders { + /** The name of the response header to be modified. */ + header: string; + /** The operation to be performed on a header. */ + operation: _RuleActionResponseHeadersOperation; + /** The new value for the header. Must be specified for the 'append' and 'set' operations. */ + value?: string | undefined; + } + + /** The action to take if this rule is matched. */ + interface _RuleAction { + type: _RuleActionType; + /** Describes how the redirect should be performed. Only valid when type is 'redirect'. */ + redirect?: _RuleActionRedirect | undefined; + /** The request headers to modify for the request. Only valid when type is 'modifyHeaders'. */ + requestHeaders?: _RuleActionRequestHeaders[] | undefined; + /** The response headers to modify for the request. Only valid when type is 'modifyHeaders'. */ + responseHeaders?: _RuleActionResponseHeaders[] | undefined; + } + + interface _UpdateSessionRulesOptions { + /** IDs of the rules to remove. Any invalid IDs will be ignored. */ + removeRuleIds?: number[] | undefined; + /** Rules to add. */ + addRules?: Rule[] | undefined; + } + + interface _UpdateEnabledRulesetsUpdateRulesetOptions { + disableRulesetIds?: string[] | undefined; + enableRulesetIds?: string[] | undefined; + } + + interface _TestMatchOutcomeReturnResult { + /** The rules (if any) that match the hypothetical request. */ + matchedRules: MatchedRule[]; + } + + /** The details of the request to test. */ + interface _TestMatchOutcomeRequest { + /** The URL of the hypothetical request. */ + url: string; + /** The initiator URL (if any) for the hypothetical request. */ + initiator?: string | undefined; + /** Standard HTTP method of the hypothetical request. */ + method?: string | undefined; + /** The resource type of the hypothetical request. */ + type: ResourceType; + /** + * The ID of the tab in which the hypothetical request takes place. Does not need to correspond to a real tab ID. Default is -1, meaning that the request isn't related to a tab. + */ + tabId?: number | undefined; + } + + interface _TestMatchOutcomeOptions { + /** Whether to account for rules from other installed extensions during rule evaluation. */ + includeOtherExtensions?: boolean | undefined; + } + + /* declarativeNetRequest functions */ + /** + * Modifies the current set of session scoped rules for the extension. The rules with IDs listed in options.removeRuleIds are first removed, and then the rules given in options.addRules are added. These rules are not persisted across sessions and are backed in memory. + */ + function updateSessionRules(options: _UpdateSessionRulesOptions): Promise; + + /** Returns the ids for the current set of enabled static rulesets. */ + function getEnabledRulesets(): Promise; + + /** Returns the ids for the current set of enabled static rulesets. */ + function updateEnabledRulesets(updateRulesetOptions: _UpdateEnabledRulesetsUpdateRulesetOptions): Promise; + + /** Returns the remaining number of static rules an extension can enable */ + function getAvailableStaticRuleCount(): Promise; + + /** Returns the current set of session scoped rules for the extension. */ + function getSessionRules(): Promise; + + /** + * Checks if any of the extension's declarativeNetRequest rules would match a hypothetical request. + * @param request The details of the request to test. + */ + function testMatchOutcome( + request: _TestMatchOutcomeRequest, + options?: _TestMatchOutcomeOptions, + ): Promise<_TestMatchOutcomeReturnResult>; +} + +/** + * Asynchronous DNS API + * + * Permissions: `dns` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.dns { + /* dns types */ + /** An object encapsulating a DNS Record. */ + interface DNSRecord { + /** + * The canonical hostname for this record. this value is empty if the record was not fetched with the 'canonical_name' flag. + */ + canonicalName?: string | undefined; + /** Record retreived with TRR. */ + isTRR: string; + addresses: string[]; + } + + type ResolveFlags = _ResolveFlags[]; + + type _ResolveFlags = + | 'allow_name_collisions' + | 'bypass_cache' + | 'canonical_name' + | 'disable_ipv4' + | 'disable_ipv6' + | 'disable_trr' + | 'offline' + | 'priority_low' + | 'priority_medium' + | 'speculate'; + + /* dns functions */ + /** Resolves a hostname to a DNS record. */ + function resolve(hostname: string, flags?: ResolveFlags): Promise; +} + +/** + * Permissions: `downloads` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.downloads { + /* downloads types */ + type FilenameConflictAction = 'uniquify' | 'overwrite' | 'prompt'; + + type InterruptReason = + | 'FILE_FAILED' + | 'FILE_ACCESS_DENIED' + | 'FILE_NO_SPACE' + | 'FILE_NAME_TOO_LONG' + | 'FILE_TOO_LARGE' + | 'FILE_VIRUS_INFECTED' + | 'FILE_TRANSIENT_ERROR' + | 'FILE_BLOCKED' + | 'FILE_SECURITY_CHECK_FAILED' + | 'FILE_TOO_SHORT' + | 'NETWORK_FAILED' + | 'NETWORK_TIMEOUT' + | 'NETWORK_DISCONNECTED' + | 'NETWORK_SERVER_DOWN' + | 'NETWORK_INVALID_REQUEST' + | 'SERVER_FAILED' + | 'SERVER_NO_RANGE' + | 'SERVER_BAD_CONTENT' + | 'SERVER_UNAUTHORIZED' + | 'SERVER_CERT_PROBLEM' + | 'SERVER_FORBIDDEN' + | 'USER_CANCELED' + | 'USER_SHUTDOWN' + | 'CRASH'; + + /** + * *file*: + * The download's filename is suspicious. + * *url*: + * The download's URL is known to be malicious. + * *content*: + * The downloaded file is known to be malicious. + * *uncommon*: + * The download's URL is not commonly downloaded and could be dangerous. + * *safe*: + * The download presents no known danger to the user's computer. + * + * These string constants will never change, however the set of DangerTypes may change. + */ + type DangerType = 'file' | 'url' | 'content' | 'uncommon' | 'host' | 'unwanted' | 'safe' | 'accepted'; + + /** + * *in_progress*: + * The download is currently receiving data from the server. + * *interrupted*: + * An error broke the connection with the file host. + * *complete*: + * The download completed successfully. + * + * These string constants will never change, however the set of States may change. + */ + type State = 'in_progress' | 'interrupted' | 'complete'; + + interface DownloadItem { + /** An identifier that is persistent across browser sessions. */ + id: number; + /** Absolute URL. */ + url: string; + referrer?: string | undefined; + /** Absolute local path. */ + filename: string; + /** False if this download is recorded in the history, true if it is not recorded. */ + incognito: boolean; + /** The cookie store ID of the contextual identity. */ + cookieStoreId?: string | undefined; + /** Indication of whether this download is thought to be safe or known to be suspicious. */ + danger: DangerType; + /** The file's MIME type. */ + mime?: string | undefined; + /** Number of milliseconds between the unix epoch and when this download began. */ + startTime: string; + /** Number of milliseconds between the unix epoch and when this download ended. */ + endTime?: string | undefined; + estimatedEndTime?: string | undefined; + /** Indicates whether the download is progressing, interrupted, or complete. */ + state: State; + /** True if the download has stopped reading data from the host, but kept the connection open. */ + paused: boolean; + canResume: boolean; + /** Number indicating why a download was interrupted. */ + error?: InterruptReason | undefined; + /** Number of bytes received so far from the host, without considering file compression. */ + bytesReceived: number; + /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ + totalBytes: number; + /** Number of bytes in the whole file post-decompression, or -1 if unknown. */ + fileSize: number; + exists: boolean; + byExtensionId?: string | undefined; + byExtensionName?: string | undefined; + } + + interface StringDelta { + current?: string | undefined; + previous?: string | undefined; + } + + interface DoubleDelta { + current?: number | undefined; + previous?: number | undefined; + } + + interface BooleanDelta { + current?: boolean | undefined; + previous?: boolean | undefined; + } + + /** + * A time specified as a Date object, a number or string representing milliseconds since the epoch, or an ISO 8601 string + */ + type DownloadTime = string | extensionTypes.Date; + + /** + * Parameters that combine to specify a predicate that can be used to select a set of downloads. Used for example in search() and erase() + */ + interface DownloadQuery { + /** + * This array of search terms limits results to DownloadItems whose `filename` or `url` contain all of the search terms that do not begin with a dash '-' and none of the search terms that do begin with a dash. + */ + query?: string[] | undefined; + /** Limits results to downloads that started before the given ms since the epoch. */ + startedBefore?: DownloadTime | undefined; + /** Limits results to downloads that started after the given ms since the epoch. */ + startedAfter?: DownloadTime | undefined; + /** Limits results to downloads that ended before the given ms since the epoch. */ + endedBefore?: DownloadTime | undefined; + /** Limits results to downloads that ended after the given ms since the epoch. */ + endedAfter?: DownloadTime | undefined; + /** Limits results to downloads whose totalBytes is greater than the given integer. */ + totalBytesGreater?: number | undefined; + /** Limits results to downloads whose totalBytes is less than the given integer. */ + totalBytesLess?: number | undefined; + /** Limits results to DownloadItems whose `filename` matches the given regular expression. */ + filenameRegex?: string | undefined; + /** Limits results to DownloadItems whose `url` matches the given regular expression. */ + urlRegex?: string | undefined; + /** + * Setting this integer limits the number of results. Otherwise, all matching DownloadItems will be returned. + */ + limit?: number | undefined; + /** + * Setting elements of this array to DownloadItem properties in order to sort the search results. For example, setting `orderBy='startTime'` sorts the DownloadItems by their start time in ascending order. To specify descending order, prefix `orderBy` with a hyphen: '-startTime'. + */ + orderBy?: string[] | undefined; + id?: number | undefined; + /** Absolute URL. */ + url?: string | undefined; + /** Absolute local path. */ + filename?: string | undefined; + /** The cookie store ID of the contextual identity. */ + cookieStoreId?: string | undefined; + /** Indication of whether this download is thought to be safe or known to be suspicious. */ + danger?: DangerType | undefined; + /** The file's MIME type. */ + mime?: string | undefined; + startTime?: string | undefined; + endTime?: string | undefined; + /** Indicates whether the download is progressing, interrupted, or complete. */ + state?: State | undefined; + /** True if the download has stopped reading data from the host, but kept the connection open. */ + paused?: boolean | undefined; + /** Why a download was interrupted. */ + error?: InterruptReason | undefined; + /** Number of bytes received so far from the host, without considering file compression. */ + bytesReceived?: number | undefined; + /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */ + totalBytes?: number | undefined; + /** Number of bytes in the whole file post-decompression, or -1 if unknown. */ + fileSize?: number | undefined; + exists?: boolean | undefined; + } + + /** The HTTP method to use if the URL uses the HTTP[S] protocol. */ + type _DownloadOptionsMethod = 'GET' | 'POST'; + + interface _DownloadOptionsHeaders { + /** Name of the HTTP header. */ + name: string; + /** Value of the HTTP header. */ + value: string; + } + + /** What to download and how. */ + interface _DownloadOptions { + /** The URL to download. */ + url: string; + /** A file path relative to the Downloads directory to contain the downloaded file. */ + filename?: string | undefined; + /** Whether to associate the download with a private browsing session. */ + incognito?: boolean | undefined; + /** The cookie store ID of the contextual identity; requires "cookies" permission. */ + cookieStoreId?: string | undefined; + conflictAction?: FilenameConflictAction | undefined; + /** + * Use a file-chooser to allow the user to select a filename. If the option is not specified, the file chooser will be shown only if the Firefox "Always ask you where to save files" option is enabled (i.e. the pref `browser.download.useDownloadDir` is set to `false`). + */ + saveAs?: boolean | undefined; + /** The HTTP method to use if the URL uses the HTTP[S] protocol. */ + method?: _DownloadOptionsMethod | undefined; + /** + * Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary containing the keys `name` and either `value` or `binaryValue`, restricted to those allowed by XMLHttpRequest. + */ + headers?: _DownloadOptionsHeaders[] | undefined; + /** Post body. */ + body?: string | undefined; + /** + * When this flag is set to `true`, then the browser will allow downloads to proceed after encountering HTTP errors such as `404 Not Found`. + */ + allowHttpErrors?: boolean | undefined; + } + + interface _GetFileIconOptions { + /** + * The size of the icon. The returned icon will be square with dimensions size * size pixels. The default size for the icon is 32x32 pixels. + */ + size?: number | undefined; + } + + interface _OnChangedDownloadDelta { + /** The `id` of the DownloadItem that changed. */ + id: number; + /** Describes a change in a DownloadItem's `url`. */ + url?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `filename`. */ + filename?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `danger`. */ + danger?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `mime`. */ + mime?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `startTime`. */ + startTime?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `endTime`. */ + endTime?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `state`. */ + state?: StringDelta | undefined; + canResume?: BooleanDelta | undefined; + /** Describes a change in a DownloadItem's `paused`. */ + paused?: BooleanDelta | undefined; + /** Describes a change in a DownloadItem's `error`. */ + error?: StringDelta | undefined; + /** Describes a change in a DownloadItem's `totalBytes`. */ + totalBytes?: DoubleDelta | undefined; + /** Describes a change in a DownloadItem's `fileSize`. */ + fileSize?: DoubleDelta | undefined; + exists?: BooleanDelta | undefined; + } + + /* downloads functions */ + /** + * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If both `filename` and `saveAs` are specified, then the Save As dialog will be displayed, pre-populated with the specified `filename`. If the download started successfully, `callback` will be called with the new DownloadItem's `downloadId`. If there was an error starting the download, then `callback` will be called with `downloadId=undefined` and browser.extension.lastError will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. You must not parse it. + * @param options What to download and how. + */ + function download(options: _DownloadOptions): Promise; + + /** + * Find DownloadItems. Set `query` to the empty object to get all DownloadItems. To get a specific DownloadItem, set only the `id` field. + */ + function search(query: DownloadQuery): Promise; + + /** + * Pause the download. If the request was successful the download is in a paused state. Otherwise browser.extension.lastError contains an error message. The request will fail if the download is not active. + * @param downloadId The id of the download to pause. + */ + function pause(downloadId: number): Promise; + + /** + * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise browser.extension.lastError contains an error message. The request will fail if the download is not active. + * @param downloadId The id of the download to resume. + */ + function resume(downloadId: number): Promise; + + /** + * Cancel a download. When `callback` is run, the download is cancelled, completed, interrupted or doesn't exist anymore. + * @param downloadId The id of the download to cancel. + */ + function cancel(downloadId: number): Promise; + + /** + * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, browser.extension.lastError will contain an error message. + * @param downloadId The identifier for the download. + */ + function getFileIcon(downloadId: number, options?: _GetFileIconOptions): Promise; + + /** Open the downloaded file. */ + function open(downloadId: number): Promise; + + /** Show the downloaded file in its folder in a file manager. */ + function show(downloadId: number): Promise; + + function showDefaultFolder(): void; + + /** Erase matching DownloadItems from history */ + function erase(query: DownloadQuery): Promise; + + function removeFile(downloadId: number): Promise; + + /** + * Prompt the user to either accept or cancel a dangerous download. `acceptDanger()` does not automatically accept dangerous downloads. + * @deprecated Unsupported on Firefox at this time. + */ + function acceptDanger(downloadId: number): Promise; + + /** + * Initiate dragging the file to another application. + * @deprecated Unsupported on Firefox at this time. + */ + function drag(downloadId: number): void; + + /** @deprecated Unsupported on Firefox at this time. */ + function setShelfEnabled(enabled: boolean): void; + + /* downloads events */ + /** This event fires with the DownloadItem object when a download begins. */ + const onCreated: WebExtEvent<(downloadItem: DownloadItem) => void>; + + /** + * Fires with the `downloadId` when a download is erased from history. + * @param downloadId The `id` of the DownloadItem that was erased. + */ + const onErased: WebExtEvent<(downloadId: number) => void>; + + /** + * When any of a DownloadItem's properties except `bytesReceived` changes, this event fires with the `downloadId` and an object containing the properties that changed. + */ + const onChanged: WebExtEvent<(downloadDelta: _OnChangedDownloadDelta) => void>; +} + +/** + * The `browser.events` namespace contains common types used by APIs dispatching events to notify you when something interesting happens. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.events { + /* events types */ + /** Description of a declarative rule for handling events. */ + interface Rule { + /** Optional identifier that allows referencing this rule. */ + id?: string | undefined; + /** Tags can be used to annotate rules and perform operations on sets of rules. */ + tags?: string[] | undefined; + /** List of conditions that can trigger the actions. */ + conditions: any[]; + /** List of actions that are triggered if one of the condtions is fulfilled. */ + actions: any[]; + /** Optional priority of this rule. Defaults to 100. */ + priority?: number | undefined; + } + + /** An object which allows the addition and removal of listeners for a Chrome event. */ + interface Event { + /** + * Registers an event listener _callback_ to an event. + * @param callback Called when an event occurs. The parameters of this function depend on the type of event. + */ + addListener(callback: () => void): void; + /** + * Deregisters an event listener _callback_ from an event. + * @param callback Listener that shall be unregistered. + */ + removeListener(callback: () => void): void; + /** + * @param callback Listener whose registration status shall be tested. + * @returns True if _callback_ is registered to the event. + */ + hasListener(callback: () => void): boolean; + /** @returns True if any event listeners are registered to the event. */ + hasListeners(): boolean; + /** + * Registers rules to handle events. + * @param eventName Name of the event this function affects. + * @param webViewInstanceId If provided, this is an integer that uniquely identfies the associated with this function call. + * @param rules Rules to be registered. These do not replace previously registered rules. + * @deprecated Unsupported on Firefox at this time. + */ + addRules?(eventName: string, webViewInstanceId: number, rules: Rule[]): Promise; + /** + * Returns currently registered rules. + * @param eventName Name of the event this function affects. + * @param webViewInstanceId If provided, this is an integer that uniquely identfies the associated with this function call. + * @param [ruleIdentifiers] If an array is passed, only rules with identifiers contained in this array are returned. + * @deprecated Unsupported on Firefox at this time. + */ + getRules?(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): Promise; + /** + * Unregisters currently registered rules. + * @param eventName Name of the event this function affects. + * @param webViewInstanceId If provided, this is an integer that uniquely identfies the associated with this function call. + * @param [ruleIdentifiers] If an array is passed, only rules with identifiers contained in this array are unregistered. + * @deprecated Unsupported on Firefox at this time. + */ + removeRules?(eventName: string, webViewInstanceId: number, ruleIdentifiers?: string[]): Promise; + } + + /** Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ + interface UrlFilter { + /** + * Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. + */ + hostContains?: string | undefined; + /** Matches if the host name of the URL is equal to a specified string. */ + hostEquals?: string | undefined; + /** Matches if the host name of the URL starts with a specified string. */ + hostPrefix?: string | undefined; + /** Matches if the host name of the URL ends with a specified string. */ + hostSuffix?: string | undefined; + /** Matches if the path segment of the URL contains a specified string. */ + pathContains?: string | undefined; + /** Matches if the path segment of the URL is equal to a specified string. */ + pathEquals?: string | undefined; + /** Matches if the path segment of the URL starts with a specified string. */ + pathPrefix?: string | undefined; + /** Matches if the path segment of the URL ends with a specified string. */ + pathSuffix?: string | undefined; + /** Matches if the query segment of the URL contains a specified string. */ + queryContains?: string | undefined; + /** Matches if the query segment of the URL is equal to a specified string. */ + queryEquals?: string | undefined; + /** Matches if the query segment of the URL starts with a specified string. */ + queryPrefix?: string | undefined; + /** Matches if the query segment of the URL ends with a specified string. */ + querySuffix?: string | undefined; + /** + * Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. + */ + urlContains?: string | undefined; + /** + * Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. + */ + urlEquals?: string | undefined; + /** + * Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the [RE2 syntax](https://github.com/google/re2/blob/master/doc/syntax.txt). + */ + urlMatches?: string | undefined; + /** + * Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the [RE2 syntax](https://github.com/google/re2/blob/master/doc/syntax.txt). + */ + originAndPathMatches?: string | undefined; + /** + * Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. + */ + urlPrefix?: string | undefined; + /** + * Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. + */ + urlSuffix?: string | undefined; + /** Matches if the scheme of the URL is equal to any of the schemes specified in the array. */ + schemes?: string[] | undefined; + /** + * Matches if the port of the URL is contained in any of the specified port lists. For example `[80, 443, [1000, 1200]]` matches all requests on port 80, 443 and in the range 1000-1200. + */ + ports?: Array | undefined; + } +} + +/** Not allowed in: Content scripts, Devtools pages */ +declare namespace browser.experiments { + /* experiments types */ + interface ExperimentAPI { + schema: ExperimentURL; + parent?: _ExperimentAPIParent | undefined; + child?: _ExperimentAPIChild | undefined; + } + + type ExperimentURL = string; + + type APIPaths = APIPath[]; + + type APIPath = string[]; + + type APIEvents = APIEvent[]; + + type APIEvent = 'startup'; + + type APIParentScope = 'addon_parent' | 'content_parent' | 'devtools_parent'; + + type APIChildScope = 'addon_child' | 'content_child' | 'devtools_child'; + + interface _ExperimentAPIParent { + events?: APIEvents | undefined; + paths?: APIPaths | undefined; + script: ExperimentURL; + scopes?: APIParentScope[] | undefined; + } + + interface _ExperimentAPIChild { + paths: APIPaths; + script: ExperimentURL; + scopes: APIChildScope[]; + } +} + +/** + * The `browser.extension` API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing. + */ +declare namespace browser.extension { + /* extension types */ + /** The type of extension view. */ + type ViewType = 'tab' | 'popup' | 'sidebar'; + + /** + * Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be `undefined`. + * @deprecated Please use `runtime.lastError`. + * Not supported on manifest versions above 2. + */ + interface _LastError { + /** Description of the error that has taken place. */ + message: string; + } + + interface _GetViewsFetchProperties { + /** + * The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'popup', 'sidebar'. + */ + type?: ViewType | undefined; + /** The window to restrict the search to. If omitted, returns all views. */ + windowId?: number | undefined; + /** Find a view according to a tab id. If this field is omitted, returns all views. */ + tabId?: number | undefined; + } + + /* extension properties */ + /** + * Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be `undefined`. + * @deprecated Please use `runtime.lastError`. + * Not supported on manifest versions above 2. + */ + const lastError: _LastError | undefined; + + /** + * True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior. + */ + const inIncognitoContext: boolean | undefined; + + /* extension functions */ + /** + * Converts a relative path within an extension install directory to a fully-qualified URL. + * @param path A path to a resource within an extension expressed relative to its install directory. + * @deprecated Please use `runtime.getURL`. + * Not supported on manifest versions above 2. + * @returns The fully-qualified URL to the resource. + */ + function getURL(path: string): string; + + /** + * Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. + * @returns Array of global objects + */ + function getViews(fetchProperties?: _GetViewsFetchProperties): Window[]; + + /** + * Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page. + */ + function getBackgroundPage(): Window | void; + + /** + * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox. + */ + function isAllowedIncognitoAccess(): Promise; + + /** + * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox. + */ + function isAllowedFileSchemeAccess(): Promise; + + /** + * Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the browser vendor's store. + * @deprecated Unsupported on Firefox at this time. + */ + function setUpdateUrlData(data: string): void; + + /* extension events */ + /** + * Fired when a request is sent from either an extension process or a content script. + * @param request The request sent by the calling script. + * @param sendResponse Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one `onRequest` listener in the same document, then only one may send a response. + * @deprecated Please use `runtime.onMessage`. + */ + const onRequest: + | WebExtEvent<(request: any, sender: runtime.MessageSender, sendResponse: (response?: any) => void) => void> + | undefined; + + /** + * Fired when a request is sent from another extension. + * @param request The request sent by the calling script. + * @param sendResponse Function to call when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. + * @deprecated Please use `runtime.onMessageExternal`. + */ + const onRequestExternal: + | WebExtEvent<(request: any, sender: runtime.MessageSender, sendResponse: (response?: any) => void) => void> + | undefined; +} + +/** + * The `browser.extensionTypes` API contains type declarations for WebExtensions. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.extensionTypes { + /* extensionTypes types */ + /** The format of an image. */ + type ImageFormat = 'jpeg' | 'png'; + + /** Details about the format, quality, area and scale of the capture. */ + interface ImageDetails { + /** The format of the resulting image. Default is `"jpeg"`. */ + format?: ImageFormat | undefined; + /** + * When format is `"jpeg"`, controls the quality of the resulting image. This value is ignored for PNG images. As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease. + */ + quality?: number | undefined; + /** + * The area of the document to capture, in CSS pixels, relative to the page. If omitted, capture the visible viewport. + */ + rect?: _ImageDetailsRect | undefined; + /** The scale of the resulting image. Defaults to `devicePixelRatio`. */ + scale?: number | undefined; + /** + * If true, temporarily resets the scroll position of the document to 0\. Only takes effect if rect is also specified. + */ + resetScrollPosition?: boolean | undefined; + } + + /** The soonest that the JavaScript or CSS will be injected into the tab. */ + type RunAt = 'document_start' | 'document_end' | 'document_idle'; + + /** The origin of the CSS to inject, this affects the cascading order (priority) of the stylesheet. */ + type CSSOrigin = 'user' | 'author'; + + /** + * Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time. + */ + interface InjectDetails { + /** + * JavaScript or CSS code to inject. + * + * **Warning:** + * Be careful using the `code` parameter. Incorrect use of it may open your extension to [cross site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. + */ + code?: string | undefined; + /** JavaScript or CSS file to inject. */ + file?: string | undefined; + /** + * If allFrames is `true`, implies that the JavaScript or CSS should be injected into all frames of current page. By default, it's `false` and is only injected into the top frame. + */ + allFrames?: boolean | undefined; + /** + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is `false`. + */ + matchAboutBlank?: boolean | undefined; + /** The ID of the frame to inject the script into. This may not be used in combination with `allFrames`. */ + frameId?: number | undefined; + /** The soonest that the JavaScript or CSS will be injected into the tab. Defaults to "document_idle". */ + runAt?: RunAt | undefined; + /** The css origin of the stylesheet to inject. Defaults to "author". */ + cssOrigin?: CSSOrigin | undefined; + } + + type Date = string | number | globalThis.Date; + + type ExtensionFileOrCode = + | { + file: _manifest.ExtensionURL; + } + | { + code: string; + }; + + /** A plain JSON value */ + type PlainJSONValue = null | string | number | boolean | _PlainJSONArray | _PlainJSONObject; + + /** + * The area of the document to capture, in CSS pixels, relative to the page. If omitted, capture the visible viewport. + */ + interface _ImageDetailsRect { + x: number; + y: number; + width: number; + height: number; + } + + interface _PlainJSONArray extends Array {} + + interface _PlainJSONObject { + [key: string]: PlainJSONValue; + } +} + +/** + * Exposes the browser's profiler. + * + * Permissions: `geckoProfiler` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.geckoProfiler { + /* geckoProfiler types */ + type ProfilerFeature = + | 'java' + | 'js' + | 'mainthreadio' + | 'fileio' + | 'fileioall' + | 'noiostacks' + | 'screenshots' + | 'seqstyle' + | 'stackwalk' + | 'jsallocations' + | 'nostacksampling' + | 'preferencereads' + | 'nativeallocations' + | 'ipcmessages' + | 'audiocallbacktracing' + | 'cpu' + | 'notimerresolutionchange' + | 'cpuallthreads' + | 'samplingallthreads' + | 'markersallthreads' + | 'unregisteredthreads' + | 'processcpu' + | 'power' + | 'responsiveness'; + + type Supports = 'windowLength'; + + interface _StartSettings { + /** + * The maximum size in bytes of the buffer used to store profiling data. A larger value allows capturing a profile that covers a greater amount of time. + */ + bufferSize: number; + /** + * The length of the window of time that's kept in the buffer. Any collected samples are discarded as soon as they are older than the number of seconds specified in this setting. Zero means no duration restriction. + */ + windowLength?: number | undefined; + /** + * Interval in milliseconds between samples of profiling data. A smaller value will increase the detail of the profiles captured. + */ + interval: number; + /** A list of active features for the profiler. */ + features: ProfilerFeature[]; + /** A list of thread names for which to capture profiles. */ + threads?: string[] | undefined; + } + + /* geckoProfiler functions */ + /** Starts the profiler with the specified settings. */ + function start(settings: _StartSettings): Promise; + + /** Stops the profiler and discards any captured profile data. */ + function stop(): Promise; + + /** Pauses the profiler, keeping any profile data that is already written. */ + function pause(): Promise; + + /** Resumes the profiler with the settings that were initially used to start it. */ + function resume(): Promise; + + /** + * Gathers the profile data from the current profiling session, and writes it to disk. The returned promise resolves to a path that locates the created file. + * @param fileName The name of the file inside the profile/profiler directory + */ + function dumpProfileToFile(fileName: string): Promise; + + /** Gathers the profile data from the current profiling session. */ + function getProfile(): Promise; + + /** + * Gathers the profile data from the current profiling session. The returned promise resolves to an array buffer that contains a JSON string. + */ + function getProfileAsArrayBuffer(): Promise; + + /** + * Gathers the profile data from the current profiling session. The returned promise resolves to an array buffer that contains a gzipped JSON string. + */ + function getProfileAsGzippedArrayBuffer(): Promise; + + /** + * Gets the debug symbols for a particular library. + * @param debugName The name of the library's debug file. For example, 'xul.pdb + * @param breakpadId The Breakpad ID of the library + */ + function getSymbols(debugName: string, breakpadId: string): Promise; + + /* geckoProfiler events */ + /** + * Fires when the profiler starts/stops running. + * @param isRunning Whether the profiler is running or not. Pausing the profiler will not affect this value. + */ + const onRunning: WebExtEvent<(isRunning: boolean) => void>; +} + +/** + * Use the `browser.i18n` infrastructure to implement internationalization across your whole app or extension. + */ +declare namespace browser.i18n { + /* i18n types */ + /** + * An ISO language code such as `en` or `fr`. For a complete list of languages supported by this method, see [kLanguageInfoTable](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc). For an unknown language, `und` will be returned, which means that [percentage] of the text is unknown to CLD + */ + type LanguageCode = string; + + /** DetectedLanguage object that holds detected ISO language code and its percentage in the input string */ + interface _DetectLanguageReturnResultLanguages { + language: LanguageCode; + /** The percentage of the detected language */ + percentage: number; + } + + /** + * LanguageDetectionResult object that holds detected langugae reliability and array of DetectedLanguage + */ + interface _DetectLanguageReturnResult { + /** CLD detected language reliability */ + isReliable: boolean; + /** array of detectedLanguage */ + languages: _DetectLanguageReturnResultLanguages[]; + } + + /* i18n functions */ + /** + * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use `i18n.getUILanguage`. + */ + function getAcceptLanguages(): Promise; + + /** + * Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the `getMessage()` call is wrong — for example, _messageName_ is not a string or the _substitutions_ array has more than 9 elements — this method returns `undefined`. + * @param messageName The name of the message, as specified in the `messages.json` file. + * @param [substitutions] Substitution strings, if the message requires any. + * @returns Message localized for current locale. + */ + function getMessage(messageName: string, substitutions?: any): string; + + /** + * Gets the browser UI language of the browser. This is different from `i18n.getAcceptLanguages` which returns the preferred user languages. + * @returns The browser UI language code such as en-US or fr-FR. + */ + function getUILanguage(): string; + + /** + * Detects the language of the provided text using CLD. + * @param text User input string to be translated. + */ + function detectLanguage(text: string): Promise<_DetectLanguageReturnResult>; +} + +/** + * Use the browser.identity API to get OAuth2 access tokens. + * + * Permissions: `identity` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.identity { + /* identity types */ + /** An object encapsulating an OAuth account id. */ + interface AccountInfo { + /** A unique identifier for the account. This ID will not change for the lifetime of the account. */ + id: string; + } + + interface _GetAuthTokenDetails { + interactive?: boolean | undefined; + account?: AccountInfo | undefined; + scopes?: string[] | undefined; + } + + interface _GetProfileUserInfoReturnUserinfo { + email: string; + id: string; + } + + interface _RemoveCachedAuthTokenReturnUserinfo { + email: string; + id: string; + } + + interface _RemoveCachedAuthTokenDetails { + token: string; + } + + interface _LaunchWebAuthFlowDetails { + url: _manifest.HttpURL; + interactive?: boolean | undefined; + } + + /* identity functions */ + /** + * Retrieves a list of AccountInfo objects describing the accounts present on the profile. + * @deprecated Unsupported on Firefox at this time. + */ + function getAccounts(): Promise; + + /** + * Gets an OAuth2 access token using the client ID and scopes specified in the oauth2 section of manifest.json. + * @deprecated Unsupported on Firefox at this time. + */ + function getAuthToken(details?: _GetAuthTokenDetails): Promise; + + /** + * Retrieves email address and obfuscated gaia id of the user signed into a profile. + * @deprecated Unsupported on Firefox at this time. + */ + function getProfileUserInfo(): Promise<_GetProfileUserInfoReturnUserinfo>; + + /** + * Removes an OAuth2 access token from the Identity API's token cache. + * @deprecated Unsupported on Firefox at this time. + */ + function removeCachedAuthToken( + details: _RemoveCachedAuthTokenDetails, + ): Promise<_RemoveCachedAuthTokenReturnUserinfo>; + + /** Starts an auth flow at the specified URL. */ + function launchWebAuthFlow(details: _LaunchWebAuthFlowDetails): Promise; + + /** + * Generates a redirect URL to be used in |launchWebAuthFlow|. + * @param [path] The path appended to the end of the generated URL. + */ + function getRedirectURL(path?: string): string; + + /* identity events */ + /** + * Fired when signin state changes for an account on the user's profile. + * @deprecated Unsupported on Firefox at this time. + */ + const onSignInChanged: WebExtEvent<(account: AccountInfo, signedIn: boolean) => void> | undefined; +} + +/** + * Use the `browser.idle` API to detect when the machine's idle state changes. + * + * Permissions: `idle` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.idle { + /* idle types */ + type IdleState = 'active' | 'idle'; + + /* idle functions */ + /** + * Returns "idle" if the user has not generated any input for a specified number of seconds, or "active" otherwise. + * @param detectionIntervalInSeconds The system is considered idle if detectionIntervalInSeconds seconds have elapsed since the last user input detected. + */ + function queryState(detectionIntervalInSeconds: number): Promise; + + /** + * Sets the interval, in seconds, used to determine when the system is in an idle state for onStateChanged events. The default interval is 60 seconds. + * @param intervalInSeconds Threshold, in seconds, used to determine when the system is in an idle state. + */ + function setDetectionInterval(intervalInSeconds: number): void; + + /* idle events */ + /** + * Fired when the system changes to an active or idle state. The event fires with "idle" if the the user has not generated any input for a specified number of seconds, and "active" when the user generates input on an idle system. + */ + const onStateChanged: WebExtEvent<(newState: IdleState) => void>; +} + +/** + * The `browser.management` API provides ways to manage the list of extensions that are installed and running. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.management { + /* management types */ + /** Information about an icon belonging to an extension. */ + interface IconInfo { + /** + * A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24, and 16. + */ + size: number; + /** + * The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is disabled, for example), append `?grayscale=true` to the URL. + */ + url: string; + } + + /** A reason the item is disabled. */ + type ExtensionDisabledReason = 'unknown' | 'permissions_increase'; + + /** The type of this extension, 'extension' or 'theme'. */ + type ExtensionType = 'extension' | 'theme'; + + /** + * How the extension was installed. One of + * `development`: The extension was loaded unpacked in developer mode, + * `normal`: The extension was installed normally via an .xpi file, + * `sideload`: The extension was installed by other software on the machine, + * `other`: The extension was installed by other means. + */ + type ExtensionInstallType = 'development' | 'normal' | 'sideload' | 'other'; + + /** Information about an installed extension. */ + interface ExtensionInfo { + /** The extension's unique identifier. */ + id: string; + /** The name of this extension. */ + name: string; + /** A short version of the name of this extension. */ + shortName?: string | undefined; + /** The description of this extension. */ + description: string; + /** The version of this extension. */ + version: string; + /** The version name of this extension if the manifest specified one. */ + versionName?: string | undefined; + /** Whether this extension can be disabled or uninstalled by the user. */ + mayDisable: boolean; + /** Whether it is currently enabled or disabled. */ + enabled: boolean; + /** A reason the item is disabled. */ + disabledReason?: ExtensionDisabledReason | undefined; + /** The type of this extension, 'extension' or 'theme'. */ + type: ExtensionType; + /** The URL of the homepage of this extension. */ + homepageUrl?: string | undefined; + /** The update URL of this extension. */ + updateUrl?: string | undefined; + /** The url for the item's options page, if it has one. */ + optionsUrl: string; + /** + * A list of icon information. Note that this just reflects what was declared in the manifest, and the actual image at that url may be larger or smaller than what was declared, so you might consider using explicit width and height attributes on img tags referencing these images. See the manifest documentation on icons for more details. + */ + icons?: IconInfo[] | undefined; + /** Returns a list of API based permissions. */ + permissions?: string[] | undefined; + /** Returns a list of host based permissions. */ + hostPermissions?: string[] | undefined; + /** How the extension was installed. */ + installType: ExtensionInstallType; + } + + interface _InstallReturnResult { + id: _manifest.ExtensionID; + } + + interface _InstallOptions { + /** URL pointing to the XPI file on addons.mozilla.org or similar. */ + url: _manifest.HttpURL; + /** A hash of the XPI file, using sha256 or stronger. */ + hash?: string | undefined; + } + + interface _UninstallSelfOptions { + /** Whether or not a confirm-uninstall dialog should prompt the user. Defaults to false. */ + showConfirmDialog?: boolean | undefined; + /** The message to display to a user when being asked to confirm removal of the extension. */ + dialogMessage?: string | undefined; + } + + /* management functions */ + /** Returns a list of information about installed extensions. */ + function getAll(): Promise; + + /** + * Returns information about the installed extension that has the given ID. + * @param id The ID from an item of `management.ExtensionInfo`. + */ + function get(id: _manifest.ExtensionID): Promise; + + /** Installs and enables a theme extension from the given url. */ + function install(options: _InstallOptions): Promise<_InstallReturnResult>; + + /** + * Returns information about the calling extension. Note: This function can be used without requesting the 'management' permission in the manifest. + */ + function getSelf(): Promise; + + /** + * Uninstalls the calling extension. Note: This function can be used without requesting the 'management' permission in the manifest. + */ + function uninstallSelf(options?: _UninstallSelfOptions): Promise; + + /** + * Enables or disables the given add-on. + * @param id ID of the add-on to enable/disable. + * @param enabled Whether to enable or disable the add-on. + */ + function setEnabled(id: string, enabled: boolean): Promise; + + /* management events */ + /** Fired when an addon has been disabled. */ + const onDisabled: WebExtEvent<(info: ExtensionInfo) => void>; + + /** Fired when an addon has been enabled. */ + const onEnabled: WebExtEvent<(info: ExtensionInfo) => void>; + + /** Fired when an addon has been installed. */ + const onInstalled: WebExtEvent<(info: ExtensionInfo) => void>; + + /** Fired when an addon has been uninstalled. */ + const onUninstalled: WebExtEvent<(info: ExtensionInfo) => void>; +} + +/** + * This API provides the ability to determine the status of and detect changes in the network connection. This API can only be used in privileged extensions. + * + * Permissions: `networkStatus` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.networkStatus { + /* networkStatus types */ + interface NetworkLinkInfo { + /** Status of the network link, if "unknown" then link is usually assumed to be "up" */ + status: _NetworkLinkInfoStatus; + /** If known, the type of network connection that is avialable. */ + type: _NetworkLinkInfoType; + /** If known, the network id or name. */ + id?: string | undefined; + } + + /** Status of the network link, if "unknown" then link is usually assumed to be "up" */ + type _NetworkLinkInfoStatus = 'unknown' | 'up' | 'down'; + + /** If known, the type of network connection that is avialable. */ + type _NetworkLinkInfoType = 'unknown' | 'ethernet' | 'usb' | 'wifi' | 'wimax' | 'mobile'; + + /* networkStatus functions */ + /** Returns the $(ref:NetworkLinkInfo} of the current network connection. */ + function getLinkInfo(): Promise; + + /* networkStatus events */ + /** Fired when the network connection state changes. */ + const onConnectionChanged: WebExtEvent<(details: NetworkLinkInfo) => void>; +} + +/** + * Permissions: `notifications` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.notifications { + /* notifications types */ + type TemplateType = 'basic' | 'image' | 'list' | 'progress'; + + type PermissionLevel = 'granted' | 'denied'; + + interface NotificationItem { + /** Title of one item of a list notification. */ + title: string; + /** Additional details about this item. */ + message: string; + } + + interface CreateNotificationOptions { + /** Which type of notification to display. */ + type: TemplateType; + /** A URL to the sender's avatar, app icon, or a thumbnail for image notifications. */ + iconUrl?: string | undefined; + /** A URL to the app icon mask. */ + appIconMaskUrl?: string | undefined; + /** Title of the notification (e.g. sender name for email). */ + title: string; + /** Main notification content. */ + message: string; + /** Alternate notification content with a lower-weight font. */ + contextMessage?: string | undefined; + /** Priority ranges from -2 to 2\. -2 is lowest priority. 2 is highest. Zero is default. */ + priority?: number | undefined; + /** A timestamp associated with the notification, in milliseconds past the epoch. */ + eventTime?: number | undefined; + /** + * Text and icons for up to two notification action buttons. + * @deprecated Unsupported on Firefox at this time. + */ + buttons?: _CreateNotificationOptionsButtons[] | undefined; + /** A URL to the image thumbnail for image-type notifications. */ + imageUrl?: string | undefined; + /** Items for multi-item notifications. */ + items?: NotificationItem[] | undefined; + /** Current progress ranges from 0 to 100. */ + progress?: number | undefined; + /** + * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification. + */ + isClickable?: boolean | undefined; + } + + interface UpdateNotificationOptions { + /** Which type of notification to display. */ + type?: TemplateType | undefined; + /** A URL to the sender's avatar, app icon, or a thumbnail for image notifications. */ + iconUrl?: string | undefined; + /** A URL to the app icon mask. */ + appIconMaskUrl?: string | undefined; + /** Title of the notification (e.g. sender name for email). */ + title?: string | undefined; + /** Main notification content. */ + message?: string | undefined; + /** Alternate notification content with a lower-weight font. */ + contextMessage?: string | undefined; + /** Priority ranges from -2 to 2\. -2 is lowest priority. 2 is highest. Zero is default. */ + priority?: number | undefined; + /** A timestamp associated with the notification, in milliseconds past the epoch. */ + eventTime?: number | undefined; + /** + * Text and icons for up to two notification action buttons. + * @deprecated Unsupported on Firefox at this time. + */ + buttons?: _UpdateNotificationOptionsButtons[] | undefined; + /** A URL to the image thumbnail for image-type notifications. */ + imageUrl?: string | undefined; + /** Items for multi-item notifications. */ + items?: NotificationItem[] | undefined; + /** Current progress ranges from 0 to 100. */ + progress?: number | undefined; + /** + * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification. + */ + isClickable?: boolean | undefined; + } + + interface _CreateNotificationOptionsButtons { + title: string; + iconUrl?: string | undefined; + } + + interface _UpdateNotificationOptionsButtons { + title: string; + iconUrl?: string | undefined; + } + + /* notifications functions */ + /** + * Creates and displays a notification. + * @param options Contents of the notification. + */ + function create(options: CreateNotificationOptions): Promise; + /** + * Creates and displays a notification. + * @param notificationId Identifier of the notification. If it is empty, this method generates an id. If it matches an existing notification, this method first clears that notification before proceeding with the create operation. + * @param options Contents of the notification. + */ + function create(notificationId: string, options: CreateNotificationOptions): Promise; + + /** + * Updates an existing notification. + * @param notificationId The id of the notification to be updated. + * @param options Contents of the notification to update to. + * @deprecated Unsupported on Firefox at this time. + */ + function update(notificationId: string, options: UpdateNotificationOptions): Promise; + + /** + * Clears an existing notification. + * @param notificationId The id of the notification to be updated. + */ + function clear(notificationId: string): Promise; + + /** Retrieves all the notifications. */ + function getAll(): Promise<{ [key: string]: CreateNotificationOptions }>; + + /** + * Retrieves whether the user has enabled notifications from this app or extension. + * @deprecated Unsupported on Firefox at this time. + */ + function getPermissionLevel(): Promise; + + /* notifications events */ + /** + * Fired when the notification closed, either by the system or by user action. + * @param notificationId The notificationId of the closed notification. + * @param byUser True if the notification was closed by the user. + */ + const onClosed: WebExtEvent<(notificationId: string, byUser: boolean) => void>; + + /** + * Fired when the user clicked in a non-button area of the notification. + * @param notificationId The notificationId of the clicked notification. + */ + const onClicked: WebExtEvent<(notificationId: string) => void>; + + /** + * Fired when the user pressed a button in the notification. + * @param notificationId The notificationId of the clicked notification. + * @param buttonIndex The index of the button clicked by the user. + */ + const onButtonClicked: WebExtEvent<(notificationId: string, buttonIndex: number) => void>; + + /** + * Fired when the user changes the permission level. + * @param level The new permission level. + * @deprecated Unsupported on Firefox at this time. + */ + const onPermissionLevelChanged: WebExtEvent<(level: PermissionLevel) => void> | undefined; + + /** + * Fired when the user clicked on a link for the app's notification settings. + * @deprecated Unsupported on Firefox at this time. + */ + const onShowSettings: WebExtEvent<() => void> | undefined; + + /** + * Fired when the notification is shown. + * @param notificationId The notificationId of the shown notification. + */ + const onShown: WebExtEvent<(notificationId: string) => void>; +} + +/** + * Use the `browser.pageAction` API to put icons inside the address bar. Page actions represent actions that can be taken on the current page, but that aren't applicable to all pages. + * + * Manifest keys: `page_action` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.pageAction { + /* pageAction types */ + /** Pixel data for an image. Must be an ImageData object (for example, from a `canvas` element). */ + type ImageDataType = ImageData; + + /** Information sent when a page action is clicked. */ + interface OnClickData { + /** An array of keyboard modifiers that were held while the menu item was clicked. */ + modifiers: _OnClickDataModifiers[]; + /** An integer value of button by which menu item was clicked. */ + button?: number | undefined; + } + + type _OnClickDataModifiers = 'Shift' | 'Alt' | 'Command' | 'Ctrl' | 'MacCtrl'; + + interface _IsShownDetails { + /** Specify the tab to get the shownness from. */ + tabId: number; + } + + interface _SetTitleDetails { + /** The id of the tab for which you want to modify the page action. */ + tabId: number; + /** The tooltip string. */ + title: string | null; + } + + interface _GetTitleDetails { + /** Specify the tab to get the title from. */ + tabId: number; + } + + interface _SetIconDetails { + /** The id of the tab for which you want to modify the page action. */ + tabId: number; + /** + * Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals `scale`, then image with size `scale` * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}' + */ + imageData?: + | ImageDataType + | { + [key: number]: ImageDataType; + } + | undefined; + /** + * Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals `scale`, then image with size `scale` * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}' + */ + path?: + | string + | { + [key: number]: string; + } + | undefined; + } + + interface _SetPopupDetails { + /** The id of the tab for which you want to modify the page action. */ + tabId: number; + /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */ + popup: string | null; + } + + interface _GetPopupDetails { + /** Specify the tab to get the popup from. */ + tabId: number; + } + + /* pageAction functions */ + /** + * Shows the page action. The page action is shown whenever the tab is selected. + * @param tabId The id of the tab for which you want to modify the page action. + */ + function show(tabId: number): Promise; + + /** + * Hides the page action. + * @param tabId The id of the tab for which you want to modify the page action. + */ + function hide(tabId: number): Promise; + + /** Checks whether the page action is shown. */ + function isShown(details: _IsShownDetails): Promise; + + /** Sets the title of the page action. This is displayed in a tooltip over the page action. */ + function setTitle(details: _SetTitleDetails): void; + + /** Gets the title of the page action. */ + function getTitle(details: _GetTitleDetails): Promise; + + /** + * Sets the icon for the page action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the **path** or the **imageData** property must be specified. + */ + function setIcon(details: _SetIconDetails): Promise; + + /** Sets the html document to be opened as a popup when the user clicks on the page action's icon. */ + function setPopup(details: _SetPopupDetails): void; + + /** Gets the html document set as the popup for this page action. */ + function getPopup(details: _GetPopupDetails): Promise; + + /** Opens the extension page action in the active window. */ + function openPopup(): Promise; + + /* pageAction events */ + /** Fired when a page action icon is clicked. This event will not fire if the page action has a popup. */ + const onClicked: WebExtEvent<(tab: tabs.Tab, info?: OnClickData) => void>; +} + +/** Not allowed in: Content scripts, Devtools pages */ +declare namespace browser.permissions { + /* permissions types */ + interface Permissions { + permissions?: _manifest.OptionalPermission[] | undefined; + origins?: _manifest.MatchPattern[] | undefined; + } + + interface AnyPermissions { + permissions?: _manifest.Permission[] | undefined; + origins?: _manifest.MatchPattern[] | undefined; + } + + /* permissions functions */ + /** Get a list of all the extension's permissions. */ + function getAll(): Promise; + + /** Check if the extension has the given permissions. */ + function contains(permissions: AnyPermissions): Promise; + + /** + * Request the given permissions. + * + * Not allowed in: Devtools pages + */ + function request(permissions: Permissions): Promise; + + /** Relinquish the given permissions. */ + function remove(permissions: Permissions): Promise; + + /* permissions events */ + /** Fired when the extension acquires new permissions. */ + const onAdded: WebExtEvent<(permissions: Permissions) => void>; + + /** Fired when permissions are removed from the extension. */ + const onRemoved: WebExtEvent<(permissions: Permissions) => void>; +} + +/** + * Permissions: `privacy` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.privacy {} + +/** + * Use the `browser.privacy` API to control usage of the features in the browser that can affect a user's privacy. + * + * Permissions: `privacy` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.privacy.network { + /* privacy.network types */ + /** The IP handling policy of WebRTC. */ + type IPHandlingPolicy = + | 'default' + | 'default_public_and_private_interfaces' + | 'default_public_interface_only' + | 'disable_non_proxied_udp' + | 'proxy_only'; + + /** An object which describes TLS minimum and maximum versions. */ + interface tlsVersionRestrictionConfig { + /** The minimum TLS version supported. */ + minimum?: _TlsVersionRestrictionConfigMinimum | undefined; + /** The maximum TLS version supported. */ + maximum?: _TlsVersionRestrictionConfigMaximum | undefined; + } + + /** The mode for https-only mode. */ + type HTTPSOnlyModeOption = 'always' | 'private_browsing' | 'never'; + + /** The minimum TLS version supported. */ + type _TlsVersionRestrictionConfigMinimum = 'TLSv1' | 'TLSv1.1' | 'TLSv1.2' | 'TLSv1.3' | 'unknown'; + + /** The maximum TLS version supported. */ + type _TlsVersionRestrictionConfigMaximum = 'TLSv1' | 'TLSv1.1' | 'TLSv1.2' | 'TLSv1.3' | 'unknown'; + + /* privacy.network properties */ + /** + * If enabled, the browser attempts to speed up your web browsing experience by pre-resolving DNS entries, prerendering sites (``), and preemptively opening TCP and SSL connections to servers. This preference's value is a boolean, defaulting to `true`. + */ + const networkPredictionEnabled: types.Setting; + + /** Allow users to enable and disable RTCPeerConnections (aka WebRTC). */ + const peerConnectionEnabled: types.Setting; + + /** + * Allow users to specify the media performance/privacy tradeoffs which impacts how WebRTC traffic will be routed and how much local address information is exposed. This preference's value is of type IPHandlingPolicy, defaulting to `default`. + */ + const webRTCIPHandlingPolicy: types.Setting; + + /** + * This property controls the minimum and maximum TLS versions. This setting's value is an object of `tlsVersionRestrictionConfig`. + */ + const tlsVersionRestriction: types.Setting; + + /** + * Allow users to query the mode for 'HTTPS-Only Mode'. This setting's value is of type HTTPSOnlyModeOption, defaulting to `never`. + */ + const httpsOnlyMode: types.Setting; + + /** + * Allow users to query the status of 'Global Privacy Control'. This setting's value is of type boolean, defaulting to `false`. + */ + const globalPrivacyControl: types.Setting; +} + +/** + * Use the `browser.privacy` API to control usage of the features in the browser that can affect a user's privacy. + * + * Permissions: `privacy` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.privacy.services { + /* privacy.services properties */ + /** + * If enabled, the password manager will ask if you want to save passwords. This preference's value is a boolean, defaulting to `true`. + */ + const passwordSavingEnabled: types.Setting; +} + +/** + * Use the `browser.privacy` API to control usage of the features in the browser that can affect a user's privacy. + * + * Permissions: `privacy` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.privacy.websites { + /* privacy.websites types */ + /** The mode for tracking protection. */ + type TrackingProtectionModeOption = 'always' | 'never' | 'private_browsing'; + + /** The settings for cookies. */ + interface CookieConfig { + /** The type of cookies to allow. */ + behavior?: _CookieConfigBehavior | undefined; + /** + * Whether to create all cookies as nonPersistent (i.e., session) cookies. + * @deprecated This property has no effect anymore and its value is always `false`.`` + */ + nonPersistentCookies?: boolean | undefined; + } + + /** The type of cookies to allow. */ + type _CookieConfigBehavior = + | 'allow_all' + | 'reject_all' + | 'reject_third_party' + | 'allow_visited' + | 'reject_trackers' + | 'reject_trackers_and_partition_foreign'; + + /* privacy.websites properties */ + /** + * If disabled, the browser blocks third-party sites from setting cookies. The value of this preference is of type boolean, and the default value is `true`. + * @deprecated Unsupported on Firefox at this time. + */ + const thirdPartyCookiesAllowed: types.Setting | undefined; + + /** + * If enabled, the browser sends auditing pings when requested by a website (``). The value of this preference is of type boolean, and the default value is `true`. + */ + const hyperlinkAuditingEnabled: types.Setting; + + /** + * If enabled, the browser sends `referer` headers with your requests. Yes, the name of this preference doesn't match the misspelled header. No, we're not going to change it. The value of this preference is of type boolean, and the default value is `true`. + */ + const referrersEnabled: types.Setting; + + /** + * If enabled, the browser attempts to appear similar to other users by reporting generic information to websites. This can prevent websites from uniquely identifying users. Examples of data that is spoofed include number of CPU cores, precision of JavaScript timers, the local timezone, and disabling features such as GamePad support, and the WebSpeech and Navigator APIs. The value of this preference is of type boolean, and the default value is `false`. + */ + const resistFingerprinting: types.Setting; + + /** + * If enabled, the browser will associate all data (including cookies, HSTS data, cached images, and more) for any third party domains with the domain in the address bar. This prevents third party trackers from using directly stored information to identify you across different websites, but may break websites where you login with a third party account (such as a Facebook or Google login.) The value of this preference is of type boolean, and the default value is `false`. + */ + const firstPartyIsolate: types.Setting; + + /** + * **Available on Windows and ChromeOS only**: If enabled, the browser provides a unique ID to plugins in order to run protected content. The value of this preference is of type boolean, and the default value is `true`. + * @deprecated Unsupported on Firefox at this time. + */ + const protectedContentEnabled: types.Setting | undefined; + + /** + * Allow users to specify the mode for tracking protection. This setting's value is of type TrackingProtectionModeOption, defaulting to `private_browsing_only`. + */ + const trackingProtectionMode: types.Setting; + + /** + * Allow users to specify the default settings for allowing cookies, as well as whether all cookies should be created as non-persistent cookies. This setting's value is of type CookieConfig. + */ + const cookieConfig: types.Setting; +} + +/** + * Provides access to global proxy settings for Firefox and proxy event listeners to handle dynamic proxy implementations. + * + * Permissions: `proxy` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.proxy { + /* proxy types */ + /** An object which describes proxy settings. */ + interface ProxyConfig { + /** The type of proxy to use. */ + proxyType?: _ProxyConfigProxyType | undefined; + /** The address of the http proxy, can include a port. */ + http?: string | undefined; + /** Use the http proxy server for all protocols. */ + httpProxyAll?: boolean | undefined; + /** + * The address of the ftp proxy, can include a port. Deprecated since Firefox 88. + * @deprecated The address of the ftp proxy, can include a port. Deprecated since Firefox 88. + */ + ftp?: string | undefined; + /** The address of the ssl proxy, can include a port. */ + ssl?: string | undefined; + /** The address of the socks proxy, can include a port. */ + socks?: string | undefined; + /** The version of the socks proxy. */ + socksVersion?: number | undefined; + /** A list of hosts which should not be proxied. */ + passthrough?: string | undefined; + /** A URL to use to configure the proxy. */ + autoConfigUrl?: string | undefined; + /** Do not prompt for authentication if password is saved. */ + autoLogin?: boolean | undefined; + /** Proxy DNS when using SOCKS v5. */ + proxyDNS?: boolean | undefined; + /** + * If true (the default value), do not use newer TLS protocol features that might have interoperability problems on the Internet. This is intended only for use with critical infrastructure like the updates, and is only available to privileged addons. + */ + respectBeConservative?: boolean | undefined; + } + + /** The type of proxy to use. */ + type _ProxyConfigProxyType = 'none' | 'autoDetect' | 'system' | 'manual' | 'autoConfig'; + + interface _OnRequestDetails { + /** + * The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request. + */ + requestId: string; + url: string; + /** Standard HTTP method. */ + method: string; + /** + * The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (`type` is `main_frame` or `sub_frame`), `frameId` indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab. + */ + frameId: number; + /** ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists. */ + parentFrameId: number; + /** True for private browsing requests. */ + incognito?: boolean | undefined; + /** The cookie store ID of the contextual identity. */ + cookieStoreId?: string | undefined; + /** URL of the resource that triggered this request. */ + originUrl?: string | undefined; + /** URL of the page into which the requested resource will be loaded. */ + documentUrl?: string | undefined; + /** The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab. */ + tabId: number; + /** How the requested resource will be used. */ + type: webRequest.ResourceType; + /** The time when this signal is triggered, in milliseconds since the epoch. */ + timeStamp: number; + /** Indicates if this response was fetched from disk cache. */ + fromCache: boolean; + /** The HTTP request headers that are going to be sent out with this request. */ + requestHeaders?: webRequest.HttpHeaders | undefined; + /** Url classification if the request has been classified. */ + urlClassification: webRequest.UrlClassification; + /** Indicates if this request and its content window hierarchy is third party. */ + thirdParty: boolean; + } + + interface _ProxyOnRequestEvent void> { + addListener(cb: TCallback, filter: webRequest.RequestFilter, extraInfoSpec?: Array<'requestHeaders'>): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + /* proxy properties */ + /** Configures proxy settings. This setting's value is an object of type ProxyConfig. */ + const settings: types.Setting; + + /* proxy events */ + /** Fired when proxy data is needed for a request. */ + const onRequest: _ProxyOnRequestEvent; + + /** Notifies about errors caused by the invalid use of the proxy API. */ + const onError: WebExtEvent<(error: Error) => void>; +} + +/** + * Use the `browser.runtime` API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs. + */ +declare namespace browser.runtime { + /* runtime types */ + /** An object which allows two way communication with other pages. */ + interface Port { + name: string; + disconnect: () => void; + postMessage: (message: object) => void; + /** This property will **only** be present on ports passed to onConnect/onConnectExternal listeners. */ + sender?: MessageSender | undefined; + error?: Error | undefined; + onMessage: WebExtEvent<(response: object) => void>; + onDisconnect: WebExtEvent<(port: Port) => void>; + } + + /** An object containing information about the script context that sent a message or request. */ + interface MessageSender { + /** + * The `tabs.Tab` which opened the connection, if any. This property will **only** be present when the connection was opened from a tab (including content scripts), and **only** if the receiver is an extension, not an app. + */ + tab?: tabs.Tab | undefined; + /** + * The frame that opened the connection. 0 for top-level frames, positive for child frames. This will only be set when `tab` is set. + */ + frameId?: number | undefined; + /** The ID of the extension or app that opened the connection, if any. */ + id?: string | undefined; + /** + * The URL of the page or frame that opened the connection. If the sender is in an iframe, it will be iframe's URL not the URL of the page which hosts it. + */ + url?: string | undefined; + /** + * The TLS channel ID of the page or frame that opened the connection, if requested by the extension or app, and if available. + * @deprecated Unsupported on Firefox at this time. + */ + tlsChannelId?: string | undefined; + } + + /** The operating system the browser is running on. */ + type PlatformOs = 'mac' | 'win' | 'android' | 'cros' | 'linux' | 'openbsd'; + + /** The machine's processor architecture. */ + type PlatformArch = 'aarch64' | 'arm' | 'ppc64' | 's390x' | 'sparc64' | 'x86-32' | 'x86-64' | 'noarch'; + + /** An object containing information about the current platform. */ + interface PlatformInfo { + /** The operating system the browser is running on. */ + os: PlatformOs; + /** The machine's processor architecture. */ + arch: PlatformArch; + /** + * The native client architecture. This may be different from arch on some platforms. + * @deprecated Unsupported on Firefox at this time. + */ + nacl_arch?: PlatformNaclArch | undefined; + } + + /** An object containing information about the current browser. */ + interface BrowserInfo { + /** The name of the browser, for example 'Firefox'. */ + name: string; + /** The name of the browser vendor, for example 'Mozilla'. */ + vendor: string; + /** The browser's version, for example '42.0.0' or '0.8.1pre'. */ + version: string; + /** The browser's build ID/date, for example '20160101'. */ + buildID: string; + } + + /** Result of the update check. */ + type RequestUpdateCheckStatus = 'throttled' | 'no_update' | 'update_available'; + + /** The reason that this event is being dispatched. */ + type OnInstalledReason = 'install' | 'update' | 'browser_update'; + + /** + * The reason that the event is being dispatched. 'app_update' is used when the restart is needed because the application is updated to a newer version. 'os_update' is used when the restart is needed because the browser/OS is updated to a newer version. 'periodic' is used when the system runs for more than the permitted uptime set in the enterprise policy. + */ + type OnRestartRequiredReason = 'app_update' | 'os_update' | 'periodic'; + + type PlatformNaclArch = 'arm' | 'x86-32' | 'x86-64'; + + /** This will be defined during an API method callback if there was an error */ + interface _LastError { + /** Details about the error which occurred. */ + message?: string | undefined; + } + + /** If an update is available, this contains more information about the available update. */ + interface _RequestUpdateCheckReturnDetails { + /** The version of the available update. */ + version: string; + } + + interface _ConnectConnectInfo { + /** Will be passed into onConnect for processes that are listening for the connection event. */ + name?: string | undefined; + /** + * Whether the TLS channel ID will be passed into onConnectExternal for processes that are listening for the connection event. + */ + includeTlsChannelId?: boolean | undefined; + } + + interface _SendMessageOptions { + /** + * Whether the TLS channel ID will be passed into onMessageExternal for processes that are listening for the connection event. + * @deprecated Unsupported on Firefox at this time. + */ + includeTlsChannelId?: boolean | undefined; + } + + type DirectoryEntry = any; + + interface _OnInstalledDetails { + /** The reason that this event is being dispatched. */ + reason: OnInstalledReason; + /** + * Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'. + */ + previousVersion?: string | undefined; + /** Indicates whether the addon is installed as a temporary extension. */ + temporary: boolean; + /** + * Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'. + * @deprecated Unsupported on Firefox at this time. + */ + id?: string | undefined; + } + + /** The manifest details of the available update. */ + interface _OnUpdateAvailableDetails { + /** The version number of the available update. */ + version: string; + } + + /* runtime properties */ + /** This will be defined during an API method callback if there was an error */ + const lastError: _LastError | undefined; + + /** The ID of the extension/app. */ + const id: string; + + /* runtime functions */ + /** + * Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set. + */ + function getBackgroundPage(): Promise; + + /** + * Open your Extension's options page, if possible. + * + * The precise behavior may depend on your manifest's `options_ui` or `options_page` key, or what the browser happens to support at the time. + * + * If your Extension does not declare an options page, or the browser failed to create one for some other reason, the callback will set `lastError`. + */ + function openOptionsPage(): Promise; + + /** + * Returns details about the app or extension from the manifest. The object returned is a serialization of the full manifest file. + */ + function getManifest(): _manifest.WebExtensionManifest; + + /** + * Converts a relative path within an app/extension install directory to a fully-qualified URL. + * @param path A path to a resource within an app/extension expressed relative to its install directory. + * @returns The fully-qualified URL to the resource. + */ + function getURL(path: string): string; + + /** + * Get the frameId of any window global or frame element. + * @param target A WindowProxy or a Browsing Context container element (IFrame, Frame, Embed, Object) for the target frame. + * @returns The frameId of the target frame, or -1 if it doesn't exist. + */ + function getFrameId(target: any): number; + + /** + * Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics, and implement surveys. Maximum 255 characters. + * @param [url] URL to be opened after the extension is uninstalled. This URL must have an http: or https: scheme. Set an empty string to not open a new tab upon uninstallation. + */ + function setUninstallURL(url?: string): Promise; + + /** Reloads the app or extension. */ + function reload(): void; + + /** + * Requests an update check for this app/extension. + * @deprecated Unsupported on Firefox at this time. + */ + function requestUpdateCheck(): Promise; + + /** + * Restart the device when the app runs in kiosk mode. Otherwise, it's no-op. + * @deprecated Unsupported on Firefox at this time. + */ + function restart(): void; + + /** + * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via `tabs.connect`. + * @returns Port through which messages can be sent and received. The port's `runtime.Port onDisconnect` event is fired if the extension/app does not exist. + */ + function connect(): Port; + /** + * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via `tabs.connect`. + * @param extensionId The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for web messaging. + * @returns Port through which messages can be sent and received. The port's `runtime.Port onDisconnect` event is fired if the extension/app does not exist. + */ + function connect(extensionId: string, connectInfo?: _ConnectConnectInfo): Port; + /** + * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via `tabs.connect`. + * @returns Port through which messages can be sent and received. The port's `runtime.Port onDisconnect` event is fired if the extension/app does not exist. + */ + function connect(connectInfo: _ConnectConnectInfo): Port; + + /** + * Connects to a native application in the host machine. + * + * Not allowed in: Devtools pages + * @param application The name of the registered application to connect to. + * @returns Port through which messages can be sent and received with the application + */ + function connectNative(application: string): Port; + + /** + * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to `runtime.connect` but only sends a single message, with an optional response. If sending to your extension, the `runtime.onMessage` event will be fired in each page, or `runtime.onMessageExternal`, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use `tabs.sendMessage`. + */ + function sendMessage(message: any, options?: _SendMessageOptions): Promise; + /** + * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to `runtime.connect` but only sends a single message, with an optional response. If sending to your extension, the `runtime.onMessage` event will be fired in each page, or `runtime.onMessageExternal`, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use `tabs.sendMessage`. + * @param extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging. + */ + function sendMessage(extensionId: string, message: any, options?: _SendMessageOptions): Promise; + + /** + * Send a single message to a native application. + * + * Not allowed in: Devtools pages + * @param application The name of the native messaging host. + * @param message The message that will be passed to the native messaging host. + */ + function sendNativeMessage(application: string, message: any): Promise; + + /** Returns information about the current browser. */ + function getBrowserInfo(): Promise; + + /** Returns information about the current platform. */ + function getPlatformInfo(): Promise; + + /** + * Returns a DirectoryEntry for the package directory. + * @deprecated Unsupported on Firefox at this time. + */ + function getPackageDirectoryEntry(): Promise; + + /* runtime events */ + /** + * Fired when a profile that has this extension installed first starts up. This event is not fired for incognito profiles. + */ + const onStartup: WebExtEvent<() => void>; + + /** + * Fired when the extension is first installed, when the extension is updated to a new version, and when the browser is updated to a new version. + */ + const onInstalled: WebExtEvent<(details: _OnInstalledDetails) => void>; + + /** + * Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded. + */ + const onSuspend: WebExtEvent<() => void>; + + /** Sent after onSuspend to indicate that the app won't be unloaded after all. */ + const onSuspendCanceled: WebExtEvent<() => void>; + + /** + * Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call `runtime.reload`. If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call `runtime.reload` manually in response to this event the update will not get installed until the next time the browser itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if `runtime.reload` is called in response to this event. + * @param details The manifest details of the available update. + */ + const onUpdateAvailable: WebExtEvent<(details: _OnUpdateAvailableDetails) => void>; + + /** + * Fired when an update for the browser is available, but isn't installed immediately because a browser restart is required. + * @deprecated Please use `runtime.onRestartRequired`. + */ + const onBrowserUpdateAvailable: WebExtEvent<() => void> | undefined; + + /** Fired when a connection is made from either an extension process or a content script. */ + const onConnect: WebExtEvent<(port: Port) => void>; + + /** Fired when a connection is made from another extension. */ + const onConnectExternal: WebExtEvent<(port: Port) => void>; + + /** + * Fired when a message is sent from either an extension process or a content script. + * @param message The message sent by the calling script. + * @param sendResponse Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one `onMessage` listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until `sendResponse` is called). + * @returns Return true from the event listener if you wish to call `sendResponse` after the event listener returns. + */ + const onMessage: WebExtEvent< + (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => boolean | Promise | void + >; + + /** + * Fired when a message is sent from another extension/app. Cannot be used in a content script. + * @param message The message sent by the calling script. + * @param sendResponse Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one `onMessage` listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until `sendResponse` is called). + * @returns Return true from the event listener if you wish to call `sendResponse` after the event listener returns. + */ + const onMessageExternal: WebExtEvent< + (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => boolean | Promise | void + >; + + /** + * Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps. + * @param reason The reason that the event is being dispatched. + * @deprecated Unsupported on Firefox at this time. + */ + const onRestartRequired: WebExtEvent<(reason: OnRestartRequiredReason) => void> | undefined; +} + +/** + * Use the scripting API to execute script in different contexts. + * + * Permissions: `scripting` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.scripting { + /* scripting types */ + /** Details of a script injection */ + interface ScriptInjection { + /** + * The arguments to curry into a provided function. This is only valid if the `func` parameter is specified. These arguments must be JSON-serializable. + */ + args?: any[] | undefined; + /** + * The path of the JS files to inject, relative to the extension's root directory. Exactly one of `files` and `func` must be specified. + */ + files?: string[] | undefined; + /** + * A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of `files` and `func` must be specified. + */ + func?: () => void | undefined; + /** Details specifying the target into which to inject the script. */ + target: InjectionTarget; + world?: ExecutionWorld | undefined; + /** + * Whether the injection should be triggered in the target as soon as possible (but not necessarily prior to page load). + */ + injectImmediately?: boolean | undefined; + } + + /** Result of a script injection. */ + interface InjectionResult { + /** The frame ID associated with the injection. */ + frameId: number; + /** The result of the script execution. */ + result?: any; + /** + * The error property is set when the script execution failed. The value is typically an (Error) object with a message property, but could be any value (including primitives and undefined) if the script threw or rejected with such a value. + */ + error?: any; + } + + interface InjectionTarget { + /** The IDs of specific frames to inject into. */ + frameIds?: number[] | undefined; + /** + * Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if `frameIds` is specified. + */ + allFrames?: boolean | undefined; + /** The ID of the tab into which to inject. */ + tabId: number; + } + + interface CSSInjection { + /** A string containing the CSS to inject. Exactly one of `files` and `css` must be specified. */ + css?: string | undefined; + /** + * The path of the CSS files to inject, relative to the extension's root directory. Exactly one of `files` and `css` must be specified. + */ + files?: string[] | undefined; + /** The style origin for the injection. Defaults to `'AUTHOR'`. */ + origin?: _CSSInjectionOrigin | undefined; + /** Details specifying the target into which to inject the CSS. */ + target: InjectionTarget; + } + + interface ContentScriptFilter { + /** + * The IDs of specific scripts to retrieve with `getRegisteredContentScripts()` or to unregister with `unregisterContentScripts()`. + */ + ids?: string[] | undefined; + } + + /** + * The JavaScript world for a script to execute within. We currently only support the `'ISOLATED'` world. + */ + type ExecutionWorld = 'ISOLATED'; + + interface RegisteredContentScript { + /** + * If specified true, it will inject into all frames, even if the frame is not the top-most frame in the tab. Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched. + */ + allFrames?: boolean | undefined; + /** Excludes pages that this content script would otherwise be injected into. */ + excludeMatches?: string[] | undefined; + /** The id of the content script, specified in the API call. */ + id: string; + /** + * The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. + */ + js?: _manifest.ExtensionURL[] | undefined; + /** + * Specifies which pages this content script will be injected into. Must be specified for `registerContentScripts()`. + */ + matches?: string[] | undefined; + /** + * Specifies when JavaScript files are injected into the web page. The preferred and default value is `document_idle`. + */ + runAt?: extensionTypes.RunAt | undefined; + /** Specifies if this content script will persist into future sessions. Defaults to true. */ + persistAcrossSessions?: boolean | undefined; + /** + * The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array. + */ + css?: _manifest.ExtensionURL[] | undefined; + } + + /** The style origin for the injection. Defaults to `'AUTHOR'`. */ + type _CSSInjectionOrigin = 'USER' | 'AUTHOR'; + + interface _UpdateContentScriptsScripts { + /** Specifies if this content script will persist into future sessions. */ + persistAcrossSessions?: boolean | undefined; + /** + * If specified true, it will inject into all frames, even if the frame is not the top-most frame in the tab. Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched. + */ + allFrames?: boolean | undefined; + /** Excludes pages that this content script would otherwise be injected into. */ + excludeMatches?: string[] | undefined; + /** The id of the content script, specified in the API call. */ + id: string; + /** + * The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. + */ + js?: _manifest.ExtensionURL[] | undefined; + /** + * Specifies which pages this content script will be injected into. Must be specified for `registerContentScripts()`. + */ + matches?: string[] | undefined; + /** + * Specifies when JavaScript files are injected into the web page. The preferred and default value is `document_idle`. + */ + runAt?: extensionTypes.RunAt | undefined; + /** + * The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array. + */ + css?: _manifest.ExtensionURL[] | undefined; + } + + /* scripting functions */ + /** + * Injects a script into a target context. The script will be run at `document_idle`. + * @param injection The details of the script which to inject. + */ + function executeScript(injection: ScriptInjection): Promise; + + /** + * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored. + * @param injection The details of the styles to insert. + */ + function insertCSS(injection: CSSInjection): Promise; + + /** + * Removes a CSS stylesheet that was previously inserted by this extension from a target context. + * @param injection The details of the styles to remove. Note that the `css`, `files`, and `origin` properties must exactly match the stylesheet inserted through `insertCSS`. Attempting to remove a non-existent stylesheet is a no-op. + */ + function removeCSS(injection: CSSInjection): Promise; + + /** + * Registers one or more content scripts for this extension. + * @param scripts Contains a list of scripts to be registered. If there are errors during script parsing/file validation, or if the IDs specified already exist, then no scripts are registered. + */ + function registerContentScripts(scripts: RegisteredContentScript[]): Promise; + + /** + * Returns all dynamically registered content scripts for this extension that match the given filter. + * @param [filter] An object to filter the extension's dynamically registered scripts. + */ + function getRegisteredContentScripts(filter?: ContentScriptFilter): Promise; + + /** + * Unregisters one or more content scripts for this extension. + * @param [filter] If specified, only unregisters dynamic content scripts which match the filter. Otherwise, all of the extension's dynamic content scripts are unregistered. + */ + function unregisterContentScripts(filter?: ContentScriptFilter): Promise; + + /** + * Updates one or more content scripts for this extension. + * @param scripts Contains a list of scripts to be updated. If there are errors during script parsing/file validation, or if the IDs specified do not already exist, then no scripts are updated. + */ + function updateContentScripts(scripts: _UpdateContentScriptsScripts[]): Promise; +} + +/** + * Use the `browser.storage` API to store, retrieve, and track changes to user data. + * + * Permissions: `storage` + */ +declare namespace browser.storage { + /* storage types */ + interface StorageChange { + /** The old value of the item, if there was an old value. */ + oldValue?: any; + /** The new value of the item, if there is a new value. */ + newValue?: any; + } + + interface StorageArea { + /** + * Gets one or more items from storage. + * @param [keys] A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in `null` to get the entire contents of storage. + */ + get(keys?: string | string[] | { [key: string]: any }): Promise<{ [key: string]: any }>; + /** + * Gets the amount of space (in bytes) being used by one or more items. + * @param [keys] A single key or list of keys to get the total usage for. An empty list will return 0\. Pass in `null` to get the total usage of all of storage. + * @deprecated Unsupported on Firefox at this time. + */ + getBytesInUse?(keys?: string | string[]): Promise; + /** + * Sets multiple items. + * @param items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected. + * + * Primitive values such as numbers will serialize as expected. Values with a `typeof` `"object"` and `"function"` will typically serialize to `{}`, with the exception of `Array` (serializes as expected), `Date`, and `Regex` (serialize using their `String` representation). + */ + set(items: { [key: string]: any }): Promise; + /** + * Removes one or more items from storage. + * @param keys A single key or a list of keys for items to remove. + */ + remove(keys: string | string[]): Promise; + /** Removes all items from storage. */ + clear(): Promise; + /** + * Fired when one or more items change. + * @param changes Object mapping each key that changed to its corresponding `storage.StorageChange` for that item. + */ + onChanged: WebExtEvent<(changes: { [key: string]: StorageChange }) => void>; + } + + interface StorageAreaSync { + /** + * Gets one or more items from storage. + * @param [keys] A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in `null` to get the entire contents of storage. + */ + get(keys?: string | string[] | { [key: string]: any }): Promise<{ [key: string]: any }>; + /** + * Gets the amount of space (in bytes) being used by one or more items. + * @param [keys] A single key or list of keys to get the total usage for. An empty list will return 0\. Pass in `null` to get the total usage of all of storage. + */ + getBytesInUse(keys?: string | string[]): Promise; + /** + * Sets multiple items. + * @param items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected. + * + * Primitive values such as numbers will serialize as expected. Values with a `typeof` `"object"` and `"function"` will typically serialize to `{}`, with the exception of `Array` (serializes as expected), `Date`, and `Regex` (serialize using their `String` representation). + */ + set(items: { [key: string]: any }): Promise; + /** + * Removes one or more items from storage. + * @param keys A single key or a list of keys for items to remove. + */ + remove(keys: string | string[]): Promise; + /** Removes all items from storage. */ + clear(): Promise; + /** + * Fired when one or more items change. + * @param changes Object mapping each key that changed to its corresponding `storage.StorageChange` for that item. + */ + onChanged: WebExtEvent<(changes: { [key: string]: StorageChange }) => void>; + } + + /* storage properties */ + /** Items in the `sync` storage area are synced by the browser. */ + const sync: StorageAreaSync; + + /** Items in the `local` storage area are local to each machine. */ + const local: StorageArea; + + /** + * Items in the `managed` storage area are set by administrators or native applications, and are read-only for the extension; trying to modify this namespace results in an error. + */ + const managed: StorageArea; + + /* storage events */ + /** + * Fired when one or more items change. + * @param changes Object mapping each key that changed to its corresponding `storage.StorageChange` for that item. + * @param areaName The name of the storage area (`"sync"`, `"local"` or `"managed"`) the changes are for. + */ + const onChanged: WebExtEvent<(changes: { [key: string]: StorageChange }, areaName: string) => void>; +} + +/** + * Use the `browser.telemetry` API to send telemetry data to the Mozilla Telemetry service. Restricted to Mozilla privileged webextensions. + * + * Permissions: `telemetry` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.telemetry { + /* telemetry types */ + /** + * Type of scalar: 'count' for numeric values, 'string' for string values, 'boolean' for boolean values. Maps to `nsITelemetry.SCALAR_TYPE_*`. + */ + type ScalarType = 'count' | 'string' | 'boolean'; + + /** Represents registration data for a Telemetry scalar. */ + interface ScalarData { + kind: ScalarType; + /** True if this is a keyed scalar. */ + keyed?: boolean | undefined; + /** True if this data should be recorded on release. */ + record_on_release?: boolean | undefined; + /** + * True if this scalar entry is expired. This allows recording it without error, but it will be discarded. + */ + expired?: boolean | undefined; + } + + /** Represents registration data for a Telemetry event. */ + interface EventData { + /** List of methods for this event entry. */ + methods: string[]; + /** List of objects for this event entry. */ + objects: string[]; + /** List of allowed extra keys for this event entry. */ + extra_keys: string[]; + /** True if this data should be recorded on release. */ + record_on_release?: boolean | undefined; + /** + * True if this event entry is expired. This allows recording it without error, but it will be discarded. + */ + expired?: boolean | undefined; + } + + /** Options object. */ + interface _SubmitPingOptions { + /** True if the ping should contain the client id. */ + addClientId?: boolean | undefined; + /** True if the ping should contain the environment data. */ + addEnvironment?: boolean | undefined; + /** Set to override the environment data. */ + overrideEnvironment?: { [key: string]: any } | undefined; + /** If true, send the ping using the PingSender. */ + usePingSender?: boolean | undefined; + } + + /** Options object. */ + interface _SubmitEncryptedPingOptions { + /** Schema name used for payload. */ + schemaName: string; + /** Schema version used for payload. */ + schemaVersion: number; + } + + /* telemetry functions */ + /** + * Submits a custom ping to the Telemetry back-end. See `submitExternalPing` inside TelemetryController.jsm for more details. + * @param type The type of the ping. + * @param message The data payload for the ping. + * @param options Options object. + */ + function submitPing(type: string, message: { [key: string]: any }, options: _SubmitPingOptions): Promise; + + /** + * Submits a custom ping to the Telemetry back-end, with an encrypted payload. Requires a telemetry entry in the manifest to be used. + * @param message The data payload for the ping, which will be encrypted. + * @param options Options object. + */ + function submitEncryptedPing(message: { [key: string]: any }, options: _SubmitEncryptedPingOptions): Promise; + + /** Checks if Telemetry upload is enabled. */ + function canUpload(): Promise; + + /** + * Adds the value to the given scalar. + * @param name The scalar name. + * @param value The numeric value to add to the scalar. Only unsigned integers supported. + */ + function scalarAdd(name: string, value: number): Promise; + + /** + * Sets the named scalar to the given value. Throws if the value type doesn't match the scalar type. + * @param name The scalar name + * @param value The value to set the scalar to + */ + function scalarSet(name: string, value: string | boolean | number | { [key: string]: any }): Promise; + + /** + * Sets the scalar to the maximum of the current and the passed value + * @param name The scalar name. + * @param value The numeric value to set the scalar to. Only unsigned integers supported. + */ + function scalarSetMaximum(name: string, value: number): Promise; + + /** + * Adds the value to the given keyed scalar. + * @param name The scalar name + * @param key The key name + * @param value The numeric value to add to the scalar. Only unsigned integers supported. + */ + function keyedScalarAdd(name: string, key: string, value: number): Promise; + + /** + * Sets the keyed scalar to the given value. Throws if the value type doesn't match the scalar type. + * @param name The scalar name. + * @param key The key name. + * @param value The value to set the scalar to. + */ + function keyedScalarSet( + name: string, + key: string, + value: string | boolean | number | { [key: string]: any }, + ): Promise; + + /** + * Sets the keyed scalar to the maximum of the current and the passed value + * @param name The scalar name. + * @param key The key name. + * @param value The numeric value to set the scalar to. Only unsigned integers supported. + */ + function keyedScalarSetMaximum(name: string, key: string, value: number): Promise; + + /** + * Record an event in Telemetry. Throws when trying to record an unknown event. + * @param category The category name. + * @param method The method name. + * @param object The object name. + * @param [value] An optional string value to record. + * @param [extra] An optional object of the form (string -> string). It should only contain registered extra keys. + */ + function recordEvent( + category: string, + method: string, + object: string, + value?: string, + extra?: { [key: string]: string }, + ): Promise; + + /** + * Register new scalars to record them from addons. See nsITelemetry.idl for more details. + * @param category The unique category the scalars are registered in. + * @param data An object that contains registration data for multiple scalars. Each property name is the scalar name, and the corresponding property value is an object of ScalarData type. + */ + function registerScalars(category: string, data: { [key: string]: ScalarData }): Promise; + + /** + * Register new events to record them from addons. See nsITelemetry.idl for more details. + * @param category The unique category the events are registered in. + * @param data An object that contains registration data for 1+ events. Each property name is the category name, and the corresponding property value is an object of EventData type. + */ + function registerEvents(category: string, data: { [key: string]: EventData }): Promise; + + /** + * Enable recording of events in a category. Events default to recording disabled. This allows to toggle recording for all events in the specified category. + * @param category The category name. + * @param enabled Whether recording is enabled for events in that category. + */ + function setEventRecordingEnabled(category: string, enabled: boolean): Promise; +} + +/** + * The theme API allows customizing of visual elements of the browser. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.theme { + /* theme types */ + /** Info provided in the onUpdated listener. */ + interface ThemeUpdateInfo { + /** The new theme after update */ + theme: object; + /** The id of the window the theme has been applied to */ + windowId?: number | undefined; + } + + /* theme functions */ + /** + * Returns the current theme for the specified window or the last focused window. + * @param [windowId] The window for which we want the theme. + */ + function getCurrent(windowId?: number): Promise<_manifest.ThemeType>; + + /** + * Make complete updates to the theme. Resolves when the update has completed. + * @param details The properties of the theme to update. + */ + function update(details: _manifest.ThemeType): void; + /** + * Make complete updates to the theme. Resolves when the update has completed. + * @param windowId The id of the window to update. No id updates all windows. + * @param details The properties of the theme to update. + */ + function update(windowId: number, details: _manifest.ThemeType): void; + + /** + * Removes the updates made to the theme. + * @param [windowId] The id of the window to reset. No id resets all windows. + */ + function reset(windowId?: number): void; + + /* theme events */ + /** + * Fired when a new theme has been applied + * @param updateInfo Details of the theme update + */ + const onUpdated: WebExtEvent<(updateInfo: ThemeUpdateInfo) => void>; +} + +/** + * Contains types used by other schemas. + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.types { + /* types types */ + /** + * The scope of the Setting. One of + * + * * `regular`: setting for the regular profile (which is inherited by the incognito profile if not overridden elsewhere), + * * `regular_only`: setting for the regular profile only (not inherited by the incognito profile), + * * `incognito_persistent`: setting for the incognito profile that survives browser restarts (overrides regular preferences), + * * `incognito_session_only`: setting for the incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences). + * + * Only `regular` is supported by Firefox at this time. + */ + type SettingScope = 'regular' | 'regular_only' | 'incognito_persistent' | 'incognito_session_only'; + + /** + * One of + * + * * `not_controllable`: cannot be controlled by any extension + * * `controlled_by_other_extensions`: controlled by extensions with higher precedence + * * `controllable_by_this_extension`: can be controlled by this extension + * * `controlled_by_this_extension`: controlled by this extension + */ + type LevelOfControl = + | 'not_controllable' + | 'controlled_by_other_extensions' + | 'controllable_by_this_extension' + | 'controlled_by_this_extension'; + + interface Setting { + /** + * Gets the value of a setting. + * @param details Which setting to consider. + */ + get(details: _GetDetails): Promise<_GetReturnDetails>; + /** + * Sets the value of a setting. + * @param details Which setting to change. + */ + set(details: _SetDetails): Promise; + /** + * Clears the setting, restoring any default value. + * @param details Which setting to clear. + */ + clear(details: _ClearDetails): Promise; + /** Fired after the setting changes. */ + onChange: WebExtEvent<(details: _OnChangeDetails) => void>; + } + + /** Details of the currently effective value. */ + interface _GetReturnDetails { + /** The value of the setting. */ + value: any; + /** The level of control of the setting. */ + levelOfControl: LevelOfControl; + /** + * Whether the effective value is specific to the incognito session. + * This property will _only_ be present if the `incognito` property in the `details` parameter of `get()` was true. + */ + incognitoSpecific?: boolean | undefined; + } + + /** Which setting to consider. */ + interface _GetDetails { + /** Whether to return the value that applies to the incognito session (default false). */ + incognito?: boolean | undefined; + } + + /** Which setting to change. */ + interface _SetDetails { + /** + * The value of the setting. + * Note that every setting has a specific value type, which is described together with the setting. An extension should _not_ set a value of a different type. + */ + value: any; + /** Where to set the setting (default: regular). */ + scope?: SettingScope | undefined; + } + + /** Which setting to clear. */ + interface _ClearDetails { + /** Where to clear the setting (default: regular). */ + scope?: SettingScope | undefined; + } + + interface _OnChangeDetails { + /** The value of the setting after the change. */ + value: any; + /** The level of control of the setting. */ + levelOfControl: LevelOfControl; + /** + * Whether the value that has changed is specific to the incognito session. + * This property will _only_ be present if the user has enabled the extension in incognito mode. + */ + incognitoSpecific?: boolean | undefined; + } +} + +/** + * Manifest keys: `user_scripts`, `user_scripts` + * + * Not supported on manifest versions above 2. + * + * Not allowed in: Devtools pages + */ +declare namespace browser.userScripts { + /* userScripts types */ + /** Details of a user script */ + interface UserScriptOptions { + /** The list of JS files to inject */ + js: extensionTypes.ExtensionFileOrCode[]; + /** An opaque user script metadata value */ + scriptMetadata?: extensionTypes.PlainJSONValue | undefined; + matches: _manifest.MatchPattern[]; + excludeMatches?: _manifest.MatchPattern[] | undefined; + includeGlobs?: string[] | undefined; + excludeGlobs?: string[] | undefined; + /** + * If allFrames is `true`, implies that the JavaScript should be injected into all frames of current page. By default, it's `false` and is only injected into the top frame. + */ + allFrames?: boolean | undefined; + /** + * If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is `false`. + */ + matchAboutBlank?: boolean | undefined; + /** The soonest that the JavaScript will be injected into the tab. Defaults to "document_idle". */ + runAt?: extensionTypes.RunAt | undefined; + /** limit the set of matched tabs to those that belong to the given cookie store id */ + cookieStoreId?: string[] | string | undefined; + } + + /** An object that represents a user script registered programmatically */ + interface RegisteredUserScript { + /** Unregister a user script registered programmatically */ + unregister(): Promise; + } + + interface _OnBeforeScriptUserScript { + /** The userScript metadata (as set in userScripts.register) */ + metadata: any; + /** The userScript global */ + global: any; + /** + * Exports all the properties of a given plain object as userScript globals + * @param sourceObject A plain object whose properties are exported as userScript globals + */ + defineGlobals: (sourceObject: object) => void; + /** + * Convert a given value to make it accessible to the userScript code + * @param value A value to convert into an object accessible to the userScript + */ + export: (value: any) => any; + } + + /* userScripts functions */ + /** + * Register a user script programmatically given its `userScripts.UserScriptOptions`, and resolves to a `userScripts.RegisteredUserScript` instance + */ + function register(userScriptOptions: UserScriptOptions): Promise; + + /* userScripts events */ + /** + * Event called when a new userScript global has been created + * + * Allowed in: Content scripts only + */ + const onBeforeScript: WebExtEvent<(userScript: _OnBeforeScriptUserScript) => void>; +} + +/** + * Use the `browser.webNavigation` API to receive notifications about the status of navigation requests in-flight. + * + * Permissions: `webNavigation` + * + * Not allowed in: Content scripts, Devtools pages + */ +declare namespace browser.webNavigation { + /* webNavigation types */ + /** + * Cause of the navigation. The same transition types as defined in the history API are used. These are the same transition types as defined in the history API except with `"start_page"` in place of `"auto_toplevel"` (for backwards compatibility). + */ + type TransitionType = + | 'link' + | 'typed' + | 'auto_bookmark' + | 'auto_subframe' + | 'manual_subframe' + | 'generated' + | 'start_page' + | 'form_submit' + | 'reload' + | 'keyword' + | 'keyword_generated'; + + type TransitionQualifier = 'client_redirect' | 'server_redirect' | 'forward_back' | 'from_address_bar'; + + interface EventUrlFilters { + url: events.UrlFilter[]; + } + + /** Information about the requested frame, null if the specified frame ID and/or tab ID are invalid. */ + interface _GetFrameReturnDetails { + /** + * True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired. + */ + errorOccurred?: boolean | undefined; + /** + * The URL currently associated with this frame, if the frame identified by the frameId existed at one point in the given tab. The fact that an URL is associated with a given frameId does not imply that the corresponding frame still exists. + */ + url: string; + /** The ID of the tab in which the frame is. */ + tabId: number; + /** + * The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe. + */ + frameId: number; + /** ID of frame that wraps the frame. Set to -1 of no parent frame exists. */ + parentFrameId: number; + } + + /** Information about the frame to retrieve information about. */ + interface _GetFrameDetails { + /** The ID of the tab in which the frame is. */ + tabId: number; + /** The ID of the process runs the renderer for this tab. */ + processId?: number | undefined; + /** The ID of the frame in the given tab. */ + frameId: number; + } + + interface _GetAllFramesReturnDetails { + /** + * True if the last navigation in this frame was interrupted by an error, i.e. the onErrorOccurred event fired. + */ + errorOccurred?: boolean | undefined; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** The ID of the tab in which the frame is. */ + tabId: number; + /** + * The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe. + */ + frameId: number; + /** ID of frame that wraps the frame. Set to -1 of no parent frame exists. */ + parentFrameId: number; + /** The URL currently associated with this frame. */ + url: string; + } + + /** Information about the tab to retrieve all frames from. */ + interface _GetAllFramesDetails { + /** The ID of the tab. */ + tabId: number; + } + + interface _OnBeforeNavigateDetails { + /** The ID of the tab in which the navigation is about to occur. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique for a given tab and process. + */ + frameId: number; + /** ID of frame that wraps the frame. Set to -1 of no parent frame exists. */ + parentFrameId: number; + /** The time when the browser was about to start the navigation, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnBeforeNavigateEvent void> { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnCommittedDetails { + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. + */ + frameId: number; + /** + * Cause of the navigation. + * @deprecated Unsupported on Firefox at this time. + */ + transitionType?: TransitionType | undefined; + /** + * A list of transition qualifiers. + * @deprecated Unsupported on Firefox at this time. + */ + transitionQualifiers?: TransitionQualifier[] | undefined; + /** The time when the navigation was committed, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnCommittedEvent void> { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnDOMContentLoadedDetails { + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. + */ + frameId: number; + /** The time when the page's DOM was fully constructed, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnDOMContentLoadedEvent void> { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnCompletedDetails { + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. + */ + frameId: number; + /** The time when the document finished loading, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnCompletedEvent void> { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnErrorOccurredDetails { + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. + */ + frameId: number; + /** + * The error description. + * @deprecated Unsupported on Firefox at this time. + */ + error?: string | undefined; + /** The time when the error occurred, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnErrorOccurredEvent void> { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnCreatedNavigationTargetDetails { + /** The ID of the tab in which the navigation is triggered. */ + sourceTabId: number; + /** The ID of the process runs the renderer for the source tab. */ + sourceProcessId: number; + /** + * The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame. + */ + sourceFrameId: number; + /** The URL to be opened in the new window. */ + url: string; + /** The ID of the tab in which the url is opened */ + tabId: number; + /** The time when the browser was about to create a new view, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnCreatedNavigationTargetEvent< + TCallback = (details: _OnCreatedNavigationTargetDetails) => void, + > { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnReferenceFragmentUpdatedDetails { + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. + */ + frameId: number; + /** + * Cause of the navigation. + * @deprecated Unsupported on Firefox at this time. + */ + transitionType?: TransitionType | undefined; + /** + * A list of transition qualifiers. + * @deprecated Unsupported on Firefox at this time. + */ + transitionQualifiers?: TransitionQualifier[] | undefined; + /** The time when the navigation was committed, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnReferenceFragmentUpdatedEvent< + TCallback = (details: _OnReferenceFragmentUpdatedDetails) => void, + > { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + interface _OnTabReplacedDetails { + /** The ID of the tab that was replaced. */ + replacedTabId: number; + /** The ID of the tab that replaced the old tab. */ + tabId: number; + /** The time when the replacement happened, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _OnHistoryStateUpdatedDetails { + /** The ID of the tab in which the navigation occurs. */ + tabId: number; + url: string; + /** + * The ID of the process runs the renderer for this tab. + * @deprecated Unsupported on Firefox at this time. + */ + processId?: number | undefined; + /** + * 0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab. + */ + frameId: number; + /** + * Cause of the navigation. + * @deprecated Unsupported on Firefox at this time. + */ + transitionType?: TransitionType | undefined; + /** + * A list of transition qualifiers. + * @deprecated Unsupported on Firefox at this time. + */ + transitionQualifiers?: TransitionQualifier[] | undefined; + /** The time when the navigation was committed, in milliseconds since the epoch. */ + timeStamp: number; + } + + interface _WebNavigationOnHistoryStateUpdatedEvent void> { + addListener(cb: TCallback, filters?: EventUrlFilters): void; + removeListener(cb: TCallback): void; + hasListener(cb: TCallback): boolean; + } + + /* webNavigation functions */ + /** + * Retrieves information about the given frame. A frame refers to an