UserScripts.UserScriptOptions
UserScriptOptions 对象表示要注册的内容脚本。它的语法与 browser.contentScripts.register 支持的 contentScript 选项类似。不同之处在于
- 它不支持 CSS 属性(使用 browser.contentScripts.register 动态注册/注销样式表)
- 它支持一个可选的 scriptMetadata 属性(作为普通 JSON 对象,其中包含与已注册的 userScripts 关联的一些元数据属性)
UserScriptOptions 对象具有以下属性
allFrames可选-
与
content_scripts键中的all_frames相同。 excludeGlobs可选-
与
content_scripts键中的exclude_globs相同。 excludeMatches可选-
与
content_scripts键中的exclude_matches相同。 includeGlobs可选-
与
content_scripts键中的include_globs相同。 js可选-
对象数组。每个对象都有一个名为
file的属性,该属性是扩展的 manifest.json 中的 URL,并指向要注册的 JavaScript 文件,或者一个名为code的属性,该属性是要注册的一些 JavaScript 代码。 matchAboutBlank可选-
与
content_scripts键中的match_about_blank相同。 matches-
与
content_scripts键中的matches相同。 runAt可选-
与
content_scripts键中的run_at相同。 scriptMetadata可选-
用户脚本元数据值
它具有与 browser.contentScripts.register 支持的 contentScript 选项类似的语法。