From 3fcc5774c2c5f74ef112b9b84ec0478d610a9683 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Wed, 13 Dec 2017 20:15:50 +0100 Subject: [PATCH] Only Firefox < 57 block on pre-intercept --- lib/intercept.js | 46 ++++++++++++++++++++++++---------------- releaseNotes.txt | 4 +--- test/settingsLoading.php | 4 +++- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/lib/intercept.js b/lib/intercept.js index 7884981..953a5b2 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -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) } diff --git a/releaseNotes.txt b/releaseNotes.txt index 0027373..d364ee0 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -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 diff --git a/test/settingsLoading.php b/test/settingsLoading.php index de32117..cb01fc3 100644 --- a/test/settingsLoading.php +++ b/test/settingsLoading.php @@ -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"; } \ No newline at end of file