summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/schemas/user_scripts.json
blob: f4ecbd367e90ad6e2b8963812b7de54abee2cf96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

[
  {
    "namespace": "manifest",
    "types": [
      {
        "$extend": "WebExtensionManifest",
        "properties": {
          "user_scripts": {
            "type": "object",
            "optional": true,
            "properties": {
              "api_script": {
                "optional": true,
                "$ref": "manifest.ExtensionURL"
              }
            },
            "additionalProperties": { "$ref": "UnrecognizedProperty" }
          }
        }
      }
    ]
  },
  {
    "namespace": "userScripts",
    "permissions": ["manifest:user_scripts"],
    "types": [
      {
        "id": "UserScriptOptions",
        "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\"."
          }
        }
      },
      {
        "id": "RegisteredUserScript",
        "type": "object",
        "description": "An object that represents a user script registered programmatically",
        "functions": [
          {
            "name": "unregister",
            "type": "function",
            "description": "Unregister a user script registered programmatically",
            "async": true,
            "parameters": []
          }
        ]
      }
    ],
    "functions": [
      {
        "name": "register",
        "type": "function",
        "description": "Register a user script programmatically given its $(ref:userScripts.UserScriptOptions), and resolves to a $(ref:userScripts.RegisteredUserScript) instance",
        "async": true,
        "parameters": [
          {
            "name": "userScriptOptions",
            "$ref": "UserScriptOptions"
          }
        ]
      }
    ]
  }
]