Browser extension proxy switching lets you change your browser's proxy in one click, or route certain sites through a proxy automatically while everything else goes direct, without touching your system settings. Under the hood, every proxy switcher uses the same small browser API. Understanding it helps you pick an extension safely, debug it when it misbehaves, or write your own in under 50 lines.
How Proxy Extensions Work
Chromium browsers expose chrome.proxy to extensions with the proxy permission. An extension can set one of a few modes:
- direct: no proxy.
- fixed_servers: send everything through one proxy, with an optional bypass list.
- pac_script: run a small JavaScript function on each URL that returns which proxy to use, or DIRECT.
- system: fall back to the operating system's settings.
Firefox has a similar proxy API with a per-request listener. Either way, the browser applies the setting to its own traffic only, not other apps.
Authentication is separate. The proxy API has no credential field, so extensions answer the proxy's 407 challenge with the webRequest onAuthRequired event, the same technique used in the Selenium proxy guide.
Why Rules Beat One-Click Switching
Turning a proxy on for the whole browser sends everything through it: your email, video, software updates, background tabs. With per-GB billing, that's expensive and unnecessary. Rule-based switching with a PAC script routes only the sites you care about. A typical rule set:
- Sites you're checking geo-results on: through a proxy in that country.
- Your own admin panels and work tools: direct.
- Everything else: direct.
Build a Minimal Proxy Switcher (Manifest V3)
Make a folder with two files. manifest.json:
{
"manifest_version": 3,
"name": "Simple Proxy Rules",
"version": "1.0",
"permissions": ["proxy", "webRequest", "webRequestAuthProvider", "storage"],
"host_permissions": ["<all_urls>"],
"background": { "service_worker": "background.js" }
}background.js sets a PAC script that proxies only listed domains and supplies credentials when the proxy asks:
const PROXIED = ['example-target.com', 'another-site.co.uk'];
const USER = 'USERNAME-country-gb-session-ext1-time-60';
const PASS = 'PASSWORD';
const pac = 'function FindProxyForURL(url, host) {\n' +
' var list = ' + JSON.stringify(PROXIED) + ';\n' +
' for (var i = 0; i < list.length; i++) {\n' +
' if (host === list[i] || dnsDomainIs(host, "." + list[i])) return "PROXY global.nodeproxies.xyz:8080";\n' +
' }\n' +
' return "DIRECT";\n' +
'}';
function apply() {
chrome.proxy.settings.set({
value: { mode: 'pac_script', pacScript: { data: pac } },
scope: 'regular'
});
}
chrome.runtime.onInstalled.addListener(apply);
chrome.runtime.onStartup.addListener(apply);
chrome.webRequest.onAuthRequired.addListener(
(details, callback) => {
if (!details.isProxy) return callback({});
callback({ authCredentials: { username: USER, password: PASS } });
},
{ urls: ['<all_urls>'] },
['asyncBlocking']
);Load it from chrome://extensions with Developer mode on and "Load unpacked". Visit a listed site and our what is my IP tool side by side: only the listed site should go through the proxy. To switch off, call chrome.proxy.settings.clear({ scope: 'regular' }), or disable the extension.
Adding Profiles
A "profile" in a switcher is just a saved combination of mode, server and credentials. In the DIY version, store profiles with chrome.storage.local, add a small popup with buttons, and call apply() with the selected one. For country switching, the only thing that changes is the username, for example USERNAME-country-us versus USERNAME-country-de. Countries are listed on the residential proxies page.
Choosing a Third-Party Extension Safely
A proxy extension can see every URL you visit and can hold your proxy credentials. Before installing one:
- Prefer open-source extensions whose code you or others can review.
- Check the permissions. A proxy switcher needs proxy and usually webRequest; it shouldn't need access to read and change page content on every site unless it explains why.
- Watch for ownership changes. Popular extensions are sometimes sold and updated with tracking code.
- Store credentials only in extensions you trust, and use a proxy password you don't use anywhere else.
Common Problems
- Endless login prompts: the extension isn't answering onAuthRequired, or the credentials are wrong. See how to fix proxy error 407.
- Two extensions fighting: only one extension can control the proxy setting at a time. The most recently enabled wins.
- Policy-managed browsers: a company policy can lock proxy settings and override extensions.
- IP changes between page loads: you're on a rotating username. Add a session, as in the example.
Using NodeProxies with a Proxy Extension
Point the extension at global.nodeproxies.xyz:8080 (HTTP) and enter your dashboard credentials. Chromium can't authenticate to SOCKS5 proxies, so use the HTTP endpoint. Rule-based routing keeps usage small, which suits pay-as-you-go pricing from 100 MB. For many separate browser identities, read proxies for antidetect browsers. Register to start.
FAQ
Can a browser extension set a proxy with a username and password?
Yes. It sets the server through the proxy API and supplies credentials through the webRequest onAuthRequired event.
Does a proxy extension affect other apps on my computer?
No. It only changes the proxy for that browser profile.
Can I use a different proxy for different websites?
Yes. Use a PAC script that returns a proxy for some hosts and DIRECT for the rest.
