mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-03-03 06:42:41 +01:00
parent
ab344294d7
commit
0f07cde869
@ -26,6 +26,9 @@
|
||||
function getHash(domRect){
|
||||
return hash(new Float64Array([domRect.x, domRect.y, domRect.width, domRect.height]));
|
||||
}
|
||||
function getValueHash(value){
|
||||
return hash(new Float32Array([value]));
|
||||
}
|
||||
|
||||
const registeredRects = new WeakMap();
|
||||
function registerDOMRect(domRect, notify){
|
||||
@ -46,21 +49,32 @@
|
||||
}
|
||||
|
||||
const cache = {};
|
||||
const valueCache = [{}, {}, {}, {}];
|
||||
function getFakeDomRect(window, domRect, prefs, notify){
|
||||
|
||||
var rng = randomSupply.getRng(4, window);
|
||||
function getFakeValue(value, i){
|
||||
if ((value * prefs("domRectIntegerFactor", window.location)) % 1 === 0){
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
return value + 0.01 * (rng(i) / 0xffffffff - 0.5);
|
||||
}
|
||||
}
|
||||
const hash = getHash(domRect);
|
||||
let cached = cache[hash];
|
||||
if (!cached){
|
||||
notify("fakedDOMRectReadout");
|
||||
const rng = randomSupply.getRng(4, window);
|
||||
const getFakeValue = function getFakeValue(value, i){
|
||||
const valueHash = getValueHash(value);
|
||||
const cache = valueCache[i];
|
||||
let cachedValue = cache[valueHash];
|
||||
if (typeof cachedValue === "number"){
|
||||
return cachedValue;
|
||||
}
|
||||
if ((value * prefs("domRectIntegerFactor", window.location)) % 1 === 0){
|
||||
cache[valueHash] = value;
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
const fakedValue = value + 0.01 * (rng(i) / 0xffffffff - 0.5);
|
||||
const fakedHash = getValueHash(fakedValue);
|
||||
cache[valueHash] = fakedValue;
|
||||
cache[fakedHash] = fakedValue;
|
||||
return fakedValue;
|
||||
}
|
||||
};
|
||||
cached = new domRect.constructor(
|
||||
getFakeValue(domRect.x, 0),
|
||||
getFakeValue(domRect.y, 1),
|
||||
|
@ -6,7 +6,7 @@ Version 0.5.5:
|
||||
-
|
||||
|
||||
fixes:
|
||||
-
|
||||
- Google images did not work for some users
|
||||
|
||||
known issues:
|
||||
- if a data URL is blocked the page action button does not appear
|
||||
|
Loading…
x
Reference in New Issue
Block a user