UNPKG

@types/chrome

Version:
938 lines (838 loc) 755 kB
/// <reference types="filesystem" /> /// <reference path="./har-format/index.d.ts" /> /// <reference path="./chrome-cast/index.d.ts" /> // Helpers type SetRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; type SetPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; //////////////////// // Global object //////////////////// interface Window { chrome: typeof chrome; } declare namespace chrome { //////////////////// // Accessibility Features //////////////////// /** * 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: 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; /** * 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: chrome.types.ChromeSetting<boolean>; } //////////////////// // Action //////////////////// /** * 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 { 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`. */ color: string | ColorArray; /** 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. 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; } export type ColorArray = [number, number, number, number]; export interface TitleDetails { /** 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 | undefined; } export interface PopupDetails { /** 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. */ popup: string; } export interface TabIconDetails { /** 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; /** Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */ tabId?: number | undefined; /** 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 { /** 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 { /** The ID of the tab to query state for. If no tab is specified, the non-tab-specific state is returned. */ tabId?: number | undefined; } /** * 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; } /** * Disables the action for a tab. * @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<void>; export function disable(callback: () => void): void; export function disable(tabId: number | undefined, callback: () => 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. * * Can return its result via Promise. */ export function enable(tabId?: number): Promise<void>; export function enable(callback: () => void): void; export function enable(tabId: number | undefined, callback: () => void): void; /** * Gets the background color of the action. * * Can return its result via Promise. */ export function getBadgeBackgroundColor(details: TabDetails): Promise<ColorArray>; export function getBadgeBackgroundColor(details: TabDetails, callback: (result: ColorArray) => void): void; /** * 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<string>; export function getBadgeText(details: TabDetails, callback: (result: string) => void): void; /** * Gets the text color of the action. * * Can return its result via Promise. * @since Chrome 110 */ export function getBadgeTextColor(details: TabDetails): Promise<ColorArray>; export function getBadgeTextColor(details: TabDetails, callback: (result: ColorArray) => void): void; /** * Gets the html document set as the popup for this action. * * Can return its result via Promise. */ export function getPopup(details: TabDetails): Promise<string>; export function getPopup(details: TabDetails, callback: (result: string) => void): void; /** * Gets the title of the action. * * Can return its result via Promise. */ export function getTitle(details: TabDetails): Promise<string>; export function getTitle(details: TabDetails, callback: (result: string) => void): void; /** * Returns the user-specified settings relating to an extension's action. * * Can return its result via Promise. * @since Chrome 91 */ export function getUserSettings(): Promise<UserSettings>; 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 */ export function isEnabled(tabId?: number): Promise<boolean>; export function isEnabled(callback: (isEnabled: boolean) => void): void; export function isEnabled(tabId: number | undefined, callback: (isEnabled: boolean) => 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. * * Can return its result via Promise. * @since Chrome 127 */ export function openPopup(options?: OpenPopupOptions): Promise<void>; export function openPopup(callback: () => void): void; export function openPopup(options: OpenPopupOptions | undefined, callback: () => void): void; /** * Sets the background color for the badge. * * Can return its result via Promise. */ export function setBadgeBackgroundColor(details: BadgeColorDetails): Promise<void>; export function setBadgeBackgroundColor(details: BadgeColorDetails, callback: () => void): void; /** * Sets the badge text for the action. The badge is displayed on top of the icon. * * Can return its result via Promise. */ export function setBadgeText(details: BadgeTextDetails): Promise<void>; export function setBadgeText(details: BadgeTextDetails, callback: () => void): void; /** * Sets the text color for the badge. * * Can return its result via Promise. * @since Chrome 110 */ export function setBadgeTextColor(details: BadgeColorDetails): Promise<void>; export function setBadgeTextColor(details: BadgeColorDetails, callback: () => 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. * * Can return its result via Promise. */ export function setIcon(details: TabIconDetails): Promise<void>; export function setIcon(details: TabIconDetails, callback: () => void): void; /** * Sets the html document to be opened as a popup when the user clicks on the action's icon. * * Can return its result via Promise. */ export function setPopup(details: PopupDetails): Promise<void>; export function setPopup(details: PopupDetails, callback: () => void): void; /** * Sets the title of the action. This shows up in the tooltip. * * Can return its result via Promise. */ export function setTitle(details: TitleDetails): Promise<void>; 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: 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: events.Event<(change: UserSettingsChange) => void>; } //////////////////// // Alarms //////////////////// /** * 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<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. * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only). */ 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 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; /** * Gets an array of all the alarms. */ export function getAll(callback: (alarms: Alarm[]) => void): void; /** * Gets an array of all the alarms. * @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only). */ export function getAll(): Promise<Alarm[]>; /** * Clears all alarms. * function(boolean wasCleared) {...}; * @return The `clearAll` method provides its result via callback or returned as a `Promise` (MV3 only). */ export function clearAll(): Promise<boolean>; /** * Clears all alarms. */ export function clearAll(callback: (wasCleared: boolean) => void): void; /** * Clears the alarm with the given name. * @param name The name of the alarm to clear. Defaults to the empty string. * @return The `clear` method provides its result via callback or returned as a `Promise` (MV3 only). */ 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(callback: (wasCleared: boolean) => void): void; export function clear(name: string, callback: (wasCleared: boolean) => void): void; /** * Clears the alarm without a name. */ export function clear(callback: (wasCleared: boolean) => void): void; /** * Clears the alarm without a name. * @return The `clear` method provides its result via callback or returned as a `Promise` (MV3 only). */ export function clear(): Promise<void>; /** * Retrieves details about the specified alarm. */ export function get(callback: (alarm?: Alarm) => void): void; /** * Retrieves details about the specified alarm. * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only). */ export function get(): 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; /** * Retrieves details about the specified alarm. * @param name The name of the alarm to get. Defaults to the empty string. * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only). */ export function get(name: string): Promise<Alarm | undefined>; /** Fired when an alarm has elapsed. Useful for event pages. */ export var onAlarm: AlarmEvent; } //////////////////// // Audio //////////////////// /** * 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 * @since Chrome 59 */ export namespace audio { export interface AudioDeviceInfo { /** Device name */ deviceName: string; /** Type of the device */ deviceType: DeviceType; /** The user-friendly name (e.g. "USB Microphone"). */ displayName: string; /** The unique identifier of the audio device. */ id: 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; /** Stream type associated with this device. */ streamType: StreamType; } export interface DeviceFilter { /** If set, only audio devices whose active state matches this value will satisfy the filter. */ isActive?: boolean; /** If set, only audio devices whose stream type is included in this list will satisfy the filter. */ streamTypes?: StreamType[]; } 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 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; } /** Available audio device types. */ export enum DeviceType { ALSA_LOOPBACK = "ALSA_LOOPBACK", BLUETOOTH = "BLUETOOTH", FRONT_MIC = "FRONT_MIC", HDMI = "HDMI", HEADPHONE = "HEADPHONE", HOTWORD = "HOTWORD", INTERNAL_MIC = "INTERNAL_MIC", INTERNAL_SPEAKER = "INTERNAL_SPEAKER", KEYBOARD_MIC = "KEYBOARD_MIC", LINEOUT = "LINEOUT", MIC = "MIC", OTHER = "OTHER", POST_DSP_LOOPBACK = "POST_DSP_LOOPBACK", POST_MIX_LOOPBACK = "POST_MIX_LOOPBACK", REAR_MIC = "REAR_MIC", USB = "USB", } export interface LevelChangedEvent { /** ID of device whose sound level has changed. */ deviceId: string; /** The device's new sound level. */ level: number; } export interface MuteChangedEvent { /** Whether or not the stream is now muted. */ isMuted: boolean; /** 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; } /** Type of stream an audio device provides. */ export enum StreamType { INPUT = "INPUT", OUTPUT = "OUTPUT", } /** * Gets a list of audio devices filtered based on filter. * Can return its result via Promise in Manifest V3 or later since Chrome 116. */ export function getDevices(filter?: DeviceFilter): Promise<AudioDeviceInfo[]>; 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<boolean>; 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<void>; 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<void>; 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<void>; 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: chrome.events.Event<(devices: AudioDeviceInfo[]) => void>; /** * Fired when sound level changes for an active audio device. */ 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: chrome.events.Event<(event: MuteChangedEvent) => void>; } //////////////////// // Bookmarks //////////////////// /** * 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" */ export namespace bookmarks { /** A node (either a bookmark or a folder) in the bookmark tree. Child nodes are ordered within their parent folder. */ export interface BookmarkTreeNode { /** An ordered list of children of this node. */ children?: BookmarkTreeNode[]; /** When this node was created, in milliseconds since the epoch (`new Date(dateAdded)`). */ dateAdded?: number; /** When the contents of this folder last changed, in milliseconds since the epoch. */ dateGroupModified?: number; /** * When this node was last opened, in milliseconds since the epoch. Not set for folders. * @since Chrome 114 */ dateLastUsed?: 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}`; /** 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 0-based position of this node within its parent folder. */ index?: number; /** The `id` of the parent folder. Omitted for the root node. */ parentId?: string; /** * 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; /** The text displayed for the node. */ 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; } /** * 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 enum BookmarkTreeNodeUnmodifiable { MANAGED = "managed", } /** Object passed to the create() function. */ export interface CreateDetails { index?: number; /** Defaults to the Other Bookmarks folder. */ parentId?: string; title?: string; url?: string; } /** * 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", /** Bookmarks which are displayed in the full list of bookmarks on all platforms. */ OTHER = "other", /** 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", } /** @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. * * Can return its result via Promise since Chrome 90. */ export function create(bookmark: CreateDetails): Promise<BookmarkTreeNode>; 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 * * Can return its result via Promise since Chrome 90. */ export function get(idOrIdList: string | [string, ...string[]]): Promise<BookmarkTreeNode[]>; export function get( idOrIdList: string | [string, ...string[]], callback: (results: BookmarkTreeNode[]) => void, ): void; /** * Retrieves the children of the specified BookmarkTreeNode id. * * Can return its result via Promise since Chrome Chrome 90 */ export function getChildren(id: string): Promise<BookmarkTreeNode[]>; export function getChildren(id: string, callback: (results: BookmarkTreeNode[]) => void): void; /** * Retrieves the recently added bookmarks. * @param numberOfItems The maximum number of items to return. * * Can return its result via Promise since Chrome Chrome 90 */ export function getRecent(numberOfItems: number): Promise<BookmarkTreeNode[]>; 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. * * Can return its result via Promise since Chrome Chrome 90 */ export function getSubTree(id: string): Promise<BookmarkTreeNode[]>; export function getSubTree(id: string, callback: (results: BookmarkTreeNode[]) => void): void; /** * Retrieves the entire Bookmarks hierarchy. * * Can return its result via Promise since Chrome Chrome 90 */ export function getTree(): Promise<BookmarkTreeNode[]>; export function getTree(callback: (results: BookmarkTreeNode[]) => void): void; interface MoveDestination { parentId?: string; index?: number; } /** * Moves the specified BookmarkTreeNode to the provided location. * * Can return its result via Promise since Chrome Chrome 90 */ export function move(id: string, destination: MoveDestination): Promise<BookmarkTreeNode>; export function move( id: string, destination: MoveDestination, callback: (result: BookmarkTreeNode) => void, ): void; /** * Removes a bookmark or an empty bookmark folder. * * Can return its result via Promise since Chrome Chrome 90 */ export function remove(id: string): Promise<void>; export function remove(id: string, callback: () => void): void; /** * Recursively removes a bookmark folder. * * Can return its result via Promise since Chrome Chrome 90 */ export function removeTree(id: string): Promise<void>; 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.*/ query?: string; /** The URL of the bookmark; matches verbatim. Note that folders have no URL. */ url?: string; /** The title of the bookmark; matches verbatim. */ title?: string; } /** * Searches for BookmarkTreeNodes matching the given query. Queries specified with an object produce BookmarkTreeNodes matching all specified properties. * @param query Either a string of words and quoted phrases that are matched against bookmark URLs and titles, or an object. If an object, the properties `query`, `url`, and `title` may be specified and bookmarks matching all specified properties will be produced. * * Can return its result via Promise since Chrome Chrome 90 */ export function search(query: string | SearchQuery): Promise<BookmarkTreeNode[]>; export function search(query: string | SearchQuery, callback: (results: BookmarkTreeNode[]) => void): void; interface UpdateChanges { title?: string; url?: string; } /** * Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged. **Note:** Currently, only 'title' and 'url' are supported. * * Can return its result via Promise since Chrome Chrome 90 */ export function update(id: string, changes: UpdateChanges): Promise<BookmarkTreeNode>; 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.*/ 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. */ 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 >; /** 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 >; } //////////////////// // 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. * * Manifest: "browser_action" * * MV2 only */ export namespace browserAction { 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. */ 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. */ tabId?: number | undefined; } export type ColorArray = [number, number, number, number]; 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. */ 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. */ 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. Initial