The new StackOverflow homepage is annoying. I thought I’d quickly set up the browser to redirect to the /questions subpage instead. I wrote the script for it. However, I’ve noticed that when I specify the StackOverflow homepage directly, it keeps redirecting every request to the /questions subpage (e.g., profile, specific question, etc.) incorrectly.
[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"url": "https://stackoverflow.com/questions"
}
},
"condition": {
"urlFilter": "https://stackoverflow.com",
"resourceTypes": ["main_frame"]
}
}
]
Tests
https://stackoverflow.com | redirected (OK) |
https://stackoverflow.com/another | redirected (FAIL) | expected: not redirect
How can I formulate in Manifest v3 to redirect only https://stackoverflow.com?
>Solution :
You should be able to use
[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"url": "https://stackoverflow.com/questions"
}
},
"condition": {
"urlFilter": "https://stackoverflow.com/|",
"resourceTypes": ["main_frame"]
}
}
]
since a | dictates that no more characters may come after it.
See: chrome.declarativeNetRequest – URL filter syntax – Chrome Extension API