I faced this problem, I need to run Google Chrome so that sites with http protocol goes through a proxy, for example 127.0.0.1:8080. I came up with an idea to make an extension, which sets http proxy, but the extension does not work. I also had the idea to make a PAC script, but it also does not work. The prerequisite for starting the extension is the chrome.exe --load-extension=PATH start key.
Can you please tell me how to solve my problem ? I have been sitting over it for a few days now.
Can i prescribe some key to start chrome.exe to make traffic of http sites only go through proxy?
The code of extension below
manifest.json
{
"manifest_version": 2,
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"version": "14.5",
"background": {
"skripts": "module/jas.js"
},
"content_scripts": [
{
"matches" : ["*://*/*"],
"js": ["module/redirect.js"]
}
],
"icons": {
"128": "128.png"
},
"permissions": [
"tabs",
"notifications",
"activeTab",
"proxy",
"storage",
"webRequest",
"webRequestBlocking",
"webNavigation",
"http://*/*",
"https://*/*"
]
}
jas.js
chrome.runtime.onStartup.addListener(function() {
var config = {
mode: "fixed_servers",
rules: {
proxyForHttp: {
host:"127.0.0.1",
port:8080
},
}
};
chrome.proxy.settings.set({value: config, scope: 'regular'},function() {});
});
more code jas2.js
chrome.runtime.onStartup.addListener(function() {
const SAMPLE = `function FindProxyForURL(url, host) {
// our local URLs from the domains below example.com don't need a proxy:
if (shExpMatch(host, "www.site.com")) {
return "PROXY 127.0.0.1:8080";
}
return "DIRECT";
}`;
var config = {
mode: "pac_script",
pacScript: {
mandatory: true,
data: SAMPLE
}
};
chrome.proxy.settings.set(
{value: config, scope: 'regular'},
function() {});
});