[Android] Work-around for Firefox "forgetting" tabs.

This commit is contained in:
hackademix 2022-01-14 23:38:59 +01:00
parent 09e6d5a8e5
commit 46b7c3c5db
1 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/* /*
* NoScript - a Firefox extension for whitelist driven safe JavaScript execution * NoScript - a Firefox extension for whitelist driven safe JavaScript execution
* *
* Copyright (C) 2005-2021 Giorgio Maone <https://maone.net> * Copyright (C) 2005-2022 Giorgio Maone <https://maone.net>
* *
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* *
@ -40,12 +40,13 @@ addEventListener("unload", e => {
let tabId; let tabId;
let isBrowserAction = true; let isBrowserAction = true;
let optionsClosed = false; let optionsClosed = false;
let tab = (await browser.tabs.query({
windowId: browser.windows ? let tabFlags = {active: true};
(await browser.windows.getLastFocused()).id if (browser.windows) tabFlags.lastFocusedWindow = true; // Desktop browsers only
: null, let tab = (await browser.tabs.query(tabFlags))[0] ||
active: true // work-around for Firefox "forgetting" tabs on Android
}))[0]; (await browser.tabs.query({url: ["*://*/*", "file:///*", "ftp://*/*"]}))[0];
let pageTab = tab; let pageTab = tab;
if (!tab || tab.id === -1) { if (!tab || tab.id === -1) {