Fixed shortcut and context menu doing nothing unless browserAction icon is visible on Firefox (issue #58).
This commit is contained in:
parent
974d22848d
commit
528c8ea577
|
@ -54,19 +54,23 @@
|
|||
};
|
||||
|
||||
let Commands = {
|
||||
openPageUI() {
|
||||
async openPageUI() {
|
||||
if (ns.popupOpening) return;
|
||||
ns.popupOpening = true;
|
||||
ns.popupOpened = false;
|
||||
let openPanel = async () => {
|
||||
ns.popupOpening = false;
|
||||
if (ns.popupOpened) return;
|
||||
messageHandler.openStandalonePopup();
|
||||
};
|
||||
try {
|
||||
browser.browserAction.openPopup();
|
||||
await browser.browserAction.openPopup();
|
||||
setTimeout(openPanel, 500);
|
||||
return;
|
||||
} catch (e) {
|
||||
openPanel();
|
||||
debug(e);
|
||||
}
|
||||
browser.windows.create({
|
||||
url: popupURL,
|
||||
width: 800,
|
||||
height: 600,
|
||||
type: "panel"
|
||||
});
|
||||
},
|
||||
|
||||
togglePermissions() {},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
browser.runtime.onConnect.addListener(port => {
|
||||
if (port.name === "noscript.popup") {
|
||||
ns.popupOpened = true;
|
||||
let pendingReload = false;
|
||||
let tabId = -1;
|
||||
port.onMessage.addListener(m => {
|
||||
|
@ -9,6 +10,7 @@ browser.runtime.onConnect.addListener(port => {
|
|||
}
|
||||
});
|
||||
port.onDisconnect.addListener(() => {
|
||||
ns.popupOpened = false;
|
||||
if (pendingReload) {
|
||||
browser.tabs.reload(tabId);
|
||||
}
|
||||
|
|
|
@ -43,10 +43,9 @@ addEventListener("unload", e => {
|
|||
tabId = tab.id;
|
||||
}
|
||||
|
||||
|
||||
let port = browser.runtime.connect({name: "noscript.popup"});
|
||||
await UI.init(tabId);
|
||||
|
||||
let port = browser.runtime.connect({name: "noscript.popup"})
|
||||
function pendingReload(b) {
|
||||
try {
|
||||
port.postMessage({tabId, pendingReload: b});
|
||||
|
|
Loading…
Reference in New Issue