Brave-Detection-Blocker-Chr.../popup.js

31 lines
937 B
JavaScript
Raw Permalink Normal View History

2022-11-01 00:58:19 +00:00
'use strict'
2022-03-25 18:10:48 +00:00
2022-11-01 00:58:19 +00:00
const myTabs = document.querySelectorAll('ul.nav-tabs > li')
2022-03-25 18:10:48 +00:00
function myTabClicks(tabClickEvent) {
2022-11-01 00:58:19 +00:00
for (let i = 0; i < myTabs.length; i++) {
myTabs[i].classList.remove('active')
}
2022-03-25 18:10:48 +00:00
2022-11-01 00:58:19 +00:00
const clickedTab = tabClickEvent.currentTarget
clickedTab.classList.add('active')
tabClickEvent.preventDefault()
2022-03-25 18:10:48 +00:00
2022-11-01 00:58:19 +00:00
const myContentPanes = document.querySelectorAll('.tab-pane')
2022-03-25 18:10:48 +00:00
2022-11-01 00:58:19 +00:00
for (let i = 0; i < myContentPanes.length; i++) {
myContentPanes[i].classList.remove('active')
}
2022-03-25 18:10:48 +00:00
2022-11-01 00:58:19 +00:00
const anchorReference = tabClickEvent.target
const activePaneId = anchorReference.getAttribute('href')
const activePane = document.querySelector(activePaneId)
activePane.classList.add('active')
2022-03-25 18:10:48 +00:00
}
for (let i = 0; i < myTabs.length; i++) {
2022-11-01 00:58:19 +00:00
myTabs[i].addEventListener('click', myTabClicks)
2022-03-25 18:10:48 +00:00
}
2022-11-01 00:58:19 +00:00
const imgURL = chrome.runtime.getURL('images/BDB-ICON256.png')
document.getElementById('logo').src = imgURL