Proxy in Chrome Extension

六眼飞鱼酱① 提交于 2019-12-14 03:16:13

问题


I want to create a Chrome Extension wich changes the Proxy Settings of Chrome. Everything works correct but the problem is that i have to authenticate with username and password with the proxy.

Any idea how to do this ?

          var config = {
    mode: "fixed_servers",
    rules: {
      proxyForHttp: {
  scheme: "https",
  host: "209.164.75.72",
  port: 9786,
  username:'myusernmae',
  password:'proxypassword'

      },
      bypassList: ["foobar.com"]
    }
  };
  chrome.proxy.settings.set(
      {value: config, scope: 'regular'},
      function() {
    console.debug(chrome);    

          });

The above code doesnt work as seen here there are no valid documentation how to authenticate the proxy https://developer.chrome.com/extensions/proxy


回答1:


You can listen for chrome.webRequest.onAuthRequired to provide the credentials when details.isProxy is true. You'll need the webRequest and webRequestBlocking permissions.

That's how Chrome-proxy-helper works.



来源:https://stackoverflow.com/questions/26187895/proxy-in-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!