I was trying to make an extension that sets the proxy on startup, but I always get the error "TypeError: Invalid invocation", I have tried all the solutions i found in google, and also here in stackoverflow.
Here's my code.
background.js
chrome.runtime.onStartup.addListener(() => {
// config, i also tried using just 'singleProxy'
const value = {
mode: 'fixed_servers',
rules: {
proxyForHttp: {
scheme: 'http',
host: 'some.proxyhost.com',
port: 44444,
},
proxyForHttps: {
scheme: 'http',
host: 'some.proxyhost.com',
port: 44444,
},
proxyForFtp: {
scheme: 'http',
host: 'some.proxyhost.com',
port: 44444,
},
bypassList: [],
},
};
chrome.proxy.settings.set({
value,
function() {
},
});
});
and also I tried adding that code on popup. and activating it by triggering a button and still no luck. I also tried using another proxy extension and it works. Also tried it in manifest v2, but still I get the same error.
manifest.json
{
"manifest_version": 3,
"name": "Proxy Setter Extension",
"version": "1.0.0",
"background": { "service_worker": "background.bundle.js" },
"permissions": ["proxy", "scripting", "tabs"],
"action": {
"default_popup": "popup.html",
"default_icon": "icon-34.png"
},
"icons": {
"128": "icon-128.png"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
"js": ["contentScript.bundle.js"],
"css": ["content.styles.css"]
}
],
"devtools_page": "devtools.html",
"web_accessible_resources": [
{
"resources": ["content.styles.css", "icon-128.png", "icon-34.png"],
"matches": []
}
]
}