From 507ec8c8eeef5d42b3ac21eb9c27277b7ae3713e Mon Sep 17 00:00:00 2001 From: fkloft Date: Sat, 7 Feb 2015 15:50:43 +0100 Subject: [PATCH 1/2] Use unminified source for chain.js --- external/load.js | 154 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 1 deletion(-) diff --git a/external/load.js b/external/load.js index ed4381da..27aacf19 100644 --- a/external/load.js +++ b/external/load.js @@ -1,7 +1,159 @@ /* Copyright (c) 2010 Chris O'Hara . MIT Licensed */ //Include the chain.js microframework (http://github.com/chriso/chain.js) -(function(a){a=a||{};var b={},c,d;c=function(a,d,e){var f=a.halt=!1;a.error=function(a){throw a},a.next=function(c){c&&(f=!1);if(!a.halt&&d&&d.length){var e=d.shift(),g=e.shift();f=!0;try{b[g].apply(a,[e,e.length,g])}catch(h){a.error(h)}}return a};for(var g in b){if(typeof a[g]==="function")continue;(function(e){a[e]=function(){var g=Array.prototype.slice.call(arguments);if(e==="onError"){if(d){b.onError.apply(a,[g,g.length]);return a}var h={};b.onError.apply(h,[g,g.length]);return c(h,null,"onError")}g.unshift(e);if(!d)return c({},[g],e);a.then=a[e],d.push(g);return f?a:a.next()}})(g)}e&&(a.then=a[e]),a.call=function(b,c){c.unshift(b),d.unshift(c),a.next(!0)};return a.next()},d=a.addMethod=function(d){var e=Array.prototype.slice.call(arguments),f=e.pop();for(var g=0,h=e.length;g' + //e.g. adding 'run' also adds 'thenRun' as a method + if (!--len) { + handlers['then' + method.substr(0,1).toUpperCase() + method.substr(1)] = handler; + } + createChain(exports); + }; + + //chain() - Run each function sequentially + add('chain', function (args) { + var self = this, next = function () { + if (self.halt) { + return; + } else if (!args.length) { + return self.next(true); + } + try { + if (null != args.shift().call(self, next, self.error)) { + next(); + } + } catch (e) { + self.error(e); + } + }; + next(); + }); + + //run() - Run each function in parallel and progress once all functions are complete + add('run', function (args, arg_len) { + var self = this, chain = function () { + if (self.halt) { + return; + } else if (!--arg_len) { + self.next(true); + } + }; + var error = function (e) { + self.error(e); + }; + for (var i = 0, len = arg_len; !self.halt && i < len; i++) { + if (null != args[i].call(self, chain, error)) { + chain(); + } + } + }); + + //defer() - Defer execution of the next method + add('defer', function (args) { + var self = this; + setTimeout(function () { + self.next(true); + }, args.shift()); + }); + + //onError() - Attach an error handler + add('onError', function (args, arg_len) { + var self = this; + this.error = function (err) { + self.halt = true; + for (var i = 0; i < arg_len; i++) { + args[i].call(self, err); + } + }; + }); + +}(this)); + var head = document.getElementsByTagName('head')[0] || document.documentElement; From 57fc2295b3a44b3b9cd37485b0c2ca2008624b29 Mon Sep 17 00:00:00 2001 From: fkloft Date: Sat, 7 Feb 2015 18:25:40 +0100 Subject: [PATCH 2/2] Fix error in botguard detection access to top.opener would throw a SecurityError if opened from intel link. --- code/extract_niantic_parameters.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/extract_niantic_parameters.js b/code/extract_niantic_parameters.js index f03e7804..9ca99b81 100644 --- a/code/extract_niantic_parameters.js +++ b/code/extract_niantic_parameters.js @@ -21,8 +21,12 @@ window.extractFromStock = function() { if(!window[topLevel]) continue; // need an example for a request object for(var property in window[topLevel]) { - if(window[topLevel][property] == "getRegionScoreDetails") { - return Object.getPrototypeOf(window[topLevel]); + try { + if(window[topLevel][property] == "getRegionScoreDetails") { + return Object.getPrototypeOf(window[topLevel]); + } + } catch(e) { // might throw SecurityError or others (noticed on top.opener, which might be cross-origin) + continue; } } }