UNPKG

chrome-types

Version:

TypeScript definitions for Chrome extensions

1,493 lines (1,200 loc) 938 kB
/** * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Generated on Fri Jan 16 2026 22:25:33 GMT+0000 (Coordinated Universal Time) // Built at d848dfaecedc6a6d47988fa2f68932d934dd9275 // Includes MV3+ APIs only. // Extensions APIs incorrectly reference `usb.Device`, which is a Platform Apps only API. // WebUSB is available in Chrome 61+. declare namespace usb { interface Device { /** * An opaque ID for the USB device. It remains unchanged until the device is unplugged. */ device: number; /** * The device vendor ID. */ vendorId: number; /** * The product ID. */ productId: number; /** * The device version (bcdDevice field). */ version: number; /** * The iProduct string read from the device, if available. */ productName: string; /** * The iManufacturer string read from the device, if available. */ manufacturerName: string; /** * The iSerialNumber string read from the device, if available. */ serialNumber: string; } } // The MV3 API `action` incorrectly references the MV2-only API `browserAction`. declare namespace browserAction { /** * A tuple of RGBA values. */ type ColorArray = [number, number, number, number]; /** * Pixel data for an image. Must be an ImageData object; for example, from a `canvas` element. */ type ImageDataType = ImageData; } // These are stubs for DOM APIs not nessecarily available in TS' defaults. interface Entry {} interface FileEntry extends Entry {} interface DirectoryEntry extends Entry {} interface LocalMediaStream {} interface DOMFileSystem extends FileSystem {} // This is used to support addListener() where additional parameters are supported. // The name is detected inside the developer.chrome.com repository and special actions are taken. type CustomChromeEvent<H extends (...args: any) => void> = Omit<chrome.events.Event<H>, 'addListener'> & { // nb. This just copies the description from `chrome.events.Event.addListener`. /** * Registers an event listener _callback_ to an event. */ readonly addListener: H; }; declare namespace chrome { /** * Use the `chrome.accessibilityFeatures` API to manage Chrome's accessibility features. This API relies on the [ChromeSetting prototype of the type API](https://developer.chrome.com/docs/extensions/reference/types/#ChromeSetting) 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. * * @chrome-permission accessibilityFeatures.modify * @chrome-permission accessibilityFeatures.read * @chrome-platform chromeos * @chrome-platform linux * @chrome-platform mac * @chrome-platform win */ export namespace accessibilityFeatures { /** * **ChromeOS only.** * * 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. */ export const spokenFeedback: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * Enlarged cursor. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. */ export const largeCursor: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. */ export const stickyKeys: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. */ export const highContrast: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. */ export const screenMagnifier: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. */ export const autoclick: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. */ export const virtualKeyboard: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * Caret highlighting. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. * * @since Chrome 51 */ export const caretHighlight: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * Cursor highlighting. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. * * @since Chrome 51 */ export const cursorHighlight: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. * * @since Chrome 85 */ export const cursorColor: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. * * @since Chrome 87 */ export const dockedMagnifier: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * Focus highlighting. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. * * @since Chrome 51 */ export const focusHighlight: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * 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. * * @since Chrome 51 */ export const selectToSpeak: types.ChromeSetting<boolean>; /** * **ChromeOS only.** * * Switch Access. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. * * @since Chrome 51 */ export const switchAccess: types.ChromeSetting<boolean>; /** * `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. */ export const animationPolicy: types.ChromeSetting<"allowed" | "once" | "none">; /** * **ChromeOS only.** * * Dictation. The value indicates whether the feature is enabled or not. `get()` requires `accessibilityFeatures.read` permission. `set()` and `clear()` require `accessibilityFeatures.modify` permission. * * @since Chrome 90 */ export const dictation: types.ChromeSetting<boolean>; } /** * Use the `chrome.action` API to control the extension's icon in the Google Chrome toolbar. * * @since Chrome 88 * @chrome-manifest action * @chrome-min-manifest MV3 */ export namespace action { export interface TabDetails { /** * The ID of the tab to query state for. If no tab is specified, the non-tab-specific state is returned. */ tabId?: number; } /** * The collection of user-specified settings relating to an extension's action. * * @since Chrome 91 */ export interface UserSettings { /** * 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; } /** * @since Chrome 130 */ export interface UserSettingsChange { /** * 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; } /** * @since Chrome 99 */ export interface OpenPopupOptions { /** * The ID of the window to open the action popup in. Defaults to the currently-active window if unspecified. */ windowId?: number; } /** * Fired when an action icon is clicked. This event will not fire if the action has a popup. */ export const onClicked: events.Event<( tab: tabs.Tab, ) => void>; /** * Fired when user-specified settings relating to an extension's action change. * * @since Chrome 130 */ export const onUserSettingsChanged: events.Event<( change: UserSettingsChange, ) => void>; /** * Sets the title of the action. This shows up in the tooltip. */ export function setTitle( details: { /** * The string the action should display when moused over. */ title: string, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, ): Promise<void>; /** * Sets the title of the action. This shows up in the tooltip. */ export function setTitle( details: { /** * The string the action should display when moused over. */ title: string, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, callback?: () => void, ): void; /** * Gets the title of the action. */ export function getTitle( details: TabDetails, ): Promise<string>; /** * Gets the title of the action. */ export function getTitle( details: TabDetails, callback?: ( result: string, ) => void, ): void; /** * 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. * * @chrome-returns-extra since Chrome 96 */ export function setIcon( details: { /** * 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?: extensionTypes.ImageDataType | {[name: string]: any}, /** * 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 | {[name: string]: any}, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, ): Promise<void>; /** * 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. */ export function setIcon( details: { /** * 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?: extensionTypes.ImageDataType | {[name: string]: any}, /** * 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 | {[name: string]: any}, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, callback?: () => void, ): void; /** * Sets the HTML document to be opened as a popup when the user clicks on the action's icon. */ export function setPopup( details: { /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, /** * The relative path to the HTML file to show in a popup. If set to the empty string (`''`), no popup is shown. */ popup: string, }, ): Promise<void>; /** * Sets the HTML document to be opened as a popup when the user clicks on the action's icon. */ export function setPopup( details: { /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, /** * The relative path to the HTML file to show in a popup. If set to the empty string (`''`), no popup is shown. */ popup: string, }, callback?: () => void, ): void; /** * Gets the html document set as the popup for this action. */ export function getPopup( details: TabDetails, ): Promise<string>; /** * Gets the html document set as the popup for this action. */ export function getPopup( details: TabDetails, callback?: ( result: string, ) => void, ): void; /** * Sets the badge text for the action. The badge is displayed on top of the icon. */ export function setBadgeText( details: { /** * 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, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, ): Promise<void>; /** * Sets the badge text for the action. The badge is displayed on top of the icon. */ export function setBadgeText( details: { /** * 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, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, callback?: () => void, ): void; /** * Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If [displayActionCountAsBadgeText](https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#setExtensionActionOptions) is enabled, a placeholder text will be returned unless the [declarativeNetRequestFeedback](https://developer.chrome.com/docs/extensions/develop/concepts/declare-permissions#declarativeNetRequestFeedback) permission is present or tab-specific badge text was provided. */ export function getBadgeText( details: TabDetails, ): Promise<string>; /** * Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If [displayActionCountAsBadgeText](https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#setExtensionActionOptions) is enabled, a placeholder text will be returned unless the [declarativeNetRequestFeedback](https://developer.chrome.com/docs/extensions/develop/concepts/declare-permissions#declarativeNetRequestFeedback) permission is present or tab-specific badge text was provided. */ export function getBadgeText( details: TabDetails, callback?: ( result: string, ) => void, ): void; /** * Sets the background color for the badge. */ export function setBadgeBackgroundColor( details: { /** * 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 | extensionTypes.ColorArray, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, ): Promise<void>; /** * Sets the background color for the badge. */ export function setBadgeBackgroundColor( details: { /** * 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 | extensionTypes.ColorArray, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, callback?: () => void, ): void; /** * Gets the background color of the action. */ export function getBadgeBackgroundColor( details: TabDetails, ): Promise<extensionTypes.ColorArray>; /** * Gets the background color of the action. */ export function getBadgeBackgroundColor( details: TabDetails, callback?: ( result: extensionTypes.ColorArray, ) => void, ): void; /** * Sets the text color for the badge. * * @since Chrome 110 */ export function setBadgeTextColor( details: { /** * 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`. Not setting this value will cause a color to be automatically chosen that will contrast with the badge's background color so the text will be visible. Colors with alpha values equivalent to 0 will not be set and will return an error. */ color: string | extensionTypes.ColorArray, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, ): Promise<void>; /** * Sets the text color for the badge. * * @since Chrome 110 */ export function setBadgeTextColor( details: { /** * 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`. Not setting this value will cause a color to be automatically chosen that will contrast with the badge's background color so the text will be visible. Colors with alpha values equivalent to 0 will not be set and will return an error. */ color: string | extensionTypes.ColorArray, /** * Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number, }, callback?: () => void, ): void; /** * Gets the text color of the action. * * @since Chrome 110 */ export function getBadgeTextColor( details: TabDetails, ): Promise<extensionTypes.ColorArray>; /** * Gets the text color of the action. * * @since Chrome 110 */ export function getBadgeTextColor( details: TabDetails, callback?: ( result: extensionTypes.ColorArray, ) => void, ): void; /** * 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. */ export function enable( tabId?: number, ): Promise<void>; /** * 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. */ export function enable( tabId?: number, callback?: () => void, ): void; /** * Disables the action for a tab. * * @param tabId The ID of the tab for which you want to modify the action. */ export function disable( tabId?: number, ): Promise<void>; /** * Disables the action for a tab. * * @param tabId The ID of the tab for which you want to modify the action. */ export function disable( tabId?: number, callback?: () => 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. * * @param tabId The ID of the tab for which you want check enabled status. * @since Chrome 110 */ export function isEnabled( tabId?: number, ): Promise<boolean>; /** * 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. * * @param tabId The ID of the tab for which you want check enabled status. * @since Chrome 110 */ export function isEnabled( tabId?: number, /** * @param isEnabled True if the extension action is enabled. */ callback?: ( isEnabled: boolean, ) => void, ): void; /** * Returns the user-specified settings relating to an extension's action. * * @since Chrome 91 */ export function getUserSettings(): Promise<UserSettings>; /** * Returns the user-specified settings relating to an extension's action. * * @since Chrome 91 */ export function getUserSettings( callback?: ( userSettings: UserSettings, ) => void, ): void; /** * 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. * @since Chrome 127 */ export function openPopup( options?: OpenPopupOptions, ): Promise<void>; /** * 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. * @since Chrome 127 */ export function openPopup( options?: OpenPopupOptions, callback?: () => void, ): void; } /** * Use the `chrome.alarms` API to schedule code to run periodically or at a specified time in the future. * * @chrome-permission alarms */ export namespace alarms { export interface Alarm { /** * Name of this alarm. */ name: string; /** * 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; /** * If not null, the alarm is a repeating alarm and will fire again in `periodInMinutes` minutes. */ periodInMinutes?: number; } export interface AlarmCreateInfo { /** * Time at which the alarm should fire, in milliseconds past the epoch (e.g. `Date.now() + n`). */ when?: number; /** * Length of time in minutes after which the `onAlarm` event should fire. */ delayInMinutes?: number; /** * 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; } /** * Fired when an alarm has elapsed. Useful for event pages. */ export const onAlarm: 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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds. * * 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. * * @chrome-returns-extra since Chrome 111 * @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`. * @returns Promise that resolves when the alarm has been created. */ export function create( name: string, alarmInfo: AlarmCreateInfo, ): Promise<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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds. * * 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. * * @chrome-returns-extra since Chrome 111 * @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`. * @returns Promise that resolves when the alarm has been created. */ export function create( alarmInfo: AlarmCreateInfo, ): Promise<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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds. * * 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, /** * @since Chrome 111 */ 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 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds. * * 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, /** * @since Chrome 111 */ callback?: () => void, ): void; /** * Retrieves details about the specified alarm. * * @chrome-returns-extra since Chrome 91 * @param name The name of the alarm to get. Defaults to the empty string. */ export function get( name?: string, ): Promise<Alarm | undefined>; /** * Retrieves details about the specified alarm. * * @param name The name of the alarm to get. Defaults to the empty string. */ export function get( name?: string, callback?: ( alarm?: Alarm, ) => void, ): void; /** * Gets an array of all the alarms. * * @chrome-returns-extra since Chrome 91 */ export function getAll(): Promise<Alarm[]>; /** * Gets an array of all the alarms. */ export function getAll( callback?: ( alarms: Alarm[], ) => void, ): void; /** * Clears the alarm with the given name. * * @chrome-returns-extra since Chrome 91 * @param name The name of the alarm to clear. Defaults to the empty string. */ export function clear( name?: string, ): Promise<boolean>; /** * Clears the alarm with the given name. * * @param name The name of the alarm to clear. Defaults to the empty string. */ export function clear( name?: string, callback?: ( wasCleared: boolean, ) => void, ): void; /** * Clears all alarms. * * @chrome-returns-extra since Chrome 91 */ export function clearAll(): Promise<boolean>; /** * Clears all alarms. */ export function clearAll( callback?: ( wasCleared: boolean, ) => void, ): void; } /** * 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. * * @since Chrome 59 * @chrome-permission audio * @chrome-platform chromeos */ export namespace audio { /** * Type of stream an audio device provides. */ export type StreamType = "INPUT" | "OUTPUT"; /** * Available audio device types. */ export type DeviceType = "HEADPHONE" | "MIC" | "USB" | "BLUETOOTH" | "HDMI" | "INTERNAL_SPEAKER" | "INTERNAL_MIC" | "FRONT_MIC" | "REAR_MIC" | "KEYBOARD_MIC" | "HOTWORD" | "LINEOUT" | "POST_MIX_LOOPBACK" | "POST_DSP_LOOPBACK" | "ALSA_LOOPBACK" | "OTHER"; export interface AudioDeviceInfo { /** * The unique identifier of the audio device. */ id: string; /** * Stream type associated with this device. */ streamType: StreamType; /** * Type of the device. */ deviceType: DeviceType; /** * The user-friendly name (e.g. "USB Microphone"). */ displayName: string; /** * Device name. */ deviceName: string; /** * True if this is the current active device. */ isActive: boolean; /** * The sound level of the device, volume for output, gain for input. */ level: number; /** * The stable/persisted device id string when available. */ stableDeviceId?: string; } export interface DeviceFilter { /** * If set, only audio devices whose stream type is included in this list will satisfy the filter. */ streamTypes?: StreamType[]; /** * If set, only audio devices whose active state matches this value will satisfy the filter. */ isActive?: boolean; } export interface DeviceProperties { /** * The audio device's desired sound level. Defaults to the device's current sound level. * * If used with audio input device, represents audio device gain. * * If used with audio output device, represents audio device volume. */ level?: number; } export interface DeviceIdLists { /** * List of input devices specified by their ID. * * To indicate input devices should be unaffected, leave this property unset. */ input?: string[]; /** * List of output devices specified by their ID. * * To indicate output devices should be unaffected, leave this property unset. */ output?: string[]; } export interface MuteChangedEvent { /** * The type of the stream for which the mute value changed. The updated mute value applies to all devices with this stream type. */ streamType: StreamType; /** * Whether or not the stream is now muted. */ isMuted: boolean; } export interface LevelChangedEvent { /** * ID of device whose sound level has changed. */ deviceId: string; /** * The device's new sound level. */ level: number; } /** * Fired when sound level changes for an active audio device. */ export const onLevelChanged: 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: events.Event<( event: MuteChangedEvent, ) => void>; /** * Fired when audio devices change, either new devices being added, or existing devices being removed. */ export const onDeviceListChanged: events.Event<( devices: AudioDeviceInfo[], ) => void>; /** * Gets a list of audio devices filtered based on `filter`. * * @chrome-returns-extra since Chrome 116 * @param filter Device properties by which to filter the list of returned audio devices. If the filter is not set or set to `{}`, returned device list will contain all available audio devices. * @returns Reports the requested list of audio devices. */ export function getDevices( filter?: DeviceFilter, ): Promise<AudioDeviceInfo[]>; /** * Gets a list of audio devices filtered based on `filter`. * * @param filter Device properties by which to filter the list of returned audio devices. If the filter is not set or set to `{}`, returned device list will contain all available audio devices. */ export function getDevices( filter?: DeviceFilter, callback?: ( devices: AudioDeviceInfo[], ) => void, ): void; /** * Sets lists of active input and/or output devices. * * @chrome-returns-extra since Chrome 116 * @param ids Specifies IDs of devices that should be active. If either the input or output list is not set, devices in that category are unaffected. It is an error to pass in a non-existent device ID. */ export function setActiveDevices( ids: DeviceIdLists, ): Promise<void>; /** * Sets lists of active input and/or output devices. * * @param ids Specifies IDs of devices that should be active. If either the input or output list is not set, devices in that category are unaffected. It is an error to pass in a non-existent device ID. */ export function setActiveDevices( ids: DeviceIdLists, callback?: () => void, ): void; /** * Sets the properties for the input or output device. * * @chrome-returns-extra since Chrome 116 */ export function setProperties( id: string, properties: DeviceProperties, ): Promise<void>; /** * Sets the properties for the input or output device. */ export function setProperties( id: string, properties: DeviceProperties, callback?: () => void, ): void; /** * Gets the system-wide mute state for the specified stream type. * * @chrome-returns-extra since Chrome 116 * @param streamType Stream type for which mute state should be fetched. * @returns Promise that resolves with a boolean indicating whether mute is set or not for specified stream type. */ export function getMute( streamType: StreamType, ): Promise<boolean>; /** * Gets the system-wide mute state for the specified stream type. * * @param streamType Stream type for which mute state should be fetched. */ export function getMute( streamType: StreamType, callback?: ( value: boolean, ) => void, ): void; /** * Sets mute state for a stream type. The mute state will apply to all audio devices with the specified audio stream type. * * @chrome-returns-extra since Chrome 116 * @param streamType Stream type for which mute state should be set. * @param isMuted New mute value. */ export function setMute( streamType: StreamType, isMuted: boolean, ): Promise<void>; /** * Sets mute state for a stream type. The mute state will apply to all audio devices with the specified audio stream type. * * @param streamType Stream type for which mute state should be set. * @param isMuted New mute value. */ export function setMute( streamType: StreamType, isMuted: boolean, callback?: () => void, ): void; } /** * Use the `chrome.bookmarks` API to create, organize, and otherwise manipulate bookmarks. Also see [Override Pages](https://developer.chrome.com/docs/extensions/override), which you can use to create a custom Bookmark Manager page. * * @chrome-permission bookmarks */ export namespace bookmarks { /** * Indicates the type of folder. * * @chrome-enum "bookmarks-bar" The folder whose contents is displayed at the top of the browser window. * @chrome-enum "other" Bookmarks which are displayed in the full list of bookmarks on all platforms. * @chrome-enum "mobile" Bookmarks generally available on the user's mobile devices, but modifiable by extension or in the bookmarks manager. * @chrome-enum "managed" A top-level folder that may be present if the system administrator or the custodian of a supervised user has configured bookmarks. * @since Chrome 134 */ export type FolderType = "bookmarks-bar" | "other" | "mobile" | "managed"; /** * Indicates the reason why this node is unmodifiable. The `managed` value indicates that this node was configured by the system administrator. Omitted if the node can be modified by the user and the extension (default). * * @since Chrome 44 */ export type BookmarkTreeNodeUnmodifiable = "managed"; /** * A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder. */ export interface BookmarkTreeNode { /** * The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted. */ id: string; /** * The `id` of the parent folder. Omitted for the root node. */ parentId?: string; /** * The 0-based position of this node within its parent folder. */ index?: number; /** * The URL navigated to when a user clicks the bookmark. Omitted for folders. */ url?: string; /** * The text displayed for the node. */ title: string; /** * When this node was created, in milliseconds since the epoch (`new Date(dateAdded)`). */ dateAdded?: number; /** * When this node was last opened, in milliseconds since the epoch. Not set for folders. * * @since Chrome 114 */ dateLastUsed?: number; /** * When the contents of this folder last changed, in milliseconds since the epoch. */ dateGroupModified?: number; /** * If present, this is a folder that is added by the browser and that cannot be modified by the user or the extension. Child nodes may be modified, if this node does not have the `unmodifiable` property set. Omitted if the node can be modified by the user and the extension (default). * * There may be zero, one or multiple nodes of each folder type. A folder may be added or removed by the browser, but not via the extensions API. * * @since Chrome 134 */ folderType?: FolderType; /** * 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; /** * Whether this node is synced with the user's remote account storage by the browser. This can be used to distinguish between account and local-only versions of the same {@link FolderType}. The value of this property may change for an existing node, for example as a result of user action. * * Note: this reflects whether the node is saved to the browser's built-in account provider. It is possible that a node could be synced via a third-party, even if this value is false. * * For managed nodes (nodes where `unmodifiable` is set to `true`), this property will always be `false`. * * @since Chrome 134 */ syncing: boolean; /** * An ordered list of children of this node. */ children?: BookmarkTreeNode[]; } /** * Object passed to the create() function. */ export interface CreateDetails { /** * Defaults to the Other Bookmarks folder. */ parentId?: string; index?: number; title?: string; url?: string; } /** * @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; /** * The `id` associated with the root level node. * * @since Pending */ export const ROOT_NODE_ID: "0"; /** * Fired when a bookmark or folder is created. */ export const onCreated: events.Event<( 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. */ export const onRemoved: events.Event<( id: string, removeInfo: { parentId: string, index: number, /** * @since Chrome 48 */ node: BookmarkTreeNode, }, ) => void>; /** * 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 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>; /** * 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 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<