Source code

Revision control

Copy as Markdown

Other Tools

[
{
"namespace": "manifest",
"types": [
{
"$extend": "OptionalOnlyPermission",
"choices": [
{
"type": "string",
"enum": ["userScripts"]
}
]
},
{
"$extend": "WebExtensionManifest",
"properties": {
"user_scripts": {
"type": "object",
"max_manifest_version": 2,
"optional": true,
"properties": {
"api_script": {
"optional": true,
"$ref": "manifest.ExtensionURL"
}
},
"additionalProperties": { "$ref": "UnrecognizedProperty" }
}
}
}
]
},
{
"namespace": "userScripts",
"permissions": ["manifest:user_scripts", "userScripts"],
"types": [
{
"id": "UserScriptOptions",
"max_manifest_version": 2,
"type": "object",
"description": "Details of a user script",
"properties": {
"js": {
"type": "array",
"optional": false,
"description": "The list of JS files to inject",
"minItems": 1,
"items": { "$ref": "extensionTypes.ExtensionFileOrCode" }
},
"scriptMetadata": {
"description": "An opaque user script metadata value",
"$ref": "extensionTypes.PlainJSONValue",
"optional": true
},
"matches": {
"type": "array",
"optional": false,
"minItems": 1,
"items": { "$ref": "manifest.MatchPattern" }
},
"excludeMatches": {
"type": "array",
"optional": true,
"minItems": 1,
"items": { "$ref": "manifest.MatchPattern" }
},
"includeGlobs": {
"type": "array",
"optional": true,
"items": { "type": "string" }
},
"excludeGlobs": {
"type": "array",
"optional": true,
"items": { "type": "string" }
},
"allFrames": {
"type": "boolean",
"default": false,
"optional": true,
"description": "If allFrames is <code>true</code>, implies that the JavaScript should be injected into all frames of current page. By default, it's <code>false</code> and is only injected into the top frame."
},
"matchAboutBlank": {
"type": "boolean",
"default": false,
"optional": true,
"description": "If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is <code>false</code>."
},
"runAt": {
"$ref": "extensionTypes.RunAt",
"default": "document_idle",
"optional": true,
"description": "The soonest that the JavaScript will be injected into the tab. Defaults to \"document_idle\"."
},
"cookieStoreId": {
"choices": [
{
"type": "array",
"minItems": 1,
"items": { "type": "string" }
},
{
"type": "string"
}
],
"optional": true,
"description": "limit the set of matched tabs to those that belong to the given cookie store id"
}
}
},
{
"id": "RegisteredUserScript",
"min_manifest_version": 3,
"type": "object",
"description": "An object that represents a user script registered programmatically",
"properties": {
"id": {
"type": "string",
"optional": false,
"description": "The ID of the user script specified in the API call. This property must not start with a '_' as it's reserved as a prefix for generated script IDs."
},
"allFrames": {
"type": "boolean",
"optional": true,
"description": "If allFrames is <code>true</code>, implies that the JavaScript should be injected into all frames of current page. By default, it's <code>false</code> and is only injected into the top frame."
},
"js": {
"type": "array",
"optional": false,
"description": "The list of ScriptSource objects defining sources of scripts to be injected into matching pages.",
"items": { "$ref": "ScriptSource" }
},
"matches": {
"type": "array",
"optional": true,
"description": "At least one of matches or includeGlobs should be non-empty. The script runs in documents whose URL match either pattern.",
"items": { "$ref": "manifest.MatchPattern" }
},
"excludeMatches": {
"type": "array",
"optional": true,
"items": { "$ref": "manifest.MatchPattern" }
},
"includeGlobs": {
"type": "array",
"optional": true,
"description": "At least one of matches or includeGlobs should be non-empty. The script runs in documents whose URL match either pattern.",
"items": { "type": "string" }
},
"excludeGlobs": {
"type": "array",
"optional": true,
"items": { "type": "string" }
},
"runAt": {
"$ref": "extensionTypes.RunAt",
"optional": true,
"description": "The soonest that the JavaScript will be injected into the tab. Defaults to \"document_idle\"."
},
"world": {
"$ref": "ExecutionWorld",
"optional": true,
"description": "The JavaScript script for a script to execute within. Defaults to \"USER_SCRIPT\"."
},
"worldId": {
"type": "string",
"optional": true,
"description": "If specified, specifies a specific user script world ID to execute in. Only valid if `world` is omitted or is `USER_SCRIPT`. If `worldId` is omitted, the script will execute in the default user script world (\"\"). Values with leading underscores (`_`) are reserved. The maximum length is 256."
}
}
},
{
"id": "ExecutionWorld",
"min_manifest_version": 3,
"type": "string",
"enum": ["MAIN", "USER_SCRIPT"],
"description": "The JavaScript world for a script to execute within. <code>USER_SCRIPT</code> is the default execution environment of user scripts, <code>MAIN</code> is the web page's execution environment."
},
{
"id": "UserScriptFilter",
"min_manifest_version": 3,
"type": "object",
"description": "Optional filter to use with getScripts() and unregister().",
"properties": {
"ids": {
"type": "array",
"optional": true,
"items": { "type": "string" }
}
}
},
{
"id": "ScriptSource",
"min_manifest_version": 3,
"description": "Object with file xor code property. Equivalent to the ExtensionFileOrCode, except the file remains a relative URL.",
"choices": [
{
"type": "object",
"properties": {
"file": {
"type": "string",
"description": "The path of the JavaScript file to inject relative to the extension's root directory.",
"format": "unresolvedRelativeUrl"
}
}
},
{
"type": "object",
"properties": {
"code": {
"type": "string"
}
}
}
]
},
{
"id": "WorldProperties",
"min_manifest_version": 3,
"type": "object",
"description": "The configuration of a USER_SCRIPT world.",
"properties": {
"worldId": {
"type": "string",
"optional": true,
"default": "",
"description": "The identifier of the world. Values with leading underscores (`_`) are reserved. The maximum length is 256. Defaults to the default USER_SCRIPT world (\"\")."
},
"csp": {
"type": "string",
"optional": true,
"description": "The world's Content Security Policy. Defaults to the CSP of regular content scripts, which prohibits dynamic code execution such as eval."
},
"messaging": {
"type": "boolean",
"optional": true,
"default": false,
"description": "Whether the runtime.sendMessage and runtime.connect methods are exposed. Defaults to not exposing these messaging APIs."
}
}
}
],
"functions": [
{
"name": "register",
"max_manifest_version": 2,
"type": "function",
"description": "Register a user script programmatically given its $(ref:userScripts.UserScriptOptions), and resolves to an object with the unregister() function",
"async": "callback",
"parameters": [
{
"name": "userScriptOptions",
"$ref": "UserScriptOptions"
},
{
"name": "callback",
"type": "function",
"parameters": [
{
"name": "legacyRegisteredUserScript",
"type": "object",
"description": "An object that represents a user script registered programmatically",
"properties": {
"unregister": {
"type": "function",
"description": "Unregister a user script registered programmatically",
"async": true,
"parameters": []
}
}
}
]
}
]
},
{
"name": "register",
"min_manifest_version": 3,
"type": "function",
"description": "Registers one or more user scripts for this extension.",
"async": true,
"parameters": [
{
"name": "scripts",
"type": "array",
"items": { "$ref": "RegisteredUserScript" },
"description": "List of user scripts to be registered."
}
]
},
{
"name": "update",
"min_manifest_version": 3,
"type": "function",
"description": "Updates one or more user scripts for this extension.",
"async": true,
"parameters": [
{
"name": "scripts",
"type": "array",
"items": {
"type": "object",
"$import": "RegisteredUserScript",
"properties": {
"js": {
"type": "array",
"optional": true,
"items": { "$ref": "ScriptSource" }
}
}
},
"description": "List of user scripts to be updated."
}
]
},
{
"name": "unregister",
"min_manifest_version": 3,
"type": "function",
"description": "Unregisters all dynamically-registered user scripts for this extension.",
"async": true,
"parameters": [
{
"name": "filter",
"$ref": "UserScriptFilter",
"optional": true,
"description": "If specified, this method unregisters only the user scripts that match it."
}
]
},
{
"name": "getScripts",
"min_manifest_version": 3,
"type": "function",
"description": "Returns all dynamically-registered user scripts for this extension.",
"async": "callback",
"parameters": [
{
"name": "filter",
"$ref": "UserScriptFilter",
"optional": true,
"description": "If specified, this method returns only the user scripts that match it."
},
{
"name": "callback",
"type": "function",
"parameters": [
{
"name": "scripts",
"type": "array",
"items": { "$ref": "RegisteredUserScript" },
"description": "List of registered user scripts."
}
]
}
]
},
{
"name": "configureWorld",
"min_manifest_version": 3,
"type": "function",
"description": "Configures the environment for scripts running in a USER_SCRIPT world.",
"async": true,
"parameters": [
{
"name": "properties",
"$ref": "WorldProperties",
"description": "The desired configuration for a USER_SCRIPT world."
}
]
},
{
"name": "resetWorldConfiguration",
"min_manifest_version": 3,
"type": "function",
"description": "Resets the configuration for a given world. That world will fall back to the default world's configuration.",
"async": true,
"parameters": [
{
"name": "worldId",
"type": "string",
"optional": true,
"default": "",
"description": "The ID of the USER_SCRIPT world to reset. If omitted or empty, resets the default world's configuration."
}
]
},
{
"name": "getWorldConfigurations",
"min_manifest_version": 3,
"type": "function",
"description": "Returns all registered USER_SCRIPT world configurations.",
"async": "callback",
"parameters": [
{
"name": "callback",
"type": "function",
"parameters": [
{
"name": "configurations",
"type": "array",
"items": { "$ref": "WorldProperties" },
"description": "All configurations registered with configureWorld()."
}
]
}
]
}
]
}
]