MWI-Hit-Tracker-Canvas

A Tampermonkey script to track MWI hits on Canvas

当前为 2025-05-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MWI-Hit-Tracker-Canvas
  3. // @namespace MWI-Hit-Tracker-Canvas
  4. // @version 0.8
  5. // @author Artintel, BKN46
  6. // @description A Tampermonkey script to track MWI hits on Canvas
  7. // @icon https://www.milkywayidle.com/favicon.svg
  8. // @include https://*.milkywayidle.com/*
  9. // @match https://www.milkywayidle.com/*
  10. // @license MIT
  11. // ==/UserScript==
  12. (function () {
  13. 'use strict';
  14.  
  15. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  16.  
  17. var check = function (it) {
  18. return it && it.Math == Math && it;
  19. };
  20.  
  21. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  22. var global$c =
  23. // eslint-disable-next-line es/no-global-this -- safe
  24. check(typeof globalThis == 'object' && globalThis) ||
  25. check(typeof window == 'object' && window) ||
  26. // eslint-disable-next-line no-restricted-globals -- safe
  27. check(typeof self == 'object' && self) ||
  28. check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
  29. // eslint-disable-next-line no-new-func -- fallback
  30. (function () { return this; })() || Function('return this')();
  31.  
  32. var objectGetOwnPropertyDescriptor = {};
  33.  
  34. var fails$8 = function (exec) {
  35. try {
  36. return !!exec();
  37. } catch (error) {
  38. return true;
  39. }
  40. };
  41.  
  42. var fails$7 = fails$8;
  43.  
  44. // Detect IE8's incomplete defineProperty implementation
  45. var descriptors = !fails$7(function () {
  46. // eslint-disable-next-line es/no-object-defineproperty -- required for testing
  47. return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
  48. });
  49.  
  50. var objectPropertyIsEnumerable = {};
  51.  
  52. var $propertyIsEnumerable = {}.propertyIsEnumerable;
  53. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  54. var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  55.  
  56. // Nashorn ~ JDK8 bug
  57. var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
  58.  
  59. // `Object.prototype.propertyIsEnumerable` method implementation
  60. // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
  61. objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
  62. var descriptor = getOwnPropertyDescriptor$1(this, V);
  63. return !!descriptor && descriptor.enumerable;
  64. } : $propertyIsEnumerable;
  65.  
  66. var createPropertyDescriptor$2 = function (bitmap, value) {
  67. return {
  68. enumerable: !(bitmap & 1),
  69. configurable: !(bitmap & 2),
  70. writable: !(bitmap & 4),
  71. value: value
  72. };
  73. };
  74.  
  75. var toString = {}.toString;
  76.  
  77. var classofRaw$1 = function (it) {
  78. return toString.call(it).slice(8, -1);
  79. };
  80.  
  81. var fails$6 = fails$8;
  82. var classof$2 = classofRaw$1;
  83.  
  84. var split = ''.split;
  85.  
  86. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  87. var indexedObject = fails$6(function () {
  88. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  89. // eslint-disable-next-line no-prototype-builtins -- safe
  90. return !Object('z').propertyIsEnumerable(0);
  91. }) ? function (it) {
  92. return classof$2(it) == 'String' ? split.call(it, '') : Object(it);
  93. } : Object;
  94.  
  95. // `RequireObjectCoercible` abstract operation
  96. // https://tc39.es/ecma262/#sec-requireobjectcoercible
  97. var requireObjectCoercible$2 = function (it) {
  98. if (it == undefined) throw TypeError("Can't call method on " + it);
  99. return it;
  100. };
  101.  
  102. // toObject with fallback for non-array-like ES3 strings
  103. var IndexedObject = indexedObject;
  104. var requireObjectCoercible$1 = requireObjectCoercible$2;
  105.  
  106. var toIndexedObject$3 = function (it) {
  107. return IndexedObject(requireObjectCoercible$1(it));
  108. };
  109.  
  110. // `IsCallable` abstract operation
  111. // https://tc39.es/ecma262/#sec-iscallable
  112. var isCallable$d = function (argument) {
  113. return typeof argument === 'function';
  114. };
  115.  
  116. var isCallable$c = isCallable$d;
  117.  
  118. var isObject$5 = function (it) {
  119. return typeof it === 'object' ? it !== null : isCallable$c(it);
  120. };
  121.  
  122. var global$b = global$c;
  123. var isCallable$b = isCallable$d;
  124.  
  125. var aFunction = function (argument) {
  126. return isCallable$b(argument) ? argument : undefined;
  127. };
  128.  
  129. var getBuiltIn$4 = function (namespace, method) {
  130. return arguments.length < 2 ? aFunction(global$b[namespace]) : global$b[namespace] && global$b[namespace][method];
  131. };
  132.  
  133. var getBuiltIn$3 = getBuiltIn$4;
  134.  
  135. var engineUserAgent = getBuiltIn$3('navigator', 'userAgent') || '';
  136.  
  137. var global$a = global$c;
  138. var userAgent = engineUserAgent;
  139.  
  140. var process = global$a.process;
  141. var Deno = global$a.Deno;
  142. var versions = process && process.versions || Deno && Deno.version;
  143. var v8 = versions && versions.v8;
  144. var match, version;
  145.  
  146. if (v8) {
  147. match = v8.split('.');
  148. version = match[0] < 4 ? 1 : match[0] + match[1];
  149. } else if (userAgent) {
  150. match = userAgent.match(/Edge\/(\d+)/);
  151. if (!match || match[1] >= 74) {
  152. match = userAgent.match(/Chrome\/(\d+)/);
  153. if (match) version = match[1];
  154. }
  155. }
  156.  
  157. var engineV8Version = version && +version;
  158.  
  159. /* eslint-disable es/no-symbol -- required for testing */
  160.  
  161. var V8_VERSION = engineV8Version;
  162. var fails$5 = fails$8;
  163.  
  164. // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
  165. var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$5(function () {
  166. var symbol = Symbol();
  167. // Chrome 38 Symbol has incorrect toString conversion
  168. // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
  169. return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
  170. // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
  171. !Symbol.sham && V8_VERSION && V8_VERSION < 41;
  172. });
  173.  
  174. /* eslint-disable es/no-symbol -- required for testing */
  175.  
  176. var NATIVE_SYMBOL$1 = nativeSymbol;
  177.  
  178. var useSymbolAsUid = NATIVE_SYMBOL$1
  179. && !Symbol.sham
  180. && typeof Symbol.iterator == 'symbol';
  181.  
  182. var isCallable$a = isCallable$d;
  183. var getBuiltIn$2 = getBuiltIn$4;
  184. var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
  185.  
  186. var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
  187. return typeof it == 'symbol';
  188. } : function (it) {
  189. var $Symbol = getBuiltIn$2('Symbol');
  190. return isCallable$a($Symbol) && Object(it) instanceof $Symbol;
  191. };
  192.  
  193. var tryToString$1 = function (argument) {
  194. try {
  195. return String(argument);
  196. } catch (error) {
  197. return 'Object';
  198. }
  199. };
  200.  
  201. var isCallable$9 = isCallable$d;
  202. var tryToString = tryToString$1;
  203.  
  204. // `Assert: IsCallable(argument) is true`
  205. var aCallable$5 = function (argument) {
  206. if (isCallable$9(argument)) return argument;
  207. throw TypeError(tryToString(argument) + ' is not a function');
  208. };
  209.  
  210. var aCallable$4 = aCallable$5;
  211.  
  212. // `GetMethod` abstract operation
  213. // https://tc39.es/ecma262/#sec-getmethod
  214. var getMethod$4 = function (V, P) {
  215. var func = V[P];
  216. return func == null ? undefined : aCallable$4(func);
  217. };
  218.  
  219. var isCallable$8 = isCallable$d;
  220. var isObject$4 = isObject$5;
  221.  
  222. // `OrdinaryToPrimitive` abstract operation
  223. // https://tc39.es/ecma262/#sec-ordinarytoprimitive
  224. var ordinaryToPrimitive$1 = function (input, pref) {
  225. var fn, val;
  226. if (pref === 'string' && isCallable$8(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
  227. if (isCallable$8(fn = input.valueOf) && !isObject$4(val = fn.call(input))) return val;
  228. if (pref !== 'string' && isCallable$8(fn = input.toString) && !isObject$4(val = fn.call(input))) return val;
  229. throw TypeError("Can't convert object to primitive value");
  230. };
  231.  
  232. var shared$3 = {exports: {}};
  233.  
  234. var global$9 = global$c;
  235.  
  236. var setGlobal$3 = function (key, value) {
  237. try {
  238. // eslint-disable-next-line es/no-object-defineproperty -- safe
  239. Object.defineProperty(global$9, key, { value: value, configurable: true, writable: true });
  240. } catch (error) {
  241. global$9[key] = value;
  242. } return value;
  243. };
  244.  
  245. var global$8 = global$c;
  246. var setGlobal$2 = setGlobal$3;
  247.  
  248. var SHARED = '__core-js_shared__';
  249. var store$3 = global$8[SHARED] || setGlobal$2(SHARED, {});
  250.  
  251. var sharedStore = store$3;
  252.  
  253. var store$2 = sharedStore;
  254.  
  255. (shared$3.exports = function (key, value) {
  256. return store$2[key] || (store$2[key] = value !== undefined ? value : {});
  257. })('versions', []).push({
  258. version: '3.18.3',
  259. mode: 'global',
  260. copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
  261. });
  262.  
  263. var requireObjectCoercible = requireObjectCoercible$2;
  264.  
  265. // `ToObject` abstract operation
  266. // https://tc39.es/ecma262/#sec-toobject
  267. var toObject$2 = function (argument) {
  268. return Object(requireObjectCoercible(argument));
  269. };
  270.  
  271. var toObject$1 = toObject$2;
  272.  
  273. var hasOwnProperty = {}.hasOwnProperty;
  274.  
  275. // `HasOwnProperty` abstract operation
  276. // https://tc39.es/ecma262/#sec-hasownproperty
  277. var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
  278. return hasOwnProperty.call(toObject$1(it), key);
  279. };
  280.  
  281. var id = 0;
  282. var postfix = Math.random();
  283.  
  284. var uid$2 = function (key) {
  285. return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
  286. };
  287.  
  288. var global$7 = global$c;
  289. var shared$2 = shared$3.exports;
  290. var hasOwn$8 = hasOwnProperty_1;
  291. var uid$1 = uid$2;
  292. var NATIVE_SYMBOL = nativeSymbol;
  293. var USE_SYMBOL_AS_UID = useSymbolAsUid;
  294.  
  295. var WellKnownSymbolsStore = shared$2('wks');
  296. var Symbol$1 = global$7.Symbol;
  297. var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
  298.  
  299. var wellKnownSymbol$8 = function (name) {
  300. if (!hasOwn$8(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
  301. if (NATIVE_SYMBOL && hasOwn$8(Symbol$1, name)) {
  302. WellKnownSymbolsStore[name] = Symbol$1[name];
  303. } else {
  304. WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
  305. }
  306. } return WellKnownSymbolsStore[name];
  307. };
  308.  
  309. var isObject$3 = isObject$5;
  310. var isSymbol$1 = isSymbol$2;
  311. var getMethod$3 = getMethod$4;
  312. var ordinaryToPrimitive = ordinaryToPrimitive$1;
  313. var wellKnownSymbol$7 = wellKnownSymbol$8;
  314.  
  315. var TO_PRIMITIVE = wellKnownSymbol$7('toPrimitive');
  316.  
  317. // `ToPrimitive` abstract operation
  318. // https://tc39.es/ecma262/#sec-toprimitive
  319. var toPrimitive$1 = function (input, pref) {
  320. if (!isObject$3(input) || isSymbol$1(input)) return input;
  321. var exoticToPrim = getMethod$3(input, TO_PRIMITIVE);
  322. var result;
  323. if (exoticToPrim) {
  324. if (pref === undefined) pref = 'default';
  325. result = exoticToPrim.call(input, pref);
  326. if (!isObject$3(result) || isSymbol$1(result)) return result;
  327. throw TypeError("Can't convert object to primitive value");
  328. }
  329. if (pref === undefined) pref = 'number';
  330. return ordinaryToPrimitive(input, pref);
  331. };
  332.  
  333. var toPrimitive = toPrimitive$1;
  334. var isSymbol = isSymbol$2;
  335.  
  336. // `ToPropertyKey` abstract operation
  337. // https://tc39.es/ecma262/#sec-topropertykey
  338. var toPropertyKey$2 = function (argument) {
  339. var key = toPrimitive(argument, 'string');
  340. return isSymbol(key) ? key : String(key);
  341. };
  342.  
  343. var global$6 = global$c;
  344. var isObject$2 = isObject$5;
  345.  
  346. var document$1 = global$6.document;
  347. // typeof document.createElement is 'object' in old IE
  348. var EXISTS$1 = isObject$2(document$1) && isObject$2(document$1.createElement);
  349.  
  350. var documentCreateElement$1 = function (it) {
  351. return EXISTS$1 ? document$1.createElement(it) : {};
  352. };
  353.  
  354. var DESCRIPTORS$5 = descriptors;
  355. var fails$4 = fails$8;
  356. var createElement = documentCreateElement$1;
  357.  
  358. // Thank's IE8 for his funny defineProperty
  359. var ie8DomDefine = !DESCRIPTORS$5 && !fails$4(function () {
  360. // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
  361. return Object.defineProperty(createElement('div'), 'a', {
  362. get: function () { return 7; }
  363. }).a != 7;
  364. });
  365.  
  366. var DESCRIPTORS$4 = descriptors;
  367. var propertyIsEnumerableModule = objectPropertyIsEnumerable;
  368. var createPropertyDescriptor$1 = createPropertyDescriptor$2;
  369. var toIndexedObject$2 = toIndexedObject$3;
  370. var toPropertyKey$1 = toPropertyKey$2;
  371. var hasOwn$7 = hasOwnProperty_1;
  372. var IE8_DOM_DEFINE$1 = ie8DomDefine;
  373.  
  374. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  375. var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  376.  
  377. // `Object.getOwnPropertyDescriptor` method
  378. // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
  379. objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
  380. O = toIndexedObject$2(O);
  381. P = toPropertyKey$1(P);
  382. if (IE8_DOM_DEFINE$1) try {
  383. return $getOwnPropertyDescriptor(O, P);
  384. } catch (error) { /* empty */ }
  385. if (hasOwn$7(O, P)) return createPropertyDescriptor$1(!propertyIsEnumerableModule.f.call(O, P), O[P]);
  386. };
  387.  
  388. var objectDefineProperty = {};
  389.  
  390. var isObject$1 = isObject$5;
  391.  
  392. // `Assert: Type(argument) is Object`
  393. var anObject$b = function (argument) {
  394. if (isObject$1(argument)) return argument;
  395. throw TypeError(String(argument) + ' is not an object');
  396. };
  397.  
  398. var DESCRIPTORS$3 = descriptors;
  399. var IE8_DOM_DEFINE = ie8DomDefine;
  400. var anObject$a = anObject$b;
  401. var toPropertyKey = toPropertyKey$2;
  402.  
  403. // eslint-disable-next-line es/no-object-defineproperty -- safe
  404. var $defineProperty = Object.defineProperty;
  405.  
  406. // `Object.defineProperty` method
  407. // https://tc39.es/ecma262/#sec-object.defineproperty
  408. objectDefineProperty.f = DESCRIPTORS$3 ? $defineProperty : function defineProperty(O, P, Attributes) {
  409. anObject$a(O);
  410. P = toPropertyKey(P);
  411. anObject$a(Attributes);
  412. if (IE8_DOM_DEFINE) try {
  413. return $defineProperty(O, P, Attributes);
  414. } catch (error) { /* empty */ }
  415. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  416. if ('value' in Attributes) O[P] = Attributes.value;
  417. return O;
  418. };
  419.  
  420. var DESCRIPTORS$2 = descriptors;
  421. var definePropertyModule$2 = objectDefineProperty;
  422. var createPropertyDescriptor = createPropertyDescriptor$2;
  423.  
  424. var createNonEnumerableProperty$5 = DESCRIPTORS$2 ? function (object, key, value) {
  425. return definePropertyModule$2.f(object, key, createPropertyDescriptor(1, value));
  426. } : function (object, key, value) {
  427. object[key] = value;
  428. return object;
  429. };
  430.  
  431. var redefine$3 = {exports: {}};
  432.  
  433. var isCallable$7 = isCallable$d;
  434. var store$1 = sharedStore;
  435.  
  436. var functionToString = Function.toString;
  437.  
  438. // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
  439. if (!isCallable$7(store$1.inspectSource)) {
  440. store$1.inspectSource = function (it) {
  441. return functionToString.call(it);
  442. };
  443. }
  444.  
  445. var inspectSource$2 = store$1.inspectSource;
  446.  
  447. var global$5 = global$c;
  448. var isCallable$6 = isCallable$d;
  449. var inspectSource$1 = inspectSource$2;
  450.  
  451. var WeakMap$1 = global$5.WeakMap;
  452.  
  453. var nativeWeakMap = isCallable$6(WeakMap$1) && /native code/.test(inspectSource$1(WeakMap$1));
  454.  
  455. var shared$1 = shared$3.exports;
  456. var uid = uid$2;
  457.  
  458. var keys = shared$1('keys');
  459.  
  460. var sharedKey$3 = function (key) {
  461. return keys[key] || (keys[key] = uid(key));
  462. };
  463.  
  464. var hiddenKeys$4 = {};
  465.  
  466. var NATIVE_WEAK_MAP = nativeWeakMap;
  467. var global$4 = global$c;
  468. var isObject = isObject$5;
  469. var createNonEnumerableProperty$4 = createNonEnumerableProperty$5;
  470. var hasOwn$6 = hasOwnProperty_1;
  471. var shared = sharedStore;
  472. var sharedKey$2 = sharedKey$3;
  473. var hiddenKeys$3 = hiddenKeys$4;
  474.  
  475. var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
  476. var WeakMap = global$4.WeakMap;
  477. var set, get, has;
  478.  
  479. var enforce = function (it) {
  480. return has(it) ? get(it) : set(it, {});
  481. };
  482.  
  483. var getterFor = function (TYPE) {
  484. return function (it) {
  485. var state;
  486. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  487. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  488. } return state;
  489. };
  490. };
  491.  
  492. if (NATIVE_WEAK_MAP || shared.state) {
  493. var store = shared.state || (shared.state = new WeakMap());
  494. var wmget = store.get;
  495. var wmhas = store.has;
  496. var wmset = store.set;
  497. set = function (it, metadata) {
  498. if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  499. metadata.facade = it;
  500. wmset.call(store, it, metadata);
  501. return metadata;
  502. };
  503. get = function (it) {
  504. return wmget.call(store, it) || {};
  505. };
  506. has = function (it) {
  507. return wmhas.call(store, it);
  508. };
  509. } else {
  510. var STATE = sharedKey$2('state');
  511. hiddenKeys$3[STATE] = true;
  512. set = function (it, metadata) {
  513. if (hasOwn$6(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
  514. metadata.facade = it;
  515. createNonEnumerableProperty$4(it, STATE, metadata);
  516. return metadata;
  517. };
  518. get = function (it) {
  519. return hasOwn$6(it, STATE) ? it[STATE] : {};
  520. };
  521. has = function (it) {
  522. return hasOwn$6(it, STATE);
  523. };
  524. }
  525.  
  526. var internalState = {
  527. set: set,
  528. get: get,
  529. has: has,
  530. enforce: enforce,
  531. getterFor: getterFor
  532. };
  533.  
  534. var DESCRIPTORS$1 = descriptors;
  535. var hasOwn$5 = hasOwnProperty_1;
  536.  
  537. var FunctionPrototype = Function.prototype;
  538. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  539. var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
  540.  
  541. var EXISTS = hasOwn$5(FunctionPrototype, 'name');
  542. // additional protection from minified / mangled / dropped function names
  543. var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
  544. var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
  545.  
  546. var functionName = {
  547. EXISTS: EXISTS,
  548. PROPER: PROPER,
  549. CONFIGURABLE: CONFIGURABLE
  550. };
  551.  
  552. var global$3 = global$c;
  553. var isCallable$5 = isCallable$d;
  554. var hasOwn$4 = hasOwnProperty_1;
  555. var createNonEnumerableProperty$3 = createNonEnumerableProperty$5;
  556. var setGlobal$1 = setGlobal$3;
  557. var inspectSource = inspectSource$2;
  558. var InternalStateModule$1 = internalState;
  559. var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
  560.  
  561. var getInternalState$1 = InternalStateModule$1.get;
  562. var enforceInternalState = InternalStateModule$1.enforce;
  563. var TEMPLATE = String(String).split('String');
  564.  
  565. (redefine$3.exports = function (O, key, value, options) {
  566. var unsafe = options ? !!options.unsafe : false;
  567. var simple = options ? !!options.enumerable : false;
  568. var noTargetGet = options ? !!options.noTargetGet : false;
  569. var name = options && options.name !== undefined ? options.name : key;
  570. var state;
  571. if (isCallable$5(value)) {
  572. if (String(name).slice(0, 7) === 'Symbol(') {
  573. name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
  574. }
  575. if (!hasOwn$4(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
  576. createNonEnumerableProperty$3(value, 'name', name);
  577. }
  578. state = enforceInternalState(value);
  579. if (!state.source) {
  580. state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
  581. }
  582. }
  583. if (O === global$3) {
  584. if (simple) O[key] = value;
  585. else setGlobal$1(key, value);
  586. return;
  587. } else if (!unsafe) {
  588. delete O[key];
  589. } else if (!noTargetGet && O[key]) {
  590. simple = true;
  591. }
  592. if (simple) O[key] = value;
  593. else createNonEnumerableProperty$3(O, key, value);
  594. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  595. })(Function.prototype, 'toString', function toString() {
  596. return isCallable$5(this) && getInternalState$1(this).source || inspectSource(this);
  597. });
  598.  
  599. var objectGetOwnPropertyNames = {};
  600.  
  601. var ceil = Math.ceil;
  602. var floor = Math.floor;
  603.  
  604. // `ToIntegerOrInfinity` abstract operation
  605. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  606. var toIntegerOrInfinity$2 = function (argument) {
  607. var number = +argument;
  608. // eslint-disable-next-line no-self-compare -- safe
  609. return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
  610. };
  611.  
  612. var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
  613.  
  614. var max = Math.max;
  615. var min$1 = Math.min;
  616.  
  617. // Helper for a popular repeating case of the spec:
  618. // Let integer be ? ToInteger(index).
  619. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  620. var toAbsoluteIndex$1 = function (index, length) {
  621. var integer = toIntegerOrInfinity$1(index);
  622. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  623. };
  624.  
  625. var toIntegerOrInfinity = toIntegerOrInfinity$2;
  626.  
  627. var min = Math.min;
  628.  
  629. // `ToLength` abstract operation
  630. // https://tc39.es/ecma262/#sec-tolength
  631. var toLength$1 = function (argument) {
  632. return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  633. };
  634.  
  635. var toLength = toLength$1;
  636.  
  637. // `LengthOfArrayLike` abstract operation
  638. // https://tc39.es/ecma262/#sec-lengthofarraylike
  639. var lengthOfArrayLike$2 = function (obj) {
  640. return toLength(obj.length);
  641. };
  642.  
  643. var toIndexedObject$1 = toIndexedObject$3;
  644. var toAbsoluteIndex = toAbsoluteIndex$1;
  645. var lengthOfArrayLike$1 = lengthOfArrayLike$2;
  646.  
  647. // `Array.prototype.{ indexOf, includes }` methods implementation
  648. var createMethod = function (IS_INCLUDES) {
  649. return function ($this, el, fromIndex) {
  650. var O = toIndexedObject$1($this);
  651. var length = lengthOfArrayLike$1(O);
  652. var index = toAbsoluteIndex(fromIndex, length);
  653. var value;
  654. // Array#includes uses SameValueZero equality algorithm
  655. // eslint-disable-next-line no-self-compare -- NaN check
  656. if (IS_INCLUDES && el != el) while (length > index) {
  657. value = O[index++];
  658. // eslint-disable-next-line no-self-compare -- NaN check
  659. if (value != value) return true;
  660. // Array#indexOf ignores holes, Array#includes - not
  661. } else for (;length > index; index++) {
  662. if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
  663. } return !IS_INCLUDES && -1;
  664. };
  665. };
  666.  
  667. var arrayIncludes = {
  668. // `Array.prototype.includes` method
  669. // https://tc39.es/ecma262/#sec-array.prototype.includes
  670. includes: createMethod(true),
  671. // `Array.prototype.indexOf` method
  672. // https://tc39.es/ecma262/#sec-array.prototype.indexof
  673. indexOf: createMethod(false)
  674. };
  675.  
  676. var hasOwn$3 = hasOwnProperty_1;
  677. var toIndexedObject = toIndexedObject$3;
  678. var indexOf = arrayIncludes.indexOf;
  679. var hiddenKeys$2 = hiddenKeys$4;
  680.  
  681. var objectKeysInternal = function (object, names) {
  682. var O = toIndexedObject(object);
  683. var i = 0;
  684. var result = [];
  685. var key;
  686. for (key in O) !hasOwn$3(hiddenKeys$2, key) && hasOwn$3(O, key) && result.push(key);
  687. // Don't enum bug & hidden keys
  688. while (names.length > i) if (hasOwn$3(O, key = names[i++])) {
  689. ~indexOf(result, key) || result.push(key);
  690. }
  691. return result;
  692. };
  693.  
  694. // IE8- don't enum bug keys
  695. var enumBugKeys$3 = [
  696. 'constructor',
  697. 'hasOwnProperty',
  698. 'isPrototypeOf',
  699. 'propertyIsEnumerable',
  700. 'toLocaleString',
  701. 'toString',
  702. 'valueOf'
  703. ];
  704.  
  705. var internalObjectKeys$1 = objectKeysInternal;
  706. var enumBugKeys$2 = enumBugKeys$3;
  707.  
  708. var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
  709.  
  710. // `Object.getOwnPropertyNames` method
  711. // https://tc39.es/ecma262/#sec-object.getownpropertynames
  712. // eslint-disable-next-line es/no-object-getownpropertynames -- safe
  713. objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  714. return internalObjectKeys$1(O, hiddenKeys$1);
  715. };
  716.  
  717. var objectGetOwnPropertySymbols = {};
  718.  
  719. // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
  720. objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
  721.  
  722. var getBuiltIn$1 = getBuiltIn$4;
  723. var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
  724. var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
  725. var anObject$9 = anObject$b;
  726.  
  727. // all object keys, includes non-enumerable and symbols
  728. var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
  729. var keys = getOwnPropertyNamesModule.f(anObject$9(it));
  730. var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
  731. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  732. };
  733.  
  734. var hasOwn$2 = hasOwnProperty_1;
  735. var ownKeys = ownKeys$1;
  736. var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
  737. var definePropertyModule$1 = objectDefineProperty;
  738.  
  739. var copyConstructorProperties$1 = function (target, source) {
  740. var keys = ownKeys(source);
  741. var defineProperty = definePropertyModule$1.f;
  742. var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
  743. for (var i = 0; i < keys.length; i++) {
  744. var key = keys[i];
  745. if (!hasOwn$2(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  746. }
  747. };
  748.  
  749. var fails$3 = fails$8;
  750. var isCallable$4 = isCallable$d;
  751.  
  752. var replacement = /#|\.prototype\./;
  753.  
  754. var isForced$1 = function (feature, detection) {
  755. var value = data[normalize(feature)];
  756. return value == POLYFILL ? true
  757. : value == NATIVE ? false
  758. : isCallable$4(detection) ? fails$3(detection)
  759. : !!detection;
  760. };
  761.  
  762. var normalize = isForced$1.normalize = function (string) {
  763. return String(string).replace(replacement, '.').toLowerCase();
  764. };
  765.  
  766. var data = isForced$1.data = {};
  767. var NATIVE = isForced$1.NATIVE = 'N';
  768. var POLYFILL = isForced$1.POLYFILL = 'P';
  769.  
  770. var isForced_1 = isForced$1;
  771.  
  772. var global$2 = global$c;
  773. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  774. var createNonEnumerableProperty$2 = createNonEnumerableProperty$5;
  775. var redefine$2 = redefine$3.exports;
  776. var setGlobal = setGlobal$3;
  777. var copyConstructorProperties = copyConstructorProperties$1;
  778. var isForced = isForced_1;
  779.  
  780. /*
  781. options.target - name of the target object
  782. options.global - target is the global object
  783. options.stat - export as static methods of target
  784. options.proto - export as prototype methods of target
  785. options.real - real prototype method for the `pure` version
  786. options.forced - export even if the native feature is available
  787. options.bind - bind methods to the target, required for the `pure` version
  788. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  789. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  790. options.sham - add a flag to not completely full polyfills
  791. options.enumerable - export as enumerable property
  792. options.noTargetGet - prevent calling a getter on target
  793. options.name - the .name of the function if it does not match the key
  794. */
  795. var _export = function (options, source) {
  796. var TARGET = options.target;
  797. var GLOBAL = options.global;
  798. var STATIC = options.stat;
  799. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  800. if (GLOBAL) {
  801. target = global$2;
  802. } else if (STATIC) {
  803. target = global$2[TARGET] || setGlobal(TARGET, {});
  804. } else {
  805. target = (global$2[TARGET] || {}).prototype;
  806. }
  807. if (target) for (key in source) {
  808. sourceProperty = source[key];
  809. if (options.noTargetGet) {
  810. descriptor = getOwnPropertyDescriptor(target, key);
  811. targetProperty = descriptor && descriptor.value;
  812. } else targetProperty = target[key];
  813. FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  814. // contained in target
  815. if (!FORCED && targetProperty !== undefined) {
  816. if (typeof sourceProperty === typeof targetProperty) continue;
  817. copyConstructorProperties(sourceProperty, targetProperty);
  818. }
  819. // add a flag to not completely full polyfills
  820. if (options.sham || (targetProperty && targetProperty.sham)) {
  821. createNonEnumerableProperty$2(sourceProperty, 'sham', true);
  822. }
  823. // extend global
  824. redefine$2(target, key, sourceProperty, options);
  825. }
  826. };
  827.  
  828. var anInstance$1 = function (it, Constructor, name) {
  829. if (it instanceof Constructor) return it;
  830. throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation');
  831. };
  832.  
  833. var internalObjectKeys = objectKeysInternal;
  834. var enumBugKeys$1 = enumBugKeys$3;
  835.  
  836. // `Object.keys` method
  837. // https://tc39.es/ecma262/#sec-object.keys
  838. // eslint-disable-next-line es/no-object-keys -- safe
  839. var objectKeys$1 = Object.keys || function keys(O) {
  840. return internalObjectKeys(O, enumBugKeys$1);
  841. };
  842.  
  843. var DESCRIPTORS = descriptors;
  844. var definePropertyModule = objectDefineProperty;
  845. var anObject$8 = anObject$b;
  846. var objectKeys = objectKeys$1;
  847.  
  848. // `Object.defineProperties` method
  849. // https://tc39.es/ecma262/#sec-object.defineproperties
  850. // eslint-disable-next-line es/no-object-defineproperties -- safe
  851. var objectDefineProperties = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
  852. anObject$8(O);
  853. var keys = objectKeys(Properties);
  854. var length = keys.length;
  855. var index = 0;
  856. var key;
  857. while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]);
  858. return O;
  859. };
  860.  
  861. var getBuiltIn = getBuiltIn$4;
  862.  
  863. var html$1 = getBuiltIn('document', 'documentElement');
  864.  
  865. /* global ActiveXObject -- old IE, WSH */
  866.  
  867. var anObject$7 = anObject$b;
  868. var defineProperties = objectDefineProperties;
  869. var enumBugKeys = enumBugKeys$3;
  870. var hiddenKeys = hiddenKeys$4;
  871. var html = html$1;
  872. var documentCreateElement = documentCreateElement$1;
  873. var sharedKey$1 = sharedKey$3;
  874.  
  875. var GT = '>';
  876. var LT = '<';
  877. var PROTOTYPE = 'prototype';
  878. var SCRIPT = 'script';
  879. var IE_PROTO$1 = sharedKey$1('IE_PROTO');
  880.  
  881. var EmptyConstructor = function () { /* empty */ };
  882.  
  883. var scriptTag = function (content) {
  884. return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
  885. };
  886.  
  887. // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
  888. var NullProtoObjectViaActiveX = function (activeXDocument) {
  889. activeXDocument.write(scriptTag(''));
  890. activeXDocument.close();
  891. var temp = activeXDocument.parentWindow.Object;
  892. activeXDocument = null; // avoid memory leak
  893. return temp;
  894. };
  895.  
  896. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  897. var NullProtoObjectViaIFrame = function () {
  898. // Thrash, waste and sodomy: IE GC bug
  899. var iframe = documentCreateElement('iframe');
  900. var JS = 'java' + SCRIPT + ':';
  901. var iframeDocument;
  902. iframe.style.display = 'none';
  903. html.appendChild(iframe);
  904. // https://github.com/zloirock/core-js/issues/475
  905. iframe.src = String(JS);
  906. iframeDocument = iframe.contentWindow.document;
  907. iframeDocument.open();
  908. iframeDocument.write(scriptTag('document.F=Object'));
  909. iframeDocument.close();
  910. return iframeDocument.F;
  911. };
  912.  
  913. // Check for document.domain and active x support
  914. // No need to use active x approach when document.domain is not set
  915. // see https://github.com/es-shims/es5-shim/issues/150
  916. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  917. // avoid IE GC bug
  918. var activeXDocument;
  919. var NullProtoObject = function () {
  920. try {
  921. activeXDocument = new ActiveXObject('htmlfile');
  922. } catch (error) { /* ignore */ }
  923. NullProtoObject = typeof document != 'undefined'
  924. ? document.domain && activeXDocument
  925. ? NullProtoObjectViaActiveX(activeXDocument) // old IE
  926. : NullProtoObjectViaIFrame()
  927. : NullProtoObjectViaActiveX(activeXDocument); // WSH
  928. var length = enumBugKeys.length;
  929. while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
  930. return NullProtoObject();
  931. };
  932.  
  933. hiddenKeys[IE_PROTO$1] = true;
  934.  
  935. // `Object.create` method
  936. // https://tc39.es/ecma262/#sec-object.create
  937. var objectCreate = Object.create || function create(O, Properties) {
  938. var result;
  939. if (O !== null) {
  940. EmptyConstructor[PROTOTYPE] = anObject$7(O);
  941. result = new EmptyConstructor();
  942. EmptyConstructor[PROTOTYPE] = null;
  943. // add "__proto__" for Object.getPrototypeOf polyfill
  944. result[IE_PROTO$1] = O;
  945. } else result = NullProtoObject();
  946. return Properties === undefined ? result : defineProperties(result, Properties);
  947. };
  948.  
  949. var fails$2 = fails$8;
  950.  
  951. var correctPrototypeGetter = !fails$2(function () {
  952. function F() { /* empty */ }
  953. F.prototype.constructor = null;
  954. // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
  955. return Object.getPrototypeOf(new F()) !== F.prototype;
  956. });
  957.  
  958. var hasOwn$1 = hasOwnProperty_1;
  959. var isCallable$3 = isCallable$d;
  960. var toObject = toObject$2;
  961. var sharedKey = sharedKey$3;
  962. var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
  963.  
  964. var IE_PROTO = sharedKey('IE_PROTO');
  965. var ObjectPrototype = Object.prototype;
  966.  
  967. // `Object.getPrototypeOf` method
  968. // https://tc39.es/ecma262/#sec-object.getprototypeof
  969. // eslint-disable-next-line es/no-object-getprototypeof -- safe
  970. var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
  971. var object = toObject(O);
  972. if (hasOwn$1(object, IE_PROTO)) return object[IE_PROTO];
  973. var constructor = object.constructor;
  974. if (isCallable$3(constructor) && object instanceof constructor) {
  975. return constructor.prototype;
  976. } return object instanceof Object ? ObjectPrototype : null;
  977. };
  978.  
  979. var fails$1 = fails$8;
  980. var isCallable$2 = isCallable$d;
  981. var getPrototypeOf = objectGetPrototypeOf;
  982. var redefine$1 = redefine$3.exports;
  983. var wellKnownSymbol$6 = wellKnownSymbol$8;
  984.  
  985. var ITERATOR$2 = wellKnownSymbol$6('iterator');
  986. var BUGGY_SAFARI_ITERATORS = false;
  987.  
  988. // `%IteratorPrototype%` object
  989. // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
  990. var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
  991.  
  992. /* eslint-disable es/no-array-prototype-keys -- safe */
  993. if ([].keys) {
  994. arrayIterator = [].keys();
  995. // Safari 8 has buggy iterators w/o `next`
  996. if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
  997. else {
  998. PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
  999. if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
  1000. }
  1001. }
  1002.  
  1003. var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$1(function () {
  1004. var test = {};
  1005. // FF44- legacy iterators case
  1006. return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
  1007. });
  1008.  
  1009. if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
  1010.  
  1011. // `%IteratorPrototype%[@@iterator]()` method
  1012. // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
  1013. if (!isCallable$2(IteratorPrototype$2[ITERATOR$2])) {
  1014. redefine$1(IteratorPrototype$2, ITERATOR$2, function () {
  1015. return this;
  1016. });
  1017. }
  1018.  
  1019. var iteratorsCore = {
  1020. IteratorPrototype: IteratorPrototype$2,
  1021. BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
  1022. };
  1023.  
  1024. // https://github.com/tc39/proposal-iterator-helpers
  1025. var $$2 = _export;
  1026. var global$1 = global$c;
  1027. var anInstance = anInstance$1;
  1028. var isCallable$1 = isCallable$d;
  1029. var createNonEnumerableProperty$1 = createNonEnumerableProperty$5;
  1030. var fails = fails$8;
  1031. var hasOwn = hasOwnProperty_1;
  1032. var wellKnownSymbol$5 = wellKnownSymbol$8;
  1033. var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
  1034.  
  1035. var TO_STRING_TAG$3 = wellKnownSymbol$5('toStringTag');
  1036.  
  1037. var NativeIterator = global$1.Iterator;
  1038.  
  1039. // FF56- have non-standard global helper `Iterator`
  1040. var FORCED = !isCallable$1(NativeIterator)
  1041. || NativeIterator.prototype !== IteratorPrototype$1
  1042. // FF44- non-standard `Iterator` passes previous tests
  1043. || !fails(function () { NativeIterator({}); });
  1044.  
  1045. var IteratorConstructor = function Iterator() {
  1046. anInstance(this, IteratorConstructor);
  1047. };
  1048.  
  1049. if (!hasOwn(IteratorPrototype$1, TO_STRING_TAG$3)) {
  1050. createNonEnumerableProperty$1(IteratorPrototype$1, TO_STRING_TAG$3, 'Iterator');
  1051. }
  1052.  
  1053. if (FORCED || !hasOwn(IteratorPrototype$1, 'constructor') || IteratorPrototype$1.constructor === Object) {
  1054. createNonEnumerableProperty$1(IteratorPrototype$1, 'constructor', IteratorConstructor);
  1055. }
  1056.  
  1057. IteratorConstructor.prototype = IteratorPrototype$1;
  1058.  
  1059. $$2({ global: true, forced: FORCED }, {
  1060. Iterator: IteratorConstructor
  1061. });
  1062.  
  1063. var iterators = {};
  1064.  
  1065. var wellKnownSymbol$4 = wellKnownSymbol$8;
  1066. var Iterators$1 = iterators;
  1067.  
  1068. var ITERATOR$1 = wellKnownSymbol$4('iterator');
  1069. var ArrayPrototype = Array.prototype;
  1070.  
  1071. // check on default Array iterator
  1072. var isArrayIteratorMethod$1 = function (it) {
  1073. return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$1] === it);
  1074. };
  1075.  
  1076. var aCallable$3 = aCallable$5;
  1077.  
  1078. // optional / simple context binding
  1079. var functionBindContext = function (fn, that, length) {
  1080. aCallable$3(fn);
  1081. if (that === undefined) return fn;
  1082. switch (length) {
  1083. case 0: return function () {
  1084. return fn.call(that);
  1085. };
  1086. case 1: return function (a) {
  1087. return fn.call(that, a);
  1088. };
  1089. case 2: return function (a, b) {
  1090. return fn.call(that, a, b);
  1091. };
  1092. case 3: return function (a, b, c) {
  1093. return fn.call(that, a, b, c);
  1094. };
  1095. }
  1096. return function (/* ...args */) {
  1097. return fn.apply(that, arguments);
  1098. };
  1099. };
  1100.  
  1101. var wellKnownSymbol$3 = wellKnownSymbol$8;
  1102.  
  1103. var TO_STRING_TAG$2 = wellKnownSymbol$3('toStringTag');
  1104. var test = {};
  1105.  
  1106. test[TO_STRING_TAG$2] = 'z';
  1107.  
  1108. var toStringTagSupport = String(test) === '[object z]';
  1109.  
  1110. var TO_STRING_TAG_SUPPORT = toStringTagSupport;
  1111. var isCallable = isCallable$d;
  1112. var classofRaw = classofRaw$1;
  1113. var wellKnownSymbol$2 = wellKnownSymbol$8;
  1114.  
  1115. var TO_STRING_TAG$1 = wellKnownSymbol$2('toStringTag');
  1116. // ES3 wrong here
  1117. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  1118.  
  1119. // fallback for IE11 Script Access Denied error
  1120. var tryGet = function (it, key) {
  1121. try {
  1122. return it[key];
  1123. } catch (error) { /* empty */ }
  1124. };
  1125.  
  1126. // getting tag from ES6+ `Object.prototype.toString`
  1127. var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
  1128. var O, tag, result;
  1129. return it === undefined ? 'Undefined' : it === null ? 'Null'
  1130. // @@toStringTag case
  1131. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$1)) == 'string' ? tag
  1132. // builtinTag case
  1133. : CORRECT_ARGUMENTS ? classofRaw(O)
  1134. // ES3 arguments fallback
  1135. : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
  1136. };
  1137.  
  1138. var classof = classof$1;
  1139. var getMethod$2 = getMethod$4;
  1140. var Iterators = iterators;
  1141. var wellKnownSymbol$1 = wellKnownSymbol$8;
  1142.  
  1143. var ITERATOR = wellKnownSymbol$1('iterator');
  1144.  
  1145. var getIteratorMethod$2 = function (it) {
  1146. if (it != undefined) return getMethod$2(it, ITERATOR)
  1147. || getMethod$2(it, '@@iterator')
  1148. || Iterators[classof(it)];
  1149. };
  1150.  
  1151. var aCallable$2 = aCallable$5;
  1152. var anObject$6 = anObject$b;
  1153. var getIteratorMethod$1 = getIteratorMethod$2;
  1154.  
  1155. var getIterator$1 = function (argument, usingIterator) {
  1156. var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
  1157. if (aCallable$2(iteratorMethod)) return anObject$6(iteratorMethod.call(argument));
  1158. throw TypeError(String(argument) + ' is not iterable');
  1159. };
  1160.  
  1161. var anObject$5 = anObject$b;
  1162. var getMethod$1 = getMethod$4;
  1163.  
  1164. var iteratorClose$2 = function (iterator, kind, value) {
  1165. var innerResult, innerError;
  1166. anObject$5(iterator);
  1167. try {
  1168. innerResult = getMethod$1(iterator, 'return');
  1169. if (!innerResult) {
  1170. if (kind === 'throw') throw value;
  1171. return value;
  1172. }
  1173. innerResult = innerResult.call(iterator);
  1174. } catch (error) {
  1175. innerError = true;
  1176. innerResult = error;
  1177. }
  1178. if (kind === 'throw') throw value;
  1179. if (innerError) throw innerResult;
  1180. anObject$5(innerResult);
  1181. return value;
  1182. };
  1183.  
  1184. var anObject$4 = anObject$b;
  1185. var isArrayIteratorMethod = isArrayIteratorMethod$1;
  1186. var lengthOfArrayLike = lengthOfArrayLike$2;
  1187. var bind = functionBindContext;
  1188. var getIterator = getIterator$1;
  1189. var getIteratorMethod = getIteratorMethod$2;
  1190. var iteratorClose$1 = iteratorClose$2;
  1191.  
  1192. var Result = function (stopped, result) {
  1193. this.stopped = stopped;
  1194. this.result = result;
  1195. };
  1196.  
  1197. var iterate$1 = function (iterable, unboundFunction, options) {
  1198. var that = options && options.that;
  1199. var AS_ENTRIES = !!(options && options.AS_ENTRIES);
  1200. var IS_ITERATOR = !!(options && options.IS_ITERATOR);
  1201. var INTERRUPTED = !!(options && options.INTERRUPTED);
  1202. var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
  1203. var iterator, iterFn, index, length, result, next, step;
  1204.  
  1205. var stop = function (condition) {
  1206. if (iterator) iteratorClose$1(iterator, 'normal', condition);
  1207. return new Result(true, condition);
  1208. };
  1209.  
  1210. var callFn = function (value) {
  1211. if (AS_ENTRIES) {
  1212. anObject$4(value);
  1213. return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
  1214. } return INTERRUPTED ? fn(value, stop) : fn(value);
  1215. };
  1216.  
  1217. if (IS_ITERATOR) {
  1218. iterator = iterable;
  1219. } else {
  1220. iterFn = getIteratorMethod(iterable);
  1221. if (!iterFn) throw TypeError(String(iterable) + ' is not iterable');
  1222. // optimisation for array iterators
  1223. if (isArrayIteratorMethod(iterFn)) {
  1224. for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
  1225. result = callFn(iterable[index]);
  1226. if (result && result instanceof Result) return result;
  1227. } return new Result(false);
  1228. }
  1229. iterator = getIterator(iterable, iterFn);
  1230. }
  1231.  
  1232. next = iterator.next;
  1233. while (!(step = next.call(iterator)).done) {
  1234. try {
  1235. result = callFn(step.value);
  1236. } catch (error) {
  1237. iteratorClose$1(iterator, 'throw', error);
  1238. }
  1239. if (typeof result == 'object' && result && result instanceof Result) return result;
  1240. } return new Result(false);
  1241. };
  1242.  
  1243. // https://github.com/tc39/proposal-iterator-helpers
  1244. var $$1 = _export;
  1245. var iterate = iterate$1;
  1246. var anObject$3 = anObject$b;
  1247.  
  1248. $$1({ target: 'Iterator', proto: true, real: true }, {
  1249. forEach: function forEach(fn) {
  1250. iterate(anObject$3(this), fn, { IS_ITERATOR: true });
  1251. }
  1252. });
  1253.  
  1254. var redefine = redefine$3.exports;
  1255.  
  1256. var redefineAll$1 = function (target, src, options) {
  1257. for (var key in src) redefine(target, key, src[key], options);
  1258. return target;
  1259. };
  1260.  
  1261. var aCallable$1 = aCallable$5;
  1262. var anObject$2 = anObject$b;
  1263. var create = objectCreate;
  1264. var createNonEnumerableProperty = createNonEnumerableProperty$5;
  1265. var redefineAll = redefineAll$1;
  1266. var wellKnownSymbol = wellKnownSymbol$8;
  1267. var InternalStateModule = internalState;
  1268. var getMethod = getMethod$4;
  1269. var IteratorPrototype = iteratorsCore.IteratorPrototype;
  1270.  
  1271. var setInternalState = InternalStateModule.set;
  1272. var getInternalState = InternalStateModule.get;
  1273.  
  1274. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  1275.  
  1276. var iteratorCreateProxy = function (nextHandler, IS_ITERATOR) {
  1277. var IteratorProxy = function Iterator(state) {
  1278. state.next = aCallable$1(state.iterator.next);
  1279. state.done = false;
  1280. state.ignoreArg = !IS_ITERATOR;
  1281. setInternalState(this, state);
  1282. };
  1283.  
  1284. IteratorProxy.prototype = redefineAll(create(IteratorPrototype), {
  1285. next: function next(arg) {
  1286. var state = getInternalState(this);
  1287. var args = arguments.length ? [state.ignoreArg ? undefined : arg] : IS_ITERATOR ? [] : [undefined];
  1288. state.ignoreArg = false;
  1289. var result = state.done ? undefined : nextHandler.call(state, args);
  1290. return { done: state.done, value: result };
  1291. },
  1292. 'return': function (value) {
  1293. var state = getInternalState(this);
  1294. var iterator = state.iterator;
  1295. state.done = true;
  1296. var $$return = getMethod(iterator, 'return');
  1297. return { done: true, value: $$return ? anObject$2($$return.call(iterator, value)).value : value };
  1298. },
  1299. 'throw': function (value) {
  1300. var state = getInternalState(this);
  1301. var iterator = state.iterator;
  1302. state.done = true;
  1303. var $$throw = getMethod(iterator, 'throw');
  1304. if ($$throw) return $$throw.call(iterator, value);
  1305. throw value;
  1306. }
  1307. });
  1308.  
  1309. if (!IS_ITERATOR) {
  1310. createNonEnumerableProperty(IteratorProxy.prototype, TO_STRING_TAG, 'Generator');
  1311. }
  1312.  
  1313. return IteratorProxy;
  1314. };
  1315.  
  1316. var anObject$1 = anObject$b;
  1317. var iteratorClose = iteratorClose$2;
  1318.  
  1319. // call something on iterator step with safe closing on error
  1320. var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
  1321. try {
  1322. return ENTRIES ? fn(anObject$1(value)[0], value[1]) : fn(value);
  1323. } catch (error) {
  1324. iteratorClose(iterator, 'throw', error);
  1325. }
  1326. };
  1327.  
  1328. // https://github.com/tc39/proposal-iterator-helpers
  1329. var $ = _export;
  1330. var aCallable = aCallable$5;
  1331. var anObject = anObject$b;
  1332. var createIteratorProxy = iteratorCreateProxy;
  1333. var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
  1334.  
  1335. var IteratorProxy = createIteratorProxy(function (args) {
  1336. var iterator = this.iterator;
  1337. var result = anObject(this.next.apply(iterator, args));
  1338. var done = this.done = !!result.done;
  1339. if (!done) return callWithSafeIterationClosing(iterator, this.mapper, result.value);
  1340. });
  1341.  
  1342. $({ target: 'Iterator', proto: true, real: true }, {
  1343. map: function map(mapper) {
  1344. return new IteratorProxy({
  1345. iterator: anObject(this),
  1346. mapper: aCallable(mapper)
  1347. });
  1348. }
  1349. });
  1350.  
  1351. const isZHInGameSetting = localStorage.getItem("i18nextLng")?.toLowerCase()?.startsWith("zh"); // 获取游戏内设置语言
  1352. let isZH = isZHInGameSetting; // MWITools 本身显示的语言默认由游戏内设置语言决定
  1353.  
  1354. let settingsMap = {
  1355. tracker0: {
  1356. id: "tracker0",
  1357. desc: isZH ? "玩家 #1" : "player #1",
  1358. isTrue: true,
  1359. r: 255,
  1360. g: 99,
  1361. b: 132
  1362. },
  1363. tracker1: {
  1364. id: "tracker1",
  1365. desc: isZH ? "玩家 #2" : "player #2",
  1366. isTrue: true,
  1367. r: 54,
  1368. g: 162,
  1369. b: 235
  1370. },
  1371. tracker2: {
  1372. id: "tracker2",
  1373. desc: isZH ? "玩家 #3" : "player #3",
  1374. isTrue: true,
  1375. r: 255,
  1376. g: 206,
  1377. b: 86
  1378. },
  1379. tracker3: {
  1380. id: "tracker3",
  1381. desc: isZH ? "玩家 #4" : "player #4",
  1382. isTrue: true,
  1383. r: 75,
  1384. g: 192,
  1385. b: 192
  1386. },
  1387. tracker4: {
  1388. id: "tracker4",
  1389. desc: isZH ? "玩家 #5" : "player #5",
  1390. isTrue: true,
  1391. r: 153,
  1392. g: 102,
  1393. b: 255
  1394. },
  1395. tracker6: {
  1396. id: "tracker6",
  1397. desc: isZH ? "敌人" : "enemies",
  1398. isTrue: true,
  1399. r: 255,
  1400. g: 0,
  1401. b: 0
  1402. }
  1403. };
  1404. readSettings();
  1405. function waitForSetttins() {
  1406. const targetNode = document.querySelector("div.SettingsPanel_profileTab__214Bj");
  1407. if (targetNode) {
  1408. if (!targetNode.querySelector("#tracker_settings")) {
  1409. targetNode.insertAdjacentHTML("beforeend", `<div id="tracker_settings"></div>`);
  1410. const insertElem = targetNode.querySelector("div#tracker_settings");
  1411. insertElem.insertAdjacentHTML("beforeend", `<div style="float: left; color: orange">${isZH ? "MWI-Hit-Tracker 设置 :" : "MWI-Hit-Tracker Settings: "}</div></br>`);
  1412. for (const setting of Object.values(settingsMap)) {
  1413. insertElem.insertAdjacentHTML("beforeend", `<div class="tracker-option"><input type="checkbox" id="${setting.id}" ${setting.isTrue ? "checked" : ""}></input>${setting.desc}<div class="color-preview" id="colorPreview_${setting.id}"></div></div>`);
  1414. // 颜色自定义
  1415. const colorPreview = document.getElementById('colorPreview_' + setting.id);
  1416. let currentColor = {
  1417. r: setting.r,
  1418. g: setting.g,
  1419. b: setting.b
  1420. };
  1421.  
  1422. // 点击打开颜色选择器
  1423. colorPreview.addEventListener('click', () => {
  1424. const settingColor = {
  1425. r: settingsMap[setting.id].r,
  1426. g: settingsMap[setting.id].g,
  1427. b: settingsMap[setting.id].b
  1428. };
  1429. const modal = createColorPicker(settingColor, newColor => {
  1430. currentColor = newColor;
  1431. settingsMap[setting.id].r = newColor.r;
  1432. settingsMap[setting.id].g = newColor.g;
  1433. settingsMap[setting.id].b = newColor.b;
  1434. localStorage.setItem("tracker_settingsMap", JSON.stringify(settingsMap));
  1435. updatePreview();
  1436. });
  1437. document.body.appendChild(modal);
  1438. });
  1439. function updatePreview() {
  1440. colorPreview.style.backgroundColor = `rgb(${currentColor.r},${currentColor.g},${currentColor.b})`;
  1441. }
  1442. updatePreview();
  1443. function createColorPicker(initialColor, callback) {
  1444. // 创建弹窗容器
  1445. const backdrop = document.createElement('div');
  1446. backdrop.className = 'modal-backdrop';
  1447. const modal = document.createElement('div');
  1448. modal.className = 'color-picker-modal';
  1449.  
  1450. // 颜色预览
  1451. //const preview = document.createElement('div');
  1452. //preview.className = 'color-preview';
  1453. //preview.style.height = '100px';
  1454. // 创建SVG容器
  1455. const preview = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  1456. preview.setAttribute("width", "200");
  1457. preview.setAttribute("height", "150");
  1458. preview.style.display = 'block';
  1459. // 创建抛物线路径
  1460. const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
  1461. Object.assign(path.style, {
  1462. strokeWidth: '5px',
  1463. fill: 'none',
  1464. strokeLinecap: 'round'
  1465. });
  1466. path.setAttribute("d", "M 0 130 Q 100 0 200 130");
  1467. preview.appendChild(path);
  1468.  
  1469. // 颜色控制组件
  1470. const controls = document.createElement('div');
  1471. ['r', 'g', 'b'].forEach(channel => {
  1472. const container = document.createElement('div');
  1473. container.className = 'slider-container';
  1474.  
  1475. // 标签
  1476. const label = document.createElement('label');
  1477. label.textContent = channel.toUpperCase() + ':';
  1478. label.style.color = "white";
  1479.  
  1480. // 滑块
  1481. const slider = document.createElement('input');
  1482. slider.type = 'range';
  1483. slider.min = 0;
  1484. slider.max = 255;
  1485. slider.value = initialColor[channel];
  1486.  
  1487. // 输入框
  1488. const input = document.createElement('input');
  1489. input.type = 'number';
  1490. input.min = 0;
  1491. input.max = 255;
  1492. input.value = initialColor[channel];
  1493. input.style.width = '60px';
  1494.  
  1495. // 双向绑定
  1496. const updateChannel = value => {
  1497. value = Math.min(255, Math.max(0, parseInt(value) || 0));
  1498. slider.value = value;
  1499. input.value = value;
  1500. currentColor[channel] = value;
  1501. path.style.stroke = getColorString(currentColor);
  1502. };
  1503. slider.addEventListener('input', e => updateChannel(e.target.value));
  1504. input.addEventListener('change', e => updateChannel(e.target.value));
  1505. container.append(label, slider, input);
  1506. controls.append(container);
  1507. });
  1508.  
  1509. // 操作按钮
  1510. const actions = document.createElement('div');
  1511. actions.className = 'modal-actions';
  1512. const confirmBtn = document.createElement('button');
  1513. confirmBtn.textContent = isZH ? '确定' : 'OK';
  1514. confirmBtn.onclick = () => {
  1515. callback(currentColor);
  1516. backdrop.remove();
  1517. };
  1518. const cancelBtn = document.createElement('button');
  1519. cancelBtn.textContent = isZH ? '取消' : 'Cancel';
  1520. cancelBtn.onclick = () => backdrop.remove();
  1521. actions.append(cancelBtn, confirmBtn);
  1522.  
  1523. // 组装弹窗
  1524. const getColorString = color => `rgb(${color.r},${color.g},${color.b})`;
  1525. path.style.stroke = getColorString(settingsMap[setting.id]);
  1526. modal.append(preview, controls, actions);
  1527. backdrop.append(modal);
  1528.  
  1529. // 点击背景关闭
  1530. backdrop.addEventListener('click', e => {
  1531. if (e.target === backdrop) backdrop.remove();
  1532. });
  1533. return backdrop;
  1534. }
  1535. }
  1536. insertElem.addEventListener("change", saveSettings);
  1537. }
  1538. }
  1539. setTimeout(waitForSetttins, 500);
  1540. }
  1541. function saveSettings() {
  1542. for (const checkbox of document.querySelectorAll("div#tracker_settings input")) {
  1543. settingsMap[checkbox.id].isTrue = checkbox.checked;
  1544. localStorage.setItem("tracker_settingsMap", JSON.stringify(settingsMap));
  1545. }
  1546. }
  1547. function readSettings() {
  1548. const ls = localStorage.getItem("tracker_settingsMap");
  1549. if (ls) {
  1550. const lsObj = JSON.parse(ls);
  1551. for (const option of Object.values(lsObj)) {
  1552. if (settingsMap.hasOwnProperty(option.id)) {
  1553. settingsMap[option.id].isTrue = option.isTrue;
  1554. settingsMap[option.id].r = option.r;
  1555. settingsMap[option.id].g = option.g;
  1556. settingsMap[option.id].b = option.b;
  1557. }
  1558. }
  1559. }
  1560. }
  1561. const style = document.createElement('style');
  1562. style.textContent = `
  1563. .tracker-option {
  1564. display: flex;
  1565. align-items: center;
  1566. }
  1567.  
  1568. .color-preview {
  1569. cursor: pointer;
  1570. width: 20px;
  1571. height: 20px;
  1572. margin: 3px 3px;
  1573. border: 1px solid #ccc;
  1574. border-radius: 3px;
  1575. }
  1576.  
  1577. .color-picker-modal {
  1578. position: fixed;
  1579. top: 50%;
  1580. left: 50%;
  1581. transform: translate(-50%, -50%);
  1582. background: rgba(0, 0, 0, 0.5);
  1583. padding: 20px;
  1584. border: 1px solid rgba(255, 255, 255, 0.2);
  1585. border-radius: 8px;
  1586. box-shadow: 0 0 20px rgba(0,0,0,0.2);
  1587. z-index: 1000;
  1588. }
  1589.  
  1590. .modal-backdrop {
  1591. position: fixed;
  1592. top: 0;
  1593. left: 0;
  1594. right: 0;
  1595. bottom: 0;
  1596. background: rgba(0,0,0,0.5);
  1597. z-index: 999;
  1598. }
  1599.  
  1600. .modal-actions {
  1601. margin-top: 20px;
  1602. display: flex;
  1603. gap: 10px;
  1604. justify-content: flex-end;
  1605. }
  1606. `;
  1607. document.head.appendChild(style);
  1608.  
  1609. const canvas = initTrackerCanvas();
  1610. const ctx = canvas.getContext('2d');
  1611. function initTrackerCanvas() {
  1612. const gamePanel = document.querySelector("body");
  1613. const canvas = document.createElement('canvas');
  1614. canvas.id = 'hitTrackerCanvas';
  1615. canvas.style.position = 'fixed';
  1616. canvas.style.top = '0';
  1617. canvas.style.left = '0';
  1618. canvas.style.pointerEvents = 'none';
  1619. canvas.style.zIndex = '200';
  1620. canvas.style.width = '100%';
  1621. canvas.style.height = '100%';
  1622. canvas.width = window.innerWidth;
  1623. canvas.height = window.innerHeight;
  1624. canvas.pointerEvents = 'none';
  1625. gamePanel.appendChild(canvas);
  1626. window.addEventListener('resize', () => {
  1627. canvas.width = window.innerWidth;
  1628. canvas.height = window.innerHeight;
  1629. });
  1630. return canvas;
  1631. }
  1632.  
  1633. // Update shake animation effect to ensure element returns to original position
  1634. function applyShakeEffect(element, intensity = 1, duration = 500) {
  1635. if (!element) return;
  1636.  
  1637. // Store the element's original position/transform
  1638. const originalTransform = element.style.transform || '';
  1639. const originalTransition = element.style.transition || '';
  1640.  
  1641. // Scale intensity based on size/damage
  1642. const scaledIntensity = Math.min(10, intensity);
  1643.  
  1644. // Apply CSS animation
  1645. element.style.transition = 'transform 50ms ease-in-out';
  1646. let shakeCount = 0;
  1647. const maxShakes = Math.ceil(intensity);
  1648. const shakeInterval = 50;
  1649. const interval = setInterval(() => {
  1650. if (shakeCount >= maxShakes) {
  1651. // Ensure element returns to original position
  1652. clearInterval(interval);
  1653. element.style.transform = originalTransform;
  1654. element.style.transition = originalTransition;
  1655. return;
  1656. }
  1657.  
  1658. // Random offset for shaking effect
  1659. const xOffset = (Math.random() - 0.5) * 2 * scaledIntensity;
  1660. const yOffset = (Math.random() - 0.5) * 2 * scaledIntensity;
  1661. element.style.transform = `${originalTransform} translate(${xOffset}px, ${yOffset}px)`;
  1662. shakeCount++;
  1663. }, shakeInterval);
  1664.  
  1665. // Additional safeguard: ensure element returns to original position after max duration
  1666. setTimeout(() => {
  1667. clearInterval(interval);
  1668. element.style.transform = 'translate(0, 0)';
  1669. element.style.transition = originalTransition;
  1670. }, shakeInterval * (maxShakes + 1)); // Slightly longer than maxShakes * interval time
  1671. }
  1672.  
  1673. // 更新和渲染所有爆炸
  1674. function updateExplosions() {
  1675. // 遍历所有活跃的爆炸
  1676. for (let i = activeExplosions.length - 1; i >= 0; i--) {
  1677. const explosion = activeExplosions[i];
  1678. explosion.count++;
  1679. if (explosion.count >= explosion.maxCount) {
  1680. // 爆炸结束,从列表中移除
  1681. activeExplosions.splice(i, 1);
  1682. continue;
  1683. }
  1684. ctx.save();
  1685.  
  1686. // 更新和绘制冲击波
  1687. explosion.shockwaves.forEach((wave, index) => {
  1688. wave.radius += (wave.maxRadius - wave.radius) * 0.1;
  1689. wave.life -= 10;
  1690. if (wave.life > 0) {
  1691. const alpha = wave.life / 400;
  1692. ctx.beginPath();
  1693. ctx.strokeStyle = wave.color;
  1694. ctx.arc(wave.x, wave.y, wave.radius, 0, Math.PI * 2);
  1695. // ctx.strokeStyle = `${wave.color.slice(0, -2)}${alpha})`;
  1696. ctx.lineWidth = 5 * alpha;
  1697. ctx.stroke();
  1698. }
  1699. });
  1700.  
  1701. // 更新和绘制主要爆炸粒子
  1702. explosion.particles.forEach((p, index) => {
  1703. p.speed *= 0.96; // 速度衰减
  1704. p.x += Math.cos(p.angle) * p.speed;
  1705. p.y += Math.sin(p.angle) * p.speed + p.gravity;
  1706. p.life -= 5;
  1707. if (p.life > 0) {
  1708. const alpha = p.life / 300;
  1709. ctx.beginPath();
  1710. ctx.arc(p.x, p.y, p.size * (p.life / 300), 0, Math.PI * 2);
  1711. ctx.fillStyle = `${p.color.slice(0, -4)}%, ${alpha})`;
  1712. ctx.fill();
  1713. }
  1714. });
  1715.  
  1716. // 更新和绘制余烬
  1717. explosion.embers.forEach((e, index) => {
  1718. e.speed *= 0.99; // 慢慢减速
  1719. e.x += Math.cos(e.angle) * e.speed;
  1720. e.y += Math.sin(e.angle) * e.speed + e.gravity;
  1721. e.life -= 3;
  1722. if (e.life > 0) {
  1723. const alpha = e.life / 800;
  1724. ctx.beginPath();
  1725. ctx.arc(e.x, e.y, e.size * (e.life / 800), 0, Math.PI * 2);
  1726. ctx.fillStyle = `${e.color.slice(0, -4)}%, ${alpha})`;
  1727. ctx.fill();
  1728.  
  1729. // 余烬偶尔产生的小火花
  1730. if (Math.random() < 0.03) {
  1731. ctx.beginPath();
  1732. ctx.arc(e.x, e.y, e.size * 1.5, 0, Math.PI * 2);
  1733. ctx.fillStyle = `hsla(30, 100%, 70%, ${alpha * 0.7})`;
  1734. ctx.fill();
  1735. }
  1736. }
  1737. });
  1738.  
  1739. // 更新和绘制烟雾
  1740. explosion.smokeParticles.forEach((s, index) => {
  1741. s.x += Math.cos(s.angle) * s.speed;
  1742. s.y += Math.sin(s.angle) * s.speed + s.gravity;
  1743. s.life -= 2;
  1744. s.alpha = Math.max(0, s.alpha - 0.003);
  1745. if (s.life > 0) {
  1746. ctx.beginPath();
  1747. ctx.arc(s.x, s.y, s.size, 0, Math.PI * 2);
  1748. ctx.fillStyle = `rgba(80, 80, 80, ${s.alpha * (s.life / 1200)})`;
  1749. ctx.fill();
  1750. }
  1751. });
  1752.  
  1753. // 伤害文本
  1754. if (explosion.otherInfo.damage) {
  1755. const fontSize = Math.min(Math.max(12, Math.pow(explosion.otherInfo.damage, 0.7) / 2), 80);
  1756. const damageText = `${explosion.otherInfo.damage}`;
  1757. ctx.font = `${fontSize}px Arial`;
  1758. ctx.textAlign = 'center';
  1759. ctx.textBaseline = 'middle';
  1760. // border
  1761. ctx.strokeStyle = explosion.otherInfo.color;
  1762. ctx.lineWidth = 6;
  1763. ctx.strokeText(damageText, explosion.otherInfo.end.x, explosion.otherInfo.end.y - 20);
  1764. // main
  1765. ctx.fillStyle = 'white';
  1766. const textWidth = ctx.measureText(damageText).width;
  1767. if (textWidth < 100) {
  1768. ctx.fillText(damageText, explosion.otherInfo.end.x, explosion.otherInfo.end.y - 20);
  1769. } else {
  1770. ctx.fillText(damageText, explosion.otherInfo.end.x, explosion.otherInfo.end.y - 20, textWidth + 10);
  1771. }
  1772. }
  1773. ctx.restore();
  1774. }
  1775. }
  1776.  
  1777. // 动画循环
  1778. function animate() {
  1779. // 完全清空画布
  1780. ctx.clearRect(0, 0, canvas.width, canvas.height);
  1781.  
  1782. // 更新并绘制所有弹丸
  1783. for (let i = projectiles.length - 1; i >= 0; i--) {
  1784. const proj = projectiles[i];
  1785. proj.update();
  1786. proj.draw(ctx);
  1787. if (proj.isArrived()) {
  1788. createExplosion(proj.x, proj.y, proj.color, proj.size, proj.otherInfo); // 将弹丸大小传递给爆炸效果
  1789. projectiles.splice(i, 1);
  1790. } else if (proj.isOutOfBounds()) {
  1791. // 超出边界则移除弹丸,不产生爆炸效果
  1792. projectiles.splice(i, 1);
  1793. }
  1794. }
  1795.  
  1796. // 更新和渲染所有爆炸效果
  1797. updateExplosions();
  1798. requestAnimationFrame(animate);
  1799. }
  1800. class Projectile {
  1801. constructor(startX, startY, endX, endY, color, initialSpeed = 1, size = 10, otherInfo = {}) {
  1802. // 基础属性
  1803. this.x = startX;
  1804. this.y = startY;
  1805. this.start = {
  1806. x: startX,
  1807. y: startY
  1808. };
  1809. this.target = {
  1810. x: endX,
  1811. y: endY
  1812. };
  1813. this.otherInfo = otherInfo;
  1814. this.shakeApplied = false;
  1815.  
  1816. // 运动参数 - 向斜上方抛物线轨迹
  1817. this.gravity = 0.2; // 重力加速度
  1818. this.initialSpeed = initialSpeed; // 初始速度参数
  1819.  
  1820. // 计算水平距离和高度差
  1821. const dx = endX - startX;
  1822. const dy = endY - startY;
  1823.  
  1824. // 重新设计飞行时间计算,确保合理
  1825. // const timeInAir = distance / this.initialSpeed / 10;
  1826. const timeInAir = 80 / this.initialSpeed;
  1827.  
  1828. // 计算初始速度,修正公式确保能够到达目标
  1829. this.velocity = {
  1830. x: dx / timeInAir,
  1831. y: dy / timeInAir - this.gravity * timeInAir / 2
  1832. };
  1833.  
  1834. // 大小参数 (范围1-100)
  1835. this.sizeScale = Math.max(1, Math.min(100, size)) / 10; // 转换为比例因子
  1836.  
  1837. // 外观属性
  1838. this.size = 10 * this.sizeScale;
  1839. this.color = color;
  1840.  
  1841. // 拖尾效果
  1842. this.trail = [];
  1843. this.maxTrailLength = Math.floor(50 * Math.sqrt(this.sizeScale)); // 拖尾长度随大小增加
  1844. }
  1845. update() {
  1846. // 更新速度 (考虑重力)
  1847. this.velocity.y += this.gravity;
  1848.  
  1849. // 更新位置
  1850. this.x += this.velocity.x;
  1851. this.y += this.velocity.y;
  1852.  
  1853. // 更新拖尾
  1854. this.trail.push({
  1855. x: this.x,
  1856. y: this.y
  1857. });
  1858. if (this.trail.length > this.maxTrailLength) {
  1859. this.trail.shift();
  1860. }
  1861. }
  1862. draw(canvas) {
  1863. // 绘制拖尾
  1864. this.trail.forEach((pos, index) => {
  1865. const alpha = index / this.trail.length;
  1866. canvas.beginPath();
  1867. canvas.arc(pos.x, pos.y, this.size * alpha, 0, Math.PI * 2);
  1868. canvas.fillStyle = `${this.color}`;
  1869. canvas.fill();
  1870. });
  1871.  
  1872. // 绘制主体
  1873. canvas.beginPath();
  1874. canvas.arc(this.x, this.y, this.size, 0, Math.PI * 2);
  1875. canvas.fillStyle = this.color;
  1876. canvas.fill();
  1877.  
  1878. // 添加光晕效果
  1879. const gradient = canvas.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.size * 2);
  1880. gradient.addColorStop(0, `${this.color}`);
  1881. gradient.addColorStop(1, `${this.color}`);
  1882. canvas.fillStyle = gradient;
  1883. }
  1884. isArrived() {
  1885. // 判断是否到达目标点 (调整判定距离)
  1886. const arrivalDistance = 20;
  1887. const hasArrived = Math.hypot(this.x - this.target.x, this.y - this.target.y) < arrivalDistance;
  1888. if (hasArrived && this.otherInfo.doShake && !this.shakeApplied && this.otherInfo.endElement) {
  1889. const shakeIntensity = Math.min(this.sizeScale * 5, 10);
  1890. applyShakeEffect(this.otherInfo.endElement, shakeIntensity);
  1891. this.shakeApplied = true;
  1892. }
  1893. return hasArrived;
  1894. }
  1895. isOutOfBounds() {
  1896. return this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height;
  1897. }
  1898. }
  1899.  
  1900. // 项目管理
  1901. let projectiles = [];
  1902.  
  1903. // 存储所有活跃的爆炸效果
  1904. let activeExplosions = [];
  1905.  
  1906. // 爆炸效果函数
  1907. function createExplosion(x, y, color, size = 10, otherInfo = {}) {
  1908. // 计算爆炸大小比例
  1909. const sizeScale = Math.max(1, Math.min(100, size)) / 20;
  1910.  
  1911. // 多种粒子系统
  1912. const particles = [];
  1913. const shockwaves = [];
  1914. const embers = [];
  1915. const smokeParticles = [];
  1916.  
  1917. // 主爆炸粒子 - 数量和大小基于sizeScale
  1918. const particleCount = Math.floor(4 * sizeScale);
  1919. for (let i = 0; i < particleCount; i++) {
  1920. particles.push({
  1921. x,
  1922. y,
  1923. angle: Math.random() * Math.PI * 2,
  1924. speed: (Math.random() * 7 + 3) * Math.sqrt(sizeScale),
  1925. size: (Math.random() * 12 + 8) * sizeScale,
  1926. life: 500 * sizeScale,
  1927. // 生命时间随大小增加
  1928. // color: `hsl(${Math.floor(Math.random()*60 + 10)}, 100%, 60%)`,
  1929. color: color,
  1930. gravity: 0.3 + Math.random() * 0.1
  1931. });
  1932. }
  1933.  
  1934. // 冲击波效果 - 大小基于sizeScale
  1935. for (let i = 0; i < Math.ceil(sizeScale); i++) {
  1936. shockwaves.push({
  1937. x,
  1938. y,
  1939. radius: 7 * sizeScale,
  1940. maxRadius: (100 + Math.random() * 100) * sizeScale,
  1941. life: 800 * Math.sqrt(sizeScale),
  1942. // color: `hsla(${Math.floor(Math.random()*30 + 15)}, 100%, 50%, 0.8)`,
  1943. color: color
  1944. });
  1945. }
  1946.  
  1947. // 余烬效果 - 数量和大小基于sizeScale
  1948. const emberCount = Math.floor(20 * sizeScale);
  1949. for (let i = 0; i < emberCount; i++) {
  1950. embers.push({
  1951. x,
  1952. y,
  1953. angle: Math.random() * Math.PI * 2,
  1954. speed: (Math.random() * 2 + 0.5) * Math.sqrt(sizeScale),
  1955. size: (Math.random() * 6 + 2) * sizeScale,
  1956. life: 1200 * Math.sqrt(sizeScale),
  1957. // color: `hsl(${Math.floor(Math.random()*30 + 10)}, 100%, ${Math.floor(Math.random()*50 + 40)}%)`,
  1958. color: color,
  1959. gravity: 0.3
  1960. });
  1961. }
  1962.  
  1963. // 烟雾效果 - 数量和大小基于sizeScale
  1964. const smokeCount = Math.floor(4 * sizeScale);
  1965. for (let i = 0; i < smokeCount; i++) {
  1966. smokeParticles.push({
  1967. x,
  1968. y,
  1969. angle: Math.random() * Math.PI * 2,
  1970. speed: (Math.random() * 1 + 0.2) * Math.sqrt(sizeScale),
  1971. size: (Math.random() * 15 + 8) * sizeScale,
  1972. life: 2000 * Math.sqrt(sizeScale),
  1973. alpha: 0.7,
  1974. gravity: -1 * Math.sqrt(sizeScale) // 烟雾上升速度基于大小
  1975. });
  1976. }
  1977.  
  1978. // 闪光效果
  1979. function drawFlash() {
  1980. const flashRadius = 150 * sizeScale;
  1981. const gradient = ctx.createRadialGradient(x, y, 0, x, y, flashRadius);
  1982. gradient.addColorStop(0, 'rgba(255, 255, 200, 0.8)');
  1983. gradient.addColorStop(0.1, 'rgba(255, 230, 150, 0.6)');
  1984. gradient.addColorStop(0.4, 'rgba(255, 100, 50, 0.2)');
  1985. gradient.addColorStop(1, 'rgba(255, 50, 0, 0)');
  1986. ctx.fillStyle = gradient;
  1987. ctx.fillRect(x - flashRadius, y - flashRadius, flashRadius * 2, flashRadius * 2);
  1988. }
  1989.  
  1990. // 存储爆炸的活跃状态,用于跟踪
  1991. const explosionData = {
  1992. particles: [...particles],
  1993. shockwaves: [...shockwaves],
  1994. embers: [...embers],
  1995. smokeParticles: [...smokeParticles],
  1996. active: true,
  1997. count: 0,
  1998. maxCount: 120,
  1999. otherInfo: otherInfo
  2000. };
  2001.  
  2002. // 将这个爆炸添加到全局爆炸列表中
  2003. activeExplosions.push(explosionData);
  2004.  
  2005. // 初始闪光
  2006. drawFlash();
  2007. }
  2008. function createProjectile(startElement, endElement, color, initialSpeed = 1, damage = 200, projectileType = 'default') {
  2009. if (!startElement || !endElement) {
  2010. return;
  2011. }
  2012. const combatUnitContainer = endElement.querySelector(".CombatUnit_splatsContainer__2xcc0");
  2013. combatUnitContainer.style.visibility = "hidden";
  2014. const padding = 30;
  2015. const randomRange = {
  2016. x: Math.floor(Math.random() * (combatUnitContainer.offsetWidth - 2 * padding) - combatUnitContainer.offsetWidth / 2 + padding),
  2017. y: Math.floor(Math.random() * (combatUnitContainer.offsetHeight - 2 * padding) - combatUnitContainer.offsetHeight / 2 + padding)
  2018. };
  2019. const projectileLimit = 30;
  2020. const start = getElementCenter(startElement);
  2021. const end = getElementCenter(endElement);
  2022. end.x = Math.floor(end.x + randomRange.x);
  2023. end.y = Math.floor(end.y + randomRange.y);
  2024. const size = Math.min(Math.max(Math.pow(damage + 200, 0.8) / 20, 4), 17);
  2025. const otherInfo = {
  2026. start: start,
  2027. end: end,
  2028. damage: damage,
  2029. color: color,
  2030. doShake: damage > 0,
  2031. startElement: startElement,
  2032. endElement: endElement
  2033. };
  2034. const projectile = new Projectile(start.x, start.y, end.x, end.y, color, initialSpeed, size, otherInfo);
  2035. projectiles.push(projectile);
  2036. if (projectiles.length > projectileLimit) {
  2037. projectiles.shift();
  2038. }
  2039. }
  2040. function getElementCenter(element) {
  2041. const rect = element.getBoundingClientRect();
  2042. if (element.innerText.trim() === '') {
  2043. return {
  2044. x: rect.left + rect.width / 2,
  2045. y: rect.top
  2046. };
  2047. }
  2048. return {
  2049. x: rect.left + rect.width / 2,
  2050. y: rect.top + rect.height / 2
  2051. };
  2052. }
  2053.  
  2054. // #region Setting
  2055. waitForSetttins();
  2056. hookWS();
  2057.  
  2058. // #region Hook WS
  2059. function hookWS() {
  2060. const dataProperty = Object.getOwnPropertyDescriptor(MessageEvent.prototype, "data");
  2061. const oriGet = dataProperty.get;
  2062. dataProperty.get = hookedGet;
  2063. Object.defineProperty(MessageEvent.prototype, "data", dataProperty);
  2064. function hookedGet() {
  2065. const socket = this.currentTarget;
  2066. if (!(socket instanceof WebSocket)) {
  2067. return oriGet.call(this);
  2068. }
  2069. if (socket.url.indexOf("api.milkywayidle.com/ws") <= -1 && socket.url.indexOf("api-test.milkywayidle.com/ws") <= -1) {
  2070. return oriGet.call(this);
  2071. }
  2072. const message = oriGet.call(this);
  2073. Object.defineProperty(this, "data", {
  2074. value: message
  2075. }); // Anti-loop
  2076.  
  2077. return handleMessage(message);
  2078. }
  2079. }
  2080. let monstersHP = [];
  2081. let monstersMP = [];
  2082. let playersHP = [];
  2083. let playersMP = [];
  2084. let playersAbility = [];
  2085. function handleMessage(message) {
  2086. let obj = JSON.parse(message);
  2087. if (obj && obj.type === "new_battle") {
  2088. monstersHP = obj.monsters.map(monster => monster.currentHitpoints);
  2089. monstersMP = obj.monsters.map(monster => monster.currentManapoints);
  2090. playersHP = obj.players.map(player => player.currentHitpoints);
  2091. playersMP = obj.players.map(player => player.currentManapoints);
  2092. } else if (obj && obj.type === "battle_updated" && monstersHP.length) {
  2093. const mMap = obj.mMap;
  2094. const pMap = obj.pMap;
  2095. const monsterIndices = Object.keys(obj.mMap);
  2096. const playerIndices = Object.keys(obj.pMap);
  2097. let castMonster = -1;
  2098. monsterIndices.forEach(monsterIndex => {
  2099. if (mMap[monsterIndex].cMP < monstersMP[monsterIndex]) {
  2100. castMonster = monsterIndex;
  2101. }
  2102. monstersMP[monsterIndex] = mMap[monsterIndex].cMP;
  2103. });
  2104. let castPlayer = -1;
  2105. playerIndices.forEach(userIndex => {
  2106. if (pMap[userIndex].cMP < playersMP[userIndex]) {
  2107. castPlayer = userIndex;
  2108. }
  2109. playersMP[userIndex] = pMap[userIndex].cMP;
  2110. if (pMap[userIndex].abilityHrid) {
  2111. playersAbility[userIndex] = pMap[userIndex].abilityHrid;
  2112. }
  2113. });
  2114. monstersHP.forEach((mHP, mIndex) => {
  2115. const monster = mMap[mIndex];
  2116. if (monster) {
  2117. const hpDiff = mHP - monster.cHP;
  2118. monstersHP[mIndex] = monster.cHP;
  2119. if (hpDiff > 0 && playerIndices.length > 0) {
  2120. if (playerIndices.length > 1) {
  2121. playerIndices.forEach(userIndex => {
  2122. if (userIndex === castPlayer) {
  2123. registProjectile(userIndex, mIndex, hpDiff, false, playersAbility[userIndex]);
  2124. }
  2125. });
  2126. } else {
  2127. registProjectile(playerIndices[0], mIndex, hpDiff, false, playersAbility[playerIndices[0]]);
  2128. }
  2129. }
  2130. }
  2131. });
  2132. playersHP.forEach((pHP, pIndex) => {
  2133. const player = pMap[pIndex];
  2134. if (player) {
  2135. const hpDiff = pHP - player.cHP;
  2136. playersHP[pIndex] = player.cHP;
  2137. if (hpDiff > 0 && monsterIndices.length > 0) {
  2138. if (monsterIndices.length > 1) {
  2139. monsterIndices.forEach(monsterIndex => {
  2140. if (monsterIndex === castMonster) {
  2141. registProjectile(pIndex, monsterIndex, hpDiff, true);
  2142. }
  2143. });
  2144. } else {
  2145. registProjectile(pIndex, monsterIndices[0], hpDiff, true);
  2146. }
  2147. } else if (hpDiff < 0) {
  2148. if (castPlayer > -1) {
  2149. registProjectile(castPlayer, pIndex, -hpDiff, false, 'heal', true);
  2150. }
  2151. }
  2152. }
  2153. });
  2154. } else if (obj && obj.type === "battle_updated") {
  2155. const pMap = obj.pMap;
  2156. const playerIndices = Object.keys(obj.pMap);
  2157. playerIndices.forEach(userIndex => {
  2158. if (pMap[userIndex].abilityHrid) {
  2159. playersAbility[userIndex] = pMap[userIndex].abilityHrid;
  2160. }
  2161. });
  2162. }
  2163. return message;
  2164. }
  2165.  
  2166. // #region Main Logic
  2167.  
  2168. // 动画效果
  2169. function registProjectile(from, to, hpDiff, reversed = false, abilityHrid = 'default', toPlayer = false) {
  2170. if (reversed) {
  2171. if (!settingsMap.tracker6.isTrue) {
  2172. return null;
  2173. }
  2174. } else {
  2175. if (!settingsMap["tracker" + from].isTrue) {
  2176. return null;
  2177. }
  2178. }
  2179. const container = document.querySelector(".BattlePanel_playersArea__vvwlB");
  2180. if (container && container.children.length > 0) {
  2181. const playersContainer = container.children[0];
  2182. const effectFrom = playersContainer.children[from];
  2183. const monsterContainer = document.querySelector(".BattlePanel_monstersArea__2dzrY").children[0];
  2184. const effectTo = toPlayer ? playersContainer.children[to] : monsterContainer.children[to];
  2185. const trackerSetting = reversed ? settingsMap[`tracker6`] : settingsMap["tracker" + from];
  2186. let lineColor = "rgba(" + trackerSetting.r + ", " + trackerSetting.g + ", " + trackerSetting.b + ", 1)";
  2187. // console.log(`registProjectile: ${abilityHrid} ${hpDiff}`);
  2188. if (abilityHrid === 'heal') {
  2189. lineColor = "rgba(93, 212, 93, 0.8)";
  2190. }
  2191. if (!reversed) {
  2192. createProjectile(effectFrom, effectTo, lineColor, 1, hpDiff, abilityHrid);
  2193. } else {
  2194. createProjectile(effectTo, effectFrom, lineColor, 1, hpDiff, abilityHrid);
  2195. }
  2196. }
  2197. }
  2198.  
  2199. // 启动动画
  2200. animate();
  2201.  
  2202. })();