mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 18:42:00 +01:00
Minor performance improvements
This commit is contained in:
parent
a89bf0aba8
commit
103397e35d
@ -59,7 +59,7 @@
|
|||||||
return getURL(window.opener);
|
return getURL(window.opener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return window.location.href;
|
return href;
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.preIntercept = function preIntercept({subject: window}, apis){
|
scope.preIntercept = function preIntercept({subject: window}, apis){
|
||||||
@ -200,15 +200,13 @@
|
|||||||
}
|
}
|
||||||
function generateChecker(name, changedFunction, siteStatus, original){
|
function generateChecker(name, changedFunction, siteStatus, original){
|
||||||
return function checker(callingDepth = 2){
|
return function checker(callingDepth = 2){
|
||||||
const url = getURL(window);
|
|
||||||
if (!url){
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
const error = new Error();
|
const error = new Error();
|
||||||
|
const errorStack = error.stack;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// return original if the extension itself requested the function
|
// return original if the extension itself requested the function
|
||||||
if (
|
if (
|
||||||
error.stack
|
errorStack
|
||||||
.split("\n", callingDepth + 2)[callingDepth + 1]
|
.split("\n", callingDepth + 2)[callingDepth + 1]
|
||||||
.split("@", callingDepth + 1)[1]
|
.split("@", callingDepth + 1)[1]
|
||||||
.startsWith(extensionID)
|
.startsWith(extensionID)
|
||||||
@ -219,7 +217,7 @@
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
// stack had an unknown form
|
// stack had an unknown form
|
||||||
}
|
}
|
||||||
if (checkStack(error.stack)){
|
if (checkStack(errorStack)){
|
||||||
return {allow: true, original, window};
|
return {allow: true, original, window};
|
||||||
}
|
}
|
||||||
const funcStatus = changedFunction.getStatus(this, siteStatus, prefs);
|
const funcStatus = changedFunction.getStatus(this, siteStatus, prefs);
|
||||||
@ -227,8 +225,8 @@
|
|||||||
const This = this;
|
const This = this;
|
||||||
function notifyCallback(messageId){
|
function notifyCallback(messageId){
|
||||||
notify({
|
notify({
|
||||||
url,
|
url: getURL(window),
|
||||||
errorStack: error.stack,
|
errorStack,
|
||||||
messageId,
|
messageId,
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
functionName: name,
|
functionName: name,
|
||||||
@ -257,7 +255,7 @@
|
|||||||
this.canvas:
|
this.canvas:
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
errorStack: error.stack
|
errorStack
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
switch (funcStatus.mode){
|
switch (funcStatus.mode){
|
||||||
|
@ -13,25 +13,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.getWrapped = function getWrapped(obj){
|
scope.getWrapped = function getWrapped(obj){
|
||||||
if (!obj){
|
return obj && (obj.wrappedJSObject || obj);
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
var wrapped;
|
|
||||||
try {
|
|
||||||
wrapped = obj.wrappedJSObject || obj;
|
|
||||||
}
|
|
||||||
catch (e){
|
|
||||||
require("./logging").error("getWrapped failed for", obj, ":", e);
|
|
||||||
wrapped = obj;
|
|
||||||
}
|
|
||||||
return wrapped;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){
|
scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){
|
||||||
const check = checker.call(object);
|
const check = checker.call(object);
|
||||||
if (check.allow){
|
if (check.allow){
|
||||||
if (check.allow === true){
|
if (check.allow === true){
|
||||||
return check.original.apply(object, check.window.Array.from(args));
|
return args.length?
|
||||||
|
check.original.apply(object, check.window.Array.from(args)):
|
||||||
|
check.original.call(object);
|
||||||
}
|
}
|
||||||
return callback.call(object, args, check);
|
return callback.call(object, args, check);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user