@types/chrome
Version:
TypeScript definitions for chrome
959 lines (855 loc) • 784 kB
TypeScript
/// <reference types="filesystem" />
/// <reference path="./har-format/index.d.ts" />
/// <reference path="./chrome-cast/index.d.ts" />
////////////////////
// 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 {
/** @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. */
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;
/** 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 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 | undefined;
}
export interface PopupDetails {
/** Optional. 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 {
/** 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: number]: string } | undefined;
/** 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}' */
imageData?: ImageData | { [index: number]: ImageData } | undefined;
}
export interface OpenPopupOptions {
/** Optional. 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. */
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;
}
/**
* @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.
*/
export function disable(tabId?: number): Promise<void>;
/**
* @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;
/**
* @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.
*/
export function enable(tabId?: number): Promise<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.
* @param callback
*/
export function enable(callback: () => void): void;
export function enable(tabId: number, 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).
*/
export function getBadgeBackgroundColor(details: TabDetails): Promise<ColorArray>;
/**
* @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;
/**
* @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).
*/
export function getBadgeText(details: TabDetails): Promise<string>;
/**
* @since Chrome 110
* Gets the text color of the action.
*/
export function getBadgeTextColor(details: TabDetails, callback: (result: ColorArray) => void): void;
/**
* @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<ColorArray>;
/**
* @since Chrome 88
* Gets the html document set as the popup for this action.
*/
export function getPopup(details: TabDetails, callback: (result: string) => 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).
*/
export function getPopup(details: TabDetails): Promise<string>;
/**
* @since Chrome 88
* Gets the title of the action.
*/
export function getTitle(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).
*/
export function getTitle(details: TabDetails): Promise<string>;
/**
* @since Chrome 91
* Returns the user-specified settings relating to an extension's action.
*/
export function getUserSettings(callback: (userSettings: UserSettings) => void): void;
/**
* @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<UserSettings>;
/**
* @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;
/**
* @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<boolean>;
/**
* @since Chrome 99
* Opens the extension's popup.
* @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.
*/
export function openPopup(options?: OpenPopupOptions): Promise<void>;
/**
* @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;
/**
* @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.
*/
export function setBadgeBackgroundColor(details: BadgeColorDetails): Promise<void>;
/**
* @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.
*/
export function setBadgeText(details: BadgeTextDetails): Promise<void>;
/**
* @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.
*/
export function setBadgeTextColor(details: BadgeColorDetails): Promise<void>;
/**
* @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.
*/
export function setIcon(details: TabIconDetails): Promise<void>;
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.
*/
export function setPopup(details: PopupDetails): Promise<void>;
/**
* @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.
*/
export function setTitle(details: TitleDetails): Promise<void>;
/**
* @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: chrome.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: chrome.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>;
/**
* 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>;
/** 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>;
}
////////////////////
// Browser
////////////////////
/**
* 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
*/
export namespace browser {
export interface Options {
/** The URL to navigate to when the new tab is initially opened. */
url: string;
}
/**
* 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,
* a new one is opened prior to creating the new tab.
* @param options Configures how the tab should be opened.
* @param callback Called when the tab was successfully
* 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,
* a new one is opened prior to creating the new tab.
* @since Chrome 42
* @param options Configures how the tab should be opened.
*/
export function openTab(options: Options): 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