Advertisement
Guest User

LastPass Injected Javascript

a guest
Feb 4th, 2017
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script data-x-lastpass="">
  2. (function() {
  3.   /** @type {number} */
  4.   var requestID = 0;
  5.   if ("undefined" !== typeof CustomEvent && "function" === typeof window.dispatchEvent) {
  6.     /**
  7.      * @param {string} object
  8.      * @return {?}
  9.      */
  10.     var dispatchEvent = function(object) {
  11.       try {
  12.         if ("object" === typeof object && (object = JSON.stringify(object)), "string" === typeof object) {
  13.           return window.dispatchEvent(new CustomEvent("lprequeststart", {
  14.             detail : {
  15.               data : object,
  16.               requestID : ++requestID
  17.             }
  18.           })), requestID;
  19.         }
  20.       } catch (f) {
  21.       }
  22.     };
  23.     /**
  24.      * @param {number} opt_attributes
  25.      * @return {undefined}
  26.      */
  27.     var nextTick = function(opt_attributes) {
  28.       try {
  29.         window.dispatchEvent(new CustomEvent("lprequestend", {
  30.           detail : opt_attributes
  31.         }));
  32.       } catch (f) {
  33.       }
  34.     };
  35.     if ("undefined" !== typeof XMLHttpRequest) {
  36.       if (XMLHttpRequest.prototype) {
  37.         if (XMLHttpRequest.prototype.send) {
  38.           XMLHttpRequest.prototype.send = function(matcherFunction) {
  39.             return function(el) {
  40.               var xhr = this;
  41.               var result = dispatchEvent(el);
  42.               if (result) {
  43.                 xhr.addEventListener("loadend", function() {
  44.                   nextTick({
  45.                     requestID : result,
  46.                     statusCode : xhr.status
  47.                   });
  48.                 });
  49.               }
  50.               return matcherFunction.apply(xhr, arguments);
  51.             };
  52.           }(XMLHttpRequest.prototype.send);
  53.         }
  54.       }
  55.     }
  56.     if ("function" === typeof fetch) {
  57.       fetch = function(matcherFunction) {
  58.         return function(dataAndEvents, el) {
  59.           var result = dispatchEvent(el);
  60.           var promise = matcherFunction.apply(this, arguments);
  61.           if (result) {
  62.             /**
  63.              * @param {Object} xhr
  64.              * @return {undefined}
  65.              */
  66.             var handler = function(xhr) {
  67.               nextTick({
  68.                 requestID : result,
  69.                 statusCode : xhr && xhr.status
  70.               });
  71.             };
  72.             promise.then(handler)["catch"](handler);
  73.           }
  74.           return promise;
  75.         };
  76.       }(fetch);
  77.     }
  78.   }
  79. })();
  80. (function() {
  81.   if ("undefined" !== typeof CustomEvent) {
  82.     /**
  83.      * @param {Function} object
  84.      * @return {?}
  85.      */
  86.     var freeze = function(object) {
  87.       if (object.lpsubmit) {
  88.         return object;
  89.       }
  90.       /**
  91.        * @return {?}
  92.        */
  93.       var fire = function() {
  94.         try {
  95.           this.dispatchEvent(new CustomEvent("lpsubmit"));
  96.         } catch (k) {
  97.         }
  98.         return object.apply(this, arguments);
  99.       };
  100.       /** @type {boolean} */
  101.       fire.lpsubmit = true;
  102.       return fire;
  103.     };
  104.     window.addEventListener("DOMContentLoaded", function() {
  105.       if (document && (document.forms && 0 < document.forms.length)) {
  106.         /** @type {number} */
  107.         var i = 0;
  108.         for (;i < document.forms.length;++i) {
  109.           document.forms[i].submit = freeze(document.forms[i].submit);
  110.         }
  111.       }
  112.     }, true);
  113.     document.createElement = function(matcherFunction) {
  114.       return function() {
  115.         /** @type {Element} */
  116.         var fn = matcherFunction.apply(this, arguments);
  117.         if (fn) {
  118.           if ("FORM" === fn.nodeName) {
  119.             if (fn.submit) {
  120.               fn.submit = freeze(fn.submit);
  121.             }
  122.           }
  123.         }
  124.         return fn;
  125.       };
  126.     }(document.createElement);
  127.   }
  128. })();
  129. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement