diff --git a/src/content/app.js b/src/content/app.js index a66f9c3..e804a66 100644 --- a/src/content/app.js +++ b/src/content/app.js @@ -12,7 +12,6 @@ typeof globalThis.browser === 'undefined' && (globalThis.browser = globalThis.ch export const pref = { mode: 'disable', sync: false, - proxyDNS: true, passthrough: '', container: {}, commands: {}, @@ -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; } + } } \ No newline at end of file diff --git a/src/content/proxy.js b/src/content/proxy.js index 471626e..26250b9 100644 --- a/src/content/proxy.js +++ b/src/content/proxy.js @@ -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({}); @@ -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(); @@ -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