From 4ebd9ac9c139b12979b9ef013cffe66b9f8646cf Mon Sep 17 00:00:00 2001 From: igorlogius <67047467+igorlogius@users.noreply.github.com> Date: Fri, 5 Jan 2024 00:59:08 +0100 Subject: [PATCH] fix: add speculative delay ... sadly still necessary :( --- background.js | 24 ++++++++++++++---------- manifest.json | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/background.js b/background.js index 6df358b..2f01561 100644 --- a/background.js +++ b/background.js @@ -170,22 +170,26 @@ browser.commands.onCommand.addListener(async (command) => { }); async function handleUpdated(tabId, changeInfo, tabInfo) { - if (changeInfo.status === "complete") { - if (tabInfo.url.startsWith("http")) { + //if (changeInfo.status === "complete") + if (changeInfo.url) { + console.debug(changeInfo.url); + if (changeInfo.url.startsWith("http")) { try { const container = await browser.contextualIdentities.get( tabInfo.cookieStoreId ); if (container.name.startsWith("Temp")) { const visits = await browser.history.getVisits({ - url: tabInfo.url, + url: changeInfo.url, }); - if (visits.length === 1) { - browser.history.deleteUrl({ - url: tabInfo.url, - }); - //console.debug("removed url", tabInfo.url); + if (visits.length < 5) { + setTimeout(() => { + browser.history.deleteUrl({ + url: changeInfo.url, + }); + console.debug("removed url", tabInfo.url); + }, 2000); } } } catch (e) { @@ -201,11 +205,11 @@ var testPermissions1 = { async function handlePermissionChange(permissions) { if (await browser.permissions.contains(testPermissions1)) { - //console.debug("added handleUpdated listener"); await browser.tabs.onUpdated.addListener(handleUpdated); + console.debug("added handleUpdated listener"); } else { await browser.tabs.onUpdated.removeListener(handleUpdated); - //console.debug("removed handleUpdated listener"); + console.debug("removed handleUpdated listener"); } } browser.permissions.onAdded.addListener(handlePermissionChange); diff --git a/manifest.json b/manifest.json index ae936e0..d0f71ac 100644 --- a/manifest.json +++ b/manifest.json @@ -31,5 +31,5 @@ "tabs" ], "optional_permissions": ["bookmarks", "history"], - "version": "1.1.12" + "version": "1.1.13" }