Advertisement
h0x0d

Windows 10 11082 WEBPAGE.JS

Dec 17th, 2015
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function (nativeMsBrowser) {
  2.     nativeJSON = window.JSON;
  3.     Object.defineProperty(window, "msBrowser", {
  4.         get: delayInitMsBrowser,
  5.         configurable: true,
  6.         enumerable: true
  7.     });
  8.  
  9.     function delayInitMsBrowser() {
  10.         var wrapMsBrowser = Object.defineProperties({}, {
  11.             "runtime": {
  12.                 get: delayInitRuntime,
  13.                 configurable: true,
  14.                 enumerable: true
  15.             }
  16.         });
  17.  
  18.         // Replace delayInit with the initialized object to avoid repeated calls to delayInit.
  19.         Object.defineProperty(window, "msBrowser", {
  20.             value: wrapMsBrowser,
  21.             configurable: true,
  22.             enumerable: true
  23.         });
  24.  
  25.         return wrapMsBrowser;
  26.     }
  27.  
  28.     function delayInitRuntime() {
  29.         var wrapRuntime = {};
  30.  
  31.         Object.defineProperties(wrapRuntime, {
  32.             "sendMessage": {
  33.                 value: sendMessageIndirect.bind(nativeMsBrowser.runtime),
  34.                 configurable: true,
  35.                 enumerable: true
  36.             }
  37.         });
  38.  
  39.         function sendMessageIndirect(/* optional string extensionId, any message, optional object options, optional function responseCallback */) {
  40.  
  41.             if (arguments.length < 1) {
  42.                 return null;
  43.             }
  44.  
  45.             var index = arguments.length - 1;
  46.  
  47.             var responseCallback = null;
  48.             if (typeof arguments[index] === "function") {
  49.                 responseCallback = responseCallbackIndirect(arguments[index]);
  50.                 --index;
  51.             }
  52.  
  53.             var options = null;
  54.             if (index >= 2) {
  55.                 // More than two arguments remain so options param must  present.
  56.                 options = arguments[index];
  57.                 --index;
  58.             }
  59.             else if (index === 2) {
  60.                 // The logic: assume that the first param is the optional extension id if it is present and is a string, hence no options argument in this case.
  61.                 if (!(arguments[0] === null || typeof arguments[0] === "string")) {
  62.                     options = arguments[index];
  63.                     --index;
  64.                 }
  65.             }
  66.  
  67.             var message = arguments[index]; // Must be present.
  68.             --index;
  69.  
  70.             var extensionId = null;
  71.             if (index >= 0) {
  72.                 extensionId = arguments[index];
  73.                 --index;
  74.             }
  75.  
  76.             if (index !== -1) {
  77.                 // Requires exact number of arguments, no extra arguments allowed.
  78.                 return null;
  79.             }
  80.             else {
  81.                 // Always stringify on sendMessage side and always parse on the callback side.
  82.                 // Otherwise, callback cannot distinuish between a message sending an object and another message sending its string equivalent.
  83.                 return nativeMsBrowser.runtime.sendMessage(extensionId, nativeJSON.stringify(message), options, responseCallback);
  84.             }
  85.         };
  86.  
  87.         // Replace delayInit with the initialized object to avoid repeated calls to delayInit.
  88.         Object.defineProperty(window.msBrowser, "runtime", {
  89.             value: wrapRuntime,
  90.             configurable: true,
  91.             enumerable: true
  92.         });
  93.         return wrapRuntime;
  94.     }
  95. })(window.msBrowser);
  96.  
  97. // !!! End of File: be careful if you have to change the following line.
  98. // There is a null character at end of this line, enabling this resource to be used as a null terminated string:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement