Links 0/
diff --git a/src/js/exports.js b/src/js/exports.js
index 8e594b9..17c4150 100644
--- a/src/js/exports.js
+++ b/src/js/exports.js
@@ -54,14 +54,36 @@ export async function injectTab({
return
}
- // Inject extract.js which listens for messages
+ // // Inject extract.js which listens for messages
+ // for (const tab of tabIds) {
+ // console.debug(`injecting tab.id: ${tab}`)
+ // await chrome.scripting.executeScript({
+ // target: { tabId: tab, allFrames: true },
+ // files: ['/js/extract.js'],
+ // })
+ // }
+
+ // TODO: The only way to support frames without extra permissions is to either:
+ // Extract the frame data at injection time, or
+ // Extract the links at injection time (requires refactoring)...
+ const tabs = []
for (const tab of tabIds) {
console.debug(`injecting tab.id: ${tab}`)
- await chrome.scripting.executeScript({
- target: { tabId: tab },
+ const results = await chrome.scripting.executeScript({
+ target: { tabId: tab, allFrames: true },
files: ['/js/extract.js'],
})
+ console.debug('results:', results)
+ const frameIds = results.map((item) => item.frameId)
+ console.debug('frameIds:', frameIds)
+ frameIds.shift()
+ if (frameIds.length) {
+ tabs.push(`${tab}-${frameIds.join('-')}`)
+ } else {
+ tabs.push(tab)
+ }
}
+ console.debug('tabs:', tabs)
// Create URL to links.html if open
if (!open) {
@@ -70,7 +92,7 @@ export async function injectTab({
}
const url = new URL(chrome.runtime.getURL('/html/links.html'))
// Set URL searchParams
- url.searchParams.set('tabs', tabIds.join(','))
+ url.searchParams.set('tabs', tabs.join(','))
if (filter) {
url.searchParams.set('filter', filter)
}
diff --git a/src/js/links.js b/src/js/links.js
index 95b22fb..47c2c3c 100644
--- a/src/js/links.js
+++ b/src/js/links.js
@@ -161,18 +161,32 @@ async function initLinks() {
try {
const tabIds = urlParams.get('tabs')
const tabs = tabIds?.split(',')
- const selection = urlParams.has('selection')
+ const action = urlParams.has('selection') ? 'selection' : 'all'
+ // TODO: See the TODO in export.js for injectTab()
+ // This is a temporary fix being tested...
const allLinks = []
if (tabs?.length) {
console.debug('tabs:', tabs)
- for (const tabId of tabs) {
- const action = selection ? 'selection' : 'all'
+ for (const tab of tabs) {
+ const frames = tab.split('-')
+ const tabId = frames.shift()
+ console.debug('tabId:', tabId)
const links = await chrome.tabs.sendMessage(
parseInt(tabId),
- action
+ action,
+ { frameId: 0 }
)
allLinks.push(...links)
+ for (const frame of frames) {
+ console.debug('frame:', frame)
+ const links = await chrome.tabs.sendMessage(
+ parseInt(tabId),
+ action,
+ { frameId: parseInt(frame) }
+ )
+ allLinks.push(...links)
+ }
}
} else {
const { links } = await chrome.storage.local.get(['links'])
@@ -181,8 +195,17 @@ async function initLinks() {
await processLinks(allLinks)
} catch (e) {
console.warn('error:', e)
- alert('Error Processing Results. See Console for More Details...')
- window.close()
+ // document.getElementById('loading-spinner')?.classList?.add('d-none')
+ document.getElementById('loading-spinner')?.remove()
+
+ // TODO: Consider showing a custom alert here since alert is blocking...
+ setTimeout(() => {
+ alert('Error Processing Results. See Console for More Details...')
+ window.close()
+ }, 0)
+
+ // alert('Error Processing Results. See Console for More Details...')
+ // window.close()
}
const collapse = localStorage.getItem('findCollapse')
@@ -282,8 +305,22 @@ async function processLinks(links) {
// If no items, alert and return
if (!links.length) {
- alert('No Results')
- return window.close()
+ //document.getElementById('loading-spinner')?.classList?.add('d-none')
+ document.getElementById('loading-spinner')?.remove()
+
+ // TODO: Consider showing a custom alert here since alert is blocking...
+ setTimeout(() => {
+ alert('No Results')
+ window.close()
+ }, 0)
+
+ // requestAnimationFrame(() => {
+ // alert('No Results')
+ // window.close()
+ // })
+
+ // alert('No Results')
+ // return window.close()
}
// Update links if onlyDomains is not set
@@ -319,7 +356,9 @@ async function processLinks(links) {
}
// Hide Loading message
- document.getElementById('loading-message').classList.add('d-none')
+ // document.getElementById('loading-message').classList.add('d-none')
+ // document.getElementById('loading-spinner')?.classList?.add('d-none')
+ document.getElementById('loading-spinner')?.remove()
// Modifications for Android
const platform = await chrome.runtime.getPlatformInfo()