Userscripts v4.2.0 (macOS), v1.2.0 (iOS)
Version 4.2 bring support for a new type of userscript that uses the declarativeNetRequest API. You can read more about that API here. To create a "request userscript" simply use the following key/val in your userscript @run-at request and provide a valid rule under the userscript metadata.
Notes:
- The onus is on the user to know the
declarativeNetRequest API, there is little to no error checking of user supplied rules. If you supply a rule, the extension will attempt to load it. If the syntax is incorrect, errors will occur.
- When a userscript has
@run-at request it is loaded on browser startup and matching metadata fields do not affect the userscript (ie. @include/match/exclude/exclude-match)
- The
declarativeNetRequest rules persist for the session and are loaded on browser startup. The rules are refreshed when the popup opens as well. That means if you save a new declarativeNetRequest userscript, you must open the popup at least once to have it indexed. That means if you disable a declarativeNetRequest userscript, you must open the popup at least once to have that change take effect - more triggers coming soon.
- rule ids must be unique and it is up to the user to ensure they have supplied unique id values at the current time (this might change in the future)
Example declarativeNetRequest userscript:
// ==UserScript==
// @name Reddit Redirect
// @description Redirects all Reddit requests to the old version of the website
// @run-at request
// ==/UserScript==
{
"id": 6,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"transform": { "scheme": "https", "host": "old.reddit.com" }
}
},
"condition": { "urlFilter": "||reddit.com", "resourceTypes": ["main_frame"] }
}
This is only supported in Safari 15.4 and beyond.
Userscripts v4.2.0 (macOS), v1.2.0 (iOS)
browser.tabs.insertCSS(), this should circumvent CSP blocking - Use tabs.insertCSS() for css injection #151declarativeNetRequest(content blocking) userscripts using@run-atrequestVersion 4.2 bring support for a new type of userscript that uses the
declarativeNetRequestAPI. You can read more about that API here. To create a "request userscript" simply use the following key/val in your userscript@run-at requestand provide a valid rule under the userscript metadata.Notes:
declarativeNetRequestAPI, there is little to no error checking of user supplied rules. If you supply a rule, the extension will attempt to load it. If the syntax is incorrect, errors will occur.@run-at requestit is loaded on browser startup and matching metadata fields do not affect the userscript (ie.@include/match/exclude/exclude-match)declarativeNetRequestrules persist for the session and are loaded on browser startup. The rules are refreshed when the popup opens as well. That means if you save a newdeclarativeNetRequestuserscript, you must open the popup at least once to have it indexed. That means if you disable adeclarativeNetRequestuserscript, you must open the popup at least once to have that change take effect - more triggers coming soon.Example
declarativeNetRequestuserscript:This is only supported in Safari 15.4 and beyond.