Documentation: Chrome Windows API
A promise-based wrapper for the Chrome windows API to create, query, update, and manage browser windows.
- createWindow(createData?)
- getWindow(windowId, queryOptions?)
- getAllWindows(queryOptions?)
- getCurrentWindow(queryOptions?)
- getLastFocusedWindow(queryOptions?)
- removeWindow(windowId)
- updateWindow(windowId, updateInfo)
- onWindowBoundsChanged(callback)
- onWindowCreated(callback, filter?)
- onWindowFocusChanged(callback, filter?)
- onWindowRemoved(callback, filter?)
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(windowId: number, queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window>
Retrieves details for the window with the given ID.
getAllWindows(queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window[]>
Retrieves all windows, optionally filtered by the provided query options.
getCurrentWindow(queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window>
Gets the current window (the window that contains the code calling this method).
getLastFocusedWindow(queryOptions?: chrome.windows.QueryOptions): Promise<chrome.windows.Window>
Gets the most recently focused window.
removeWindow(windowId: number): Promise<void>
Removes (closes) the window with the given ID.
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(
callback: (windowId: number) => void
): () => void
Adds a listener that fires when the window's bounds (size or position) change. Returns an unsubscribe function.
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(
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(
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.