Merge pull request #1 from elliott-beach/patch-open2

block doubly-opening open
This commit is contained in:
Michael Zhang 2017-12-02 14:41:17 -06:00 committed by GitHub
commit 5a9b140ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -199,19 +199,22 @@
} }
}; };
const oldWindowOpen = window.open; const blockOpen = function(window){
const windowOpenProxy = new Proxy(window.open, { const oldWindowOpen = window.open;
apply: function (target, thisArg, argumentsList) { const windowOpenProxy = new Proxy(window.open, {
console.log("window.open =", oldWindowOpen); apply: function (target, thisArg, argumentsList) {
const wnd = oldWindowOpen.apply(thisArg, argumentsList); const wnd = oldWindowOpen.apply(thisArg, argumentsList);
featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v, wnd)); blockOpen(wnd);
return wnd; featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v, wnd));
} return wnd;
}); }
Object.defineProperty(window, "open", { });
get: () => windowOpenProxy Object.defineProperty(window, "open", {
}); get: () => windowOpenProxy
});
}
blockOpen(window);
featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v)); featuresToBlock.forEach((v) => blockFeatureAtKeyPath(v));
// Next, delete the WEB_API_MANAGER_PAGE global property. Technically // Next, delete the WEB_API_MANAGER_PAGE global property. Technically