Skip to content

Commit

Permalink
fix: add speculative delay ... sadly still necessary :(
Browse files Browse the repository at this point in the history
  • Loading branch information
igorlogius committed Jan 4, 2024
1 parent 20f05ab commit 4ebd9ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"tabs"
],
"optional_permissions": ["bookmarks", "history"],
"version": "1.1.12"
"version": "1.1.13"
}

0 comments on commit 4ebd9ac

Please sign in to comment.