Skip to content

Instantly share code, notes, and snippets.

@unixfox
Last active May 1, 2019 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unixfox/e8628ed8cdeb44c6adcf1d41587dabe8 to your computer and use it in GitHub Desktop.
Save unixfox/e8628ed8cdeb44c6adcf1d41587dabe8 to your computer and use it in GitHub Desktop.
Firefox web extension that enable a proxy if on mobile/cellular network
if (navigator.connection.type === "cellular") {
browser.proxy.register(
"pac.js"
);
}
{
"description": "Switching proxy if on mobile network",
"manifest_version": 2,
"name": "mobileproxy",
"version": "0.1",
"icons": {
"48": "proxy.png"
},
"permissions": [
"Network​Information",
"proxy"
],
"background": {
"scripts": [
"background.js"
]
},
"browser_specific_settings": {
"gecko": {
"id": "contact@email.com"
}
}
}
function FindProxyForURL(url, host) {
if (url.substring(0, 5) == 'http:' || url.substring(0, 6) == 'https:') {
return "HTTP 127.0.0.1:8080";
}
return "DIRECT";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment