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": []});