Skip to content

Commit

Permalink
v8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
erosman authored Jan 25, 2025
1 parent 14e5a0e commit 8fd9d52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class App {
}
}

static allowedTabUrl(url) {
static allowedTabProxy(url) {
return /^https?:\/\/.+|^about:(blank|newtab)$/.test(url);
}
}
2 changes: 1 addition & 1 deletion src/content/on-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class OnRequest {
static setTabProxy(tab, pxy) {
// const [tab] = await browser.tabs.query({currentWindow: true, active: true});
switch (true) {
case !App.allowedTabUrl(tab.url): // unacceptable URLs
case !App.allowedTabProxy(tab.url): // unacceptable URLs
case this.bypass(tab.url): // check local & global passthrough
return;
}
Expand Down
11 changes: 5 additions & 6 deletions src/content/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Popup {
// --- Quick Add (not for storage.managed)
this.quickAdd = document.querySelector('select#quickAdd');
!pref.managed && this.quickAdd.addEventListener('change', () => {
if (!this.tab) { return; }
if (!this.quickAdd.value) { return; }

browser.runtime.sendMessage({id: 'quickAdd', pref, host: this.quickAdd.value, tab: this.tab});
Expand Down Expand Up @@ -54,10 +53,6 @@ class Popup {
}

static async process() {
const [tab] = await browser.tabs.query({currentWindow: true, active: true});
// set this.tab only if tab.url is acceptable
App.allowedTabUrl(tab.url) && (this.tab = tab);

const labelTemplate = document.querySelector('template').content.firstElementChild;
const docFrag = document.createDocumentFragment();

Expand Down Expand Up @@ -113,11 +108,15 @@ class Popup {
this.quickAdd.appendChild(docFrag.cloneNode(true));
this.tabProxy.appendChild(docFrag);

// get active tab
this.tab = (await browser.tabs.query({currentWindow: true, active: true}))[0];

// Check Tab proxy (Firefox only)
App.firefox && this.checkTabProxy();
}

static async checkTabProxy() {
if (!this.tab) { return; }
if (!App.allowedTabProxy(this.tab.url)) { return; } // unacceptable URLs

const item = await browser.runtime.sendMessage({id: 'getTabProxy', tab: this.tab});
item && (this.tabProxy.value = `${item.hostname}:${item.port}`);
Expand Down

0 comments on commit 8fd9d52

Please sign in to comment.