Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix ##4522: Removes canvas rule on fingerprint protection #4523
Browse files Browse the repository at this point in the history
  • Loading branch information
gpestana authored and iccub committed Jan 4, 2022
1 parent f699f2a commit 464a092
Showing 1 changed file with 0 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,11 @@ if (webkit.messageHandlers.$<handler>) {
}
}

function installIFrameMethodTrap(obj, method) {
let orig = obj[method];
obj[method] = function () {
var last = arguments[arguments.length - 1]
if (last && last.toLowerCase() === 'canvas') {
// Prevent fingerprinting using contentDocument.createElement('canvas'),
// which evades trapInstanceMethod when the iframe is sandboxed
sendMessage({ obj: `${obj}`, method: method })
} else {
// Otherwise apply the original method
return orig.apply(this, arguments)
}
};
return orig;
}

let hooks = [
{
obj: window.CanvasRenderingContext2D.prototype,
methods: ['getImageData', 'getLineDash', 'measureText']
},
{
obj: window.HTMLCanvasElement.prototype,
methods: ['toDataURL', 'toBlob']
},
{
obj: window.WebGLRenderingContext.prototype,
methods: ['getSupportedExtensions', 'getParameter', 'getContextAttributes', 'getShaderPrecisionFormat', 'getExtension']
Expand All @@ -58,10 +38,5 @@ if (webkit.messageHandlers.$<handler>) {
});
});

// Install iframe Document Hooks
if (window.frameElement) {
installIFrameMethodTrap(document, 'createElement');
installIFrameMethodTrap(document, 'createElementNS');
}
})();
}

0 comments on commit 464a092

Please sign in to comment.