mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
parent
b7ba5c2050
commit
a181780020
3 changed files with 50 additions and 82 deletions
|
@ -89,24 +89,20 @@
|
|||
return window.screen;
|
||||
}
|
||||
|
||||
function fakeWidth(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const returnValue = Math.round(getScreenDimensions(prefs, window).width);
|
||||
if (originalValue !== returnValue){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
function fakeHeight(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const returnValue = Math.round(getScreenDimensions(prefs, window).height);
|
||||
if (originalValue !== returnValue){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return returnValue;
|
||||
function getFaker(dimension){
|
||||
return function fake(args, check){
|
||||
const {prefs, notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const returnValue = (typeof dimension) === "function"?
|
||||
dimension(window):
|
||||
dimension?
|
||||
Math.round(getScreenDimensions(prefs, window)[dimension]):
|
||||
0;
|
||||
if (originalValue !== returnValue){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return returnValue;
|
||||
};
|
||||
}
|
||||
|
||||
scope.changedGetters = [
|
||||
|
@ -116,7 +112,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get width(){
|
||||
return checkerWrapper(checker, this, arguments, fakeWidth);
|
||||
return checkerWrapper(checker, this, arguments, getFaker("width"));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "width").get;
|
||||
|
@ -128,7 +124,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get height(){
|
||||
return checkerWrapper(checker, this, arguments, fakeHeight);
|
||||
return checkerWrapper(checker, this, arguments, getFaker("height"));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "height").get;
|
||||
|
@ -140,7 +136,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get availWidth(){
|
||||
return checkerWrapper(checker, this, arguments, fakeWidth);
|
||||
return checkerWrapper(checker, this, arguments, getFaker("width"));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "availWidth").get;
|
||||
|
@ -152,7 +148,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get availHeight(){
|
||||
return checkerWrapper(checker, this, arguments, fakeHeight);
|
||||
return checkerWrapper(checker, this, arguments, getFaker("height"));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "availHeight").get;
|
||||
|
@ -164,14 +160,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get availLeft(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
if (originalValue !== 0){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, getFaker(0));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "availLeft").get;
|
||||
|
@ -183,14 +172,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get availTop(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
if (originalValue !== 0){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, getFaker(0));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "availTop").get;
|
||||
|
@ -202,15 +184,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get outerWidth(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const returnValue = window.innerWidth;
|
||||
if (originalValue !== returnValue){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return returnValue;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, getFaker(window => window.innerWidth));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "outerWidth").get;
|
||||
|
@ -222,15 +196,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get outerHeight(){
|
||||
return checkerWrapper(checker, this, arguments, function(args, check){
|
||||
const {notify, window, original} = check;
|
||||
const originalValue = original.apply(this, window.Array.from(args));
|
||||
const returnValue = window.innerHeight;
|
||||
if (originalValue !== returnValue){
|
||||
notify("fakedScreenReadout");
|
||||
}
|
||||
return returnValue;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, getFaker(window => window.innerHeight));
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "outerHeight").get;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue