Skip to content

Commit

Permalink
Fixed shortcut and context menu doing nothing unless browserAction ic…
Browse files Browse the repository at this point in the history
…on is visible on Firefox (issue #58).
  • Loading branch information
hackademix committed Dec 11, 2019
1 parent 974d228 commit 528c8ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
20 changes: 12 additions & 8 deletions src/bg/main.js
Expand Up @@ -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() {},
Expand Down
2 changes: 2 additions & 0 deletions src/bg/popupHandler.js
@@ -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 => {
Expand All @@ -9,6 +10,7 @@ browser.runtime.onConnect.addListener(port => {
}
});
port.onDisconnect.addListener(() => {
ns.popupOpened = false;
if (pendingReload) {
browser.tabs.reload(tabId);
}
Expand Down
3 changes: 1 addition & 2 deletions src/ui/popup.js
Expand Up @@ -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});
Expand Down

0 comments on commit 528c8ea

Please sign in to comment.