【发布时间】:2021-05-05 12:37:23
【问题描述】:
如何强制浏览器为特定域(例如 google.com 或 facebook.com)使用代理服务器
用例是如果 google.com 或 facebook.com 被阻止,我想通过代理连接强制连接到这些站点,而其他所有内容都直接访问 Internet。
我的代码是:
backgroud.js
function FindProxyForURL(url, host) {
// use proxy for specific domains
if (shExpMatch(host, "*.google.com|*.facebook.com"))
return "PROXY yourproxy:8080";
// by default use no proxy
return "DIRECT";
}
menifest.json
{
"background": {
"scripts": [ "background.js" ]
},
"description": "This chrome extension use for proxy.",
"author": "no one",
"manifest_version": 2,
"minimum_chrome_version": "26.0",
"name": "proxy",
"permissions": [ "<all_urls>", "webRequest", "webRequestBlocking", "storage", "tabs", "proxy", "cookies", "management", "http://*/*", "https://*/*" ],
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "0.10"
}
【问题讨论】:
标签: javascript google-chrome-extension proxy extension-methods