You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-4Lines changed: 24 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,13 +187,26 @@ Userscripts Safari currently supports the following userscript metadata:
187
187
-`@noframes`
188
188
- this key takes no value
189
189
- prevents code from being injected into nested frames
190
+
-`@grant`
191
+
- Imperative controls which special [`APIs`](#api) (if any) your script uses, one on each `@grant` line, only those API methods will be provided.
192
+
- If no `@grant` values are provided, `none` will be assumed.
193
+
- If you specify `none` and something else, `none` takes precedence.
190
194
191
195
**All userscripts need at least 1 `@match` or `@include` to run!**
192
196
193
197
## API
194
198
195
199
Userscripts currently supports the following api methods. All methods are asynchronous unless otherwise noted. Users must `@grant` these methods in order to use them in a userscript. When using API methods, it's only possible to inject into the content script scope due to security concerns.
196
200
201
+
> [!NOTE]
202
+
>
203
+
> The following API description applies to the latest development branch, you may need to check the documentation for the corresponding version. Please switch to the version you want to check via `Branches` or `Tags` at the top.
204
+
>
205
+
> For example, for the v4.x.x version of the App Store:
For API type definitions, please refer to: [`types.d.ts`](https://github.com/userscriptsup/testscripts/blob/bfce18746cd6bcab0616727401fa7ab6ef4086ac/userscripts/types.d.ts)
209
+
197
210
-`GM.addStyle(css)`
198
211
-`css: String`
199
212
- returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), resolved if succeeds, rejected with error message if fails
@@ -258,8 +271,8 @@ Userscripts currently supports the following api methods. All methods are asynch
258
271
-`headers: Object` - optional
259
272
-`overrideMimeType: String` - optional
260
273
-`timeout: Int` - optional
261
-
-`binary: Bool` - optional
262
-
-`data: String` - optional
274
+
-`binary: Bool` - optional (Deprecated, use binary data objects such as `Blob`, `ArrayBuffer`, `TypedArray`, etc. instead.)
- refer to [`XMLHttpRequests`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest)
265
278
- event handlers:
@@ -281,10 +294,17 @@ Userscripts currently supports the following api methods. All methods are asynch
281
294
-`statusText`
282
295
-`timeout`
283
296
-`responseText` (when `responseType` is `text`)
297
+
- returns a custom [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) contains an additional property `abort`, resolved with the response object.
0 commit comments