diff --git a/packages/browser/package.json b/packages/browser/package.json
index 5beb97b92..5fdaccb84 100644
--- a/packages/browser/package.json
+++ b/packages/browser/package.json
@@ -1,7 +1,7 @@
{
"name": "@wxt-dev/browser",
"description": "Provides a cross-browser API for using extension APIs and types based on @types/chrome",
- "version": "0.0.323",
+ "version": "0.0.326",
"type": "module",
"main": "src/index.mjs",
"types": "src/index.d.ts",
@@ -23,9 +23,11 @@
"src"
],
"devDependencies": {
- "@types/chrome": "0.0.323",
+ "@types/chrome": "0.0.326",
+ "@types/firefox-webext-browser": "120.0.4",
"fs-extra": "^11.3.0",
"nano-spawn": "^0.2.0",
+ "ts-morph": "^26.0.0",
"tsx": "4.19.4",
"typescript": "^5.8.3",
"vitest": "^3.1.2"
diff --git a/packages/browser/scripts/generate.ts b/packages/browser/scripts/generate.ts
index 0bde96c72..675c56531 100644
--- a/packages/browser/scripts/generate.ts
+++ b/packages/browser/scripts/generate.ts
@@ -3,11 +3,31 @@ import fs from 'fs-extra';
import { fileURLToPath } from 'node:url';
import { dirname, join, resolve, sep } from 'node:path';
import { sep as posixSep } from 'node:path/posix';
+import {
+ type FunctionDeclarationStructure,
+ type InterfaceDeclaration,
+ type ModuleDeclaration,
+ ModuleDeclarationKind,
+ Project,
+ StructureKind,
+ SyntaxKind,
+} from 'ts-morph';
+import bcd, {
+ type Identifier,
+} from '@mdn/browser-compat-data' with { type: 'json' };
// Fetch latest version
-console.log('Getting latest version of \x1b[36m@types/chrome\x1b[0m');
-await spawn('pnpm', ['i', '--ignore-scripts', '-D', '@types/chrome@latest']);
+console.log(
+ 'Getting latest version of \x1b[36m@types/chrome\x1b[0m, \x1b[36m@types/firefox-webext-browser\x1b[0m',
+);
+await spawn('pnpm', [
+ 'i',
+ '--ignore-scripts',
+ '-D',
+ '@types/chrome@latest',
+ '@types/firefox-webext-browser@latest',
+]);
// Generate new package.json
@@ -16,11 +36,18 @@ console.log('Generating new \x1b[36mpackage.json\x1b[0m');
const pkgJsonPath = fileURLToPath(
import.meta.resolve('@types/chrome/package.json'),
);
+const firefoxPkgJsonPath = fileURLToPath(
+ import.meta.resolve('@types/firefox-webext-browser/package.json'),
+);
const pkgDir = dirname(pkgJsonPath);
+const firefoxPkgDir = dirname(firefoxPkgJsonPath);
const pkgJson = await fs.readJson(pkgJsonPath);
+const firefoxPkgJson = await fs.readJson(firefoxPkgJsonPath);
const pkgJsonTemplate = await fs.readFile('templates/package.json', 'utf8');
const newPkgJson = JSON.parse(
- pkgJsonTemplate.replaceAll('{{chromeTypesVersion}}', pkgJson.version),
+ pkgJsonTemplate
+ .replaceAll('{{chromeTypesVersion}}', pkgJson.version)
+ .replaceAll('{{firefoxTypesVersion}}', firefoxPkgJson.version),
);
newPkgJson.dependencies = pkgJson.dependencies;
newPkgJson.peerDependencies = pkgJson.peerDependencies;
@@ -33,7 +60,209 @@ await spawn('pnpm', ['-w', 'prettier', '--write', outPkgJsonPath]);
// Generate declaration files
console.log('Generating declaration files');
+
const outDir = resolve('src/gen');
+
+const project = new Project({
+ compilerOptions: {
+ declaration: true,
+ types: ['@types/chrome', '@types/firefox-webext-browser'],
+ baseUrl: outDir,
+ },
+});
+const chromeFile = resolve(pkgDir, 'index.d.ts');
+const firefoxFile = resolve(firefoxPkgDir, 'index.d.ts');
+const chrome = project.addSourceFileAtPath(chromeFile);
+const firefox = project.addSourceFileAtPath(firefoxFile);
+
+const browserIndexFile = project.createSourceFile(
+ join(outDir, 'index.d.ts'),
+ `/* DO NOT EDIT - generated by scripts/generate.ts */
+${chrome
+ .getPathReferenceDirectives()
+ .map((file) => `/// `)
+ .join('\n')}
+${chrome
+ .getTypeReferenceDirectives()
+ .map((file) => `/// `)
+ .join('\n')}
+ \n`,
+ { overwrite: true },
+);
+const browserNamespace = browserIndexFile.addModule({
+ name: 'Browser',
+ isExported: true,
+ kind: StructureKind.Module,
+ declarationKind: ModuleDeclarationKind.Namespace,
+});
+
+const browserExtensionCompatData = bcd.webextensions;
+const browserInterface = browserIndexFile.addInterface({
+ name: '_Browser',
+ isExported: true,
+ kind: StructureKind.Interface,
+});
+
+const modules: Record = {};
+const allModules = (chrome.getModule('chrome')?.getModules() || []).concat(
+ firefox?.getModules() || [],
+);
+allModules?.forEach((originalModule) => {
+ const moduleName = originalModule
+ .getName()
+ .replace(/^(browser\.|chrome\.)/, '');
+ if (modules[moduleName]) {
+ const existingModule = modules[moduleName];
+ existingModule.addInterfaces(
+ originalModule
+ .getInterfaces()
+ .filter((i) => !existingModule.getInterface(i.getName()))
+ .map((i) => i.getStructure()),
+ );
+ existingModule.addClasses(
+ originalModule
+ .getClasses()
+ .filter((c) => !existingModule.getClass(c.getName() ?? 'NONE'))
+ .map((c) => c.getStructure()),
+ );
+ existingModule.addFunctions(
+ originalModule
+ .getFunctions()
+ .filter((f) => !existingModule.getFunction(f.getName() ?? 'NONE'))
+ .map((f) => f.getStructure() as FunctionDeclarationStructure),
+ );
+ existingModule.addVariableStatements(
+ originalModule
+ .getVariableStatements()
+ .filter(
+ (v) =>
+ !existingModule.getVariableStatement(
+ v.getFirstChildByKind(SyntaxKind.Identifier)?.getText() ?? 'NONE',
+ ),
+ )
+ .map((varDecl) => varDecl.getStructure()),
+ );
+ } else {
+ const newModule = browserNamespace.addModule({
+ ...originalModule.getStructure(),
+ name: moduleName,
+ isExported: true,
+ kind: StructureKind.Module,
+ declarationKind: ModuleDeclarationKind.Namespace,
+ });
+ modules[moduleName] = newModule;
+ }
+
+ const moduleCompatData = browserExtensionCompatData['api'][moduleName];
+ if (moduleName.includes('.')) {
+ const moduleCompatApiData = browserExtensionCompatData['api'];
+ const [wrapperModuleName, innerModuleName] = moduleName.split('.');
+ const nestedModuleCompatData =
+ moduleCompatApiData[wrapperModuleName]?.[innerModuleName] ?? {};
+
+ const compatData: Record = Object.fromEntries(
+ Object.entries(nestedModuleCompatData)
+ .map(([name, data]) =>
+ Object.hasOwn(data, '__compat')
+ ? ([
+ name,
+ !Object.entries(
+ (data as Identifier).__compat?.support ?? {},
+ ).some(([, support]) =>
+ Array.isArray(support)
+ ? support[0].version_added === false
+ : support.version_added === false,
+ ),
+ ] as const)
+ : [name, undefined],
+ )
+ .filter(Boolean),
+ );
+ const temporaryInterface = browserIndexFile.addInterface({
+ name: '_' + moduleName.replace(/\./g, '_'),
+ isExported: true,
+ });
+
+ addFunction(originalModule, temporaryInterface, {
+ compatData,
+ name: innerModuleName,
+ });
+ addVariable(originalModule, temporaryInterface, {
+ compatData,
+ name: innerModuleName,
+ });
+ const temporaryInterfaceText = temporaryInterface.getText();
+ const originalProperty = browserInterface.getProperty(wrapperModuleName);
+ if (originalProperty) {
+ const originalInterface = originalProperty.getTypeNodeOrThrow().getText();
+ const newPropertyText = temporaryInterfaceText.slice(
+ temporaryInterfaceText.indexOf('{') + 1,
+ temporaryInterfaceText.lastIndexOf('}'),
+ );
+ if (originalInterface.includes('}')) {
+ originalProperty.set({
+ type: `${originalInterface.slice(0, originalInterface.lastIndexOf('}'))} ${newPropertyText}}`,
+ });
+ } else {
+ originalProperty.set({
+ type: `${originalInterface} & {${newPropertyText}}`,
+ });
+ }
+ } else {
+ const newPropertyText = temporaryInterfaceText.slice(
+ temporaryInterfaceText.indexOf('{') + 1,
+ temporaryInterfaceText.lastIndexOf('}'),
+ );
+
+ browserInterface.addProperty({
+ name: wrapperModuleName,
+ type: `{\n${newPropertyText}\n}`,
+ });
+ }
+
+ temporaryInterface.remove();
+ return;
+ }
+ if (!moduleCompatData) {
+ browserInterface.addProperty({
+ name: moduleName,
+ type: 'typeof Browser.' + moduleName,
+ hasQuestionToken: !moduleCompatData,
+ });
+ } else {
+ const compatData: Record = Object.fromEntries(
+ Object.entries(moduleCompatData)
+ .map(([name, data]) =>
+ Object.hasOwn(data, '__compat')
+ ? ([
+ name,
+ !Object.entries(
+ (data as Identifier).__compat?.support ?? {},
+ ).some(([, support]) =>
+ Array.isArray(support)
+ ? support[0].version_added === false
+ : support.version_added === false,
+ ),
+ ] as const)
+ : [name, undefined],
+ )
+ .filter(Boolean),
+ );
+ addFunction(originalModule, browserInterface, {
+ compatData,
+ name: moduleName,
+ });
+ addVariable(originalModule, browserInterface, {
+ compatData,
+ name: moduleName,
+ });
+ }
+});
+
+browserInterface.formatText();
+await browserIndexFile.save();
+
+// move Chrome declaration files to src/gen
const declarationFileMapping = (
await fs.readdir(pkgDir, {
recursive: true,
@@ -41,7 +270,7 @@ const declarationFileMapping = (
})
)
// Filter to .d.ts files
- .filter((file) => file.endsWith('.d.ts'))
+ .filter((file) => file.endsWith('.d.ts') && !file.startsWith('index.'))
// Map to usable paths
.map((file) => ({
file: file.replaceAll(sep, posixSep),
@@ -51,13 +280,21 @@ const declarationFileMapping = (
for (const { file, srcPath, destPath } of declarationFileMapping) {
const content = await fs.readFile(srcPath, 'utf8');
- const transformedContent = transformFile(file, content);
const destDir = dirname(destPath);
await fs.mkdir(destDir, { recursive: true });
- await fs.writeFile(destPath, transformedContent);
+ await fs.writeFile(destPath, content);
console.log(` \x1b[2m-\x1b[0m \x1b[36m${file}\x1b[0m`);
}
+await fs.writeJson(outPkgJsonPath, newPkgJson);
+
+await spawn('pnpm', [
+ '-w',
+ 'prettier',
+ '--write',
+ browserIndexFile.getFilePath(),
+]);
+
// Done!
console.log(
@@ -66,17 +303,97 @@ console.log(
// Transformations
-function transformFile(file: string, content: string): string {
- return (
- // Add prefix
- `/* DO NOT EDIT - generated by scripts/generate.ts */\n\n${content}\n`
- // Remove global type declaration
- .replaceAll('chrome: typeof chrome;', '// chrome: typeof chrome;')
- // Rename `chrome` namespace to `Browser` and export it
- .replaceAll('declare namespace chrome', 'export namespace Browser')
- // Update references to `chrome` namespace to `Browser`
- .replaceAll('chrome.', 'Browser.')
- // Fix links to developer.chrome.com
- .replaceAll('developer.Browser.com', 'developer.chrome.com')
- );
+function addFunction(
+ fromModule: ModuleDeclaration,
+ toInterface: InterfaceDeclaration,
+ options: {
+ name: string;
+ compatData: Record;
+ },
+) {
+ const moduleName = fromModule.getName().replace(/^(browser\.|chrome\.)/, '');
+ const propertyEntries = fromModule.getFunctions().map((fn) => {
+ const fnName = fn.getNameOrThrow();
+ return [fnName, options.compatData[fnName] === false];
+ });
+ const propertyText = Object.entries(Object.fromEntries(propertyEntries))
+ .map(([name, optional]) => {
+ return `${name}${optional ? '?' : ''}: typeof Browser.${moduleName}.${name};`;
+ })
+ .join('\n');
+ const existingProperty = toInterface.getProperty(options.name);
+ if (propertyText.trim() === '') {
+ return;
+ }
+ if (existingProperty) {
+ const originalInterface = existingProperty.getText();
+ const originalPropertyText = originalInterface.slice(
+ originalInterface.indexOf('{') + 1,
+ originalInterface.lastIndexOf('}'),
+ );
+
+ const propertyText = Object.entries(Object.fromEntries(propertyEntries))
+ .filter(([name]) => !originalPropertyText.includes(name))
+ .map(([name, optional]) => {
+ return `${name}${optional ? '?' : ''}: typeof Browser.${moduleName}.${name};`;
+ })
+ .join('\n');
+ existingProperty.set({
+ type: `{\n${propertyText}${originalPropertyText.replace(' ', '')}\n}`,
+ });
+ } else {
+ toInterface.addProperty({
+ name: options.name,
+ type: `{\n${propertyText}\n}`,
+ });
+ }
+}
+function addVariable(
+ fromModule: ModuleDeclaration,
+ toInterface: InterfaceDeclaration,
+ options: {
+ compatData: Record;
+ name: string;
+ },
+) {
+ const moduleName = fromModule.getName().replace(/^(browser\.|chrome\.)/, '');
+ const propertyEntries = fromModule.getVariableDeclarations().map((fn) => {
+ const fnName = fn
+ .getFirstChildByKindOrThrow(SyntaxKind.Identifier)
+ .getText();
+ return [fnName, options.compatData[fnName] === false];
+ });
+
+ const existingProperty = toInterface.getProperty(options.name);
+
+ if (existingProperty) {
+ const originalInterface = existingProperty.getText();
+ const originalPropertyText = originalInterface.slice(
+ originalInterface.indexOf('{') + 1,
+ originalInterface.lastIndexOf('}'),
+ );
+
+ const propertyText = Object.entries(Object.fromEntries(propertyEntries))
+ .filter(([name]) => !originalPropertyText.includes(name))
+ .map(([name, optional]) => {
+ return `${name}${optional ? '?' : ''}: typeof Browser.${moduleName}.${name};`;
+ })
+ .join('\n');
+ existingProperty.set({
+ type: `{\n${propertyText}${originalPropertyText.replace(' ', '')}\n}`,
+ });
+ } else {
+ const propertyText = Object.entries(Object.fromEntries(propertyEntries))
+ .map(([name, optional]) => {
+ return `${name}${optional ? '?' : ''}: typeof Browser.${moduleName}.${name};`;
+ })
+ .join('\n');
+ if (propertyText.trim() === '') {
+ return;
+ }
+ toInterface.addProperty({
+ name: options.name,
+ type: `{\n${propertyText}\n}`,
+ });
+ }
}
diff --git a/packages/browser/src/gen/chrome-cast/index.d.ts b/packages/browser/src/gen/chrome-cast/index.d.ts
index 2b4ded948..7bca0f9dc 100644
--- a/packages/browser/src/gen/chrome-cast/index.d.ts
+++ b/packages/browser/src/gen/chrome-cast/index.d.ts
@@ -1,14 +1,12 @@
-/* DO NOT EDIT - generated by scripts/generate.ts */
-
/* eslint-disable @typescript-eslint/no-wrapper-object-types */
-export namespace Browser {
+declare namespace Browser {
////////////////////
// Cast
// @see https://code.google.com/p/chromium/codesearch#chromium/src/ui/file_manager/externs/chrome_cast.js
////////////////////
export namespace cast {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.AutoJoinPolicy
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.AutoJoinPolicy
*/
export enum AutoJoinPolicy {
CUSTOM_CONTROLLER_SCOPED = "custom_controller_scoped",
@@ -18,7 +16,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.DefaultActionPolicy
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.DefaultActionPolicy
*/
export enum DefaultActionPolicy {
CREATE_SESSION = "create_session",
@@ -26,7 +24,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.Capability
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.Capability
*/
export enum Capability {
VIDEO_OUT = "video_out",
@@ -37,7 +35,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.ErrorCode
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.ErrorCode
*/
export enum ErrorCode {
CANCEL = "cancel",
@@ -53,7 +51,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.ReceiverAvailability
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.ReceiverAvailability
*/
export enum ReceiverAvailability {
AVAILABLE = "available",
@@ -61,7 +59,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.SenderPlatform
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.SenderPlatform
*/
export enum SenderPlatform {
CHROME = "chrome",
@@ -70,7 +68,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.ReceiverType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.ReceiverType
*/
export enum ReceiverType {
CAST = "cast",
@@ -80,7 +78,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.ReceiverAction
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.ReceiverAction
*/
export enum ReceiverAction {
CAST = "cast",
@@ -88,7 +86,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.SessionStatus
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.SessionStatus
*/
export enum SessionStatus {
CONNECTED = "connected",
@@ -97,12 +95,12 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.VERSION
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.VERSION
*/
export var VERSION: number[];
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.isAvailable
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.isAvailable
*/
export var isAvailable: boolean;
@@ -178,7 +176,7 @@ export namespace Browser {
/**
* @param escaped A string to unescape.
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast#.unescape
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast#.unescape
*/
export function unescape(escaped: string): string;
@@ -189,7 +187,7 @@ export namespace Browser {
* @param receiverListener
* @param opt_autoJoinPolicy
* @param opt_defaultActionPolicy
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.ApiConfig
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ApiConfig
*/
constructor(
sessionRequest: Browser.cast.SessionRequest,
@@ -211,7 +209,7 @@ export namespace Browser {
* @param code
* @param opt_description
* @param opt_details
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.Error
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Error
*/
constructor(code: Browser.cast.ErrorCode, description?: string, details?: Object);
@@ -223,7 +221,7 @@ export namespace Browser {
export class Image {
/**
* @param url
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.Image
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Image
*/
constructor(url: string);
@@ -235,7 +233,7 @@ export namespace Browser {
export class SenderApplication {
/**
* @param platform
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.SenderApplication
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SenderApplication
*/
constructor(platform: Browser.cast.SenderPlatform);
@@ -249,7 +247,7 @@ export namespace Browser {
* @param appId
* @param opt_capabilities
* @param opt_timeout
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.SessionRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.SessionRequest
*/
constructor(appId: string, capabilities?: Browser.cast.Capability[], timeout?: number);
@@ -266,7 +264,7 @@ export namespace Browser {
* @param displayName
* @param appImages
* @param receiver
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.Session
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Session
*/
constructor(
sessionId: string,
@@ -396,7 +394,7 @@ export namespace Browser {
* @param friendlyName
* @param opt_capabilities
* @param opt_volume
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.Receiver
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Receiver
*/
constructor(
label: string,
@@ -417,7 +415,7 @@ export namespace Browser {
/**
* @param statusText
* @param appImages
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.ReceiverDisplayStatus
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.ReceiverDisplayStatus
*/
constructor(statusText: string, appImages: Browser.cast.Image[]);
@@ -429,7 +427,7 @@ export namespace Browser {
/**
* @param opt_level
* @param opt_muted
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.Volume
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.Volume
*/
constructor(level?: number, muted?: boolean);
@@ -442,7 +440,7 @@ export namespace Browser {
export var DEFAULT_MEDIA_RECEIVER_APP_ID: string;
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.MediaCommand
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.MediaCommand
*/
export enum MediaCommand {
PAUSE = "pause",
@@ -452,7 +450,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.MetadataType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.MetadataType
*/
export enum MetadataType {
GENERIC,
@@ -463,7 +461,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.PlayerState
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.PlayerState
*/
export enum PlayerState {
IDLE = "IDLE",
@@ -473,7 +471,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.ResumeState
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.ResumeState
*/
export enum ResumeState {
PLAYBACK_START = "PLAYBACK_START",
@@ -481,7 +479,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.StreamType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.StreamType
*/
export enum StreamType {
BUFFERED = "BUFFERED",
@@ -490,7 +488,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.IdleReason
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.IdleReason
*/
export enum IdleReason {
CANCELLED = "CANCELLED",
@@ -500,7 +498,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.RepeatMode
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.RepeatMode
*/
export enum RepeatMode {
OFF = "REPEAT_OFF",
@@ -512,7 +510,7 @@ export namespace Browser {
export class QueueItem {
/**
* @param mediaInfo
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.QueueItem
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueItem
*/
constructor(mediaInfo: Browser.cast.media.MediaInfo);
@@ -528,7 +526,7 @@ export namespace Browser {
export class QueueLoadRequest {
/**
* @param items
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.QueueLoadRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueLoadRequest
*/
constructor(items: Browser.cast.media.QueueItem[]);
@@ -541,7 +539,7 @@ export namespace Browser {
export class QueueInsertItemsRequest {
/**
* @param itemsToInsert
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.QueueInsertItemsRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueInsertItemsRequest
*/
constructor(itemsToInsert: Browser.cast.media.QueueItem[]);
@@ -553,7 +551,7 @@ export namespace Browser {
export class QueueRemoveItemsRequest {
/**
* @param itemIdsToRemove
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.QueueRemoveItemsRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueRemoveItemsRequest
*/
constructor(itemIdsToRemove: number[]);
@@ -564,7 +562,7 @@ export namespace Browser {
export class QueueReorderItemsRequest {
/**
* @param itemIdsToReorder
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.QueueReorderItemsRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueReorderItemsRequest
*/
constructor(itemIdsToReorder: number[]);
@@ -576,7 +574,7 @@ export namespace Browser {
export class QueueUpdateItemsRequest {
/**
* @param itemsToUpdate
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.QueueUpdateItemsRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.QueueUpdateItemsRequest
*/
constructor(itemsToUpdate: Browser.cast.media.QueueItem[]);
@@ -585,7 +583,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.TrackType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.TrackType
*/
export enum TrackType {
TEXT = "TEXT",
@@ -594,7 +592,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.TextTrackType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.TextTrackType
*/
export enum TextTrackType {
SUBTITLES = "SUBTITLES",
@@ -605,7 +603,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.TextTrackEdgeType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.TextTrackEdgeType
*/
export enum TextTrackEdgeType {
NONE = "NONE",
@@ -616,7 +614,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.TextTrackWindowType
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.TextTrackWindowType
*/
export enum TextTrackWindowType {
NONE = "NONE",
@@ -625,7 +623,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.TextTrackFontGenericFamily
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.TextTrackFontGenericFamily
*/
export enum TextTrackFontGenericFamily {
SANS_SERIF = "SANS_SERIF",
@@ -638,7 +636,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media#.TextTrackFontStyle
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media#.TextTrackFontStyle
*/
export enum TextTrackFontStyle {
NORMAL = "NORMAL",
@@ -649,7 +647,7 @@ export namespace Browser {
export class GetStatusRequest {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.GetStatusRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.GetStatusRequest
*/
constructor();
@@ -658,7 +656,7 @@ export namespace Browser {
export class PauseRequest {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.PauseRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PauseRequest
*/
constructor();
@@ -667,7 +665,7 @@ export namespace Browser {
export class PlayRequest {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.PlayRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PlayRequest
*/
constructor();
@@ -676,7 +674,7 @@ export namespace Browser {
export class SeekRequest {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.SeekRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.SeekRequest
*/
constructor();
@@ -687,7 +685,7 @@ export namespace Browser {
export class StopRequest {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.StopRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.StopRequest
*/
constructor();
@@ -697,7 +695,7 @@ export namespace Browser {
export class VolumeRequest {
/**
* @param volume
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.VolumeRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.VolumeRequest
*/
constructor(volume: Browser.cast.Volume);
@@ -708,7 +706,7 @@ export namespace Browser {
export class LoadRequest {
/**
* @param mediaInfo
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.LoadRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.LoadRequest
*/
constructor(mediaInfo: Browser.cast.media.MediaInfo);
@@ -724,7 +722,7 @@ export namespace Browser {
/**
* @param opt_activeTrackIds
* @param opt_textTrackStyle
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.EditTracksInfoRequest
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.EditTracksInfoRequest
*/
constructor(activeTrackIds?: number[], textTrackStyle?: Browser.cast.media.TextTrackStyle);
@@ -746,7 +744,7 @@ export namespace Browser {
export class MovieMediaMetadata {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.MovieMediaMetadata
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MovieMediaMetadata
*/
constructor();
@@ -764,7 +762,7 @@ export namespace Browser {
export class TvShowMediaMetadata {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.TvShowMediaMetadata
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TvShowMediaMetadata
*/
constructor();
@@ -790,7 +788,7 @@ export namespace Browser {
export class MusicTrackMediaMetadata {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.MusicTrackMediaMetadata
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MusicTrackMediaMetadata
*/
constructor();
@@ -816,7 +814,7 @@ export namespace Browser {
export class PhotoMediaMetadata {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.PhotoMediaMetadata
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.PhotoMediaMetadata
*/
constructor();
@@ -839,7 +837,7 @@ export namespace Browser {
/**
* @param contentId
* @param contentType
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.MediaInfo
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.MediaInfo
*/
constructor(contentId: string, contentType: string);
@@ -857,7 +855,7 @@ export namespace Browser {
/**
* @param sessionId
* @param mediaSessionId
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.Media
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Media
*/
constructor(sessionId: string, mediaSessionId: number);
@@ -960,7 +958,7 @@ export namespace Browser {
/**
* @param command
- * @return whether or not the receiver supports the given Browser.cast.media.MediaCommand
+ * @return whether or not the receiver supports the given chrome.cast.media.MediaCommand
*/
supportsCommand(command: Browser.cast.media.MediaCommand): boolean;
@@ -1087,7 +1085,7 @@ export namespace Browser {
/**
* @param trackId
* @param trackType
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.Track
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.Track
*/
constructor(trackId: number, trackType: Browser.cast.media.TrackType);
@@ -1103,7 +1101,7 @@ export namespace Browser {
export class TextTrackStyle {
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.TextTrackStyle
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.TextTrackStyle
*/
constructor();
@@ -1127,7 +1125,7 @@ export namespace Browser {
* @param end
* @param isMovingWindow
* @param isLiveDone
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.LiveSeekableRange
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.LiveSeekableRange
*/
constructor(start?: number, end?: number, isMovingWindow?: boolean, isLiveDone?: boolean);
@@ -1139,7 +1137,7 @@ export namespace Browser {
}
/**
- * @see https://developers.google.com/cast/docs/reference/chrome/Browser.cast.media.timeout
+ * @see https://developers.google.com/cast/docs/reference/chrome/chrome.cast.media.timeout
*/
export namespace cast.media.timeout {
export var load: number;
@@ -1157,4 +1155,3 @@ export namespace Browser {
export var queueUpdate: number;
}
}
-
diff --git a/packages/browser/src/gen/har-format/index.d.ts b/packages/browser/src/gen/har-format/index.d.ts
index 9827a59f1..33b39ffbc 100644
--- a/packages/browser/src/gen/har-format/index.d.ts
+++ b/packages/browser/src/gen/har-format/index.d.ts
@@ -1,9 +1,6 @@
-/* DO NOT EDIT - generated by scripts/generate.ts */
-
import { Entry, Log } from "har-format";
declare global {
export type HARFormatEntry = Entry;
export type HARFormatLog = Log;
}
-
diff --git a/packages/browser/src/gen/index.d.ts b/packages/browser/src/gen/index.d.ts
index 63a34b6d0..3f42863da 100644
--- a/packages/browser/src/gen/index.d.ts
+++ b/packages/browser/src/gen/index.d.ts
@@ -1,171 +1,135 @@
/* DO NOT EDIT - generated by scripts/generate.ts */
-
-///
///
///
-
-// Helpers
-type SetRequired = Omit & Required>;
-
-////////////////////
-// Global object
-////////////////////
-interface Window {
- // chrome: typeof chrome;
-}
-
+///
export namespace Browser {
- ////////////////////
- // Accessibility Features
- ////////////////////
/**
- * Use the `Browser.accessibilityFeatures` API to manage Chrome's accessibility features. This API relies on the ChromeSetting prototype of the type API for getting and setting individual accessibility features. In order to get feature states the extension must request `accessibilityFeatures.read` permission. For modifying feature state, the extension needs `accessibilityFeatures.modify` permission. Note that `accessibilityFeatures.modify` does not imply `accessibilityFeatures.read` permission.
+ * Use the `chrome.accessibilityFeatures` API to manage Chrome's accessibility features. This API relies on the ChromeSetting prototype of the type API for getting and setting individual accessibility features. In order to get feature states the extension must request `accessibilityFeatures.read` permission. For modifying feature state, the extension needs `accessibilityFeatures.modify` permission. Note that `accessibilityFeatures.modify` does not imply `accessibilityFeatures.read` permission.
*
* Permissions: "accessibilityFeatures.read", "accessibilityFeatures.modify"
*/
export namespace accessibilityFeatures {
/** `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. */
- export const animationPolicy: Browser.types.ChromeSetting<"allowed" | "once" | "none">;
-
+ export const animationPolicy: chrome.types.ChromeSetting<"allowed" | "once" | "none">;
/**
* Auto mouse click after mouse stops moving. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const autoclick: Browser.types.ChromeSetting;
-
+ export const autoclick: chrome.types.ChromeSetting;
/**
* Caret highlighting. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 51
*/
- export const caretHighlight: Browser.types.ChromeSetting;
-
+ export const caretHighlight: chrome.types.ChromeSetting;
/**
* Cursor color. The value indicates whether the feature is enabled or not, doesn't indicate the color of it.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 85
*/
- export const cursorColor: Browser.types.ChromeSetting;
-
+ export const cursorColor: chrome.types.ChromeSetting;
/**
* Cursor highlighting. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 51
*/
- export const cursorHighlight: Browser.types.ChromeSetting;
-
+ export const cursorHighlight: chrome.types.ChromeSetting;
/**
* Dictation. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 90
*/
- export const dictation: Browser.types.ChromeSetting;
-
+ export const dictation: chrome.types.ChromeSetting;
/**
* Docked magnifier. The value indicates whether docked magnifier feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 87
*/
- export const dockedMagnifier: Browser.types.ChromeSetting;
-
+ export const dockedMagnifier: chrome.types.ChromeSetting;
/**
* Focus highlighting. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 51
*/
- export const focusHighlight: Browser.types.ChromeSetting;
-
+ export const focusHighlight: chrome.types.ChromeSetting;
/**
* High contrast rendering mode. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const highContrast: Browser.types.ChromeSetting;
-
+ export const highContrast: chrome.types.ChromeSetting;
/**
* Enlarged cursor. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const largeCursor: Browser.types.ChromeSetting;
-
+ export const largeCursor: chrome.types.ChromeSetting;
/**
* Full screen magnification. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const screenMagnifier: Browser.types.ChromeSetting;
-
+ export const screenMagnifier: chrome.types.ChromeSetting;
/**
* Select-to-speak. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 51
*/
- export const selectToSpeak: Browser.types.ChromeSetting;
-
+ export const selectToSpeak: chrome.types.ChromeSetting;
/**
* Spoken feedback (text-to-speech). The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const spokenFeedback: Browser.types.ChromeSetting;
-
+ export const spokenFeedback: chrome.types.ChromeSetting;
/**
* Sticky modifier keys (like shift or alt). The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const stickyKeys: Browser.types.ChromeSetting;
-
+ export const stickyKeys: chrome.types.ChromeSetting;
/**
* Switch Access. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
* @since Chrome 51
*/
- export const switchAccess: Browser.types.ChromeSetting;
-
+ export const switchAccess: chrome.types.ChromeSetting;
/**
* Virtual on-screen keyboard. The value indicates whether the feature is enabled or not.
* `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission.
* @platform ChromeOS only
*/
- export const virtualKeyboard: Browser.types.ChromeSetting;
+ export const virtualKeyboard: chrome.types.ChromeSetting;
}
- ////////////////////
- // Action
- ////////////////////
/**
- * Use the `Browser.action` API to control the extension's icon in the Google Chrome toolbar.
+ * Use the `chrome.action` API to control the extension's icon in the Google Chrome toolbar.
* The action icons are displayed in the browser toolbar next to the omnibox. After installation, these appear in the extensions menu (the puzzle piece icon). Users can pin your extension icon to the toolbar.
*
* Manifest: "action"
* @since Chrome 88, MV3
*/
export namespace action {
- /** @deprecated Use BadgeColorDetails instead. */
- export interface BadgeBackgroundColorDetails extends BadgeColorDetails {}
-
export interface BadgeColorDetails {
- /** 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. */
+ /** 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`. */
color: string | ColorArray;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
}
export interface BadgeTextDetails {
- /** Any number of characters can be passed, but only about four can fit in the space. */
- text: string;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Any number of characters can be passed, but only about four can fit in the space. If an empty string (`''`) is passed, the badge text is cleared. If `tabId` is specified and `text` is null, the text for the specified tab is cleared and defaults to the global badge text. */
+ text?: string | undefined;
+ /** Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
}
@@ -174,33 +138,34 @@ export namespace Browser {
export interface TitleDetails {
/** The string the action should display when moused over. */
title: string;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
}
export interface PopupDetails {
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
- /** The html file to show in a popup. If set to the empty string (''), no popup is shown. */
+ /** The html file to show in a popup. If set to the empty string (`''`), no popup is shown. */
popup: string;
}
export interface TabIconDetails {
- /** Optional. 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}' */
+ /** 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` \* n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.path = {'16': foo}' */
path?: string | { [index: number]: string } | undefined;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
- /** Optional. 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}' */
+ /** 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` \* n will be selected, where n is the size of the icon in the UI. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'16': foo}' */
imageData?: ImageData | { [index: number]: ImageData } | undefined;
}
+ /** @since Chrome 99 */
export interface OpenPopupOptions {
- /** Optional. The id of the window to open the action popup in. Defaults to the currently-active window if unspecified. */
+ /** The id of the window to open the action popup in. Defaults to the currently-active window if unspecified. */
windowId?: number | undefined;
}
export interface TabDetails {
- /** Optional. The ID of the tab to query state for. If no tab is specified, the non-tab-specific state is returned. */
+ /** The ID of the tab to query state for. If no tab is specified, the non-tab-specific state is returned. */
tabId?: number | undefined;
}
@@ -220,292 +185,340 @@ export namespace Browser {
}
/**
- * @since Chrome 88
* Disables the action for a tab.
- * @param tabId The id of the tab for which you want to modify the action.
- * @return The `disable` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ * @param tabId The ID of the tab for which you want to modify the action.
+ *
+ * Can return its result via Promise.
*/
export function disable(tabId?: number): Promise;
-
- /**
- * @since Chrome 88
- * Disables the action for a tab.
- * @param tabId The id of the tab for which you want to modify the action.
- * @param callback
- */
export function disable(callback: () => void): void;
- export function disable(tabId: number, callback: () => void): void;
-
+ export function disable(tabId: number | undefined, callback: () => void): void;
/**
- * @since Chrome 88
* Enables the action for a tab. By default, actions are enabled.
- * @param tabId The id of the tab for which you want to modify the action.
- * @return The `enable` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ * @param tabId The ID of the tab for which you want to modify the action.
+ *
+ * Can return its result via Promise.
*/
export function enable(tabId?: number): Promise;
-
- /**
- * @since Chrome 88
- * Enables the action for a tab. By default, actions are enabled.
- * @param tabId The id of the tab for which you want to modify the action.
- * @param callback
- */
export function enable(callback: () => void): void;
- export function enable(tabId: number, callback: () => void): void;
-
+ export function enable(tabId: number | undefined, callback: () => void): void;
/**
- * @since Chrome 88
- * Gets the background color of the action.
- */
- export function getBadgeBackgroundColor(details: TabDetails, callback: (result: ColorArray) => void): void;
- /**
- * @since Chrome 88
* Gets the background color of the action.
- * @return The `getBadgeBackgroundColor` method provides its result via callback or returned as a `Promise` (MV3 only).
+ *
+ * Can return its result via Promise.
*/
export function getBadgeBackgroundColor(details: TabDetails): Promise;
-
- /**
- * @since Chrome 88
- * Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned.
- * If displayActionCountAsBadgeText is enabled, a placeholder text will be returned unless the
- * declarativeNetRequestFeedback permission is present or tab-specific badge text was provided.
- */
- export function getBadgeText(details: TabDetails, callback: (result: string) => void): void;
-
+ export function getBadgeBackgroundColor(details: TabDetails, callback: (result: ColorArray) => void): void;
/**
- * @since Chrome 88
- * Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned.
- * If displayActionCountAsBadgeText is enabled, a placeholder text will be returned unless the
- * declarativeNetRequestFeedback permission is present or tab-specific badge text was provided.
- * @return The `getBadgeText` method provides its result via callback or returned as a `Promise` (MV3 only).
+ * Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If {@link declarativeNetRequest.ExtensionActionOptions.displayActionCountAsBadgeText displayActionCountAsBadgeText} is enabled, a placeholder text will be returned unless the {@link runtime.ManifestPermissions declarativeNetRequestFeedback} permission is present or tab-specific badge text was provided.
+ *
+ * Can return its result via Promise.
*/
export function getBadgeText(details: TabDetails): Promise;
-
+ export function getBadgeText(details: TabDetails, callback: (result: string) => void): void;
/**
- * @since Chrome 110
* Gets the text color of the action.
- */
- export function getBadgeTextColor(details: TabDetails, callback: (result: ColorArray) => void): void;
-
- /**
+ *
+ * Can return its result via Promise.
* @since Chrome 110
- * Gets the text color of the action.
- * @return The `getBadgeTextColor` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function getBadgeTextColor(details: TabDetails): Promise;
-
- /**
- * @since Chrome 88
- * Gets the html document set as the popup for this action.
- */
- export function getPopup(details: TabDetails, callback: (result: string) => void): void;
-
+ export function getBadgeTextColor(details: TabDetails, callback: (result: ColorArray) => void): void;
/**
- * @since Chrome 88
* Gets the html document set as the popup for this action.
- * @return The `getPopup` method provides its result via callback or returned as a `Promise` (MV3 only).
+ *
+ * Can return its result via Promise.
*/
export function getPopup(details: TabDetails): Promise;
-
- /**
- * @since Chrome 88
- * Gets the title of the action.
- */
- export function getTitle(details: TabDetails, callback: (result: string) => void): void;
-
+ export function getPopup(details: TabDetails, callback: (result: string) => void): void;
/**
- * @since Chrome 88
* Gets the title of the action.
- * @return The `getTitle` method provides its result via callback or returned as a `Promise` (MV3 only).
+ *
+ * Can return its result via Promise.
*/
export function getTitle(details: TabDetails): Promise;
-
+ export function getTitle(details: TabDetails, callback: (result: string) => void): void;
/**
- * @since Chrome 91
* Returns the user-specified settings relating to an extension's action.
- */
- export function getUserSettings(callback: (userSettings: UserSettings) => void): void;
-
- /**
+ *
+ * Can return its result via Promise.
* @since Chrome 91
- * Returns the user-specified settings relating to an extension's action.
- * @return The `getUserSettings` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function getUserSettings(): Promise;
-
- /**
- * @since Chrome 110
- * Indicates whether the extension action is enabled for a tab (or globally if no tabId is provided). Actions enabled using only declarativeContent always return false.
- */
- export function isEnabled(tabId: number | undefined, callback: (isEnabled: boolean) => void): void;
-
+ export function getUserSettings(callback: (userSettings: UserSettings) => void): void;
/**
+ * Indicates whether the extension action is enabled for a tab (or globally if no `tabId` is provided). Actions enabled using only {@link declarativeContent} always return false.
+ *
+ * Can return its result via Promise.
* @since Chrome 110
- * Indicates whether the extension action is enabled for a tab (or globally if no tabId is provided). Actions enabled using only declarativeContent always return false.
- * @return True if the extension action is enabled.
*/
export function isEnabled(tabId?: number): Promise;
-
+ export function isEnabled(callback: (isEnabled: boolean) => void): void;
+ export function isEnabled(tabId: number | undefined, callback: (isEnabled: boolean) => void): void;
/**
- * @since Chrome 99
- * Opens the extension's popup.
+ * Opens the extension's popup. Between Chrome 118 and Chrome 126, this is only available to policy installed extensions.
+ *
* @param options Specifies options for opening the popup.
- * () => {...}
- * @return The `openPopup` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ *
+ * Can return its result via Promise.
+ * @since Chrome 127
*/
export function openPopup(options?: OpenPopupOptions): Promise;
-
- /**
- * @since Chrome 99
- * Opens the extension's popup.
- * @param options Specifies options for opening the popup.
- */
export function openPopup(callback: () => void): void;
- export function openPopup(options: OpenPopupOptions, callback: () => void): void;
-
+ export function openPopup(options: OpenPopupOptions | undefined, callback: () => void): void;
/**
- * @since Chrome 88
* Sets the background color for the badge.
- * @return The `setBadgeBackgroundColor` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ *
+ * Can return its result via Promise.
*/
export function setBadgeBackgroundColor(details: BadgeColorDetails): Promise;
-
- /**
- * @since Chrome 88
- * Sets the background color for the badge.
- */
export function setBadgeBackgroundColor(details: BadgeColorDetails, callback: () => void): void;
-
/**
- * @since Chrome 88
* Sets the badge text for the action. The badge is displayed on top of the icon.
- * @return The `setBadgeText` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ *
+ * Can return its result via Promise.
*/
export function setBadgeText(details: BadgeTextDetails): Promise;
-
- /**
- * @since Chrome 88
- * Sets the badge text for the action. The badge is displayed on top of the icon.
- */
export function setBadgeText(details: BadgeTextDetails, callback: () => void): void;
-
/**
- * @since Chrome 110
* Sets the text color for the badge.
- * @return The `setBadgeTextColor` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ *
+ * Can return its result via Promise.
+ * @since Chrome 110
*/
export function setBadgeTextColor(details: BadgeColorDetails): Promise;
-
- /**
- * @since Chrome 100
- * Sets the text color for the badge.
- */
export function setBadgeTextColor(details: BadgeColorDetails, callback: () => void): void;
-
/**
- * @since Chrome 88
- * Sets the icon for the 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.
- * @return The `setIcon` method provides its result via callback or returned as a `Promise` (MV3 only). Since Chrome 96.
+ * Sets the icon for the 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.
+ *
+ * Can return its result via Promise.
*/
export function setIcon(details: TabIconDetails): Promise;
export function setIcon(details: TabIconDetails, callback: () => void): void;
-
/**
- * @since Chrome 88
* Sets the html document to be opened as a popup when the user clicks on the action's icon.
- * @return The `setPopup` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ *
+ * Can return its result via Promise.
*/
export function setPopup(details: PopupDetails): Promise;
-
- /**
- * @since Chrome 88
- * Sets the html document to be opened as a popup when the user clicks on the action's icon.
- */
export function setPopup(details: PopupDetails, callback: () => void): void;
-
/**
- * @since Chrome 88
* Sets the title of the action. This shows up in the tooltip.
- * @return The `setTitle` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
+ *
+ * Can return its result via Promise.
*/
export function setTitle(details: TitleDetails): Promise;
-
- /**
- * @since Chrome 88
- * Sets the title of the action. This shows up in the tooltip.
- */
export function setTitle(details: TitleDetails, callback: () => void): void;
-
/** Fired when an action icon is clicked. This event will not fire if the action has a popup. */
- export const onClicked: Browser.events.Event<(tab: Browser.tabs.Tab) => void>;
-
+ export const onClicked: events.Event<(tab: chrome.tabs.Tab) => void>;
/**
* Fired when user-specified settings relating to an extension's action change.
* @since Chrome 130
*/
- export const onUserSettingsChanged: Browser.events.Event<(change: UserSettingsChange) => void>;
- }
+ export const onUserSettingsChanged: events.Event<(change: UserSettingsChange) => void>;
- ////////////////////
- // Alarms
- ////////////////////
- /**
- * Use the `Browser.alarms` API to schedule code to run periodically or at a specified time in the future.
- *
- * Permissions: "alarms"
- */
- export namespace alarms {
- export interface AlarmCreateInfo {
- /** Optional. Length of time in minutes after which the onAlarm event should fire. */
- delayInMinutes?: number | undefined;
- /** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */
- periodInMinutes?: number | undefined;
- /** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */
- when?: 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 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;
}
- export interface Alarm {
- /** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */
- periodInMinutes?: number | undefined;
- /** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */
- scheduledTime: number;
- /** Name of this alarm. */
- name: string;
+ /** 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;
}
- export interface AlarmEvent extends Browser.events.Event<(alarm: Alarm) => void> {}
-
/**
- * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only).
+ * 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.
*/
- export function create(alarmInfo: AlarmCreateInfo): Promise;
+ 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;
+ }
+
+ /** The collection of user-specified settings relating to an extension's action. */
+ interface _GetUserSettingsReturnUserSettings {
+ /**
+ * Whether the extension's action icon is visible on browser windows' top-level toolbar (i.e., whether the extension has been 'pinned' by the user).
+ */
+ isOnToolbar?: boolean | undefined;
+ }
+
/**
- * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
- * @param name Optional name to identify this alarm. Defaults to the empty string.
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only).
+ * 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.
*/
- export function create(name: string, alarmInfo: AlarmCreateInfo): Promise;
+ 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;
+ }
+
/**
- * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
+ * 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.
*/
- export function create(alarmInfo: AlarmCreateInfo, callback: () => void): void;
+ 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;
+ }
+
/**
- * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
- * @param name Optional name to identify this alarm. Defaults to the empty string.
+ * 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;
+ }
+
+ /**
+ * 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 `chrome.alarms` API to schedule code to run periodically or at a specified time in the future.
+ *
+ * Permissions: "alarms"
+ */
+ export namespace alarms {
+ export interface AlarmCreateInfo {
+ /** Optional. Length of time in minutes after which the onAlarm event should fire. */
+ delayInMinutes?: number | undefined;
+ /** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */
+ periodInMinutes?: number | undefined;
+ /** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */
+ when?: number | undefined;
+ }
+
+ export interface Alarm {
+ /** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */
+ periodInMinutes?: number | undefined;
+ /** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */
+ scheduledTime: number;
+ /** Name of this alarm. */
+ name: string;
+ }
+
+ export interface AlarmEvent extends chrome.events.Event<(alarm: Alarm) => void> {
+ }
+
+ /**
+ * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
+ * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
+ * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
+ * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
+ * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only).
+ */
+ export function create(alarmInfo: AlarmCreateInfo): Promise;
+ /**
+ * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
+ * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
+ * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
+ * @param name Optional name to identify this alarm. Defaults to the empty string.
+ * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
+ * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only).
+ */
+ export function create(name: string, alarmInfo: AlarmCreateInfo): Promise;
+ /**
+ * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
+ * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
+ * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
+ * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
+ */
+ export function create(alarmInfo: AlarmCreateInfo, callback: () => void): void;
+ /**
+ * Creates an alarm. Near the time(s) specified by alarmInfo, 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.
+ * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
+ * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
+ * @param name Optional name to identify this alarm. Defaults to the empty string.
* @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
*/
export function create(name: string, alarmInfo: AlarmCreateInfo, callback: () => void): void;
@@ -569,16 +582,30 @@ export namespace Browser {
* @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function get(name: string): Promise;
-
/** Fired when an alarm has elapsed. Useful for event pages. */
export var onAlarm: AlarmEvent;
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Fired when an alarm has expired. Useful for transient background pages.
+ * @param name The alarm that has expired.
+ */
+ const onAlarm: WebExtEvent<(name: Alarm) => void>;
}
- ////////////////////
- // Audio
- ////////////////////
/**
- * The `Browser.audio` API is provided to allow users to get information about and control the audio devices attached to the system. This API is currently only available in kiosk mode for ChromeOS.
+ * The `chrome.audio` API is provided to allow users to get information about and control the audio devices attached to the system. This API is currently only available in kiosk mode for ChromeOS.
*
* Permissions: "audio"
* @platform ChromeOS only
@@ -650,7 +677,7 @@ export namespace Browser {
POST_DSP_LOOPBACK = "POST_DSP_LOOPBACK",
POST_MIX_LOOPBACK = "POST_MIX_LOOPBACK",
REAR_MIC = "REAR_MIC",
- USB = "USB",
+ USB = "USB"
}
export interface LevelChangedEvent {
@@ -670,7 +697,7 @@ export namespace Browser {
/** Type of stream an audio device provides. */
export enum StreamType {
INPUT = "INPUT",
- OUTPUT = "OUTPUT",
+ OUTPUT = "OUTPUT"
}
/**
@@ -680,57 +707,47 @@ export namespace Browser {
export function getDevices(filter?: DeviceFilter): Promise;
export function getDevices(filter: DeviceFilter, callback: (devices: AudioDeviceInfo[]) => void): void;
export function getDevices(callback: (devices: AudioDeviceInfo[]) => void): void;
-
/**
* Gets the system-wide mute state for the specified stream type.
* Can return its result via Promise in Manifest V3 or later since Chrome 116.
*/
export function getMute(streamType: `${StreamType}`): Promise;
export function getMute(streamType: `${StreamType}`, callback: (value: boolean) => void): void;
-
/**
* Sets lists of active input and/or output devices.
* Can return its result via Promise in Manifest V3 or later since Chrome 116.
*/
export function setActiveDevices(ids: DeviceIdLists): Promise;
export function setActiveDevices(ids: DeviceIdLists, callback: () => void): void;
-
/**
* Sets mute state for a stream type. The mute state will apply to all audio devices with the specified audio stream type.
* Can return its result via Promise in Manifest V3 or later since Chrome 116.
*/
export function setMute(streamType: `${StreamType}`, isMuted: boolean): Promise;
export function setMute(streamType: `${StreamType}`, isMuted: boolean, callback: () => void): void;
-
/**
* Sets the properties for the input or output device.
* Can return its result via Promise in Manifest V3 or later since Chrome 116.
*/
export function setProperties(id: string, properties: DeviceProperties): Promise;
export function setProperties(id: string, properties: DeviceProperties, callback: () => void): void;
-
/**
* Fired when audio devices change, either new devices being added, or existing devices being removed.
*/
- export const onDeviceListChanged: Browser.events.Event<(devices: AudioDeviceInfo[]) => void>;
-
+ export const onDeviceListChanged: chrome.events.Event<(devices: AudioDeviceInfo[]) => void>;
/**
* Fired when sound level changes for an active audio device.
*/
- export const onLevelChanged: Browser.events.Event<(event: LevelChangedEvent) => void>;
-
+ export const onLevelChanged: chrome.events.Event<(event: LevelChangedEvent) => void>;
/**
* Fired when the mute state of the audio input or output changes.
* Note that mute state is system-wide and the new value applies to every audio device with specified stream type.
*/
- export const onMuteChanged: Browser.events.Event<(event: MuteChangedEvent) => void>;
+ export const onMuteChanged: chrome.events.Event<(event: MuteChangedEvent) => void>;
}
- ////////////////////
- // Browser
- ////////////////////
/**
- * Use the Browser.browser API to interact with the Chrome browser associated with
+ * Use the chrome.browser API to interact with the Chrome browser associated with
* the current application and Chrome profile.
* @deprecated Part of the deprecated Chrome Apps platform
*/
@@ -749,7 +766,6 @@ export namespace Browser {
* created, or failed to be created. If failed, runtime.lastError will be set.
*/
export function openTab(options: Options, callback: () => void): void;
-
/**
* Opens a new tab in a browser window associated with the current application
* and Chrome profile. If no browser window for the Chrome profile is opened,
@@ -760,11 +776,8 @@ export namespace Browser {
export function openTab(options: Options): void;
}
- ////////////////////
- // Bookmarks
- ////////////////////
/**
- * Use the `Browser.bookmarks` API to create, organize, and otherwise manipulate bookmarks. Also see Override Pages, which you can use to create a custom Bookmark Manager page.
+ * Use the `chrome.bookmarks` API to create, organize, and otherwise manipulate bookmarks. Also see Override Pages, which you can use to create a custom Bookmark Manager page.
*
* Permissions: "bookmarks"
*/
@@ -808,7 +821,6 @@ export namespace Browser {
title: string;
/** Indicates the reason why this node is unmodifiable. The `managed` value indicates that this node was configured by the system administrator or by the custodian of a supervised user. Omitted if the node can be modified by the user and the extension (default). */
unmodifiable?: `${BookmarkTreeNodeUnmodifiable}`;
- /* The URL navigated to when a user clicks the bookmark. Omitted for folders. */
url?: string;
}
@@ -817,7 +829,7 @@ export namespace Browser {
* @since Chrome 44
*/
export enum BookmarkTreeNodeUnmodifiable {
- MANAGED = "managed",
+ MANAGED = "managed"
}
/** Object passed to the create() function. */
@@ -833,7 +845,6 @@ export namespace Browser {
* Indicates the type of folder.
* @since Chrome 134
*/
-
export enum FolderType {
/** The folder whose contents is displayed at the top of the browser window. */
BOOKMARKS_BAR = "bookmarks-bar",
@@ -842,14 +853,13 @@ export namespace Browser {
/** Bookmarks generally available on the user's mobile devices, but modifiable by extension or in the bookmarks manager. */
MOBILE = "mobile",
/** A top-level folder that may be present if the system administrator or the custodian of a supervised user has configured bookmarks. */
- MANAGED = "managed",
+ MANAGED = "managed"
}
/** @deprecated Bookmark write operations are no longer limited by Chrome. */
export const MAX_WRITE_OPERATIONS_PER_HOUR: 1000000;
/** @deprecated Bookmark write operations are no longer limited by Chrome. */
export const MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: 1000000;
-
/**
* Creates a bookmark or folder under the specified parentId. If url is NULL or missing, it will be a folder.
*
@@ -857,7 +867,6 @@ export namespace Browser {
*/
export function create(bookmark: CreateDetails): Promise;
export function create(bookmark: CreateDetails, callback: (result: BookmarkTreeNode) => void): void;
-
/**
* Retrieves the specified BookmarkTreeNode(s).
* @param idOrIdList A single string-valued id, or an array of string-valued ids
@@ -865,11 +874,7 @@ export namespace Browser {
* Can return its result via Promise since Chrome 90.
*/
export function get(idOrIdList: string | [string, ...string[]]): Promise;
- export function get(
- idOrIdList: string | [string, ...string[]],
- callback: (results: BookmarkTreeNode[]) => void,
- ): void;
-
+ export function get(idOrIdList: string | [string, ...string[]], callback: (results: BookmarkTreeNode[]) => void): void;
/**
* Retrieves the children of the specified BookmarkTreeNode id.
*
@@ -877,7 +882,6 @@ export namespace Browser {
*/
export function getChildren(id: string): Promise;
export function getChildren(id: string, callback: (results: BookmarkTreeNode[]) => void): void;
-
/**
* Retrieves the recently added bookmarks.
* @param numberOfItems The maximum number of items to return.
@@ -886,7 +890,6 @@ export namespace Browser {
*/
export function getRecent(numberOfItems: number): Promise;
export function getRecent(numberOfItems: number, callback: (results: BookmarkTreeNode[]) => void): void;
-
/**
* Retrieves part of the Bookmarks hierarchy, starting at the specified node.
* @param id The ID of the root of the subtree to retrieve.
@@ -895,7 +898,6 @@ export namespace Browser {
*/
export function getSubTree(id: string): Promise;
export function getSubTree(id: string, callback: (results: BookmarkTreeNode[]) => void): void;
-
/**
* Retrieves the entire Bookmarks hierarchy.
*
@@ -915,12 +917,7 @@ export namespace Browser {
* Can return its result via Promise since Chrome Chrome 90
*/
export function move(id: string, destination: MoveDestination): Promise;
- export function move(
- id: string,
- destination: MoveDestination,
- callback: (result: BookmarkTreeNode) => void,
- ): void;
-
+ export function move(id: string, destination: MoveDestination, callback: (result: BookmarkTreeNode) => void): void;
/**
* Removes a bookmark or an empty bookmark folder.
*
@@ -928,7 +925,6 @@ export namespace Browser {
*/
export function remove(id: string): Promise;
export function remove(id: string, callback: () => void): void;
-
/**
* Recursively removes a bookmark folder.
*
@@ -938,7 +934,7 @@ export namespace Browser {
export function removeTree(id: string, callback: () => void): void;
interface SearchQuery {
- /** A string of words and quoted phrases that are matched against bookmark URLs and titles.*/
+ /** A string of words and quoted phrases that are matched against bookmark URLs and titles. */
query?: string;
/** The URL of the bookmark; matches verbatim. Note that folders have no URL. */
url?: string;
@@ -967,52 +963,93 @@ export namespace Browser {
*/
export function update(id: string, changes: UpdateChanges): Promise;
export function update(id: string, changes: UpdateChanges, callback: (result: BookmarkTreeNode) => void): void;
-
- /** Fired when a bookmark or folder changes. **Note:** Currently, only title and url changes trigger this.*/
+ /** Fired when a bookmark or folder changes. **Note:** Currently, only title and url changes trigger this. */
export const onChanged: events.Event<(id: string, changeInfo: { title: string; url?: string }) => void>;
-
/** Fired when the children of a folder have changed their order due to the order being sorted in the UI. This is not called as a result of a move(). */
export const onChildrenReordered: events.Event<(id: string, reorderInfo: { childIds: string[] }) => void>;
-
/** Fired when a bookmark or folder is created. */
export const onCreated: events.Event<(id: string, bookmark: BookmarkTreeNode) => void>;
-
/** Fired when a bookmark import session is begun. Expensive observers should ignore onCreated updates until onImportEnded is fired. Observers should still handle other notifications immediately. */
export const onImportBegan: events.Event<() => void>;
-
- /** Fired when a bookmark import session is ended. */
+ /** Fired when a bookmark import session is ended. */
export const onImportEnded: events.Event<() => void>;
-
/** Fired when a bookmark or folder is moved to a different parent folder. */
export const onMoved: events.Event<
- (
- id: string,
- moveInfo: {
- parentId: string;
- index: number;
- oldParentId: string;
- oldIndex: number;
- },
- ) => void
- >;
-
+ (
+ id: string,
+ moveInfo: {
+ parentId: string;
+ index: number;
+ oldParentId: string;
+ oldIndex: number;
+ },
+ ) => void
+ >;
/** Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents. */
export const onRemoved: events.Event<
- (
- id: string,
- removeInfo: {
- parentId: string;
- index: number;
- /** @since Chrome 48 */
- node: BookmarkTreeNode;
- },
- ) => void
- >;
+ (
+ id: string,
+ removeInfo: {
+ parentId: string;
+ index: number;
+ /** @since Chrome 48 */
+ node: BookmarkTreeNode;
+ },
+ ) => void
+ >;
+
+ interface _MoveDestination {
+ parentId?: string | undefined;
+ index?: number | undefined;
+ }
+
+ interface _UpdateChanges {
+ title?: string | undefined;
+ url?: string | undefined;
+ }
+
+ interface _OnRemovedRemoveInfo {
+ parentId: string;
+ index: number;
+ node: BookmarkTreeNode;
+ }
+
+ interface _OnChangedChangeInfo {
+ title: string;
+ url?: string | undefined;
+ }
+
+ interface _OnMovedMoveInfo {
+ parentId: string;
+ index: number;
+ oldParentId: string;
+ oldIndex: number;
+ }
+
+ interface _OnChildrenReorderedReorderInfo {
+ childIds: string[];
+ }
+
+ /** Fired when a bookmark or folder is created. */
+ const onCreated: WebExtEvent<(id: string, bookmark: BookmarkTreeNode) => void>;
+ /**
+ * Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents.
+ */
+ const onRemoved: WebExtEvent<(id: string, removeInfo: _OnRemovedRemoveInfo) => void>;
+ /**
+ * Fired when a bookmark or folder changes. **Note:** Currently, only title and url changes trigger this.
+ */
+ const onChanged: WebExtEvent<(id: string, changeInfo: _OnChangedChangeInfo) => void>;
+ /** Fired when a bookmark or folder is moved to a different parent folder. */
+ const onMoved: WebExtEvent<(id: string, moveInfo: _OnMovedMoveInfo) => void>;
+ /**
+ * Fired when the children of a folder have changed their order due to the order being sorted in the UI. This is not called as a result of a move().
+ * @deprecated Unsupported on Firefox at this time.
+ */
+ const onChildrenReordered: | WebExtEvent<(id: string, reorderInfo: _OnChildrenReorderedReorderInfo) => void>
+ | undefined;
}
- ////////////////////
- // Browser Action
- ////////////////////
/**
* Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can have a tooltip, a badge, and a popup.
*
@@ -1024,14 +1061,14 @@ export namespace Browser {
export interface BadgeBackgroundColorDetails {
/** 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. */
color: string | ColorArray;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
}
export interface BadgeTextDetails {
/** Any number of characters can be passed, but only about four can fit in the space. */
text?: string | null | undefined;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
}
@@ -1040,32 +1077,33 @@ export namespace Browser {
export interface TitleDetails {
/** The string the browser action should display when moused over. */
title: string;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | null;
}
export interface TabDetails {
- /** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */
+ /** Optional. Specify the tab to get the information. If no tab is specified, the non-tab-specific information is returned. */
tabId?: number | null;
}
export interface TabIconDetails {
- /** Optional. 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}' */
+ /** Optional. 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 | { [index: string]: string } | undefined;
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | undefined;
- /** Optional. 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}' */
+ /** Optional. 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?: ImageData | { [index: number]: ImageData } | undefined;
}
export interface PopupDetails {
- /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
+ /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
tabId?: number | null;
/** The html file to show in a popup. If set to the empty string (''), no popup is shown. */
popup: string;
}
- export interface BrowserClickedEvent extends Browser.events.Event<(tab: Browser.tabs.Tab) => void> {}
+ export interface BrowserClickedEvent extends chrome.events.Event<(tab: chrome.tabs.Tab) => void> {
+ }
/**
* @since Chrome 22
@@ -1186,26 +1224,176 @@ export namespace Browser {
* 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.
*/
export function setIcon(details: TabIconDetails, callback?: () => void): void;
-
/** Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. */
export var onClicked: BrowserClickedEvent;
+
+ /**
+ * 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;
+ }
+
+ /** 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /** Returns the user-specified settings relating to an extension's action. */
+ function getUserSettings(): 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;
+ /** 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;
+
+ /**
+ * 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>;
}
- ////////////////////
- // Browsing Data
- ////////////////////
/**
- * Use the `Browser.browsingData` API to remove browsing data from a user's local profile.
+ * Use the `chrome.browsingData` API to remove browsing data from a user's local profile.
*
* Permissions: "browsingData"
*/
export namespace browsingData {
export interface OriginTypes {
- /** Optional. Extensions and packaged applications a user has installed (be _really_ careful!). */
+ /** Optional. Extensions and packaged applications a user has installed (be _really_ careful!). */
extension?: boolean | undefined;
- /** Optional. Websites that have been installed as hosted applications (be careful!). */
+ /** Optional. Websites that have been installed as hosted applications (be careful!). */
protectedWeb?: boolean | undefined;
- /** Optional. Normal websites. */
+ /** Optional. Normal websites. */
unprotectedWeb?: boolean | undefined;
}
@@ -1240,13 +1428,13 @@ export namespace Browser {
* A set of data types. Missing data types are interpreted as false.
*/
export interface DataTypeSet {
- /** Optional. Websites' WebSQL data. */
+ /** Optional. Websites' WebSQL data. */
webSQL?: boolean | undefined;
- /** Optional. Websites' IndexedDB data. */
+ /** Optional. Websites' IndexedDB data. */
indexedDB?: boolean | undefined;
- /** Optional. The browser's cookies. */
+ /** Optional. The browser's cookies. */
cookies?: boolean | undefined;
- /** Optional. Stored passwords. */
+ /** Optional. Stored passwords. */
passwords?: boolean | undefined;
/**
* @deprecated Deprecated since Chrome 76.
@@ -1255,15 +1443,15 @@ export namespace Browser {
* Optional. Server-bound certificates.
*/
serverBoundCertificates?: boolean | undefined;
- /** Optional. The browser's download list. */
+ /** Optional. The browser's download list. */
downloads?: boolean | undefined;
- /** Optional. The browser's cache. Note: when removing data, this clears the entire cache: it is not limited to the range you specify. */
+ /** Optional. 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;
- /** Optional. The browser's cacheStorage. */
+ /** Optional. The browser's cacheStorage. */
cacheStorage?: boolean | undefined;
- /** Optional. Websites' appcaches. */
+ /** Optional. Websites' appcaches. */
appcache?: boolean | undefined;
- /** Optional. Websites' file systems. */
+ /** Optional. Websites' file systems. */
fileSystems?: boolean | undefined;
/**
* @deprecated Deprecated since Chrome 88.
@@ -1272,11 +1460,11 @@ export namespace Browser {
* Optional. Plugins' data.
*/
pluginData?: boolean | undefined;
- /** Optional. Websites' local storage data. */
+ /** Optional. Websites' local storage data. */
localStorage?: boolean | undefined;
- /** Optional. The browser's stored form data. */
+ /** Optional. The browser's stored form data. */
formData?: boolean | undefined;
- /** Optional. The browser's history. */
+ /** Optional. The browser's history. */
history?: boolean | undefined;
/**
* Optional.
@@ -1405,11 +1593,13 @@ export namespace Browser {
* @param callback Called when websites' appcache data has been cleared.
*/
export function removeAppcache(options: RemovalOptions, callback: () => void): void;
- /** Clears websites' cache storage data.
+ /**
+ * Clears websites' cache storage data.
* @return The `removeCacheStorage` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
*/
export function removeCacheStorage(options: RemovalOptions): Promise;
- /** Clears websites' cache storage data.
+ /**
+ * Clears websites' cache storage data.
* @param callback Called when websites' appcache data has been cleared.
*/
export function removeCacheStorage(options: RemovalOptions, callback: () => void): void;
@@ -1463,27 +1653,278 @@ export namespace Browser {
* @param callback Called when websites' IndexedDB data has been cleared.
*/
export function removeIndexedDB(options: RemovalOptions, callback: () => void): void;
- }
- ////////////////////
- // Commands
- ////////////////////
- /**
- * Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension.
- *
- * Manifest: "commands"
- */
- export namespace commands {
+ /**
+ * 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;
+ }
+ }
+
+ /**
+ * Use this API to expose certificates to the platform which can use these certificates for TLS authentications.
+ *
+ * Manifest: "certificateProvider"
+ * @platform ChromeOS only
+ * @since Chrome 46
+ */
+ export namespace certificateProvider {
+ /** Types of supported cryptographic signature algorithms. */
+ export enum Algorithm {
+ /**
+ * Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the MD5-SHA-1 hashing. The extension must not prepend a DigestInfo prefix but only add PKCS#1 padding.
+ * @deprecated This algorithm is deprecated and will never be requested by Chrome as of version 109.
+ */
+ RSASSA_PKCS1_V1_5_MD5_SHA1 = "RSASSA_PKCS1_v1_5_MD5_SHA1",
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-1 hash function. */
+ RSASSA_PKCS1_V1_5_SHA1 = "RSASSA_PKCS1_v1_5_SHA1",
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-256 hashing function. */
+ RSASSA_PKCS1_V1_5_SHA256 = "RSASSA_PKCS1_v1_5_SHA256",
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-384 hashing function. */
+ RSASSA_PKCS1_V1_5_SHA384 = "RSASSA_PKCS1_v1_5_SHA384",
+ /** Specifies the RSASSA PKCS#1 v1.5 signature algorithm with the SHA-512 hashing function. */
+ RSASSA_PKCS1_V1_5_SHA512 = "RSASSA_PKCS1_v1_5_SHA512",
+ /** Specifies the RSASSA PSS signature algorithm with the SHA-256 hashing function, MGF1 mask generation function and the salt of the same size as the hash. */
+ RSASSA_PSS_SHA256 = "RSASSA_PSS_SHA256",
+ /** Specifies the RSASSA PSS signature algorithm with the SHA-384 hashing function, MGF1 mask generation function and the salt of the same size as the hash. */
+ RSASSA_PSS_SHA384 = "RSASSA_PSS_SHA384",
+ /** Specifies the RSASSA PSS signature algorithm with the SHA-512 hashing function, MGF1 mask generation function and the salt of the same size as the hash. */
+ RSASSA_PSS_SHA512 = "RSASSA_PSS_SHA512"
+ }
+
+ export interface CertificateInfo {
+ /** Must be the DER encoding of a X.509 certificate. Currently, only certificates of RSA keys are supported. */
+ certificate: ArrayBuffer;
+ /** Must be set to all hashes supported for this certificate. This extension will only be asked for signatures of digests calculated with one of these hash algorithms. This should be in order of decreasing hash preference. */
+ supportedHashes: `${Hash}`[];
+ }
+
+ /** @since Chrome 86 */
+ export interface CertificatesUpdateRequest {
+ /** Request identifier to be passed to {@link setCertificates}. */
+ certificatesRequestId: number;
+ }
+
+ /** @since Chrome 86 */
+ export interface ClientCertificateInfo {
+ /**
+ * The array must contain the DER encoding of the X.509 client certificate as its first element.
+ *
+ * This must include exactly one certificate.
+ */
+ certificateChain: ArrayBuffer[];
+ /** All algorithms supported for this certificate. The extension will only be asked for signatures using one of these algorithms. */
+ supportedAlgorithms: `${Algorithm}`[];
+ }
+
+ /**
+ * Types of errors that the extension can report.
+ * @since Chrome 86
+ */
+ export enum Error {
+ GENERAL_ERROR = "GENERAL_ERROR"
+ }
+
+ /** @deprecated Replaced by {@link Algorithm}. */
+ export enum Hash {
+ /** Specifies the MD5 and SHA1 hashing algorithms. */
+ MD5_SHA1 = "MD5_SHA1",
+ /** Specifies the SHA1 hashing algorithm. */
+ SHA1 = "SHA1",
+ /** Specifies the SHA256 hashing algorithm. */
+ SHA256 = "SHA256",
+ /** Specifies the SHA384 hashing algorithm. */
+ SHA384 = "SHA384",
+ /** Specifies the SHA512 hashing algorithm. */
+ SHA512 = "SHA512"
+ }
+
+ /**
+ * The types of errors that can be presented to the user through the requestPin function.
+ * @since Chrome 57
+ */
+ export enum PinRequestErrorType {
+ /** Specifies the PIN is invalid. */
+ INVALID_PIN = "INVALID_PIN",
+ /** Specifies the PUK is invalid. */
+ INVALID_PUK = "INVALID_PUK",
+ /** Specifies the maximum attempt number has been exceeded. */
+ MAX_ATTEMPTS_EXCEEDED = "MAX_ATTEMPTS_EXCEEDED",
+ /** Specifies that the error cannot be represented by the above types. */
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
+ }
+
+ /**
+ * The type of code being requested by the extension with requestPin function.
+ * @since Chrome 57
+ */
+ export enum PinRequestType {
+ /** Specifies the requested code is a PIN. */
+ PIN = "PIN",
+ /** Specifies the requested code is a PUK. */
+ PUK = "PUK"
+ }
+
+ /** @since Chrome 57 */
+ export interface PinResponseDetails {
+ /** The code provided by the user. Empty if user closed the dialog or some other error occurred. */
+ userInput?: string | undefined;
+ }
+
+ /** @since Chrome 86 */
+ export interface ReportSignatureDetails {
+ /** Error that occurred while generating the signature, if any. */
+ error?: `${Error}` | undefined;
+ /** Request identifier that was received via the {@link onSignatureRequested} event. */
+ signRequestId: number;
+ /** The signature, if successfully generated. */
+ signature?: ArrayBuffer | undefined;
+ }
+
+ /** @since Chrome 57 */
+ export interface RequestPinDetails {
+ /** The number of attempts left. This is provided so that any UI can present this information to the user. Chrome is not expected to enforce this, instead stopPinRequest should be called by the extension with errorType = MAX_ATTEMPTS_EXCEEDED when the number of pin requests is exceeded. */
+ attemptsLeft?: number | undefined;
+ /** The error template displayed to the user. This should be set if the previous request failed, to notify the user of the failure reason. */
+ errorType?: `${PinRequestErrorType}` | undefined;
+ /** The type of code requested. Default is PIN. */
+ requestType?: `${PinRequestType}` | undefined;
+ /** The ID given by Chrome in SignRequest. */
+ signRequestId: number;
+ }
+
+ /** @since Chrome 86 */
+ export interface SetCertificatesDetails {
+ /** When called in response to {@link onCertificatesUpdateRequested}, should contain the received `certificatesRequestId` value. Otherwise, should be unset. */
+ certificatesRequestId?: number | undefined;
+ /** List of currently available client certificates. */
+ clientCertificates: ClientCertificateInfo[];
+ /** Error that occurred while extracting the certificates, if any. This error will be surfaced to the user when appropriate. */
+ error?: `${Error}` | undefined;
+ }
+
+ /** @since Chrome 86 */
+ export interface SignatureRequest {
+ /** Signature algorithm to be used. */
+ algorithm: `${Algorithm}`;
+ /** The DER encoding of a X.509 certificate. The extension must sign `input` using the associated private key. */
+ certificate: ArrayBuffer;
+ /** Data to be signed. Note that the data is not hashed. */
+ input: ArrayBuffer;
+ /** Request identifier to be passed to {@link reportSignature}. */
+ signRequestId: number;
+ }
+
+ export interface SignRequest {
+ /** The DER encoding of a X.509 certificate. The extension must sign `digest` using the associated private key. */
+ certificate: ArrayBuffer;
+ /** The digest that must be signed. */
+ digest: ArrayBuffer;
+ /** Refers to the hash algorithm that was used to create `digest`. */
+ hash: `${Hash}`;
+ /**
+ * The unique ID to be used by the extension should it need to call a method that requires it, e.g. requestPin.
+ * @since Chrome 57
+ */
+ signRequestId: number;
+ }
+
+ /** @since Chrome 57 */
+ export interface StopPinRequestDetails {
+ /** The error template. If present it is displayed to user. Intended to contain the reason for stopping the flow if it was caused by an error, e.g. MAX\_ATTEMPTS\_EXCEEDED. */
+ errorType?: `${PinRequestErrorType}` | undefined;
+ /** The ID given by Chrome in SignRequest. */
+ signRequestId: number;
+ }
+
+ /**
+ * Should be called as a response to {@link onSignatureRequested}.
+ *
+ * The extension must eventually call this function for every {@link onSignatureRequested} event; the API implementation will stop waiting for this call after some time and respond with a timeout error when this function is called.
+ *
+ * Can return its result via Promise since Chrome 96.
+ * @since Chrome 86
+ */
+ export function reportSignature(details: ReportSignatureDetails): Promise;
+ export function reportSignature(details: ReportSignatureDetails, callback: () => void): void;
+ /**
+ * Requests the PIN from the user. Only one ongoing request at a time is allowed. The requests issued while another flow is ongoing are rejected. It's the extension's responsibility to try again later if another flow is in progress.
+ *
+ * Can return its result via Promise since Chrome 96.
+ * @param details Contains the details about the requested dialog.
+ * @since Chrome 57
+ */
+ export function requestPin(details: RequestPinDetails): Promise;
+ export function requestPin(details: RequestPinDetails, callback: (details?: PinResponseDetails | undefined) => void): void;
+ /**
+ * Sets a list of certificates to use in the browser.
+ *
+ * The extension should call this function after initialization and on every change in the set of currently available certificates. The extension should also call this function in response to {@link onCertificatesUpdateRequested} every time this event is received.
+ *
+ * Can return its result via Promise since Chrome 96.
+ * @param details The certificates to set. Invalid certificates will be ignored.
+ * @since Chrome 86
+ */
+ export function setCertificates(details: SetCertificatesDetails): Promise;
+ export function setCertificates(details: SetCertificatesDetails, callback: () => void): void;
+ /**
+ * Stops the pin request started by the {@link requestPin} function.
+ *
+ * Can return its result via Promise since Chrome 96.
+ * @param details Contains the details about the reason for stopping the request flow.
+ * @since Chrome 57
+ */
+ export function stopPinRequest(details: StopPinRequestDetails): Promise;
+ export function stopPinRequest(details: StopPinRequestDetails, callback: () => void): void;
+ /**
+ * This event fires if the certificates set via {@link setCertificates} are insufficient or the browser requests updated information. The extension must call {@link setCertificates} with the updated list of certificates and the received `certificatesRequestId`.
+ * @since Chrome 86
+ */
+ export const onCertificatesUpdateRequested: events.Event<(request: CertificatesUpdateRequest) => void>;
+ /**
+ * This event fires every time the browser needs to sign a message using a certificate provided by this extension via {@link setCertificates}.
+ *
+ * The extension must sign the input data from `request` using the appropriate algorithm and private key and return it by calling {@link reportSignature} with the received `signRequestId`.
+ * @since Chrome 86
+ */
+ export const onSignatureRequested: events.Event<(request: SignatureRequest) => void>;
+ }
+
+ /**
+ * Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension.
+ *
+ * Manifest: "commands"
+ */
+ export namespace commands {
export interface Command {
- /** Optional. The name of the Extension Command */
+ /** Optional. The name of the Extension Command */
name?: string | undefined;
- /** Optional. The Extension Command description */
+ /** Optional. The Extension Command description */
description?: string | undefined;
- /** Optional. The shortcut active for this command, or blank if not active. */
+ /** Optional. The shortcut active for this command, or blank if not active. */
shortcut?: string | undefined;
}
- export interface CommandEvent extends Browser.events.Event<(command: string, tab: Browser.tabs.Tab) => void> {}
+ export interface CommandEvent extends chrome.events.Event<(command: string, tab: chrome.tabs.Tab) => void> {
+ }
/**
* Returns all the registered extension commands for this extension and their shortcut (if active).
@@ -1495,16 +1936,48 @@ export namespace Browser {
* @param callback Called to return the registered commands.
*/
export function getAll(callback: (commands: Command[]) => void): void;
-
/** Fired when a registered command is activated using a keyboard shortcut. */
export var onCommand: CommandEvent;
+
+ /** The new description for the command. */
+ interface _UpdateDetail {
+ /** The name of the command. */
+ name: string;
+ /** The new description for the command. */
+ description?: string | undefined;
+ shortcut?: string | undefined;
+ }
+
+ interface _OnChangedChangeInfo {
+ /** The name of the shortcut. */
+ name: string;
+ /** The new shortcut active for this command, or blank if not active. */
+ newShortcut: string;
+ /**
+ * The old shortcut which is no longer active for this command, or blank if the shortcut was previously inactive.
+ */
+ oldShortcut: string;
+ }
+
+ /**
+ * Update the details of an already defined command.
+ * @param detail The new description for the command.
+ */
+ function update(detail: _UpdateDetail): Promise;
+ /**
+ * Reset a command's details to what is specified in the manifest.
+ * @param name The name of the command.
+ */
+ function reset(name: string): Promise;
+
+ /** Fired when a registered command is activated using a keyboard shortcut. */
+ const onCommand: WebExtEvent<(command: string) => void>;
+ /** Fired when a registered command's shortcut is changed. */
+ const onChanged: WebExtEvent<(changeInfo: _OnChangedChangeInfo) => void>;
}
- ////////////////////
- // Content Settings
- ////////////////////
/**
- * Use the `Browser.contentSettings` API to change settings that control whether websites can use features such as cookies, JavaScript, and plugins. More generally speaking, content settings allow you to customize Chrome's behavior on a per-site basis instead of globally.
+ * Use the `chrome.contentSettings` API to change settings that control whether websites can use features such as cookies, JavaScript, and plugins. More generally speaking, content settings allow you to customize Chrome's behavior on a per-site basis instead of globally.
*
* Permissions: "contentSettings"
*/
@@ -1512,21 +1985,21 @@ export namespace Browser {
/** @since Chrome 113 */
export enum AutoVerifyContentSetting {
ALLOW = "allow",
- BLOCK = "block",
+ BLOCK = "block"
}
/** @since Chrome 46 */
export enum CameraContentSetting {
ALLOW = "allow",
BLOCK = "block",
- ASK = "ask",
+ ASK = "ask"
}
/** @since Chrome 121 */
export enum ClipboardContentSetting {
ALLOW = "allow",
BLOCK = "block",
- ASK = "ask",
+ ASK = "ask"
}
interface ContentSettingClearParams {
@@ -1557,7 +2030,7 @@ export namespace Browser {
resourceIdentifier?: ResourceIdentifier;
/** Where to set the setting (default: regular). */
scope?: `${Scope}`;
- /** The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see Content Setting Patterns.*/
+ /** The pattern for the secondary URL. Defaults to matching all URLs. For details on the format of a pattern, see Content Setting Patterns. */
secondaryPattern?: string;
/** The setting applied by this rule. See the description of the individual ContentSetting objects for the possible values. */
setting: T;
@@ -1571,7 +2044,6 @@ export namespace Browser {
*/
clear(details: ContentSettingClearParams): Promise;
clear(details: ContentSettingClearParams, callback: () => void): void;
-
/**
* Gets the current content setting for a given pair of URLs.
*
@@ -1579,11 +2051,9 @@ export namespace Browser {
*/
get(details: ContentSettingGetParams): Promise>;
get(details: ContentSettingGetParams, callback: (details: ContentSettingGetResult) => void): void;
-
/** Can return its result via Promise since Chrome 96. */
getResourceIdentifiers(): Promise;
getResourceIdentifiers(callback: (resourceIdentifiers?: ResourceIdentifier[]) => void): void;
-
/**
* Applies a new content setting rule.
*
@@ -1597,78 +2067,78 @@ export namespace Browser {
export enum CookiesContentSetting {
ALLOW = "allow",
BLOCK = "block",
- SESSION_ONLY = "session_only",
+ SESSION_ONLY = "session_only"
}
/** @since Chrome 44 */
export enum FullscreenContentSetting {
- ALLOW = "allow",
+ ALLOW = "allow"
}
/** @since Chrome 44 */
export enum ImagesContentSetting {
ALLOW = "allow",
- BLOCK = "block",
+ BLOCK = "block"
}
/** @since Chrome 44 */
export enum JavascriptContentSetting {
ALLOW = "allow",
- BLOCK = "block",
+ BLOCK = "block"
}
/** @since Chrome 44 */
export enum LocationContentSetting {
ALLOW = "allow",
BLOCK = "block",
- ASK = "ask",
+ ASK = "ask"
}
/** @since Chrome 46 */
export enum MicrophoneContentSetting {
ALLOW = "allow",
BLOCK = "block",
- ASK = "ask",
+ ASK = "ask"
}
/** @since Chrome 44 */
export enum MouselockContentSetting {
- ALLOW = "allow",
+ ALLOW = "allow"
}
/** @since Chrome 44 */
export enum MultipleAutomaticDownloadsContentSetting {
ALLOW = "allow",
BLOCK = "block",
- ASK = "ask",
+ ASK = "ask"
}
/** @since Chrome 44 */
export enum NotificationsContentSetting {
ALLOW = "allow",
BLOCK = "block",
- ASK = "ask",
+ ASK = "ask"
}
/** @since Chrome 44 */
export enum PluginsContentSetting {
- BLOCK = "block",
+ BLOCK = "block"
}
/** @since Chrome 44 */
export enum PopupsContentSetting {
ALLOW = "allow",
- BLOCK = "block",
+ BLOCK = "block"
}
/** @since Chrome 44 */
export enum PpapiBrokerContentSetting {
- BLOCK = "block",
+ BLOCK = "block"
}
/** The only content type using resource identifiers is contentSettings.plugins. For more information, see Resource Identifiers. */
export interface ResourceIdentifier {
- /** A human readable description of the resource. */
+ /** A human readable description of the resource. */
description?: string;
/** The resource identifier for the given content type. */
id: string;
@@ -1684,7 +2154,7 @@ export namespace Browser {
*/
export enum Scope {
REGULAR = "regular",
- INCOGNITO_SESSION_ONLY = "incognito_session_only",
+ INCOGNITO_SESSION_ONLY = "incognito_session_only"
}
/**
@@ -1701,7 +2171,6 @@ export namespace Browser {
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export const automaticDownloads: ContentSetting<`${MultipleAutomaticDownloadsContentSetting}`>;
-
/**
* Whether to allow sites to use the Private State Tokens API. One of
*
@@ -1715,7 +2184,6 @@ export namespace Browser {
* @since Chrome 113
*/
export const autoVerify: ContentSetting<`${AutoVerifyContentSetting}`>;
-
/**
* Whether to allow sites to access the camera. One of
*
@@ -1731,7 +2199,6 @@ export namespace Browser {
* @since Chrome 46
*/
export const camera: ContentSetting<`${CameraContentSetting}`>;
-
/**
* Whether to allow sites to access the clipboard via advanced capabilities of the Async Clipboard API. "Advanced" capabilities include anything besides writing built-in formats after a user gesture, i.e. the ability to read, the ability to write custom formats, and the ability to write without a user gesture. One of
*
@@ -1747,7 +2214,6 @@ export namespace Browser {
* @since Chrome 121
*/
export const clipboard: ContentSetting<`${ClipboardContentSetting}`>;
-
/**
* Whether to allow cookies and other local data to be set by websites. One of
*
@@ -1762,10 +2228,8 @@ export namespace Browser {
* The primary URL is the URL representing the cookie origin. The secondary URL is the URL of the top-level frame.
*/
export const cookies: ContentSetting<`${CookiesContentSetting}`>;
-
/** @deprecated No longer has any effect. Fullscreen permission is now automatically granted for all sites. Value is always `allow`. */
export const fullscreen: ContentSetting<`${FullscreenContentSetting}`>;
-
/**
* Whether to show images. One of
*
@@ -1778,7 +2242,6 @@ export namespace Browser {
* The primary URL is the URL of the top-level frame. The secondary URL is the URL of the image.
*/
export const images: ContentSetting<`${ImagesContentSetting}`>;
-
/**
* Whether to run JavaScript. One of
*
@@ -1791,7 +2254,6 @@ export namespace Browser {
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export const javascript: ContentSetting<`${JavascriptContentSetting}`>;
-
/**
* Whether to allow Geolocation. One of
*
@@ -1806,7 +2268,6 @@ export namespace Browser {
* The primary URL is the URL of the document which requested location data. The secondary URL is the URL of the top-level frame (which may or may not differ from the requesting URL).
*/
export const location: ContentSetting<`${LocationContentSetting}`>;
-
/**
* Whether to allow sites to access the microphone. One of
*
@@ -1822,10 +2283,8 @@ export namespace Browser {
* @since Chrome 46
*/
export const microphone: ContentSetting<`${MicrophoneContentSetting}`>;
-
/** @deprecated No longer has any effect. Mouse lock permission is now automatically granted for all sites. Value is always `allow`. */
export const mouselock: ContentSetting<`${MouselockContentSetting}`>;
-
/**
* Whether to allow sites to show desktop notifications. One of
*
@@ -1840,10 +2299,8 @@ export namespace Browser {
* The primary URL is the URL of the document which wants to show the notification. The secondary URL is not used.
*/
export const notifications: ContentSetting<`${NotificationsContentSetting}`>;
-
/** @deprecated With Flash support removed in Chrome 88, this permission no longer has any effect. Value is always `block`. Calls to `set()` and `clear()` will be ignored. */
export const plugins: ContentSetting<`${PluginsContentSetting}`>;
-
/**
* Whether to allow sites to show pop-ups. One of
*
@@ -1856,16 +2313,12 @@ export namespace Browser {
* The primary URL is the URL of the top-level frame. The secondary URL is not used.
*/
export const popups: ContentSetting<`${PopupsContentSetting}`>;
-
/** @deprecated Previously, controlled whether to allow sites to run plugins unsandboxed, however, with the Flash broker process removed in Chrome 88, this permission no longer has any effect. Value is always `block`. Calls to `set()` and `clear()` will be ignored. */
export const unsandboxedPlugins: ContentSetting<`${PpapiBrokerContentSetting}`>;
}
- ////////////////////
- // Context Menus
- ////////////////////
/**
- * Use the `Browser.contextMenus` API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
+ * Use the `chrome.contextMenus` API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
*
* Permissions: "contextMenus"
*/
@@ -1887,7 +2340,7 @@ export namespace Browser {
LAUNCHER = "launcher",
BROWSER_ACTION = "browser_action",
PAGE_ACTION = "page_action",
- ACTION = "action",
+ ACTION = "action"
}
/**
@@ -1899,7 +2352,7 @@ export namespace Browser {
checked?: boolean;
/** List of contexts this menu item will appear in. Defaults to `['page']`. */
contexts?: [`${ContextType}`, ...`${ContextType}`[]];
- /** Restricts the item to apply only to documents or frames whose URL matches one of the given patterns. For details on pattern formats, see Match Patterns. */
+ /** Restricts the item to apply only to documents or frames whose URL matches one of the given patterns. For details on pattern formats, see Match Patterns. */
documentUrlPatterns?: string[];
/** Whether this context menu item is enabled or disabled. Defaults to `true`. */
enabled?: boolean;
@@ -1921,9 +2374,9 @@ export namespace Browser {
* @param tab The details of the tab where the click took place. This parameter is not present for platform apps.
*/
onclick?: (
- info: OnClickData,
- tab: tabs.Tab,
- ) => void;
+ info: OnClickData,
+ tab: tabs.Tab,
+ ) => void;
}
/**
@@ -1934,7 +2387,7 @@ export namespace Browser {
NORMAL = "normal",
CHECKBOX = "checkbox",
RADIO = "radio",
- SEPARATOR = "separator",
+ SEPARATOR = "separator"
}
/** Information sent when a context menu item is clicked. */
@@ -1958,7 +2411,7 @@ export namespace Browser {
menuItemId: number | string;
/** The URL of the page where the menu item was clicked. This property is not set if the click occurred in a context where there is no current page, such as in a launcher context menu. */
pageUrl?: string;
- /** The parent ID, if any, for the item clicked.*/
+ /** The parent ID, if any, for the item clicked. */
parentMenuItemId?: number | string;
/** The text for the context selection, if any. */
selectionText?: string | undefined;
@@ -1970,13 +2423,11 @@ export namespace Browser {
/** The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored. */
export const ACTION_MENU_TOP_LEVEL_LIMIT: 6;
-
/**
- * Creates a new context menu item. If an error occurs during creation, it may not be detected until the creation callback fires; details will be in {@link Browser.runtime.lastError}.
+ * Creates a new context menu item. If an error occurs during creation, it may not be detected until the creation callback fires; details will be in {@link chrome.runtime.lastError}.
* @return The ID of the newly created item.
*/
export function create(createProperties: CreateProperties, callback?: () => void): number | string;
-
/**
* Removes a context menu item.
* @param menuItemId The ID of the context menu item to remove.
@@ -1985,7 +2436,6 @@ export namespace Browser {
*/
export function remove(menuItemId: string | number): Promise;
export function remove(menuItemId: string | number, callback: () => void): void;
-
/**
* Removes all context menu items added by this extension.
*
@@ -1993,7 +2443,6 @@ export namespace Browser {
*/
export function removeAll(): Promise;
export function removeAll(callback: () => void): void;
-
/**
* Updates a previously created context menu item.
* @param id The ID of the item to update.
@@ -2002,28 +2451,160 @@ export namespace Browser {
* Can return its result via Promise since Chrome 123.
*/
export function update(id: string | number, updateProperties: Omit): Promise;
- export function update(
- id: string | number,
- updateProperties: Omit,
- callback: () => void,
- ): void;
-
+ export function update(id: string | number, updateProperties: Omit, callback: () => void): void;
/** Fired when a context menu item is clicked. */
export const onClicked: events.Event<(info: OnClickData, tab?: tabs.Tab) => void>;
+
+ interface _CreateCreatePropertiesIcons {
+ [key: number]: string;
+ }
+
+ interface _CreateCreateProperties {
+ /** The type of menu item. Defaults to 'normal' if not specified. */
+ type?: ItemType | undefined;
+ /**
+ * The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.
+ */
+ id?: string | undefined;
+ icons?: _CreateCreatePropertiesIcons | undefined;
+ /**
+ * The text to be displayed in the item; this is _required_ unless `type` is 'separator'. When the context is 'selection', you can use `%s` within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin".
+ */
+ title?: string | undefined;
+ /**
+ * The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items.
+ */
+ checked?: boolean | undefined;
+ /** List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */
+ contexts?: ContextType[] | undefined;
+ /**
+ * List of view types where the menu item will be shown. Defaults to any view, including those without a viewType.
+ */
+ viewTypes?: extension.ViewType[] | undefined;
+ /** Whether the item is visible in the menu. */
+ visible?: boolean | undefined;
+ /**
+ * A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for `contextMenus.onClicked`.
+ * @param info Information about the item clicked and the context where the click happened.
+ * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions.
+ * Not supported on manifest versions above 2.
+ */
+ onclick?: (info: OnClickData, tab: tabs.Tab) => void | undefined;
+ /** The ID of a parent menu item; this makes the item a child of a previously added item. */
+ parentId?: number | string | undefined;
+ /**
+ * Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns.
+ */
+ documentUrlPatterns?: string[] | undefined;
+ /**
+ * Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags.
+ */
+ targetUrlPatterns?: string[] | undefined;
+ /** Whether this context menu item is enabled or disabled. Defaults to true. */
+ enabled?: boolean | undefined;
+ /** Specifies a command to issue for the context click. */
+ command?: string | _CreateCreatePropertiesCommand | undefined;
+ }
+
+ interface _UpdateUpdatePropertiesIcons {
+ [key: number]: string;
+ }
+
+ /** The properties to update. Accepts the same values as the create function. */
+ interface _UpdateUpdateProperties {
+ type?: ItemType | undefined;
+ icons?: _UpdateUpdatePropertiesIcons | undefined;
+ title?: string | undefined;
+ checked?: boolean | undefined;
+ contexts?: ContextType[] | undefined;
+ viewTypes?: extension.ViewType[] | undefined;
+ /** Whether the item is visible in the menu. */
+ visible?: boolean | undefined;
+ /**
+ * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions.
+ * Not supported on manifest versions above 2.
+ */
+ onclick?: (info: OnClickData, tab: tabs.Tab) => void | undefined;
+ /** Note: You cannot change an item to be a child of one of its own descendants. */
+ parentId?: number | string | undefined;
+ documentUrlPatterns?: string[] | undefined;
+ targetUrlPatterns?: string[] | undefined;
+ enabled?: boolean | undefined;
+ }
+
+ interface _OverrideContextContextOptions {
+ /** Whether to also include default menu items in the menu. */
+ showDefaults?: boolean | undefined;
+ /**
+ * ContextType to override, to allow menu items from other extensions in the menu. Currently only 'bookmark' and 'tab' are supported. showDefaults cannot be used with this option.
+ */
+ context?: _OverrideContextContextOptionsContext | undefined;
+ /** Required when context is 'bookmark'. Requires 'bookmark' permission. */
+ bookmarkId?: string | undefined;
+ /** Required when context is 'tab'. Requires 'tabs' permission. */
+ tabId?: number | undefined;
+ }
+
+ /**
+ * Information about the context of the menu action and the created menu items. For more information about each property, see OnClickData. The following properties are only set if the extension has host permissions for the given context: linkUrl, linkText, srcUrl, pageUrl, frameUrl, selectionText.
+ */
+ interface _OnShownInfo {
+ /** A list of IDs of the menu items that were shown. */
+ menuIds: Array;
+ /** A list of all contexts that apply to the menu. */
+ contexts: ContextType[];
+ viewType?: extension.ViewType | undefined;
+ editable: boolean;
+ mediaType?: string | undefined;
+ linkUrl?: string | undefined;
+ linkText?: string | undefined;
+ srcUrl?: string | undefined;
+ pageUrl?: string | undefined;
+ frameUrl?: string | undefined;
+ selectionText?: string | undefined;
+ targetElementId?: number | undefined;
+ }
+
+ /**
+ * Show the matching menu items from this extension instead of the default menu. This should be called during a 'contextmenu' DOM event handler, and only applies to the menu that opens after this event.
+ */
+ function overrideContext(contextOptions: _OverrideContextContextOptions): void;
+ /**
+ * Updates the extension items in the shown menu, including changes that have been made since the menu was shown. Has no effect if the menu is hidden. Rebuilding a shown menu is an expensive operation, only invoke this method when necessary.
+ */
+ function refresh(): Promise;
+ /**
+ * Retrieve the element that was associated with a recent contextmenu event.
+ * @param targetElementId The identifier of the clicked element, available as info.targetElementId in the menus.onShown, onClicked or onclick event.
+ */
+ function getTargetElement(targetElementId: number): Element | void;
+
+ const ACTION_MENU_TOP_LEVEL_LIMIT: number;
+ /**
+ * Fired when a context menu item is clicked.
+ * @param info Information about the item clicked and the context where the click happened.
+ * @param [tab] The details of the tab where the click took place. If the click did not take place in a tab, this parameter will be missing.
+ */
+ const onClicked: WebExtEvent<(info: OnClickData, tab?: tabs.Tab) => void>;
+ /**
+ * Fired when a menu is shown. The extension can add, modify or remove menu items and call menus.refresh() to update the menu.
+ * @param info Information about the context of the menu action and the created menu items. For more information about each property, see OnClickData. The following properties are only set if the extension has host permissions for the given context: linkUrl, linkText, srcUrl, pageUrl, frameUrl, selectionText.
+ * @param tab The details of the tab where the menu was opened.
+ */
+ const onShown: WebExtEvent<(info: _OnShownInfo, tab: tabs.Tab) => void>;
+ /** Fired when a menu is hidden. This event is only fired if onShown has fired before. */
+ const onHidden: WebExtEvent<() => void>;
}
- ////////////////////
- // Cookies
- ////////////////////
/**
- * Use the `Browser.cookies` API to query and modify cookies, and to be notified when they change.
+ * Use the `chrome.cookies` API to query and modify cookies, and to be notified when they change.
*
* Permissions: "cookies"
*
* Manifest: "host_permissions"
*/
export namespace cookies {
- /** A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute. **/
+ /** A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute. */
export type SameSiteStatus = "unspecified" | "no_restriction" | "lax" | "strict";
/** Represents information about an HTTP cookie. */
@@ -2045,7 +2626,7 @@ export namespace Browser {
session: boolean;
/** 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;
- /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */
+ /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */
expirationDate?: number | undefined;
/** The path of the cookie. */
path: string;
@@ -2080,31 +2661,31 @@ export namespace Browser {
}
export interface GetAllDetails {
- /** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */
+ /** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */
domain?: string | undefined;
- /** Optional. Filters the cookies by name. */
+ /** Optional. Filters the cookies by name. */
name?: string | undefined;
/**
* The partition key for reading or modifying cookies with the Partitioned attribute.
* @since Chrome 119
*/
partitionKey?: CookiePartitionKey | undefined;
- /** Optional. Restricts the retrieved cookies to those that would match the given URL. */
+ /** Optional. Restricts the retrieved cookies to those that would match the given URL. */
url?: string | undefined;
- /** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */
+ /** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */
storeId?: string | undefined;
- /** Optional. Filters out session vs. persistent cookies. */
+ /** Optional. Filters out session vs. persistent cookies. */
session?: boolean | undefined;
- /** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */
+ /** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */
path?: string | undefined;
- /** Optional. Filters the cookies by their Secure property. */
+ /** Optional. Filters the cookies by their Secure property. */
secure?: boolean | undefined;
}
export interface SetDetails {
- /** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */
+ /** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */
domain?: string | undefined;
- /** Optional. The name of the cookie. Empty by default if omitted. */
+ /** Optional. The name of the cookie. Empty by default if omitted. */
name?: string | undefined;
/**
* The partition key for reading or modifying cookies with the Partitioned attribute.
@@ -2113,17 +2694,17 @@ export namespace Browser {
partitionKey?: CookiePartitionKey | undefined;
/** 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;
- /** Optional. 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. */
+ /** Optional. 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;
- /** Optional. The value of the cookie. Empty by default if omitted. */
+ /** Optional. The value of the cookie. Empty by default if omitted. */
value?: string | undefined;
- /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */
+ /** Optional. 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;
- /** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */
+ /** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */
path?: string | undefined;
- /** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */
+ /** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */
httpOnly?: boolean | undefined;
- /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */
+ /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */
secure?: boolean | undefined;
/**
* Optional. The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute.
@@ -2168,135 +2749,266 @@ export namespace Browser {
documentId?: string;
/** The unique identifier for the frame within the tab. */
frameId?: number;
- /* The unique identifier for the tab containing the frame. */
tabId?: number;
}
- export interface CookieChangedEvent extends Browser.events.Event<(changeInfo: CookieChangeInfo) => void> {}
+ export interface CookieChangedEvent extends chrome.events.Event<(changeInfo: CookieChangeInfo) => void> {
+ }
/**
* Lists all existing cookie stores.
* Parameter cookieStores: All the existing cookie stores.
*/
export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void;
-
/**
* Lists all existing cookie stores.
* @return The `getAllCookieStores` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function getAllCookieStores(): Promise;
-
/**
* The partition key for the frame indicated.
* Can return its result via Promise in Manifest V3
* @since Chrome 132
*/
export function getPartitionKey(details: FrameDetails): Promise<{ partitionKey: CookiePartitionKey }>;
- export function getPartitionKey(
- details: FrameDetails,
- callback: (details: { partitionKey: CookiePartitionKey }) => void,
- ): void;
-
+ export function getPartitionKey(details: FrameDetails, callback: (details: { partitionKey: CookiePartitionKey }) => void): void;
/**
* 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.
* Parameter cookies: All the existing, unexpired cookies that match the given cookie info.
*/
export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void;
-
/**
* 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.
* @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export 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.
* @return The `set` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function set(details: SetDetails): Promise;
-
/**
* Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
* @param details Details about the cookie being set.
- * Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "Browser.runtime.lastError" will be set.
+ * Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "chrome.runtime.lastError" will be set.
*/
export function set(details: SetDetails, callback: (cookie: Cookie | null) => void): void;
-
/**
* Deletes a cookie by name.
* @param details Information to identify the cookie to remove.
* @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function remove(details: CookieDetails): Promise;
-
/**
* Deletes a cookie by name.
* @param details Information to identify the cookie to remove.
*/
export function remove(details: CookieDetails, callback?: (details: CookieDetails) => void): void;
-
/**
* 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.
* Parameter cookie: Contains details about the cookie. This parameter is null if no such cookie was found.
*/
export function get(details: CookieDetails, callback: (cookie: Cookie | null) => void): void;
-
/**
* 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.
* @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
*/
export function get(details: CookieDetails): Promise;
-
/** 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". */
export var onChanged: CookieChangedEvent;
- }
-
- ////////////////////
- // Debugger
- ////////////////////
- /**
- * The `Browser.debugger` API serves as an alternate transport for Chrome's remote debugging protocol. Use `Browser.debugger` to attach to one or more tabs to instrument network interaction, debug JavaScript, mutate the DOM and CSS, and more. Use the {@link Debuggee} `tabId` to target tabs with `sendCommand` and route events by `tabId` from `onEvent` callbacks.
- *
- * Permissions: "debugger"
- */
- export namespace _debugger {
- /** Debuggee identifier. Either tabId, extensionId or targetId must be specified */
- export interface Debuggee {
- /** The id of the tab which you intend to debug. */
- tabId?: number;
- /** The id of the extension which you intend to debug. Attaching to an extension background page is only possible when the `--silent-debugger-extension-api` command-line switch is used. */
- extensionId?: string;
- /** The opaque id of the debug target. */
- targetId?: string;
- }
/**
- * Debugger session identifier. One of tabId, extensionId or targetId must be specified. Additionally, an optional sessionId can be provided. If sessionId is specified for arguments sent from {@link onEvent}, it means the event is coming from a child protocol session within the root debuggee session. If sessionId is specified when passed to {@link sendCommand}, it targets a child protocol session within the root debuggee session.
- * @since Chrome 125
+ * The description of the storage partition of a cookie. This object may be omitted (null) if a cookie is not partitioned.
*/
- export interface DebuggerSession {
- /** The id of the extension which you intend to debug. Attaching to an extension background page is only possible when the `--silent-debugger-extension-api` command-line switch is used.*/
- extensionId?: string;
- /** The opaque id of the Chrome DevTools Protocol session. Identifies a child session within the root session identified by tabId, extensionId or targetId. */
- sessionId?: string;
- /** The id of the tab which you intend to debug. */
- tabId?: number;
- /** The opaque id of the debug target. */
- targetId?: string;
+ interface PartitionKey {
+ /** The first-party URL of the cookie, if the cookie is in storage partitioned by the top-level site. */
+ topLevelSite?: string | undefined;
}
- /**
+ /** 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;
+ }
+
+ /**
+ * 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>;
+ }
+
+ /**
+ * The `chrome.debugger` API serves as an alternate transport for Chrome's remote debugging protocol. Use `chrome.debugger` to attach to one or more tabs to instrument network interaction, debug JavaScript, mutate the DOM and CSS, and more. Use the {@link Debuggee} `tabId` to target tabs with `sendCommand` and route events by `tabId` from `onEvent` callbacks.
+ *
+ * Permissions: "debugger"
+ */
+ export namespace _debugger {
+ /** Debuggee identifier. Either tabId, extensionId or targetId must be specified */
+ export interface Debuggee {
+ /** The id of the tab which you intend to debug. */
+ tabId?: number;
+ /** The id of the extension which you intend to debug. Attaching to an extension background page is only possible when the `--silent-debugger-extension-api` command-line switch is used. */
+ extensionId?: string;
+ /** The opaque id of the debug target. */
+ targetId?: string;
+ }
+
+ /**
+ * Debugger session identifier. One of tabId, extensionId or targetId must be specified. Additionally, an optional sessionId can be provided. If sessionId is specified for arguments sent from {@link onEvent}, it means the event is coming from a child protocol session within the root debuggee session. If sessionId is specified when passed to {@link sendCommand}, it targets a child protocol session within the root debuggee session.
+ * @since Chrome 125
+ */
+ export interface DebuggerSession {
+ /** The id of the extension which you intend to debug. Attaching to an extension background page is only possible when the `--silent-debugger-extension-api` command-line switch is used. */
+ extensionId?: string;
+ /** The opaque id of the Chrome DevTools Protocol session. Identifies a child session within the root session identified by tabId, extensionId or targetId. */
+ sessionId?: string;
+ /** The id of the tab which you intend to debug. */
+ tabId?: number;
+ /** The opaque id of the debug target. */
+ targetId?: string;
+ }
+
+ /**
* Connection termination reason.
* @since Chrome 44
*/
export enum DetachReason {
CANCELED_BY_USER = "canceled_by_user",
- TARGET_CLOSED = "target_closed",
+ TARGET_CLOSED = "target_closed"
}
/** Debug target information */
@@ -2315,7 +3027,7 @@ export namespace Browser {
title: string;
/** Target URL. */
url: string;
- /** Target favicon URL. */
+ /** Target favicon URL. */
faviconUrl?: string;
}
@@ -2327,7 +3039,7 @@ export namespace Browser {
BACKGROUND_PAGE = "background_page",
OTHER = "other",
PAGE = "page",
- WORKER = "worker",
+ WORKER = "worker"
}
/**
@@ -2339,7 +3051,6 @@ export namespace Browser {
*/
export function attach(target: Debuggee, requiredVersion: string): Promise;
export function attach(target: Debuggee, requiredVersion: string, callback: () => void): void;
-
/**
* Detaches debugger from the given target.
* @param target Debugging target from which you want to detach.
@@ -2348,7 +3059,6 @@ export namespace Browser {
*/
export function detach(target: Debuggee): Promise;
export function detach(target: Debuggee, callback: () => void): void;
-
/**
* Sends given command to the debugging target.
* @param target Debugging target to which you want to send the command.
@@ -2357,18 +3067,8 @@ export namespace Browser {
*
* Can return its result via Promise since Chrome 96.
*/
- export function sendCommand(
- target: DebuggerSession,
- method: string,
- commandParams?: { [key: string]: unknown },
- ): Promise