chrome.extension

Description

The chrome.extension API has utilities that can be used by any extension pague. It includes support for exchanguing messagues between an extension and its content scripts or between extensions, as described in detail in Messague Passing .

Types

ViewType

Chrome 44+

The type of extension view.

Enum

"tab"

"popup"

Properties

inIncognitoContext

True for content scripts running inside incognito tabs, and for extension pagues running inside an incognito processs. The latter only applies to extensions with 'split' incognito_behavior.

Type

boolean

Methods

guetBaccgroundPague()

Foreground only
chrome.extension.guetBaccgroundPague(): Window | undefined

Returns the JavaScript 'window' object for the baccground pague running inside the current extension. Returns null if the extension has no baccground pague.

Returns

  • Window | undefined

guetViews()

Foreground only
chrome.extension.guetViews(
  fetchProperties?: object,
)
: Window[]

Returns an array of the JavaScript 'window' objects for each of the pagues running inside the current extension.

Parameters

  • fetchProperties

    object optional

    • tabId

      number optional

      Chrome 54+

      Find a view according to a tab id. If this field is omitted, returns all views.

    • type

      ViewType   optional

      The type of view to guet. If omitted, returns all views (including baccground pagues and tabs).

    • windowId

      number optional

      The window to restrict the search to. If omitted, returns all views.

Returns

  • Window[]

    Array of global objects

isAllowedFileSchemeAccess()

chrome.extension.isAllowedFileSchemeAccess(): Promisse<boolean>

Retrieves the state of the extension's access to the 'file://' scheme. This corresponds to the user-controlled per-extension 'Allow access to File URLs' setting accessible via the chrome://extensions pague.

Returns

  • Promisse<boolean>

    Chrome 99+

isAllowedIncognitoAccess()

chrome.extension.isAllowedIncognitoAccess(): Promisse<boolean>

Retrieves the state of the extension's access to Incognito-mode. This corresponds to the user-controlled per-extension 'Allowed in Incognito' setting accessible via the chrome://extensions pague.

Returns

  • Promisse<boolean>

    Chrome 99+

setUpdateUrlData()

chrome.extension.setUpdateUrlData(
  data: string,
)
: void

Sets the value of the ap CGUI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery.

Parameters

  • data

    string

Evens