UserStyleSheet

Added in version 2.6.

class UserStyleSheet(**kwargs)

A CSS style sheet which can be injected in loaded pages.

Constructors

class UserStyleSheet
classmethod new(source: str, injected_frames: UserContentInjectedFrames, level: UserStyleLevel, allow_list: Sequence[str] | None = None, block_list: Sequence[str] | None = None) UserStyleSheet

Creates a new user style sheet.

Style sheets can be applied to some URIs only by passing non-null values for allow_list or block_list. Passing a None allow_list implies that all URIs are on the allow_list. The style sheet is applied if an URI matches the allow_list and not the block_list. URI patterns must be of the form [protocol]://[host]/[path], where the host and path components can contain the wildcard character (*) to represent zero or more other characters.

Added in version 2.6.

Parameters:
  • source – Source code of the user style sheet.

  • injected_frames – A UserContentInjectedFrames value

  • level – A UserStyleLevel

  • allow_list – An allow_list of URI patterns or None

  • block_list – A block_list of URI patterns or None

classmethod new_for_world(source: str, injected_frames: UserContentInjectedFrames, level: UserStyleLevel, world_name: str, allow_list: Sequence[str] | None = None, block_list: Sequence[str] | None = None) UserStyleSheet

Creates a new user style sheet for script world.

Creates a new user style sheet for script world with name world_name. See new() for a full description.

Added in version 2.22.

Parameters:
  • source – Source code of the user style sheet.

  • injected_frames – A UserContentInjectedFrames value

  • level – A UserStyleLevel

  • world_name – the name of a WebKitScriptWorld

  • allow_list – An allow_list of URI patterns or None

  • block_list – A block_list of URI patterns or None