mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
about:blank pages are treated with respect to the opening page
This commit is contained in:
parent
b563a9d3ca
commit
ec1ae73cda
@ -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:
|
||||
|
@ -5,10 +5,21 @@
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
function getDomain(window){
|
||||
if (window.location.href === "about:blank"){
|
||||
if (window !== window.parent){
|
||||
return getDomain(window.parent);
|
||||
}
|
||||
else if (window.opener){
|
||||
return getDomain(window.opener);
|
||||
}
|
||||
}
|
||||
return window.location.host;
|
||||
}
|
||||
const persistentRnd = Object.create(null);
|
||||
exports.persistent = {
|
||||
getRng: function(length, window){
|
||||
var domain = window.document.location.host;
|
||||
var domain = getDomain(window);
|
||||
if (!persistentRnd[domain]){
|
||||
// create the (sub-)domains random numbers if not existing
|
||||
persistentRnd[domain] = new Uint8Array(128);
|
||||
|
@ -10,6 +10,7 @@ Version 0.3.6:
|
||||
- faking webGL
|
||||
- added readPixels for webGL2
|
||||
- removed error message when notification can not be closed
|
||||
- about:blank pages are treated with respect to the opening page
|
||||
|
||||
Version 0.3.5
|
||||
new features:
|
||||
|
Loading…
x
Reference in New Issue
Block a user