WebExtension#
Added in version 2.52.
Superclasses: Object
Implemented Interfaces: Initable
Represents a WebExtension.
A WebExtension object encapsulates a web extension’s
resources that are defined by a `manifest.json file <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json>`__.
This class handles the reading and parsing of the manifest file along with the supporting resources like icons and localizations.
Constructors#
- class WebExtension
- classmethod new(extension_path: str) WebExtension | None#
Creates a new WebKitWebExtension from a folder containing the extension contents. The folder must contain a
manifest.jsonfile. If the manifest is invalid or missing, an error will be returned.Added in version 2.52.
- Parameters:
extension_path – A string pointing to the folder containing the extension manifest and resources
Methods#
- class WebExtension
- get_action_icon(width: float, height: float) Icon | None#
Returns the extension’s default action icon image for the specified size. This icon serves as a default and should be used to represent the extension in contexts like action sheets or toolbars prior to the extension being loaded into an extension context. Once the extension is loaded, use the
actionForTab:API to get the tab-specific icon. The returned image will be the best match for the specified size that is available in the extension’s action icon set. If no matching icon is available, the method will fall back to the extension’s icon.Added in version 2.52.
- Parameters:
width – The width to use when looking up the icon.
height – The height to use when looking up the icon.
- get_all_requested_match_patterns() list[WebExtensionMatchPattern]#
Get the set of websites that the extension requires access to for injected content and for receiving messages from websites.
Added in version 2.52.
- get_display_action_label() str | None#
Get the localized display action label for the extension.
This label serves as a default and should be used to represent the extension in contexts like action sheets or toolbars prior to the extension being loaded into an extension context. Once the extension is loaded, use the
actionForTab:API to get the tab-specific label.Added in version 2.52.
- get_display_description() str | None#
Get the localized display description for the extension.
Added in version 2.52.
- get_display_short_name() str | None#
Get the localized short name for the extension.
Added in version 2.52.
- get_display_version() str | None#
Get the localized display version for the extension.
Added in version 2.52.
- get_has_background_content() bool#
Get whether the extension has background content that can run when needed.
Added in version 2.52.
- get_has_commands() bool#
Get whether the extension includes commands that users can invoke.
These commands should be accessible via keyboard shortcuts, menu items, or other user interface elements provided by the app. The list of commands can be accessed via
commandson an extension context, and invoked viaperformCommand:.Added in version 2.52.
- get_has_content_modification_rules() bool#
Get whether the extension includes rules used for content modification or blocking.
Added in version 2.52.
- get_has_injected_content() bool#
Get whether the extension has script or stylesheet content that can be injected into webpages.
Once the extension is loaded, use the
hasInjectedContentproperty on an extension context, as the injectable content can change after the extension is loaded.Added in version 2.52.
- get_has_options_page() bool#
Get whether the extension has an options page.
The app should provide access to this page through a user interface element, which can be accessed via
optionsPageURLon an extension context.Added in version 2.52.
- get_has_override_new_tab_page() bool#
Get whether the extension provides an alternative to the default new tab page.
The app should prompt the user for permission to use the extension’s new tab page as the default, which can be accessed via
overrideNewTabPageURLon an extension context.Added in version 2.52.
- get_has_persistent_background_content() bool#
Get whether the extension has background content that stays in memory as long as the extension is loaded.
Added in version 2.52.
- get_icon(width: float, height: float) Icon | None#
Returns the extension’s icon image for the specified size. This icon should represent the extension in settings or other areas that show the extension. The returned image will be the best match for the specified size that is available in the extension’s icon set. If no matching icon can be found, the method will return
None.Added in version 2.52.
- Parameters:
width – The width to use when looking up the icon.
height – The height to use when looking up the icon.
- get_manifest_version() float#
Get the parsed manifest version, or
0if there is no version specified in the manifest.A
UNSUPPORTED_MANIFEST_VERSIONerror will be reported if the manifest version isn’t specified.Added in version 2.52.
- get_optional_permission_match_patterns() list[WebExtensionMatchPattern]#
Get the set of websites that the extension may need access to for optional functionality. These match patterns can be requested by the extension at a later time.
Added in version 2.52.
- get_optional_permissions() list[str] | None#
Get the set of permissions that the extension may need for optional functionality. These permissions can be requested by the extension at a later time.
Added in version 2.52.
- get_path() str#
Get the path pointing to the folder containing the extension manifest and resources
Added in version 2.52.
- get_requested_permission_match_patterns() list[WebExtensionMatchPattern]#
Get the set of websites that the extension requires access to for its base functionality.
Added in version 2.52.
Properties#
- class WebExtension
- props.default_locale: str#
The default locale for the
WebExtension. Seeget_default_locale()for more details.Added in version 2.52.
- props.display_action_label: str#
The localized extension action label of the
WebExtension. Seeget_display_action_label()for more details.Added in version 2.52.
- props.display_description: str#
The localized description of the
WebExtension. Seeget_display_description()for more details.Added in version 2.52.
- props.display_name: str#
The localized name of the
WebExtension. Seeget_display_name()for more details.Added in version 2.52.
- props.display_short_name: str#
The localized short name of the
WebExtension. Seeget_display_short_name()for more details.Added in version 2.52.
- props.display_version: str#
The localized display version of the
WebExtension. Seeget_display_version()for more details.Added in version 2.52.
- props.has_background_content: bool#
Whether the
WebExtensionhas background content that can run when needed. Seeget_has_background_content()for more details.Added in version 2.52.
- props.has_commands: bool#
Whether the
WebExtensionincludes commands that users can invoke. Seeget_has_commands()for more details.Added in version 2.52.
- props.has_content_modification_rules: bool#
Whether the
WebExtensionincludes rules used for content modification or blocking. See webkit_web_extension_get_content_modification_rules() for more details.Added in version 2.52.
- props.has_injected_content: bool#
Whether the
WebExtensionhas script or stylesheet content that can be injected into webpages. Seeget_has_injected_content()for more details.Added in version 2.52.
- props.has_options_page: bool#
Whether the
WebExtensionhas an options page. Seeget_has_options_page()for more details.Added in version 2.52.
- props.has_override_new_tab_page: bool#
Whether the
WebExtensionprovides an alternative to the default new tab page. Seeget_has_override_new_tab_page()for more details.Added in version 2.52.
- props.has_persistent_background_content: bool#
Whether the
WebExtensionhas background content that stays in memory as long as the extension is loaded. Seeget_has_persistent_background_content()for more details.Added in version 2.52.
- props.manifest_version: str#
The parsed manifest version of the
WebExtension. Seeget_manifest_version()for more details.Added in version 2.52.
- props.optional_permissions: list[str]#
The set of permissions that the
WebExtensionmay need for optional functionality. Seeget_optional_permissions()for more details.Added in version 2.52.
- props.path: str#
A string pointing to the folder containing the extension manifest and resources. See
get_path()for more details.Added in version 2.52.
- props.requested_permissions: list[str]#
The set of permissions that the
WebExtensionrequires for its base functionality. Seeget_requested_permissions()for more details.Added in version 2.52.
- props.version: str#
The version of the
WebExtension. Seeget_version()for more details.Added in version 2.52.