I am trying to build a chrome extension which can change proxy settings when the fire up the browser. I have followed the chrome extension documentation but still no success.
manifest.json
{
"manifest_version": 2,
"name": "Proxy",
"description": "Proxy on 127.0.0.1:8080",
"version": "1.1",
"background": {
"scripts":["background.js"]
},
"browser_action": {
"default_icon": "icon.png",
"popup":"popup.html"
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*",
"notifications",
"contextMenus",
"history",
"background",
"proxy"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
backround.js
chrome.windows.onCreated.addListener(function() {
var config = {
mode: "fixed_servers",
rules: {
proxyForHttp: {
scheme: "http",
host: "127.0.0.1",
port:"8080"
},
bypassList: ["foobar.com"]
}
};
chrome.proxy.settings.set(
{value: config, scope: 'regular'},
function() {});
});
The above code doesn't works...
Step1: To set proxy in Google Chrome Go to Option (Top-Right Side) > Click on Under the Hood Tab > Click on Change Proxy Settings and you can change Proxy from there.
Simply open toolbar popup and click on the desired category. There are five categories available to choose from. Moreover, badge icon color changes according to the chosen category. Once the proxy is set, a notification popup shows you the current state.
Change the line port:"8080"
to port:8080
and it'll work.
If via PAC script, on script code error, chrome.proxy.settings.set
handler still runs even as the proxy fails silently. This can be detected at chrome://net-internals/#events.
This page claims that console.log messages in your PAC script can be found in net log, but it doesn't seem to work.
I've been trying everything since yesterday, finally found my issue; I had to change
proxyForHttp:
--> singleProxy:
and
port:'8080'
--> port: 8080
It shouldn't be a problem with the background page. Your code is in the onCreated event on the window object. You are not guaranteed to have the extension loaded by the time the first window is created.
Simply remvove the event and have the code run, you should then have it run once when the extension is initialised.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With