// Set click events document.addEventListener("click", (e) => { var target = e.target; var targetID = target.id; var parentElm = target.parentElement; var id = 0; if (targetID == "closeBttn") { id = parseInt(parentElm.getAttribute("tabID")); browser.tabs.remove(id); parentElm.parentElement.removeChild(parentElm); } else if (targetID == "iconElm" || targetID == "faveIcon") { if (targetID == "faveIcon") target = parentElm.parentElement; oldElm.setAttribute("class", "block"); oldElm = target; target.setAttribute("class", "block block-focused"); id = parseInt(target.getAttribute("tabID")); browser.tabs.update(id, { active: true }); } else if (targetID == "goTop") { window.scrollTo(0,0); } else if (targetID == "goBottom") { window.scrollTo(0,document.body.scrollHeight); } else if (targetID == "goToTab") { // Go to selected and 100px up oldElm.scrollIntoView(); window.scrollBy(0, -100); } }); document.getElementById("searchBar").onkeypress = function () { searchTabs(); }