Skip to content

Commit

Permalink
fixed query selector from elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfredo committed Feb 21, 2024
1 parent 4825459 commit fc2c718
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function deleteTab(){

function createElement(){
const element = tabTemplate.content.firstElementChild.cloneNode(true);
element.getElementById("delete").addEventListener("click", deleteTab);
element.querySelector("#delete").addEventListener("click", deleteTab);
return element;
}

Expand All @@ -44,27 +44,19 @@ function loadTabs(items){
for (const tab of rowObjs){
console.log(tab);
const element = createElement();
element.getElementById("tabTitle").value = tab.tabTitle;
element.getElementById("url").value = tab.url;
element.querySelector("#tabTitle").value = tab.tabTitle;
element.querySelector("#url").value = tab.url;
elements.add(element);
}
tabAppendElement.append(...elements);
}

/*function clearStorage(){
chrome.storage.sync.remove([whyKey],function(){
const error = chrome.runtime.lastError;
if (error != null)
console.error(error);
})
}*/

function saveTabs(){
const tabs = [];
const tabElements = document.getElementsByClassName("tab");
Array.from(tabElements).forEach(function (tab) {
const tabTitle = tab.getElementById("tabTitle").value;
const url = tab.getElementById("url").value;
const tabTitle = tab.querySelector("#tabTitle").value;
const url = tab.querySelector("#url").value;
if (tabTitle != null && url != null){
tabs.push({tabTitle, url});
}
Expand Down

0 comments on commit fc2c718

Please sign in to comment.