Skip to content

Commit

Permalink
v8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
erosman authored Aug 18, 2024
1 parent a30f099 commit 5b07d5b
Show file tree
Hide file tree
Showing 21 changed files with 387 additions and 202 deletions.
15 changes: 10 additions & 5 deletions src/content/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
<h2 id="changelog">Changelog</h2>
<dl>
<dt>8.10</dt>
<dd>Added direct HTTP authentication (Firefox 125+)</dd>
<dd>Added new options to the proxy types</dd>
<dd>Added QUIC (HTTP) option (Chrome only) (experimental) (#124)</dd>
<dd>Updated browser detection (firefox-extension/issues/220, #139, #141)</dd>
<dd>Updated Options page user interface</dd>
<dd>Updated toolbar popup user interface</dd>
<dd>Added console log for Save file errors (#144)</dd>

<dt>8.9</dt>
<dd>Added "Log" to the toolbar popup buttons (#44)</dd>
Expand Down Expand Up @@ -75,7 +81,7 @@ <h2 id="changelog">Changelog</h2>
<dd>Updated Options save process to fill blank proxy header title display (#74)</dd>

<dt>8.3</dt>
<dd>Added enterprise policy & managed storage feature (#42) (experimental)</dd>
<dd>Added enterprise policy & managed storage feature (experimental) (#42)</dd>
<dd>Added PAC "Store Locally" feature (#46) (experimental) (Chrome only)</dd>
<dd>Added PAC view feature</dd>
<dd>Fixed an issue with empty Global Exclude</dd>
Expand Down Expand Up @@ -108,7 +114,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 Firefox on Android support (experimental) (#21)</dd>
<dd>Added Get Location feature</dd>
<dd>Added Global Exclude</dd>
<dd>Added Host Pattern to proxy feature</dd>
Expand All @@ -129,7 +135,6 @@ <h2 id="changelog">Changelog</h2>

<h2 id="credits">Credits</h2>
<dl>

<dt>Developer</dt>
<dd><a href="https://github.com/erosman" target="_blank">erosman</a></dd>

Expand All @@ -138,10 +143,10 @@ <h2 id="credits">Credits</h2>
<dd>es: <a href="https://github.com/LuisAlfredo92" target="_blank">Luis Alfredo Figueroa Bracamontes</a></dd>
<dd>fa: <a href="https://github.com/axone13" target="_blank">Matin Kargar </a></dd>
<dd>fr: <a href="https://github.com/Hugo-C" target="_blank">Hugo-C</a></dd>
<dd>ja_JP: <a href="https://github.com/yutayamate" target="_blank">Yuta Yamate</a></dd>
<dd>ja: <a href="https://github.com/yutayamate" target="_blank">Yuta Yamate</a></dd>
<dd>pl: Grzegorz Koryga</dd>
<dd>pt_BR: </dd>
<dd>ru: <a href="https://github.com/sosiska" target="_blank">Kirill Motkov</a></dd>
<dd>ru: <a href="https://github.com/sosiska" target="_blank">Kirill Motkov</a>, <a href="https://github.com/krolchonok" target="_blank">krolchonok</a></dd>
<dd>uk: <a href="https://github.com/sponsors/webknjaz" target="_blank">Sviatoslav Sydorenko</a></dd>
<dd>zh_CN: <a href="https://github.com/wsxy162" target="_blank">FeralMeow </a></dd>
<dd>zh_TW: <a href="https://github.com/samuikaze" target="_blank">samuikaze</a></dd>
Expand Down
1 change: 1 addition & 0 deletions src/content/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {Location} from './location.js';

export class Action {

// https://github.com/w3c/webextensions/issues/72#issuecomment-1848874359
// 'prefers-color-scheme' detection in Chrome background service worker
static dark = false;
Expand Down
56 changes: 50 additions & 6 deletions src/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export const pref = {
// ---------- App ------------------------------------------
export class App {

static firefox = navigator.userAgent.includes('Firefox');
// https://github.com/foxyproxy/firefox-extension/issues/220
// Proxy by patterns not working if firefox users change their userAgent to another platform
// Chrome does not support runtime.getBrowserInfo()
// Object.hasOwn(browser.runtime, 'getBrowserInfo')
// moz-extension: | chrome-extension: | safari-web-extension:
static firefox = browser.runtime.getURL('').startsWith('moz-extension:');
static android = navigator.userAgent.includes('Android');
// static chrome = navigator.userAgent.includes('Chrome');
static basic = browser.runtime.getManifest().name === browser.i18n.getMessage('extensionNameBasic');
Expand Down Expand Up @@ -63,11 +68,6 @@ export class App {
return JSON.stringify(a) === JSON.stringify(b);
}

static getFlag(cc) {
cc = /^[A-Z]{2}$/i.test(cc) && cc.toUpperCase();
return cc ? String.fromCodePoint(...[...cc].map(i => i.charCodeAt() + 127397)) : '🌎';
}

static parseURL(url) {
// rebuild file://
url.startsWith('file://') && (url = 'http' + url.substring(4));
Expand All @@ -86,4 +86,48 @@ export class App {

return url;
}

static getFlag(cc) {
cc = /^[A-Z]{2}$/i.test(cc) && cc.toUpperCase();
return cc ? String.fromCodePoint(...[...cc].map(i => i.charCodeAt() + 127397)) : '🌎';
}

static isLocal(host) {
// check local network
const isIP = /^[\d.:]+$/.test(host);
switch (true) {
// --- localhost & <local>
// case host === 'localhost':
case !host.includes('.'): // plain hostname (no dots)
case host.endsWith('.localhost'): // *.localhost

// --- IPv4
// case host === '127.0.0.1':
case isIP && host.startsWith('127.'): // 127.0.0.1 up to 127.255.255.254
case isIP && host.startsWith('169.254.'): // 169.254.0.0/16 - 169.254.0.0 to 169.254.255.255
case isIP && host.startsWith('192.168.'): // 192.168.0.0/16 - 192.168.0.0 to 192.168.255.255

// --- IPv6
// case host === '[::1]':
case host.startsWith('[::1]'): // literal IPv6 [::1]:80 with/without port
case host.toUpperCase().startsWith('[FE80::]'): // literal IPv6 [FE80::]/10
return true;
}
}

static showFlag(item) {
switch (true) {
case !!item.cc:
return this.getFlag(item.cc);

case item.type === 'direct':
return '⮕';

case this.isLocal(item.hostname):
return '🖥️';

default:
return '🌎';
}
}
}
1 change: 1 addition & 0 deletions src/content/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// webRequest.onAuthRequired on Chrome mv3 is not usable due to removal of 'blocking'
// https://source.chromium.org/chromium/chromium/src/+/main:extensions/browser/api/web_request/web_request_api.cc;l=2857
// Chrome 108 new permission 'webRequestAuthProvider'
// Firefox 126 added 'webRequestAuthProvider' permission support

import './app.js';

Expand Down
1 change: 0 additions & 1 deletion src/content/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {Proxy} from './proxy.js';
import './commands.js';

// ---------- Process Preferences --------------------------
// eslint-disable-next-line no-unused-vars
class ProcessPref {

static {
Expand Down
2 changes: 1 addition & 1 deletion src/content/color.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class Color {

static getRandom() {
return this.colors[Math.floor(Math.random()*this.colors.length)];
return this.colors[Math.floor(Math.random() * this.colors.length)];
}

static colors = [
Expand Down
11 changes: 6 additions & 5 deletions src/content/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// https://developer.chrome.com/docs/extensions/reference/commands/#event-onCommand
// https://bugzilla.mozilla.org/show_bug.cgi?id=1843866
// Add tab parameter to commands.onCommand
// Firefox commands only returns command name
// Firefox commands only returns command name (tab added in FF126)
// Chrome commands returns command, tab

import {App} from './app.js';
import {Proxy} from './proxy.js';
import {OnRequest} from './on-request.js';

// ---------- Commands (Side Effect) ------------------------
// eslint-disable-next-line no-unused-vars
class Commands {

static {
Expand All @@ -21,6 +20,8 @@ class Commands {
static async process(name, tab) {
const pref = await browser.storage.local.get();
const host = pref.commands[name];
const needTab = ['quickAdd', 'excludeHost', 'setTabProxy', 'unsetTabProxy'].includes(name);
tab ||= needTab && await browser.tabs.query({currentWindow: true, active: true});

switch (name) {
case 'proxyByPatterns':
Expand All @@ -36,7 +37,7 @@ class Commands {
break;

case 'quickAdd':
host && Proxy.quickAdd(pref, host);
host && Proxy.quickAdd(pref, host, tab);
break;

case 'excludeHost':
Expand All @@ -47,13 +48,13 @@ class Commands {
if (!App.firefox || !host) { break; } // firefox only

const proxy = pref.data.find(i => i.active && host === `${i.hostname}:${i.port}`);
proxy && OnRequest.setTabProxy(proxy);
proxy && OnRequest.setTabProxy(tab, proxy);
break;

case 'unsetTabProxy':
if (!App.firefox) { break; } // firefox only

OnRequest.unsetTabProxy();
OnRequest.setTabProxy(tab);
break;
}
}
Expand Down
Loading

0 comments on commit 5b07d5b

Please sign in to comment.