Advertisement
NikolayBezay

Untitled

Nov 10th, 2022
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. (function() {
  2. var self = {
  3. "versionId": "62e8ec83c75a390025823078",
  4. "identifier": "__ADORIC__1",
  5. "campaignId": "62e81a998240af001ef3301a",
  6. "campaignTitle": "Inpage: Free shipping cylinder page",
  7. "versionTitle": "Variation #2",
  8. "currentStep": 0,
  9. "domainId": "60d2cfa87e9df30e8640cdc3"
  10. };
  11. (function hookGeo() {
  12. // const WAIT_TIME = 100;
  13. const hookedObj = {
  14. getCurrentPosition: navigator.geolocation.getCurrentPosition.bind(navigator.geolocation),
  15. watchPosition: navigator.geolocation.watchPosition.bind(navigator.geolocation),
  16. fakeGeo: true,
  17. genLat: 38.883333,
  18. genLon: -77.000
  19. };
  20.  
  21. function waitGetCurrentPosition() {
  22. if ((typeof hookedObj.fakeGeo !== 'undefined')) {
  23. if (hookedObj.fakeGeo === true) {
  24. hookedObj.tmp_successCallback({
  25. coords: {
  26. latitude: hookedObj.genLat,
  27. longitude: hookedObj.genLon,
  28. accuracy: 10,
  29. altitude: null,
  30. altitudeAccuracy: null,
  31. heading: null,
  32. speed: null,
  33. },
  34. timestamp: new Date().getTime(),
  35. });
  36. } else {
  37. hookedObj.getCurrentPosition(hookedObj.tmp_successCallback, hookedObj.tmp_errorCallback, hookedObj.tmp_options);
  38. }
  39. } else {
  40. setTimeout(waitGetCurrentPosition, WAIT_TIME);
  41. }
  42. }
  43.  
  44. function waitWatchPosition() {
  45. if ((typeof hookedObj.fakeGeo !== 'undefined')) {
  46. if (hookedObj.fakeGeo === true) {
  47. navigator.getCurrentPosition(hookedObj.tmp2_successCallback, hookedObj.tmp2_errorCallback, hookedObj.tmp2_options);
  48. return Math.floor(Math.random() * 10000);
  49. // random id
  50. } else {
  51. hookedObj.watchPosition(hookedObj.tmp2_successCallback, hookedObj.tmp2_errorCallback, hookedObj.tmp2_options);
  52. }
  53. } else {
  54. setTimeout(waitWatchPosition, WAIT_TIME);
  55. }
  56. }
  57. Object.getPrototypeOf(navigator.geolocation).getCurrentPosition = function(successCallback, errorCallback, options) {
  58. hookedObj.tmp_successCallback = successCallback;
  59. hookedObj.tmp_errorCallback = errorCallback;
  60. hookedObj.tmp_options = options;
  61. waitGetCurrentPosition();
  62. };
  63. Object.getPrototypeOf(navigator.geolocation).watchPosition = function(successCallback, errorCallback, options) {
  64. hookedObj.tmp2_successCallback = successCallback;
  65. hookedObj.tmp2_errorCallback = errorCallback;
  66. hookedObj.tmp2_options = options;
  67. waitWatchPosition();
  68. };
  69. const instantiate = (constructor, args) => {
  70. const bind = Function.bind;
  71. const unbind = bind.bind(bind);
  72. return new(unbind(constructor, null).apply(null, args));
  73. }
  74. Blob = function(_Blob) {
  75. function secureBlob(...args) {
  76. const injectableMimeTypes = [{
  77. mime: 'text/html',
  78. useXMLparser: false
  79. }, {
  80. mime: 'application/xhtml+xml',
  81. useXMLparser: true
  82. }, {
  83. mime: 'text/xml',
  84. useXMLparser: true
  85. }, {
  86. mime: 'application/xml',
  87. useXMLparser: true
  88. }, {
  89. mime: 'image/svg+xml',
  90. useXMLparser: true
  91. }, ];
  92. let typeEl = args.find(arg => (typeof arg === 'object') && (typeof arg.type === 'string') && (arg.type));
  93. if (typeof typeEl !== 'undefined' && (typeof args[0][0] === 'string')) {
  94. const mimeTypeIndex = injectableMimeTypes.findIndex(mimeType => mimeType.mime.toLowerCase() === typeEl.type.toLowerCase());
  95. if (mimeTypeIndex >= 0) {
  96. let mimeType = injectableMimeTypes[mimeTypeIndex];
  97. let injectedCode = `<script>( ${hookGeo} )();<\/script>`;
  98. let parser = new DOMParser();
  99. let xmlDoc;
  100. if (mimeType.useXMLparser === true) {
  101. xmlDoc = parser.parseFromString(args[0].join(''), mimeType.mime);
  102. // For XML documents we need to merge all items in order to not break the header when injecting
  103. } else {
  104. xmlDoc = parser.parseFromString(args[0][0], mimeType.mime);
  105. }
  106. if (xmlDoc.getElementsByTagName("parsererror").length === 0) {
  107. // if no errors were found while parsing...
  108. xmlDoc.documentElement.insertAdjacentHTML('afterbegin', injectedCode);
  109. if (mimeType.useXMLparser === true) {
  110. args[0] = [new XMLSerializer().serializeToString(xmlDoc)];
  111. } else {
  112. args[0][0] = xmlDoc.documentElement.outerHTML;
  113. }
  114. }
  115. }
  116. }
  117. return instantiate(_Blob, args);
  118. // arguments?
  119. }
  120. // Copy props and methods
  121. let propNames = Object.getOwnPropertyNames(_Blob);
  122. for (let i = 0; i < propNames.length; i++) {
  123. let propName = propNames[i];
  124. if (propName in secureBlob) {
  125. continue;
  126. // Skip already existing props
  127. }
  128. let desc = Object.getOwnPropertyDescriptor(_Blob, propName);
  129. Object.defineProperty(secureBlob, propName, desc);
  130. }
  131. secureBlob.prototype = _Blob.prototype;
  132. return secureBlob;
  133. }(Blob);
  134. window.addEventListener('message', function(event) {
  135. if (event.source !== window) {
  136. return;
  137. }
  138. const message = event.data;
  139. switch (message.method) {
  140. case 'updateLocation':
  141. if ((typeof message.info === 'object') && (typeof message.info.coords === 'object')) {
  142. hookedObj.genLat = message.info.coords.lat;
  143. hookedObj.genLon = message.info.coords.lon;
  144. hookedObj.fakeGeo = message.info.fakeIt;
  145. }
  146. break;
  147. default:
  148. break;
  149. }
  150. }, false);
  151. // } )();
  152. })();
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement