Class UserScript

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class UserScript extends ProxyInstance
A JavaScript snippet which can be injected in loaded pages.
Since:
2.6
  • Constructor Details

    • UserScript

      public UserScript(MemorySegment address)
      Create a UserScript proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • UserScript

      public UserScript(String source, UserContentInjectedFrames injectedFrames, UserScriptInjectionTime injectionTime, @Nullable String @Nullable [] allowList, @Nullable String @Nullable [] blockList)

      Creates a new user script.

      Scripts can be applied to some URIs only by passing non-null values for allowList or blockList. Passing a null allow_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.

      Parameters:
      source - Source code of the user script.
      injectedFrames - A WebKitUserContentInjectedFrames value
      injectionTime - A WebKitUserScriptInjectionTime value
      allowList - An allow_list of URI patterns or null
      blockList - A block_list of URI patterns or null
      Since:
      2.6
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the UserScript class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • forWorld

      public static UserScript forWorld(String source, UserContentInjectedFrames injectedFrames, UserScriptInjectionTime injectionTime, String worldName, @Nullable String @Nullable [] allowList, @Nullable String @Nullable [] blockList)

      Creates a new user script for script world with name worldName.

      See webkit_user_script_new() for a full description.

      Parameters:
      source - Source code of the user script.
      injectedFrames - A WebKitUserContentInjectedFrames value
      injectionTime - A WebKitUserScriptInjectionTime value
      worldName - the name of a WebKitScriptWorld
      allowList - An allow_list of URI patterns or null
      blockList - A block_list of URI patterns or null
      Returns:
      A new WebKitUserScript
      Since:
      2.22
    • ref

      public UserScript ref()

      Atomically increments the reference count of this UserScript by one.

      This function is MT-safe and may be called from any thread.

      Returns:
      The passed WebKitUserScript
      Since:
      2.6
    • unref

      public void unref()

      Atomically decrements the reference count of this UserScript by one.

      If the reference count drops to 0, all memory allocated by WebKitUserScript is released. This function is MT-safe and may be called from any thread.

      Since:
      2.6