UserScript#
Added in version 2.6.
- class UserScript(**kwargs)#
A JavaScript snippet which can be injected in loaded pages.
Constructors#
- class UserScript
- classmethod new(source: str, injected_frames: UserContentInjectedFrames, injection_time: UserScriptInjectionTime, allow_list: list[str] | None = None, block_list: list[str] | None = None) UserScript#
Creates a new user script.
Scripts can be applied to some URIs only by passing non-null values for
allow_listorblock_list. Passing aNoneallow_list implies that all URIs are on the allow_list. The script 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 script.
injected_frames – A
UserContentInjectedFramesvalueinjection_time – A
UserScriptInjectionTimevalueallow_list – An allow_list of URI patterns or
Noneblock_list – A block_list of URI patterns or
None
- classmethod new_for_world(source: str, injected_frames: UserContentInjectedFrames, injection_time: UserScriptInjectionTime, world_name: str, allow_list: list[str] | None = None, block_list: list[str] | None = None) UserScript#
Creates a new user script 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 script.
injected_frames – A
UserContentInjectedFramesvalueinjection_time – A
UserScriptInjectionTimevalueworld_name – the name of a
WebKitScriptWorldallow_list – An allow_list of URI patterns or
Noneblock_list – A block_list of URI patterns or
None