Skip to content

Commit

Permalink
Fix Popup Links (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
smashedr authored Dec 18, 2023
1 parent f295d3d commit 8a39e14
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ document
document
.querySelectorAll('#options-form input')
.forEach((el) => el.addEventListener('change', saveOptions))
document
.querySelectorAll('[data-bs-toggle="tooltip"]')
.forEach((el) => new bootstrap.Tooltip(el))

document.getElementById('grant-perms').onclick = grantPerms
document.getElementById('toggle-site').onclick = toggleSiteClick
document.getElementById('enable-temp').onclick = enableTempClick

document
.querySelectorAll('[data-bs-toggle="tooltip"]')
.forEach((el) => new bootstrap.Tooltip(el))

/**
* Initialize Popup
* TODO: Cleanup this function
Expand Down Expand Up @@ -89,17 +88,11 @@ async function popupLinks(event) {
event.preventDefault()
const anchor = event.target.closest('a')
console.log(`anchor.href: ${anchor.href}`)
let url
if (anchor.href.endsWith('html/options.html')) {
chrome.runtime.openOptionsPage()
return window.close()
} else if (anchor.href.startsWith('http')) {
url = anchor.href
} else {
url = chrome.runtime.getURL(anchor.href)
await chrome.tabs.create({ active: true, url: anchor.href })
}
console.log('url:', url)
await chrome.tabs.create({ active: true, url })
return window.close()
}

Expand All @@ -122,9 +115,7 @@ function grantPerms(event) {
* @param {MouseEvent} event
*/
async function toggleSiteClick(event) {
console.log('toggleSiteBtn:', event)
// let { options } = await chrome.storage.sync.get(['options'])
// console.log('options:', options)
console.log('toggleSiteClick:', event)
const [tab] = await chrome.tabs.query({ currentWindow: true, active: true })
console.log('tab:', tab)
await toggleSite(tab)
Expand All @@ -137,7 +128,7 @@ async function toggleSiteClick(event) {
* @param {MouseEvent} event
*/
async function enableTempClick(event) {
console.log('enableTemp:', event)
console.log('enableTempClick:', event)
const [tab] = await chrome.tabs.query({ currentWindow: true, active: true })
console.log('tab:', tab)
await enableSite(tab, 'yellow')
Expand Down

0 comments on commit 8a39e14

Please sign in to comment.