Index: lib/popupBlocker.js |
=================================================================== |
--- a/lib/popupBlocker.js |
+++ b/lib/popupBlocker.js |
@@ -83,44 +83,50 @@ |
} |
function onCompleted(details) |
{ |
if (details.frameId == 0 && details.url != "about:blank") |
forgetPopup(details.tabId); |
} |
-chrome.webNavigation.onCreatedNavigationTarget.addListener(details => |
+// Versions of Firefox before 54 do not support |
+// webNavigation.onCreatedNavigationTarget |
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1190687 |
+if ("onCreatedNavigationTarget" in chrome.webNavigation) |
{ |
- if (loadingPopups.size == 0) |
+ chrome.webNavigation.onCreatedNavigationTarget.addListener(details => |
{ |
- chrome.webRequest.onBeforeRequest.addListener( |
- onPopupURLChanged, |
- { |
- urls: ["http://*/*", "https://*/*"], |
- types: ["main_frame"] |
- } |
- ); |
- chrome.webNavigation.onCommitted.addListener(onPopupURLChanged); |
- chrome.webNavigation.onCompleted.addListener(onCompleted); |
- chrome.tabs.onRemoved.addListener(forgetPopup); |
- } |
+ if (loadingPopups.size == 0) |
+ { |
+ chrome.webRequest.onBeforeRequest.addListener( |
+ onPopupURLChanged, |
+ { |
+ urls: ["http://*/*", "https://*/*"], |
+ types: ["main_frame"] |
+ } |
+ ); |
+ chrome.webNavigation.onCommitted.addListener(onPopupURLChanged); |
+ chrome.webNavigation.onCompleted.addListener(onCompleted); |
+ chrome.tabs.onRemoved.addListener(forgetPopup); |
+ } |
- let popup = { |
- url: details.url, |
- sourcePage: new ext.Page({id: details.sourceTabId}), |
- sourceFrame: null |
- }; |
+ let popup = { |
+ url: details.url, |
+ sourcePage: new ext.Page({id: details.sourceTabId}), |
+ sourceFrame: null |
+ }; |
- loadingPopups.set(details.tabId, popup); |
+ loadingPopups.set(details.tabId, popup); |
- let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
+ let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
- if (checkWhitelisted(popup.sourcePage, frame)) |
- { |
- forgetPopup(details.tabId); |
- } |
- else |
- { |
- popup.sourceFrame = frame; |
- checkPotentialPopup(details.tabId, popup); |
- } |
-}); |
+ if (checkWhitelisted(popup.sourcePage, frame)) |
+ { |
+ forgetPopup(details.tabId); |
+ } |
+ else |
+ { |
+ popup.sourceFrame = frame; |
+ checkPotentialPopup(details.tabId, popup); |
+ } |
+ }); |
+} |