Skip to content

Commit

Permalink
Optimize more
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Dec 5, 2024
1 parent 737df83 commit 5f7e889
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions webextensions/sidebar/tab-preview-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ async function sendTabPreviewMessage(tabId, message, deferredResultResolver) {
type: 'treestyletab:ask-tab-preview-frame-loaded',
tabId,
}).catch(_error => {}),
typeof message.previewURL == 'function' && (async () => {
message.previewURL = await message.previewURL();
})(),
]);
frameId = gotFrameId;
loadedInfo = gotLoadedInfo;
Expand Down Expand Up @@ -400,6 +403,8 @@ async function waitUntilPreviewFrameLoadedIntoTab(tabId) {

async function sendInSidebarTabPreviewMessage(message) {
log(`sendInSidebarTabPreviewMessage(${message.type}})`);
if (typeof message.previewURL == 'function')
message.previewURL = await message.previewURL();
await browser.runtime.sendMessage({
...message,
timestamp: Date.now(),
Expand Down Expand Up @@ -441,16 +446,15 @@ async function onTabSubstanceEnter(event) {
hasPreview &&
canRunScript &&
configs.tabPreviewTooltip &&
await (async () => {
(async () => { // We just define a getter function for now, because further operations may contain
try {
const previewURL = await browser.tabs.captureTab(event.target.tab.id);
return previewURL;
return await browser.tabs.captureTab(event.target.tab.id);
}
catch (_error) {
}
return null;
})()
);
})
) || null;

if (!event.target.tab)
return;
Expand Down

0 comments on commit 5f7e889

Please sign in to comment.