From 7f7a0d4b68aa40288cce6af1415ee8ecafa5a8f9 Mon Sep 17 00:00:00 2001 From: Jean Date: Sun, 29 Jun 2025 13:07:39 -0700 Subject: [PATCH] Simplify process for getting tab URL --- src/save-load-options.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/save-load-options.js b/src/save-load-options.js index b2224ba..78545cd 100644 --- a/src/save-load-options.js +++ b/src/save-load-options.js @@ -16,7 +16,8 @@ function init() { function loadDomain() { let tabs = browser.tabs.query({ active: true, currentWindow: true }); tabs.then((tabs) => { - const url = new URL(tabs[0].url); + const tab = tabs[0]; + const url = new URL(tab.url); const isAllowedProtocol = url.protocol == "https:" || url.protocol == "http:"; if (!isAllowedProtocol) { @@ -24,10 +25,10 @@ function loadDomain() { return; } - document.querySelector("#domain").textContent = url.hostname; + document.querySelector("#domain").textContent = url.host; let storage = browser.storage.local.get("domains"); storage.then((storage) => { - const hostname = document.querySelector("#domain").innerHTML; + const hostname = url.host; const domains = storage.domains; if (domains === undefined) { browser.storage.local.set({"domains": []});