mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Added support for pixel fractions
Pixel fractions can be controlled by CSS. These fractions must not be faked. For #236.
This commit is contained in:
parent
1d5953e8c7
commit
df1d59cf52
@ -898,6 +898,15 @@
|
|||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"domRectIntegerFactor_title": {
|
||||||
|
"message": "DOMRect integer factor",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"domRectIntegerFactor_description": {
|
||||||
|
"message": "Some fraction of a pixel can be controlled by CSS. To prevent detection values of a DOMRect that multiplied with this factor are integers will not be altered.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
"theme_title": {
|
"theme_title": {
|
||||||
"message": "Theme",
|
"message": "Theme",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
@ -337,7 +337,7 @@
|
|||||||
descriptor.get = exportFunction(getter, window);
|
descriptor.get = exportFunction(getter, window);
|
||||||
|
|
||||||
if (descriptor.hasOwnProperty("set") && changedGetter.setterGenerator){
|
if (descriptor.hasOwnProperty("set") && changedGetter.setterGenerator){
|
||||||
const setter = changedGetter.setterGenerator(window, descriptor.set);
|
const setter = changedGetter.setterGenerator(window, descriptor.set, prefs);
|
||||||
descriptor.set = exportFunction(setter, window);
|
descriptor.set = exportFunction(setter, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@
|
|||||||
function getDOMRectRegistration(domRect){
|
function getDOMRectRegistration(domRect){
|
||||||
return registeredRects.get(getWrapped(domRect));
|
return registeredRects.get(getWrapped(domRect));
|
||||||
}
|
}
|
||||||
function getFakeDomRect(window, domRect, notify){
|
function getFakeDomRect(window, domRect, prefs, notify){
|
||||||
|
|
||||||
var rng = randomSupply.getRng(4, window);
|
var rng = randomSupply.getRng(4, window);
|
||||||
function getFakeValue(value, i){
|
function getFakeValue(value, i){
|
||||||
if (value % 1 === 0){
|
if ((value * prefs("domRectIntegerFactor", window.location)) % 1 === 0){
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -159,17 +159,17 @@
|
|||||||
if (prefs("protectDOMRect", window.location)){
|
if (prefs("protectDOMRect", window.location)){
|
||||||
const registration = getDOMRectRegistration(this);
|
const registration = getDOMRectRegistration(this);
|
||||||
if (registration){
|
if (registration){
|
||||||
return getFakeDomRect(window, this, registration.notify)[property];
|
return getFakeDomRect(window, this, prefs, registration.notify)[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return originalValue;
|
return originalValue;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function setProperty(domRect, window, original, newValue, property){ // eslint-disable-line max-params
|
function setProperty(domRect, window, original, newValue, property, prefs){ // eslint-disable-line max-params
|
||||||
const registration = getDOMRectRegistration(domRect);
|
const registration = getDOMRectRegistration(domRect);
|
||||||
if (registration){
|
if (registration){
|
||||||
const fakeDomRect = getFakeDomRect(window, domRect, registration.notify);
|
const fakeDomRect = getFakeDomRect(window, domRect, prefs, registration.notify);
|
||||||
registeredRects.delete(getWrapped(domRect));
|
registeredRects.delete(getWrapped(domRect));
|
||||||
["x", "y", "width", "height"].forEach(function(prop){
|
["x", "y", "width", "height"].forEach(function(prop){
|
||||||
if (prop === property){
|
if (prop === property){
|
||||||
@ -200,10 +200,10 @@
|
|||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "x").get;
|
return Object.getOwnPropertyDescriptor(temp, "x").get;
|
||||||
},
|
},
|
||||||
setterGenerator: function(window, original){
|
setterGenerator: function(window, original, prefs){
|
||||||
const temp = {
|
const temp = {
|
||||||
set x(x){
|
set x(x){
|
||||||
setProperty(this, window, original, x, "x");
|
setProperty(this, window, original, x, "x", prefs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "x").set;
|
return Object.getOwnPropertyDescriptor(temp, "x").set;
|
||||||
@ -223,10 +223,10 @@
|
|||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "y").get;
|
return Object.getOwnPropertyDescriptor(temp, "y").get;
|
||||||
},
|
},
|
||||||
setterGenerator: function(window, original){
|
setterGenerator: function(window, original, prefs){
|
||||||
const temp = {
|
const temp = {
|
||||||
set y(y){
|
set y(y){
|
||||||
setProperty(this, window, original, y, "y");
|
setProperty(this, window, original, y, "y", prefs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "y").set;
|
return Object.getOwnPropertyDescriptor(temp, "y").set;
|
||||||
@ -246,10 +246,10 @@
|
|||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "width").get;
|
return Object.getOwnPropertyDescriptor(temp, "width").get;
|
||||||
},
|
},
|
||||||
setterGenerator: function(window, original){
|
setterGenerator: function(window, original, prefs){
|
||||||
const temp = {
|
const temp = {
|
||||||
set width(width){
|
set width(width){
|
||||||
setProperty(this, window, original, width, "width");
|
setProperty(this, window, original, width, "width", prefs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "width").set;
|
return Object.getOwnPropertyDescriptor(temp, "width").set;
|
||||||
@ -269,10 +269,10 @@
|
|||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "height").get;
|
return Object.getOwnPropertyDescriptor(temp, "height").get;
|
||||||
},
|
},
|
||||||
setterGenerator: function(window, original){
|
setterGenerator: function(window, original, prefs){
|
||||||
const temp = {
|
const temp = {
|
||||||
set height(height){
|
set height(height){
|
||||||
setProperty(this, window, original, height, "height");
|
setProperty(this, window, original, height, "height", prefs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "height").set;
|
return Object.getOwnPropertyDescriptor(temp, "height").set;
|
||||||
|
@ -267,6 +267,10 @@
|
|||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
urlSpecific: true
|
urlSpecific: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "domRectIntegerFactor",
|
||||||
|
defaultValue: 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "blockDataURLs",
|
name: "blockDataURLs",
|
||||||
defaultValue: true
|
defaultValue: true
|
||||||
|
@ -411,6 +411,13 @@
|
|||||||
"displayAdvancedSettings": [true]
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "domRectIntegerFactor",
|
||||||
|
"displayDependencies": {
|
||||||
|
"protectDOMRect": [true],
|
||||||
|
"displayAdvancedSettings": [true]
|
||||||
|
}
|
||||||
|
},
|
||||||
"misc",
|
"misc",
|
||||||
{
|
{
|
||||||
"name": "theme"
|
"name": "theme"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user