Skip to content

Commit

Permalink
v8.7 Android
Browse files Browse the repository at this point in the history
  • Loading branch information
erosman authored Dec 15, 2023
1 parent 41a368d commit 47852c9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
29 changes: 28 additions & 1 deletion src/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ typeof globalThis.browser === 'undefined' && (globalThis.browser = globalThis.ch
export const pref = {
mode: 'disable',
sync: false,
proxyDNS: true,
passthrough: '',
container: {},
commands: {},
Expand Down Expand Up @@ -82,7 +81,35 @@ export class App {
return url;
}

static findProxy() {
/*
// action
const item = pref.data.find(i => pref.mode === (i.type === 'pac' ? i.pac : `${i.hostname}:${i.port}`));
// commands
const proxy = pref.data.find(i => i.active && host === `${i.hostname}:${i.port}`);
// on-request
this.proxy = data.find(i => pref.mode === `${i.hostname}:${i.port}`)
data.find(i => val === `${i.hostname}:${i.port}`)
// proxy.js
pref.data.find(i =>
i.active && i.type !== 'pac' && i.hostname && mode === `${i.hostname}:${i.port}`);
const pxy = pref.data.find(i => host === `${i.hostname}:${i.port}`);
*/
}

static isBasic() {
return browser.runtime.getManifest().name === browser.i18n.getMessage('extensionNameBasic');
}

// https://bugzilla.mozilla.org/show_bug.cgi?id=1725981
// proxy.settings is not supported on Android
static hasProxySettings = this.checkProxySettings();
static checkProxySettings() {
try { browser.proxy.settings; return true; }
catch { return false; }
}
}
7 changes: 3 additions & 4 deletions src/content/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Proxy {
static async getSettings() {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1725981
// proxy.settings is not supported on Android
if (!browser.proxy.settings) { return {}; }
if (!App.hasProxySettings) { return {}; }

const conf = await browser.proxy.settings.get({});

Expand Down Expand Up @@ -104,7 +104,7 @@ export class Proxy {

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

// Incognito Access
const allowed = await browser.extension.isAllowedIncognitoAccess();
Expand All @@ -124,8 +124,7 @@ export class Proxy {
value.autoConfigUrl = pref.mode;
value.passthrough = pref.passthrough.split(/[\s,;]+/).join(', '); // convert to standard comma-separated
value.proxyDNS = pref.proxyDNS;
// no error if levelOfControl: "controlled_by_other_extensions"
browser.proxy.settings.set({value});
browser.proxy.settings.set({value}); // no error if levelOfControl: "controlled_by_other_extensions"
break;

// --- disable, direct, pattern, or single proxy
Expand Down

0 comments on commit 47852c9

Please sign in to comment.