Skip to content

Instantly share code, notes, and snippets.

@yko
Created May 5, 2023 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yko/9e76ee97e93fc060200f1b48a8e64a26 to your computer and use it in GitHub Desktop.
Save yko/9e76ee97e93fc060200f1b48a8e64a26 to your computer and use it in GitHub Desktop.
Extension demo: declarativeNetRequest.URLTransform.queryTransform.addOrReplaceParams
{
"description": "Showcasing declarativeNetRequest.URLTransform.queryTransform.addOrReplaceParams. Try 'https://www.example.com/search?q=test' and 'https://www.google.com/search?q=test'. With the extension installed, the url should receive the additional lr=-lang_en parameter",
"name": "URL Redirect",
"version": "0.1",
"manifest_version": 3,
"declarative_net_request" : {
"rule_resources" : [{
"id": "test_ruleset",
"enabled": true,
"path": "ruleset.json"
}]
},
"permissions": [
"activeTab",
"declarativeNetRequest",
"declarativeNetRequestFeedback",
"declarativeNetRequestWithHostAccess"
],
"host_permissions": ["*://example.net/*", "*://*.example.net/*", "*://example.com/*", "*://*.example.com/*", "*://*.google.com/*", "https://www.google.com/search?*", "*://*/*"]
}
[{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"transform": {
"queryTransform": {
"addOrReplaceParams": [{ "key": "lr", "value": "-lang_en" }]
}
}
}
},
"condition": {
"regexFilter": "^https://www.(example|google).com/search?",
"resourceTypes": ["main_frame", "script"]
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment