mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Get rid of eval.
This commit is contained in:
parent
32f9ea7447
commit
14a4d1cdc2
10 changed files with 96 additions and 50 deletions
|
@ -12,7 +12,8 @@
|
|||
scope = require.register("./modifiedDOMRectAPI", {});
|
||||
}
|
||||
|
||||
const {getWrapped, checkerWrapper, setProperties, getStatusByFlag} = require("./modifiedAPIFunctions");
|
||||
const extension = require("./extension");
|
||||
const {checkerWrapper, setProperties, getStatusByFlag} = require("./modifiedAPIFunctions");
|
||||
const {byteArrayToString: hash} = require("./hash");
|
||||
|
||||
|
||||
|
@ -30,7 +31,7 @@
|
|||
|
||||
const registeredRects = new WeakMap();
|
||||
function registerDOMRect(domRect, notify, window, prefs){
|
||||
registeredRects.set(getWrapped(domRect), {
|
||||
registeredRects.set(extension.getWrapped(domRect), {
|
||||
notify: function(){
|
||||
let done = false;
|
||||
return function(message){
|
||||
|
@ -45,7 +46,7 @@
|
|||
});
|
||||
}
|
||||
function getDOMRectRegistration(domRect){
|
||||
return registeredRects.get(getWrapped(domRect));
|
||||
return registeredRects.get(extension.getWrapped(domRect));
|
||||
}
|
||||
|
||||
const cache = {};
|
||||
|
@ -159,8 +160,8 @@
|
|||
],
|
||||
name: property,
|
||||
getterGenerator: function(){
|
||||
const temp = eval(`({
|
||||
get ${property}(){
|
||||
const temp = {
|
||||
get [property](){
|
||||
const registration = getDOMRectRegistration(this);
|
||||
if (registration){
|
||||
return getFakeDomRect(
|
||||
|
@ -168,24 +169,24 @@
|
|||
this,
|
||||
registration.prefs,
|
||||
registration.notify
|
||||
).${property};
|
||||
)[property];
|
||||
}
|
||||
return this.${property};
|
||||
return this[property];
|
||||
}
|
||||
})`);
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, property).get;
|
||||
}
|
||||
};
|
||||
if (!readonly){
|
||||
changedGetter.setterGenerator = function(window, original, prefs){
|
||||
const temp = eval(`({
|
||||
set ${property}(newValue){
|
||||
const temp = {
|
||||
set [property](newValue){
|
||||
const registration = getDOMRectRegistration(this);
|
||||
if (registration){
|
||||
const fakeDomRect = getFakeDomRect(window, this, prefs, registration.notify);
|
||||
registeredRects.delete(getWrapped(this));
|
||||
registeredRects.delete(extension.getWrapped(this));
|
||||
["x", "y", "width", "height"].forEach((prop) => {
|
||||
if (prop === "${property}"){
|
||||
if (prop === property){
|
||||
this[prop] = newValue;
|
||||
}
|
||||
else {
|
||||
|
@ -197,7 +198,7 @@
|
|||
original.apply(this, window.Array.from(arguments));
|
||||
}
|
||||
}
|
||||
})`);
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, property).set;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue