Skip to content

Latest commit

 

History

History
145 lines (94 loc) · 3.61 KB

File metadata and controls

145 lines (94 loc) · 3.61 KB

windows

Documentation: Chrome Windows API

A promise-based wrapper for the Chrome windows API to create, query, update, and manage browser windows.

Methods

Events


createWindow

createWindow(createData?: chrome.windows.CreateData): Promise<chrome.windows.Window | undefined>

Creates a new browser window with the specified options. Resolves with the created Window or undefined.

getWindow

getWindow(windowId: number, queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window>

Retrieves details for the window with the given ID.

getAllWindows

getAllWindows(queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window[]>

Retrieves all windows, optionally filtered by the provided query options.

getCurrentWindow

getCurrentWindow(queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window>

Gets the current window (the window that contains the code calling this method).

getLastFocusedWindow

getLastFocusedWindow(queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window>

Gets the most recently focused window.

removeWindow

removeWindow(windowId: number): Promise<void>

Removes (closes) the window with the given ID.

updateWindow

updateWindow(windowId: number, updateInfo: chrome.windows.UpdateInfo): Promise<chrome.windows.Window>

Updates the properties of the specified window and resolves with the updated Window.

onWindowBoundsChanged

onWindowBoundsChanged(
  callback: (windowId: number) => void
): () => void

Adds a listener that fires when the window's bounds (size or position) change. Returns an unsubscribe function.

onWindowCreated

onWindowCreated(
  callback: (window: chrome.windows.Window) => void,
  filter?: { windowTypes: chrome.windows.WindowType[] } // WindowEventFilter
): () => void

Adds a listener that fires when a new window is created. Optionally filter by window types. Returns an unsubscribe function.

onWindowFocusChanged

onWindowFocusChanged(
  callback: (windowId: number) => void,
  filter?: { windowTypes: chrome.windows.WindowType[] } // WindowEventFilter
): () => void

Adds a listener that fires when the focused window changes. Optionally filter by window types. Returns an unsubscribe function.

onWindowRemoved

onWindowRemoved(
  callback: (windowId: number) => void,
  filter?: { windowTypes: chrome.windows.WindowType[] } // WindowEventFilter
): () => void

Adds a listener that fires when a window is removed (closed). Optionally filter by window types. Returns an unsubscribe function.