Skip to content

Commit 46b7c3c

Browse files
committed
[Android] Work-around for Firefox "forgetting" tabs.
1 parent 09e6d5a commit 46b7c3c

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/ui/popup.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* NoScript - a Firefox extension for whitelist driven safe JavaScript execution
33
*
4-
* Copyright (C) 2005-2021 Giorgio Maone <https://maone.net>
4+
* Copyright (C) 2005-2022 Giorgio Maone <https://maone.net>
55
*
66
* SPDX-License-Identifier: GPL-3.0-or-later
77
*
@@ -40,12 +40,13 @@ addEventListener("unload", e => {
4040
let tabId;
4141
let isBrowserAction = true;
4242
let optionsClosed = false;
43-
let tab = (await browser.tabs.query({
44-
windowId: browser.windows ?
45-
(await browser.windows.getLastFocused()).id
46-
: null,
47-
active: true
48-
}))[0];
43+
44+
let tabFlags = {active: true};
45+
if (browser.windows) tabFlags.lastFocusedWindow = true; // Desktop browsers only
46+
let tab = (await browser.tabs.query(tabFlags))[0] ||
47+
// work-around for Firefox "forgetting" tabs on Android
48+
(await browser.tabs.query({url: ["*://*/*", "file:///*", "ftp://*/*"]}))[0];
49+
4950
let pageTab = tab;
5051

5152
if (!tab || tab.id === -1) {

0 commit comments

Comments
 (0)