How to obtain the system proxy settings from chrome extension?

134 views
Skip to first unread message

Karim Emara

unread,
Feb 18, 2017, 1:51:53 PM2/18/17
to Chromium-Extensions-Announce

I need to make a customized proxy settings for my chrome extension so that traffic to a specific domain goes through a proxy server while all other (user) traffic goes normally with the default system settings. According to the chrome API documentation, the only way is to use pac_script (correct me if I am wrong). Thus, the code will be something like this:

var config = {
mode: "pac_script",
pacScript: {
data: "function FindProxyForURL(url, host) {\n" +
" if (dnsDomainIs(host, 'mydomain.com') )\n" +
" return 'SOCKS5 10.0.0.1:1234';\n" +
" return 'DIRECT';\n" +
"}"
}};
chrome.proxy.settings.set({value: config, scope: 'regular'});
However, pac_script does not have the option to route traffic using system proxy settings (only 'DIRECT' which means it will skip the system settings). I thought to obtain the system proxy settings using chrome.proxy.settings.get, but this function returns an object where mode = system with no useful information.

Does anyone know how to obtain the system proxy settings from extension? Or has suggestions to handle the original problem?

Reply all
Reply to author
Forward
0 new messages