Skip to content

Commit

Permalink
Fix Popup Close for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
smashedr committed Oct 20, 2023
1 parent 1841609 commit 7f09ce2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ jobs:
name: artifacts
path: web-ext-artifacts/

- name: "Upload Artifacts to Release"
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: web-ext-artifacts/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true

- name: "Debug"
run: |
ls -l web-ext-artifacts
3 changes: 1 addition & 2 deletions src/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
<a id="btn-all" class="btn btn-outline-warning btn-sm" role="button">All Links</a>
<a id="btn-filter" class="btn btn-outline-info btn-sm" role="button">Links by Filter</a>
<a id="btn-domains" class="btn btn-outline-primary btn-sm" role="button">Only Domains</a>
<a id="btn-options" class="btn btn btn-outline-secondary btn-sm" role="button" target="_blank"
href="options.html">Open Options</a>
<button id="btn-options" data-href="html/options.html" type="button" class="btn btn-sm btn-outline-secondary">Open Options</button>
<a id="btn-about" class="btn btn-outline-secondary btn-sm" role="button">Visit Homepage</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/js/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function processLinks(links, pattern, onlyDomains) {
* @param {String} elementId
*/
function updateTable(data, elementId) {
let tbody = document
const tbody = document
.getElementById(elementId)
.getElementsByTagName('tbody')[0]
data.forEach(function (url, i) {
Expand Down
13 changes: 5 additions & 8 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ async function initOptions() {
async function saveOptions(event) {
event.preventDefault()
console.log('saveOptions')
let urlInput = document.getElementById('pattern')
let pattern = urlInput.value
const urlInput = document.getElementById('pattern')
const pattern = urlInput.value
console.log(`pattern: ${pattern}`)
await chrome.storage.sync.set({ pattern: pattern })
showToast('Options Saved')
Expand All @@ -38,11 +38,8 @@ async function saveOptions(event) {
*/
function showToast(message, bsClass = 'success') {
// TODO: Remove jQuery Dependency
// let toastContainer = document.getElementById('toast-container')
let toastContainer = $('#toast-container')
console.log('toastContainer')
console.log(toastContainer)
let toastEl = $(
const toastContainer = $('#toast-container')
const toastEl = $(
'<div class="toast align-items-center border-0 mt-3" role="alert" aria-live="assertive" aria-atomic="true">\n' +
' <div class="d-flex">\n' +
' <div class="toast-body">Options Saved</div>\n' +
Expand All @@ -53,6 +50,6 @@ function showToast(message, bsClass = 'success') {
toastEl.find('.toast-body').text(message)
toastEl.addClass('text-bg-' + bsClass)
toastContainer.append(toastEl)
let toast = new bootstrap.Toast(toastEl)
const toast = new bootstrap.Toast(toastEl)
toast.show()
}
11 changes: 11 additions & 0 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ jQuery('html').hide().fadeIn('slow')
document.getElementById('btn-all').addEventListener('click', popupClick)
document.getElementById('btn-filter').addEventListener('click', popupClick)
document.getElementById('btn-domains').addEventListener('click', popupClick)
document.getElementById('btn-options').addEventListener('click', popupClick)

document.getElementById('btn-about').addEventListener('click', () => {
const manifest = chrome.runtime.getManifest()
console.log(`url: ${manifest.homepage_url}`)
chrome.tabs.create({ active: true, url: manifest.homepage_url }).then()
window.close()
})

/**
Expand All @@ -19,6 +21,14 @@ document.getElementById('btn-about').addEventListener('click', () => {
*/
async function popupClick(event) {
console.log(event)
if (event.target.dataset.href) {
console.log(`href: ${event.target.dataset.href}`)
const url = chrome.runtime.getURL(event.target.dataset.href)
console.log(`url: ${url}`)
await chrome.tabs.create({ active: true, url })
window.close()
return
}
const filterLinks = event.target.id === 'btn-filter'
const onlyDomains = event.target.id === 'btn-domains'
const queryOptions = { active: true, lastFocusedWindow: true }
Expand All @@ -32,4 +42,5 @@ async function popupClick(event) {
const url = `${linksUrl}?tabId=${tab.id}&filterLinks=${filterLinks}&onlyDomains=${onlyDomains}`
console.log(`chrome.tabs.create: ${url}`)
await chrome.tabs.create({ active: true, url })
window.close()
}

0 comments on commit 7f09ce2

Please sign in to comment.