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 16, 2023
1 parent be7049f commit 28cb50c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 24 deletions.
14 changes: 2 additions & 12 deletions src/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export const pref = {
export class App {

static firefox = navigator.userAgent.includes('Firefox');
static android = navigator.userAgent.includes('Android');
// static chrome = navigator.userAgent.includes('Chrome');
// static isBasic = browser.runtime.getManifest().name === browser.i18n.getMessage('extensionNameBasic');

// ---------- User Preferences ---------------------------
static defaultPref = JSON.stringify(pref);
Expand Down Expand Up @@ -101,16 +103,4 @@ export class App {
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; }
}
}
8 changes: 4 additions & 4 deletions src/content/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ProcessPref {
// ---------- /Process Preferences -------------------------

// ---------- Initialisation -------------------------------
browser.runtime.onInstalled.addListener(e => {
// show help
// ['install', 'update'].includes(e.reason) && browser.tabs.create({url: '/content/help.html'});
});
// browser.runtime.onInstalled.addListener(e => {
// // show help
// ['install', 'update'].includes(e.reason) && browser.tabs.create({url: '/content/help.html'});
// });
4 changes: 2 additions & 2 deletions src/content/on-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class OnRequest {
// --- standard operation
case this.mode === 'disable': // pass direct
case this.mode === 'direct': // pass direct
case this.mode.includes('://'): // PAC URL is set
case this.mode.includes('://') && !/:\d+$/.test(this.mode): // PAC URL is set
return {type: 'direct'};

case this.mode === 'pattern': // check if url matches patterns
Expand Down Expand Up @@ -247,4 +247,4 @@ export class OnRequest {
const pxy = this.tabProxy[tab.id];
pxy ? PageAction.set(tab.id, pxy) : this.checkPageAction(tab);
}
}
}
4 changes: 2 additions & 2 deletions src/content/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Options {
// get from storage in case it was changed while options page has been open
let {mode} = await browser.storage.local.get({mode: 'disable'});
switch (true) {
case pref.mode.includes('://') && !pref.data.some(i => i.active && i.type === 'pac' && mode === i.pac):
case pref.mode.includes('://') && !/:\d+$/.test(pref.mode) && !pref.data.some(i => i.active && i.type === 'pac' && mode === i.pac):
case pref.mode.includes(':') && !pref.data.some(i => i.active && i.type !== 'pac' && mode === `${i.hostname}:${i.port}`):
case pref.mode === 'pattern' && !pref.data.some(i => i.active && i.include[0]):
mode = 'disable';
Expand Down Expand Up @@ -462,7 +462,7 @@ class Proxies {
Log.mode = pref.mode;

// --- hide elements for Basic
// App.isBasic && this.proxyDiv.classList.add('basic');
App.isBasic && this.proxyDiv.classList.add('basic');

this.process();
}
Expand Down
2 changes: 1 addition & 1 deletion src/content/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Popup {
const docFrag = document.createDocumentFragment();

// check if there are patterns, hide elements for Basic
if (/* App.isBasic || */ !pref.data.some(i => i.active && i.include[0])) {
if (App.isBasic || !pref.data.some(i => i.active && i.include[0])) {
this.list.children[0].style.display = 'none'; // hide option if there are no patterns
pref.mode === 'pattern' && (pref.mode = 'disable'); // show as disable
}
Expand Down
6 changes: 3 additions & 3 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 (!App.hasProxySettings) { return {}; }
if (App.android) { 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 (!App.hasProxySettings) { return; }
if (App.android) { return; }

// Incognito Access
const allowed = await browser.extension.isAllowedIncognitoAccess();
Expand Down Expand Up @@ -146,7 +146,7 @@ export class Proxy {
break;

// --- Proxy Auto-Configuration (PAC) URL
case pref.mode.includes('://'):
case pref.mode.includes('://') && !/:\d+$/.test(pref.mode):
config.value.mode = 'pac_script';
config.value.pacScript = {mandatory: true};
config.value.pacScript.url = pref.mode;
Expand Down

0 comments on commit 28cb50c

Please sign in to comment.