1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Minor performance improvements

This commit is contained in:
kkapsner 2019-05-10 01:11:31 +02:00
parent a89bf0aba8
commit 103397e35d
2 changed files with 12 additions and 23 deletions

View File

@ -59,7 +59,7 @@
return getURL(window.opener);
}
}
return window.location.href;
return href;
}
scope.preIntercept = function preIntercept({subject: window}, apis){
@ -200,15 +200,13 @@
}
function generateChecker(name, changedFunction, siteStatus, original){
return function checker(callingDepth = 2){
const url = getURL(window);
if (!url){
return undef;
}
const error = new Error();
const errorStack = error.stack;
try {
// return original if the extension itself requested the function
if (
error.stack
errorStack
.split("\n", callingDepth + 2)[callingDepth + 1]
.split("@", callingDepth + 1)[1]
.startsWith(extensionID)
@ -219,7 +217,7 @@
catch (e) {
// stack had an unknown form
}
if (checkStack(error.stack)){
if (checkStack(errorStack)){
return {allow: true, original, window};
}
const funcStatus = changedFunction.getStatus(this, siteStatus, prefs);
@ -227,8 +225,8 @@
const This = this;
function notifyCallback(messageId){
notify({
url,
errorStack: error.stack,
url: getURL(window),
errorStack,
messageId,
timestamp: new Date(),
functionName: name,
@ -257,7 +255,7 @@
this.canvas:
false
),
errorStack: error.stack
errorStack
});
}
switch (funcStatus.mode){

View File

@ -13,25 +13,16 @@
}
scope.getWrapped = function getWrapped(obj){
if (!obj){
return obj;
}
var wrapped;
try {
wrapped = obj.wrappedJSObject || obj;
}
catch (e){
require("./logging").error("getWrapped failed for", obj, ":", e);
wrapped = obj;
}
return wrapped;
return obj && (obj.wrappedJSObject || obj);
};
scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){
const check = checker.call(object);
if (check.allow){
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);
}