title: Setting up proxy in Chrome by my extension
body: <p>I'm trying to make Chrome extension which turns on-off proxy in browser. I wrote some code in javascript using documentation about chrome extensions, and what is interesting, some times extension works right. </p>
  
  <p>Here is some code in Golang, which iterates through list of https proxy addresses, makes http requests to www.stackoverflow using this proxy addresses and if response status code is 2xx (because some of addresses are invalid, deprecated, unavailable, banned and etc), it marks proxy address correct and prints it. </p>
  
  <p>The second block of the code sets <code>chrome.proxy.settings</code> property with found 'good' proxy address. By now I'm just copy-pasting it by hands.</p>
  
  <p><strong>The question is:</strong> Why is Golang sorts out "bad" proxy address, gives me list of "good" proxies, but Chrome, when I trying to set any of this "good" proxies gives me <code>ERR_PROXY_CONNECTION_FAILED</code>?</p>
  
  <p><strong>EDIT</strong>: in <code>Go</code> add <code>User-Agent</code> header, in <code>JavaScript</code> add <code>scheme : https</code> field to <code>config</code> object for proxy. 
  Still not working.</p>
  
  <pre class="lang-golang prettyprint-override"><code>// checkProxy returns true if proxy adress a is valid and
  // response by http request with this proxy is ok (2xx)
  //185.132.179.108:1080
  //185.132.179.107:1080
  func checkProxy(a string) (string, bool) {
      proxyUrl, err := url.Parse("http://" + a)
      httpClient := &amp;http.Client{     
          Transport: &amp;http.Transport{
              Proxy: http.ProxyURL(proxyUrl),
          },
      }
      req, err := http.NewRequest("GET", "http://stackoverflow.com", nil)
      if err != nil {
          return "", false
      }
      req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36")
      response, err := httpClient.Do(req)
      if err != nil {
          return "", false
      }   
      if response.StatusCode &lt;= 200 &amp;&amp; response.StatusCode &gt;= 299 {
          return "", false
      } else {
          return a, true
      }
  }
  </code></pre>
  
  <pre><code>
  function setProxySettings(iip, pport) {
      var config = {
          mode: "fixed_servers",
          rules: {
              //https://www.proxy-list.download/HTTPS
              // host: "107.191.63.8",
              // port: 32482
              singleProxy: {
                  scheme: "https",
                  host: iip,
                  port: parseInt(pport)
              },
          }
      };
      chrome.proxy.settings.set({
              value: config,
              scope: 'regular'
          },
          function () {});
  }
  </code></pre>