1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-15 14:09:36 +02:00

about:blank pages are treated with respect to the opening page

This commit is contained in:
kkapsner 2017-01-31 20:00:02 +01:00
parent b563a9d3ca
commit ec1ae73cda
3 changed files with 31 additions and 4 deletions

View file

@ -21,8 +21,22 @@
}
}
exports.setRandomSupplyByType = setRandomSupplyByType;
function getURL(window){
if (window.location.href === "about:blank"){
if (window !== window.parent){
return getURL(window.parent);
}
else if (window.opener){
return getURL(window.opener);
}
}
return window.location.href;
}
exports.intercept = function intercept({subject: window}, {check, checkStack, ask, notify, prefs}){
var siteStatus = check({url: window.location.href});
var siteStatus = check({url: getURL(window)});
if (siteStatus.mode !== "allow"){
apiNames.forEach(function(name){
var changedFunction = changedFunctions[name];
@ -37,7 +51,8 @@
enumerable: true,
configureable: false,
get: function(){
if (!window.location.href){
var url = getURL(window);
if (!url){
return undef;
}
var error = new Error();
@ -56,7 +71,7 @@
case "fake":
setRandomSupplyByType(prefs("rng"));
var fake = changedFunction.fakeGenerator(prefs, function(messageId){
notify({url: window.location.href, errorStack: error.stack, messageId});
notify({url, errorStack: error.stack, messageId});
}, original);
switch (fake){
case true: