diff --git a/src/js/contentscripts/fingerprinting.js b/src/js/contentscripts/fingerprinting.js index 28cdb4641b..d1b2faebda 100644 --- a/src/js/contentscripts/fingerprinting.js +++ b/src/js/contentscripts/fingerprinting.js @@ -204,9 +204,16 @@ function getFpPageScript() { ); item.obj[item.propName] = (function (orig) { + // set to true after the first write, if the method is not + // restorable. Happens if another library also overwrites + // this method. + var skipMonitoring = false; function wrapped() { var args = arguments; + if (skipMonitoring) { + return orig.apply(this, args); + } if (is_canvas_write) { // to avoid false positives, @@ -237,7 +244,13 @@ function getFpPageScript() { // optimization: one canvas write is enough, // restore original write method // to this CanvasRenderingContext2D object instance - this[item.propName] = orig; + // Careful! Only restorable if we haven't already been replaced + // by another lib, such as the hidpi polyfill + if (this[item.propName] === wrapped) { + this[item.propName] = orig; + } else { + skipMonitoring = true; + } } return orig.apply(this, args);