Skip to content

Commit

Permalink
Experimental Android support #21
Browse files Browse the repository at this point in the history
  • Loading branch information
erosman authored Sep 16, 2023
1 parent 3780d04 commit dfac35f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/content/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h2 id="changelog">Changelog</h2>
<dt>8.0</dt>
<dd>Added complete Light/Dark Theme</dd>
<dd>Added Exclude host feature</dd>
<dd>Added experimental Firefox on Android support (#21)</dd>
<dd>Added Get Location feature</dd>
<dd>Added Global Exclude</dd>
<dd>Added Host Pattern to proxy feature</dd>
Expand All @@ -33,7 +34,6 @@ <h2 id="changelog">Changelog</h2>
<dd>Update User Interface</dd>
<dd>Updated code & style for manifest v3 (MV3) compatibility</dd>
<dd>Updated Import Proxy List</dd>
<dd></dd>

</dl>

Expand Down
5 changes: 4 additions & 1 deletion src/content/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ <h3>Proxy Authentication</h3>
<li>Authentication is port-specific i.e. there can be different user/pass for <code>example.com:3128</code> & <code>example.com:443</code></li>
</ul>

<h3 class="experimental">Firefox on Android</h3>
<p>Support is experimental and based on user feedback.</p>

<h1 id="how-to">How to Use</h1>

<h4>Light/Dark Theme</h4>
Expand Down Expand Up @@ -215,7 +218,7 @@ <h3>Individual Proxy</h3>
<dd>To be used for HTTP/HTTPS/SOCKS types</dd>
<dd>If not set, authentication will be handled by the browser</dd>

<dt>PAC URL</dt>
<dt>PAC URL <span>(not available on Android)</span></dt>
<dd>Required for PAC type</dd>

</dl>
Expand Down
4 changes: 3 additions & 1 deletion src/content/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class IncognitoAccess{
static {
// https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/proxy/settings
// Changing proxy settings requires private browsing window access because proxy settings affect private and non-private windows.
App.firefox && browser.extension.isAllowedIncognitoAccess()
// https://bugzilla.mozilla.org/show_bug.cgi?id=1725981
// proxy.settings is not supported on Android
App.firefox && browser.proxy.settings && browser.extension.isAllowedIncognitoAccess()
.then(response => !response && alert(browser.i18n.getMessage('incognitoAccessError')));
}
}
Expand Down
21 changes: 13 additions & 8 deletions src/content/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import {OnRequest} from './on-request.js';
import {Action} from './action.js';

export class Proxy {
// proxy.settings not supported on Android
// https://bugzilla.mozilla.org/show_bug.cgi?id=1725981
static async getSettings() {

static async #getSettings() {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1725981
// proxy.settings is not supported on Android
if (!browser.proxy.settings) {
return {value: {}};
}

const conf = await browser.proxy.settings.get({});
// https://bugs.chromium.org/p/chromium/issues/detail?id=29683
// https://developer.chrome.com/docs/extensions/mv3/manifest/icons/
Expand Down Expand Up @@ -42,33 +47,33 @@ export class Proxy {

static async #setFirefox(pref) {
// retain settings as Network setting is partially customisable
const conf = await this.getSettings();
const conf = await this.#getSettings();
const value = conf.value;
OnRequest.mode = pref.mode;
switch (true) {
case pref.mode === 'disable':
value.proxyType = 'system';
browser.proxy.settings.set({value});
browser.proxy.settings?.set({value});
break;

// Automatic proxy configuration URL
case pref.mode.includes('://'):
value.proxyType = 'autoConfig';
value.autoConfigUrl = mode;
browser.proxy.settings.set({value});
browser.proxy.settings?.set({value});
break;

// pattern or single proxy
default:
value.proxyType = 'system';
browser.proxy.settings.set({value});
browser.proxy.settings?.set({value});
OnRequest.init(pref);
}
}

static #setChrome(pref) {
// check if proxy.settings is controlled_by_this_extension
this.getSettings();
this.#getSettings();

// https://developer.chrome.com/docs/extensions/reference/types/
// Scope and life cycle: regular | regular_only | incognito_persistent | incognito_session_only
Expand Down

0 comments on commit dfac35f

Please sign in to comment.