mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Added linting for consistent-return
This commit is contained in:
parent
635cdf8061
commit
1aff68d802
10 changed files with 43 additions and 42 deletions
|
@ -45,7 +45,7 @@
|
|||
}
|
||||
else {
|
||||
if (isWhitelisted(window.location)){
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return changeProperty;
|
||||
|
@ -265,6 +265,10 @@
|
|||
scope.protect = function protect(window, wrappedWindow, singleCallback, allCallback){
|
||||
const changeProperty = createChangeProperty(window);
|
||||
|
||||
if (!changeProperty){
|
||||
return;
|
||||
}
|
||||
|
||||
const api = {window, wrappedWindow, changeProperty, singleCallback, allCallback};
|
||||
|
||||
protectFrameProperties(api);
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
functionName: name,
|
||||
dataURL: false
|
||||
});
|
||||
return;
|
||||
return undef;
|
||||
}
|
||||
}, windowToProcess),
|
||||
set: exportFunction(function(){}, windowToProcess)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
}
|
||||
else {
|
||||
warning("logging: Settings can only be set once.");
|
||||
return settings.loaded;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -89,6 +89,26 @@
|
|||
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;
|
||||
}
|
||||
|
||||
scope.changedGetters = [
|
||||
{
|
||||
objectGetters: [function(window){return window.Screen && window.Screen.prototype;}],
|
||||
|
@ -96,15 +116,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get width(){
|
||||
return checkerWrapper(checker, this, arguments, function(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;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, fakeWidth);
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "width").get;
|
||||
|
@ -116,15 +128,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get height(){
|
||||
return checkerWrapper(checker, this, arguments, function(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;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, fakeHeight);
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "height").get;
|
||||
|
@ -136,15 +140,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get availWidth(){
|
||||
return checkerWrapper(checker, this, arguments, function(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;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, fakeWidth);
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "availWidth").get;
|
||||
|
@ -156,15 +152,7 @@
|
|||
getterGenerator: function(checker){
|
||||
const temp = {
|
||||
get availHeight(){
|
||||
return checkerWrapper(checker, this, arguments, function(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;
|
||||
});
|
||||
return checkerWrapper(checker, this, arguments, fakeHeight);
|
||||
}
|
||||
};
|
||||
return Object.getOwnPropertyDescriptor(temp, "availHeight").get;
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
}
|
||||
else {
|
||||
logging.warning("Transient setting %s cannot be stored.", name);
|
||||
return Promise.reject("Transient setting " + name + " cannot be stored.");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -162,6 +163,7 @@
|
|||
}
|
||||
else{
|
||||
logging.warning("Invalid value for %s (%s):", name, url, newValue);
|
||||
return Promise.reject("Invalid value for " + name + " (" + url + "): " + newValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -173,6 +175,7 @@
|
|||
}
|
||||
else{
|
||||
logging.warning("Invalid value for %s:", name, newValue);
|
||||
return Promise.reject("Invalid value for " + name + ": " + newValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -307,6 +310,7 @@
|
|||
}
|
||||
else {
|
||||
logging.error("Try to set unknown setting:", name);
|
||||
return Promise.reject("Try to set unknown setting: " + name);
|
||||
}
|
||||
};
|
||||
scope.get = function(name, ...args){
|
||||
|
@ -316,6 +320,7 @@
|
|||
}
|
||||
else {
|
||||
logging.error("Try to get unknown setting:", name);
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue