Skip to content

Commit

Permalink
Revert Show About handler to use async/await to work properly ↞ [auto…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Feb 25, 2025
1 parent 5698a61 commit 22e8904
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions chromium/extension/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ chrome.runtime.onMessage.addListener(async req => {
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true })
const chatgptTab = new URL(activeTab.url).hostname == 'chatgpt.com' ? activeTab
: await chrome.tabs.create({ url: chatgptURL })
if (activeTab != chatgptTab) new Promise(resolve => // after ChatGPT loads
chrome.tabs.onUpdated.addListener(async function loadedListener(tabId, changeInfo) {
if (activeTab != chatgptTab) await new Promise(resolve => // after new tab loads
chrome.tabs.onUpdated.addListener(function loadedListener(tabId, changeInfo) {
if (tabId == chatgptTab.id && changeInfo.status == 'complete') {
chrome.tabs.onUpdated.removeListener(loadedListener) ; setTimeout(resolve, 500)
}})).then(() => chrome.tabs.sendMessage(chatgptTab.id, { action: 'showAbout' }))
}}))
chrome.tabs.sendMessage(chatgptTab.id, { action: 'showAbout' })
}
});

Expand Down
7 changes: 4 additions & 3 deletions firefox/extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ chrome.runtime.onMessage.addListener(async req => {
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true })
const chatgptTab = new URL(activeTab.url).hostname == 'chatgpt.com' ? activeTab
: await chrome.tabs.create({ url: chatgptURL })
if (activeTab != chatgptTab) new Promise(resolve => // after ChatGPT loads
chrome.tabs.onUpdated.addListener(async function loadedListener(tabId, changeInfo) {
if (activeTab != chatgptTab) await new Promise(resolve => // after new tab loads
chrome.tabs.onUpdated.addListener(function loadedListener(tabId, changeInfo) {
if (tabId == chatgptTab.id && changeInfo.status == 'complete') {
chrome.tabs.onUpdated.removeListener(loadedListener) ; setTimeout(resolve, 500)
}})).then(() => chrome.tabs.sendMessage(chatgptTab.id, { action: 'showAbout' }))
}}))
chrome.tabs.sendMessage(chatgptTab.id, { action: 'showAbout' })
}
});

Expand Down

0 comments on commit 22e8904

Please sign in to comment.