diff --git a/lib/intercept.js b/lib/intercept.js index a023064..c874fb3 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -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){ diff --git a/lib/modifiedAPIFunctions.js b/lib/modifiedAPIFunctions.js index 8b3385a..edd5322 100644 --- a/lib/modifiedAPIFunctions.js +++ b/lib/modifiedAPIFunctions.js @@ -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); }