Skip to content

Latest commit

 

History

History
92 lines (60 loc) · 2.65 KB

extension.md

File metadata and controls

92 lines (60 loc) · 2.65 KB

extension

Documentation: Chrome Extension API

A promise-based wrapper for the Chrome extension API.

Methods


isAvailableExtension

isAvailableExtension(method?: ApiMethodName<typeof chrome.extension>): boolean

The optional method is a native function name, for example isAvailableExtension("getViews"). Import the public ApiMethodName type from @addon-core/browser for your own typed helpers. This checks callable presence without invoking the method; permissions and argument support still require handling.

Returns true when the extension namespace is present on the API selected by browser() in the current context. Returns false if the namespace or WebExtension environment is absent, or if accessing it throws. The check is synchronous, does not log, and reads the current API on every call without caching. Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable. Neither form verifies permissions, argument support, or a successful operation. See method availability.

import {isAvailableExtension} from "@addon-core/browser";

if (isAvailableExtension()) {
    // The namespace is present; handle operation-specific failures when using it.
}

getBackgroundPage

getBackgroundPage(): Window | null

Returns the window object of the extension's background page, or null if no background page exists.

getViews

getViews(properties?: chrome.extension.FetchProperties): Window[]

Retrieves all active extension views (e.g., background, popup, options), optionally filtered by the specified properties.

isAllowedFileSchemeAccess

isAllowedFileSchemeAccess(): Promise<boolean>

Checks if the extension has permission to access file system URLs (file://).

isAllowedIncognitoAccess

isAllowedIncognitoAccess(): Promise<boolean>

Determines whether the extension is allowed to operate in incognito mode.

setUpdateUrlData

setUpdateUrlData(data: string): void

Sets the data string to be sent as part of the extension's update check URL.