Simplify process for getting tab URL
This commit is contained in:
parent
135697a544
commit
7f7a0d4b68
|
@ -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": []});
|
||||
|
|
Loading…
Reference in New Issue