From c596c91edbf345dd41dc6757b3dcef4260a695b4 Mon Sep 17 00:00:00 2001 From: Elliott Beach Date: Sat, 2 Dec 2017 13:27:18 -0600 Subject: [PATCH] block doubly-opening open --- add-on/lib/proxyblock.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/add-on/lib/proxyblock.js b/add-on/lib/proxyblock.js index d4f43bb..020fcc1 100644 --- a/add-on/lib/proxyblock.js +++ b/add-on/lib/proxyblock.js @@ -199,19 +199,22 @@ } }; - const oldWindowOpen = window.open; - const windowOpenProxy = new Proxy(window.open, { - apply: function (target, thisArg, argumentsList) { - console.log("window.open =", oldWindowOpen); - const wnd = oldWindowOpen.apply(thisArg, argumentsList); - featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v, wnd)); - return wnd; - } - }); - Object.defineProperty(window, "open", { - get: () => windowOpenProxy - }); + const blockOpen = function(window){ + const oldWindowOpen = window.open; + const windowOpenProxy = new Proxy(window.open, { + apply: function (target, thisArg, argumentsList) { + const wnd = oldWindowOpen.apply(thisArg, argumentsList); + blockOpen(wnd); + featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v, wnd)); + return wnd; + } + }); + Object.defineProperty(window, "open", { + get: () => windowOpenProxy + }); + } + blockOpen(window); featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v)); // Next, delete the WEB_API_MANAGER_PAGE global property. Technically