在chrome扩展中设置代理

时间:2017-10-18 21:22:10

标签: google-chrome google-chrome-extension proxy

我想允许在我的chrome扩展程序上使用代理,但无论用户输入什么,都会出现ERR_NO_SUPPORTED_PROXIES。 这是我的代理连接代码:

var prxobj = JSON.parse(localStorage['proxy']);
ip = prxobj['proxyip'];
port = parseInt(prxobj['proxyport']);
var obj = {
    mode: 'fixed_servers',
    rules: {
        singleProxy: {
            scheme: 'https',
            host: ip,
            port: port
        },
        bypassList: ['']
    }
};
chrome['proxy']['settings']['set']({
    value: obj,
    scope: 'regular'
}, function() {})

代理身份验证代码:

chrome['webRequest']['onAuthRequired']['addListener'](function(first, second) {
    var objx= JSON.parse(localStorage['proxy']);
    first({
        authCredentials: {
            username: objx['proxyusername'],
            password: objx['proxypassword']
        }
    })
}, {urls: ['<all_urls>'] }, ['asyncBlocking']);

0 个答案:

没有答案