userScripts.RegisteredUserScript

表示已注册用户脚本的对象。由 userScripts.getScripts() 返回,并用作 userScripts.register()userScripts.update() 的输入。

类型

此类型的值是一个包含以下属性的对象

allFrames 可选

boolean。如果 allFramestrue,则脚本将被注入到页面所有帧中。默认情况下,它为 false,脚本仅注入到顶层帧。

id

string。用户脚本的 ID。此属性不能以 "_" 开头,因为 "_" 是为生成的脚本 ID 保留的前缀。

js 可选,用于 userScripts.update() 调用;对于 userScripts.register() 调用则是必需的。

array of userScripts.ScriptSource。要注入到匹配页面的脚本。

matches 可选

array of string。脚本要运行的页面的 匹配模式。在 userScripts.register() 调用中必须指定 matchesincludeGlobs

excludeMatches 可选

array of string。脚本不得运行的页面的 匹配模式

includeGlobs 可选

string。脚本要运行的页面的 Glob 模式。在 userScripts.register() 调用中必须指定 matchesincludeGlobs

excludeGlobs 可选

string。脚本不得运行的页面的 Glob 模式

runAt 可选

extensionTypes.RunAt。脚本注入到标签的最早时间。默认为 "document_idle"

world 可选

userScripts.ExecutionWorld。用于运行脚本的执行环境。默认为 "USER_SCRIPT"

worldId 可选

string。脚本执行的用户脚本世界的 ID。仅当 worldUSER_SCRIPT 或被省略时有效。如果省略 worldId,脚本将在默认的 USER_SCRIPT 世界("")中执行。以 "_" 开头的值是保留的。最大长度为 256 个字符。一个世界可以被多个脚本用作其执行环境。要配置世界的行为,请在第一个脚本执行于该世界之前,将该世界的 worldId 传递给 userScripts.configureWorld

浏览器兼容性