From 261b83676279949e48fe1f9c9bf4f3b8dc204057 Mon Sep 17 00:00:00 2001 From: Sebastian Streich Date: Wed, 21 Aug 2024 21:48:31 +0100 Subject: [PATCH] Polish: Make The Popup Follow the Active Tab Context (#33) Currently the Popup only takes the opener page into account. Let's make it follow pages, while switching. Should make it better to demo https://github.com/user-attachments/assets/e65c1d8c-d052-4c97-9792-8bd0cd5ad31a --- src/ui/browserAction/popupPage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ui/browserAction/popupPage.js b/src/ui/browserAction/popupPage.js index e1c0133..11ac807 100644 --- a/src/ui/browserAction/popupPage.js +++ b/src/ui/browserAction/popupPage.js @@ -52,8 +52,16 @@ export class BrowserActionPopup extends LitElement { super(); this.pageURL = null; this._siteContext = null; + browser.tabs.onUpdated.addListener(() => this.updatePage()); + browser.tabs.onActivated.addListener(() => this.updatePage()); + vpnController.state.subscribe((s) => (this.vpnState = s)); + this.updatePage(); + } + updatePage() { Utils.getCurrentTab().then(async (tab) => { if (!Utils.isValidForProxySetting(tab.url)) { + this.pageURL = null; + this._siteContext = null; return; } const hostname = Utils.getFormattedHostname(tab.url); @@ -62,8 +70,8 @@ export class BrowserActionPopup extends LitElement { this._siteContext = proxyHandler.siteContexts.value.get(this.pageURL); } }); - vpnController.state.subscribe((s) => (this.vpnState = s)); } + connectedCallback() { super.connectedCallback(); }