Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script data-x-lastpass="">
- (function() {
- /** @type {number} */
- var requestID = 0;
- if ("undefined" !== typeof CustomEvent && "function" === typeof window.dispatchEvent) {
- /**
- * @param {string} object
- * @return {?}
- */
- var dispatchEvent = function(object) {
- try {
- if ("object" === typeof object && (object = JSON.stringify(object)), "string" === typeof object) {
- return window.dispatchEvent(new CustomEvent("lprequeststart", {
- detail : {
- data : object,
- requestID : ++requestID
- }
- })), requestID;
- }
- } catch (f) {
- }
- };
- /**
- * @param {number} opt_attributes
- * @return {undefined}
- */
- var nextTick = function(opt_attributes) {
- try {
- window.dispatchEvent(new CustomEvent("lprequestend", {
- detail : opt_attributes
- }));
- } catch (f) {
- }
- };
- if ("undefined" !== typeof XMLHttpRequest) {
- if (XMLHttpRequest.prototype) {
- if (XMLHttpRequest.prototype.send) {
- XMLHttpRequest.prototype.send = function(matcherFunction) {
- return function(el) {
- var xhr = this;
- var result = dispatchEvent(el);
- if (result) {
- xhr.addEventListener("loadend", function() {
- nextTick({
- requestID : result,
- statusCode : xhr.status
- });
- });
- }
- return matcherFunction.apply(xhr, arguments);
- };
- }(XMLHttpRequest.prototype.send);
- }
- }
- }
- if ("function" === typeof fetch) {
- fetch = function(matcherFunction) {
- return function(dataAndEvents, el) {
- var result = dispatchEvent(el);
- var promise = matcherFunction.apply(this, arguments);
- if (result) {
- /**
- * @param {Object} xhr
- * @return {undefined}
- */
- var handler = function(xhr) {
- nextTick({
- requestID : result,
- statusCode : xhr && xhr.status
- });
- };
- promise.then(handler)["catch"](handler);
- }
- return promise;
- };
- }(fetch);
- }
- }
- })();
- (function() {
- if ("undefined" !== typeof CustomEvent) {
- /**
- * @param {Function} object
- * @return {?}
- */
- var freeze = function(object) {
- if (object.lpsubmit) {
- return object;
- }
- /**
- * @return {?}
- */
- var fire = function() {
- try {
- this.dispatchEvent(new CustomEvent("lpsubmit"));
- } catch (k) {
- }
- return object.apply(this, arguments);
- };
- /** @type {boolean} */
- fire.lpsubmit = true;
- return fire;
- };
- window.addEventListener("DOMContentLoaded", function() {
- if (document && (document.forms && 0 < document.forms.length)) {
- /** @type {number} */
- var i = 0;
- for (;i < document.forms.length;++i) {
- document.forms[i].submit = freeze(document.forms[i].submit);
- }
- }
- }, true);
- document.createElement = function(matcherFunction) {
- return function() {
- /** @type {Element} */
- var fn = matcherFunction.apply(this, arguments);
- if (fn) {
- if ("FORM" === fn.nodeName) {
- if (fn.submit) {
- fn.submit = freeze(fn.submit);
- }
- }
- }
- return fn;
- };
- }(document.createElement);
- }
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement