新的 StackOverflow 主页很烦人。我想我应该快速设置浏览器以重定向到
/questions
子页面。我为它写了剧本。但是,我注意到,当我直接指定 StackOverflow 主页时,它会错误地将每个请求重定向到 /questions
子页面(例如,个人资料、具体问题等)。
[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"url": "https://stackoverflow.com/questions"
}
},
"condition": {
"urlFilter": "https://stackoverflow.com",
"resourceTypes": ["main_frame"]
}
}
]
测试
https://stackoverflow.com | redirected (OK) |
https://stackoverflow.com/another | redirected (FAIL) | expected: not redirect
如何在 Manifest v3 中制定仅重定向
https://stackoverflow.com
?
你应该能够使用
[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"url": "https://stackoverflow.com/questions"
}
},
"condition": {
"urlFilter": "https://stackoverflow.com/|",
"resourceTypes": ["main_frame"]
}
}
]
因为
|
指示其后不能有更多字符。
见 https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest#url_filter_syntax