首页 > 解决方案 > 使用 declarativeNetRequest 进行动态重定向

问题描述

我想使用 declarativeNetRequest 将域中的所有 URL 重定向到以发起方 URL 作为编码参数的 URL,例如

http://www.google.com --> http://www.newsite.com?url=http%3A%2F%2Fwww.google.com
http://www.google.com?param1=true --> http://www.newsite.com?url=http%3A%2F%2Fwww.google.com%3Fparam1%3Dtrue

就像是...

  {
    "id": 1,
    "priority": 1,
    "action": {
      "type": "redirect",
      "redirect": {
        "url": `http://www.newsite.com?url=${encodeURIComponent(url)}`
      }
    }
  }

这可能吗?如果没有,还有其他方法可以实现这一目标吗?

标签: google-chromegoogle-chrome-extensionchrome-extension-manifest-v3

解决方案


推荐阅读