:right-sidebar: True WebExtension =================================================================== .. currentmodule:: gi.repository.WebKit .. versionadded:: 2.52 .. class:: WebExtension(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.Initable` Represents a `WebExtension `__\. A :obj:`~gi.repository.WebKit.WebExtension` object encapsulates a web extension’s resources that are defined by a ```manifest.json`` file `__\. This class handles the reading and parsing of the manifest file along with the supporting resources like icons and localizations. Constructors ------------ .. rst-class:: interim-class .. class:: WebExtension :no-index: .. classmethod:: new(extension_path: str) -> ~gi.repository.WebKit.WebExtension | None Creates a new WebKitWebExtension from a folder containing the extension contents. The folder must contain a ``manifest.json`` file. If the manifest is invalid or missing, an error will be returned. .. versionadded:: 2.52 :param extension_path: A string pointing to the folder containing the extension manifest and resources Methods ------- .. rst-class:: interim-class .. class:: WebExtension :no-index: .. method:: get_action_icon(width: float, height: float) -> ~gi.repository.Gio.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. .. versionadded:: 2.52 :param width: The width to use when looking up the icon. :param height: The height to use when looking up the icon. .. method:: get_all_requested_match_patterns() -> list[~gi.repository.WebKit.WebExtensionMatchPattern] Get the set of websites that the extension requires access to for injected content and for receiving messages from websites. .. versionadded:: 2.52 .. method:: get_default_locale() -> str | None Get the default locale for the extension. .. versionadded:: 2.52 .. method:: 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. .. versionadded:: 2.52 .. method:: get_display_description() -> str | None Get the localized display description for the extension. .. versionadded:: 2.52 .. method:: get_display_name() -> str | None Get the localized name for the extension. .. versionadded:: 2.52 .. method:: get_display_short_name() -> str | None Get the localized short name for the extension. .. versionadded:: 2.52 .. method:: get_display_version() -> str | None Get the localized display version for the extension. .. versionadded:: 2.52 .. method:: get_has_background_content() -> bool Get whether the extension has background content that can run when needed. .. versionadded:: 2.52 .. method:: 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 ``commands`` on an extension context, and invoked via ``performCommand:``\. .. versionadded:: 2.52 .. method:: get_has_content_modification_rules() -> bool Get whether the extension includes rules used for content modification or blocking. .. versionadded:: 2.52 .. method:: 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 ``hasInjectedContent`` property on an extension context, as the injectable content can change after the extension is loaded. .. versionadded:: 2.52 .. method:: 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 ``optionsPageURL`` on an extension context. .. versionadded:: 2.52 .. method:: 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 ``overrideNewTabPageURL`` on an extension context. .. versionadded:: 2.52 .. method:: get_has_persistent_background_content() -> bool Get whether the extension has background content that stays in memory as long as the extension is loaded. .. versionadded:: 2.52 .. method:: get_icon(width: float, height: float) -> ~gi.repository.Gio.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 :const:`None`. .. versionadded:: 2.52 :param width: The width to use when looking up the icon. :param height: The height to use when looking up the icon. .. method:: get_manifest_version() -> float Get the parsed manifest version, or ``0`` if there is no version specified in the manifest. A :obj:`~gi.repository.WebKit.WebExtensionError.UNSUPPORTED_MANIFEST_VERSION` error will be reported if the manifest version isn't specified. .. versionadded:: 2.52 .. method:: get_optional_permission_match_patterns() -> list[~gi.repository.WebKit.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. .. versionadded:: 2.52 .. method:: 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. .. versionadded:: 2.52 .. method:: get_path() -> str Get the path pointing to the folder containing the extension manifest and resources .. versionadded:: 2.52 .. method:: get_requested_permission_match_patterns() -> list[~gi.repository.WebKit.WebExtensionMatchPattern] Get the set of websites that the extension requires access to for its base functionality. .. versionadded:: 2.52 .. method:: get_requested_permissions() -> list[str] | None Get the set of permissions that the extension requires for its base functionality. .. versionadded:: 2.52 .. method:: get_version() -> str | None Get the version for the extension. .. versionadded:: 2.52 .. method:: supports_manifest_version(manifest_version: float) -> bool Checks if a manifest version is supported by the extension. .. versionadded:: 2.52 :param manifest_version: the version number to check Properties ---------- .. rst-class:: interim-class .. class:: WebExtension :no-index: .. attribute:: props.default_locale :type: str The default locale for the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_default_locale` for more details. .. versionadded:: 2.52 .. attribute:: props.display_action_label :type: str The localized extension action label of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_display_action_label` for more details. .. versionadded:: 2.52 .. attribute:: props.display_description :type: str The localized description of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_display_description` for more details. .. versionadded:: 2.52 .. attribute:: props.display_name :type: str The localized name of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_display_name` for more details. .. versionadded:: 2.52 .. attribute:: props.display_short_name :type: str The localized short name of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_display_short_name` for more details. .. versionadded:: 2.52 .. attribute:: props.display_version :type: str The localized display version of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_display_version` for more details. .. versionadded:: 2.52 .. attribute:: props.has_background_content :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` has background content that can run when needed. See :func:`~gi.repository.WebKit.WebExtension.get_has_background_content` for more details. .. versionadded:: 2.52 .. attribute:: props.has_commands :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` includes commands that users can invoke. See :func:`~gi.repository.WebKit.WebExtension.get_has_commands` for more details. .. versionadded:: 2.52 .. attribute:: props.has_content_modification_rules :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` includes rules used for content modification or blocking. See webkit_web_extension_get_content_modification_rules() for more details. .. versionadded:: 2.52 .. attribute:: props.has_injected_content :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` has script or stylesheet content that can be injected into webpages. See :func:`~gi.repository.WebKit.WebExtension.get_has_injected_content` for more details. .. versionadded:: 2.52 .. attribute:: props.has_options_page :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` has an options page. See :func:`~gi.repository.WebKit.WebExtension.get_has_options_page` for more details. .. versionadded:: 2.52 .. attribute:: props.has_override_new_tab_page :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` provides an alternative to the default new tab page. See :func:`~gi.repository.WebKit.WebExtension.get_has_override_new_tab_page` for more details. .. versionadded:: 2.52 .. attribute:: props.has_persistent_background_content :type: bool Whether the :obj:`~gi.repository.WebKit.WebExtension` has background content that stays in memory as long as the extension is loaded. See :func:`~gi.repository.WebKit.WebExtension.get_has_persistent_background_content` for more details. .. versionadded:: 2.52 .. attribute:: props.manifest_version :type: str The parsed manifest version of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_manifest_version` for more details. .. versionadded:: 2.52 .. attribute:: props.optional_permissions :type: list[str] The set of permissions that the :obj:`~gi.repository.WebKit.WebExtension` may need for optional functionality. See :func:`~gi.repository.WebKit.WebExtension.get_optional_permissions` for more details. .. versionadded:: 2.52 .. attribute:: props.path :type: str A string pointing to the folder containing the extension manifest and resources. See :func:`~gi.repository.WebKit.WebExtension.get_path` for more details. .. versionadded:: 2.52 .. attribute:: props.requested_permissions :type: list[str] The set of permissions that the :obj:`~gi.repository.WebKit.WebExtension` requires for its base functionality. See :func:`~gi.repository.WebKit.WebExtension.get_requested_permissions` for more details. .. versionadded:: 2.52 .. attribute:: props.version :type: str The version of the :obj:`~gi.repository.WebKit.WebExtension`\. See :func:`~gi.repository.WebKit.WebExtension.get_version` for more details. .. versionadded:: 2.52