1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Only Firefox < 57 block on pre-intercept

This commit is contained in:
kkapsner 2017-12-13 20:15:50 +01:00
parent 67438d15ff
commit 3fcc5774c2
3 changed files with 32 additions and 22 deletions

View File

@ -65,6 +65,12 @@
scope.intercept({subject: window}, apis);
}
else {
let firefoxVersion = navigator.userAgent.match(/Firefox\/([\d.]+)$/);
let forceLoad = true;
if (firefoxVersion){
let versionParts = firefoxVersion[1].split(".");
forceLoad = parseInt(versionParts[0], 10) >= 57;
}
let preIntercepted = false;
let intercepted = false;
const forEachFunction = function(callback){
@ -96,25 +102,29 @@
enumerable: true,
configureable: true,
get: exportFunction(function(){
var url = getURL(window);
if (!url){
return undef;
if (forceLoad){
undoPreIntercept();
settings.forceLoad();
doRealIntercept();
var descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name);
return descriptor.value || descriptor.get();
}
else {
var url = getURL(window);
if (!url){
return undef;
}
var error = new Error();
apis.notify({
url,
errorStack: error.stack,
messageId: "preBlock",
timestamp: new Date(),
functionName: name,
dataURL: false
});
return;
}
var error = new Error();
apis.notify({
url,
errorStack: error.stack,
messageId: "preBlock",
timestamp: new Date(),
functionName: name,
dataURL: false
});
return;
// undoPreIntercept();
// settings.forceLoad();
// doRealIntercept();
// var descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name);
// return descriptor.value || descriptor.get();
}, window),
set: exportFunction(function(){}, window)
}

View File

@ -1,9 +1,7 @@
Version 0.4.3:
todos:
-
changes:
- hide white, black and ignore list as they can be done with the url specific settings. They are still present and working in the background.
- if settings are not loaded fast enough the loading is not force but all APIs are blocked (only Firefox < 57)
new features:
- reset settings

View File

@ -55,7 +55,8 @@
secondFingerprint = fingerPrint();
if (firstFingerprint === secondFingerprint){
hash(firstFingerprint).then(function(hash){
document.body.appendChild(document.createTextNode("fingerprint consistent (" + firstFingerprint + ") -> good!"));
document.body.appendChild(document.createTextNode("fingerprint consistent (" + hash + ") -> good!"));
document.body.style.backgroundColor = "green";
});
}
else {
@ -68,6 +69,7 @@
}
else {
document.body.textContent = "context API blocked";
document.body.style.backgroundColor = "orange";
}
</script>
</body></html>