MWI-Hit-Tracker-Canvas

A Tampermonkey script to track MWI hits on Canvas

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

  1. // ==UserScript==
  2. // @name MWI-Hit-Tracker-Canvas
  3. // @namespace MWI-Hit-Tracker-Canvas
  4. // @version 1.0.0
  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. projectileScale: {
  1356. id: "projectileScale",
  1357. desc: isZH ? "投射物缩放" : "Projectile Scale",
  1358. value: 1.0,
  1359. min: 0.1,
  1360. max: 3.0,
  1361. step: 0.01
  1362. },
  1363. onHitScale: {
  1364. id: "onHitScale",
  1365. desc: isZH ? "命中效果缩放" : "On-hit Effect Scale",
  1366. value: 1.0,
  1367. min: 0.1,
  1368. max: 3.0,
  1369. step: 0.01
  1370. },
  1371. projectileHeightScale: {
  1372. id: "projectileHeightScale",
  1373. desc: isZH ? "弹道高度比例" : "Projectile Height Scale",
  1374. value: 1.0,
  1375. min: 0.1,
  1376. max: 3.0,
  1377. step: 0.01
  1378. },
  1379. projectileSpeedScale: {
  1380. id: "projectileSpeedScale",
  1381. desc: isZH ? "弹道速度比例" : "Projectile Speed Scale",
  1382. value: 1.0,
  1383. min: 0.1,
  1384. max: 3.0,
  1385. step: 0.01
  1386. },
  1387. shakeEffectScale: {
  1388. id: "shakeEffectScale",
  1389. desc: isZH ? "震动效果" : "Shake Effect Scale",
  1390. value: 1.0,
  1391. min: 0.0,
  1392. max: 3.0,
  1393. step: 0.01
  1394. },
  1395. particleEffectRatio: {
  1396. id: "particleEffectRatio",
  1397. desc: isZH ? "粒子效果数量" : "Particle Effect Ratio",
  1398. value: 1.0,
  1399. min: 0.0,
  1400. max: 5.0,
  1401. step: 0.1
  1402. },
  1403. particleLifespanRatio: {
  1404. id: "particleLifespanRatio",
  1405. desc: isZH ? "粒子效果持续时长" : "Particle Lifespan Ratio",
  1406. value: 1.0,
  1407. min: 0.1,
  1408. max: 5.0,
  1409. step: 0.1
  1410. },
  1411. projectileTrailLength: {
  1412. id: "projectileTrailLength",
  1413. desc: isZH ? "弹道尾迹长度" : "Projectile Trail Length",
  1414. value: 1.0,
  1415. min: 0.0,
  1416. max: 5.0,
  1417. step: 0.01
  1418. },
  1419. originalDamageDisplay: {
  1420. id: "originalDamageDisplay",
  1421. desc: isZH ? "原版伤害显示" : "Original Damage Display",
  1422. value: false
  1423. },
  1424. damageTextScale: {
  1425. id: "damageTextScale",
  1426. desc: isZH ? "伤害文本大小" : "Damage Text Scale",
  1427. value: 1.0,
  1428. min: 0.1,
  1429. max: 3.0,
  1430. step: 0.1
  1431. },
  1432. damageTextAlpha: {
  1433. id: "damageTextAlpha",
  1434. desc: isZH ? "伤害文本不透明度" : "Damage Text Alpha",
  1435. value: 0.8,
  1436. min: 0.0,
  1437. max: 1.0,
  1438. step: 0.01
  1439. },
  1440. damageTextSizeLimit: {
  1441. id: "damageTextSizeLimit",
  1442. desc: isZH ? "伤害文本尺寸上限" : "Damage Text Size Limit",
  1443. value: 70,
  1444. min: 15,
  1445. max: 200,
  1446. step: 1
  1447. },
  1448. showSelfRegen: {
  1449. id: "showSelfRegen",
  1450. desc: isZH ? "显示玩家被动回复效果" : "Show Self Regeneration",
  1451. value: true
  1452. },
  1453. damageHpBarDropDelay: {
  1454. id: "damageHpBarDropDelay",
  1455. desc: isZH ? "血条掉落延迟" : "Hp Bar Drop Delay",
  1456. value: 300,
  1457. min: 50,
  1458. max: 1000,
  1459. step: 50
  1460. },
  1461. tracker0: {
  1462. id: "tracker0",
  1463. desc: isZH ? "玩家颜色 #1" : "Player Color1",
  1464. isTrue: true,
  1465. r: 255,
  1466. g: 99,
  1467. b: 132
  1468. },
  1469. tracker1: {
  1470. id: "tracker1",
  1471. desc: isZH ? "玩家颜色 #2" : "Player Color2",
  1472. isTrue: true,
  1473. r: 54,
  1474. g: 162,
  1475. b: 235
  1476. },
  1477. tracker2: {
  1478. id: "tracker2",
  1479. desc: isZH ? "玩家颜色 #3" : "Player Color3",
  1480. isTrue: true,
  1481. r: 255,
  1482. g: 206,
  1483. b: 86
  1484. },
  1485. tracker3: {
  1486. id: "tracker3",
  1487. desc: isZH ? "玩家颜色 #4" : "Player Color4",
  1488. isTrue: true,
  1489. r: 75,
  1490. g: 192,
  1491. b: 192
  1492. },
  1493. tracker4: {
  1494. id: "tracker4",
  1495. desc: isZH ? "玩家颜色 #5" : "Player Color5",
  1496. isTrue: true,
  1497. r: 153,
  1498. g: 102,
  1499. b: 255
  1500. },
  1501. tracker6: {
  1502. id: "tracker6",
  1503. desc: isZH ? "敌人颜色" : "Enemies Color",
  1504. isTrue: true,
  1505. r: 255,
  1506. g: 0,
  1507. b: 0
  1508. }
  1509. };
  1510. readSettings();
  1511. function waitForSetttins() {
  1512. const targetNode = document.querySelector("div.SettingsPanel_profileTab__214Bj");
  1513. if (targetNode) {
  1514. if (!targetNode.querySelector("#tracker_settings")) {
  1515. targetNode.insertAdjacentHTML("beforeend", `<div id="tracker_settings"></div>`);
  1516. const insertElem = targetNode.querySelector("div#tracker_settings");
  1517. insertElem.insertAdjacentHTML("beforeend", `<div style="float: left; color: orange">${isZH ? "MWI-Hit-Tracker 设置 :" : "MWI-Hit-Tracker Settings: "}</div></br>`);
  1518. for (const setting of Object.values(settingsMap)) {
  1519. if (setting.id.startsWith("tracker")) {
  1520. 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>`);
  1521. const checkedBox = insertElem.querySelector("#" + setting.id);
  1522. checkedBox.addEventListener("change", e => {
  1523. settingsMap[setting.id].isTrue = e.target.checked;
  1524. saveSettings();
  1525. });
  1526. const colorPreview = document.getElementById('colorPreview_' + setting.id);
  1527. let currentColor = {
  1528. r: setting.r,
  1529. g: setting.g,
  1530. b: setting.b
  1531. };
  1532.  
  1533. // 点击打开颜色选择器
  1534. colorPreview.addEventListener('click', () => {
  1535. const settingColor = {
  1536. r: settingsMap[setting.id].r,
  1537. g: settingsMap[setting.id].g,
  1538. b: settingsMap[setting.id].b
  1539. };
  1540. const modal = createColorPicker(settingColor, newColor => {
  1541. currentColor = newColor;
  1542. settingsMap[setting.id].r = newColor.r;
  1543. settingsMap[setting.id].g = newColor.g;
  1544. settingsMap[setting.id].b = newColor.b;
  1545. localStorage.setItem("tracker_settingsMap", JSON.stringify(settingsMap));
  1546. updatePreview();
  1547. });
  1548. document.body.appendChild(modal);
  1549. });
  1550. function updatePreview() {
  1551. colorPreview.style.backgroundColor = `rgb(${currentColor.r},${currentColor.g},${currentColor.b})`;
  1552. }
  1553. updatePreview();
  1554. function createColorPicker(initialColor, callback) {
  1555. // 创建弹窗容器
  1556. const backdrop = document.createElement('div');
  1557. backdrop.className = 'modal-backdrop';
  1558. const modal = document.createElement('div');
  1559. modal.className = 'color-picker-modal';
  1560.  
  1561. // 创建SVG容器
  1562. const preview = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  1563. preview.setAttribute("width", "200");
  1564. preview.setAttribute("height", "150");
  1565. preview.style.display = 'block';
  1566. // 创建抛物线路径
  1567. const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
  1568. Object.assign(path.style, {
  1569. strokeWidth: '5px',
  1570. fill: 'none',
  1571. strokeLinecap: 'round'
  1572. });
  1573. path.setAttribute("d", "M 0 130 Q 100 0 200 130");
  1574. preview.appendChild(path);
  1575.  
  1576. // 颜色控制组件
  1577. const controls = document.createElement('div');
  1578. ['r', 'g', 'b'].forEach(channel => {
  1579. const container = document.createElement('div');
  1580. container.className = 'slider-container';
  1581.  
  1582. // 标签
  1583. const label = document.createElement('label');
  1584. label.textContent = channel.toUpperCase() + ':';
  1585. label.style.color = "white";
  1586.  
  1587. // 滑块
  1588. const slider = document.createElement('input');
  1589. slider.type = 'range';
  1590. slider.min = 0;
  1591. slider.max = 255;
  1592. slider.value = initialColor[channel];
  1593.  
  1594. // 输入框
  1595. const input = document.createElement('input');
  1596. input.type = 'number';
  1597. input.min = 0;
  1598. input.max = 255;
  1599. input.value = initialColor[channel];
  1600. input.style.width = '60px';
  1601.  
  1602. // 双向绑定
  1603. const updateChannel = value => {
  1604. value = Math.min(255, Math.max(0, parseInt(value) || 0));
  1605. slider.value = value;
  1606. input.value = value;
  1607. currentColor[channel] = value;
  1608. path.style.stroke = getColorString(currentColor);
  1609. };
  1610. slider.addEventListener('input', e => updateChannel(e.target.value));
  1611. input.addEventListener('change', e => updateChannel(e.target.value));
  1612. container.append(label, slider, input);
  1613. controls.append(container);
  1614. });
  1615.  
  1616. // 操作按钮
  1617. const actions = document.createElement('div');
  1618. actions.className = 'modal-actions';
  1619. const confirmBtn = document.createElement('button');
  1620. confirmBtn.textContent = isZH ? '确定' : 'OK';
  1621. confirmBtn.onclick = () => {
  1622. callback(currentColor);
  1623. backdrop.remove();
  1624. };
  1625. const cancelBtn = document.createElement('button');
  1626. cancelBtn.textContent = isZH ? '取消' : 'Cancel';
  1627. cancelBtn.onclick = () => backdrop.remove();
  1628. actions.append(cancelBtn, confirmBtn);
  1629.  
  1630. // 组装弹窗
  1631. const getColorString = color => `rgb(${color.r},${color.g},${color.b})`;
  1632. path.style.stroke = getColorString(settingsMap[setting.id]);
  1633. modal.append(preview, controls, actions);
  1634. backdrop.append(modal);
  1635.  
  1636. // 点击背景关闭
  1637. backdrop.addEventListener('click', e => {
  1638. if (e.target === backdrop) backdrop.remove();
  1639. });
  1640. return backdrop;
  1641. }
  1642. } else {
  1643. if (typeof setting.value === "boolean") {
  1644. insertElem.insertAdjacentHTML("beforeend", `<div class="tracker-option">${setting.desc}<input type="checkbox" id="trackerSetting_${setting.id}"></input></div>`);
  1645. const checkedBox = insertElem.querySelector("#trackerSetting_" + setting.id);
  1646. checkedBox.checked = setting.value;
  1647. checkedBox.addEventListener("change", e => {
  1648. settingsMap[setting.id].value = e.target.checked;
  1649. saveSettings();
  1650. });
  1651. } else if (typeof setting.value === "number") {
  1652. insertElem.insertAdjacentHTML("beforeend", `<div class="tracker-option">${setting.desc}<input type="range" id="trackerSetting_${setting.id}_range"></input><input type="number" id="trackerSetting_${setting.id}_value"></input></div>`);
  1653. const slider = document.querySelector("#trackerSetting_" + setting.id + "_range");
  1654. slider.min = setting.min;
  1655. slider.max = setting.max;
  1656. slider.step = setting.step || 0.05;
  1657. slider.value = setting.value;
  1658. const input = document.querySelector("#trackerSetting_" + setting.id + "_value");
  1659. input.min = setting.min;
  1660. input.max = setting.max;
  1661. input.step = setting.step || 0.05;
  1662. input.value = setting.value;
  1663. const updateChannel = value => {
  1664. value = Math.min(setting.max, Math.max(setting.min, parseFloat(value)));
  1665. slider.value = value;
  1666. input.value = value;
  1667. settingsMap[setting.id].value = value;
  1668. };
  1669. slider.addEventListener('input', e => updateChannel(e.target.value));
  1670. input.addEventListener('change', e => updateChannel(e.target.value));
  1671. }
  1672. }
  1673. }
  1674. insertElem.addEventListener("change", saveSettings);
  1675. }
  1676. }
  1677. setTimeout(waitForSetttins, 500);
  1678. }
  1679. function saveSettings() {
  1680. localStorage.setItem("tracker_settingsMap", JSON.stringify(settingsMap));
  1681. }
  1682. function readSettings() {
  1683. const ls = localStorage.getItem("tracker_settingsMap");
  1684. if (ls) {
  1685. const lsObj = JSON.parse(ls);
  1686. for (const option of Object.values(lsObj)) {
  1687. if (option.id.startsWith("tracker")) {
  1688. if (settingsMap.hasOwnProperty(option.id)) {
  1689. settingsMap[option.id].isTrue = option.isTrue;
  1690. settingsMap[option.id].r = option.r;
  1691. settingsMap[option.id].g = option.g;
  1692. settingsMap[option.id].b = option.b;
  1693. }
  1694. } else {
  1695. settingsMap[option.id].value = option.value;
  1696. }
  1697. }
  1698. }
  1699. }
  1700. const style = document.createElement('style');
  1701. style.textContent = `
  1702. .tracker-option {
  1703. display: flex;
  1704. align-items: left;
  1705. gap: 10px;
  1706. }
  1707.  
  1708. .color-preview {
  1709. cursor: pointer;
  1710. width: 20px;
  1711. height: 20px;
  1712. margin: 3px 3px;
  1713. border: 1px solid #ccc;
  1714. border-radius: 3px;
  1715. }
  1716.  
  1717. .color-picker-modal {
  1718. position: fixed;
  1719. top: 50%;
  1720. left: 50%;
  1721. transform: translate(-50%, -50%);
  1722. background: rgba(0, 0, 0, 0.5);
  1723. padding: 20px;
  1724. border: 1px solid rgba(255, 255, 255, 0.2);
  1725. border-radius: 8px;
  1726. box-shadow: 0 0 20px rgba(0,0,0,0.2);
  1727. z-index: 1000;
  1728. }
  1729.  
  1730. .modal-backdrop {
  1731. position: fixed;
  1732. top: 0;
  1733. left: 0;
  1734. right: 0;
  1735. bottom: 0;
  1736. background: rgba(0,0,0,0.5);
  1737. z-index: 999;
  1738. }
  1739.  
  1740. .modal-actions {
  1741. margin-top: 20px;
  1742. display: flex;
  1743. gap: 10px;
  1744. justify-content: flex-end;
  1745. }
  1746. `;
  1747. document.head.appendChild(style);
  1748.  
  1749. const onHitEffectsMap = {
  1750. "smoke": {
  1751. angle: p => Math.random() * Math.PI * 2,
  1752. alpha: p => 0.7,
  1753. speed: p => (Math.random() * 0.2 + 0.1) * Math.sqrt(p.size),
  1754. size: p => (Math.random() * 20 + 10) * p.size,
  1755. life: p => 4000 * Math.sqrt(p.size),
  1756. gravity: p => -0.2 * Math.sqrt(p.size),
  1757. draw: (ctx, p) => {
  1758. if (!p.initialized) {
  1759. p.initialized = true;
  1760. p.y -= 5 * p.size;
  1761. p.sizeVariation = Math.random() * 0.2 + 0.9; // Size variation for billowing effect
  1762. p.rotationSpeed = (Math.random() - 0.5) * 0.02; // Slow rotation
  1763. p.rotation = Math.random() * Math.PI * 2;
  1764. }
  1765. p.speed *= 0.995; // Slower deceleration
  1766. p.x += Math.cos(p.angle) * p.speed;
  1767. p.y += Math.sin(p.angle) * p.speed + p.gravity;
  1768. p.life -= 1;
  1769. p.alpha = Math.max(0, p.alpha - 0.001);
  1770. p.rotation += p.rotationSpeed;
  1771. if (p.life > 0) {
  1772. ctx.save();
  1773. ctx.translate(p.x, p.y);
  1774. ctx.rotate(p.rotation);
  1775.  
  1776. // Draw main smoke puff
  1777. ctx.beginPath();
  1778. ctx.ellipse(0, 0, p.size * p.sizeVariation, p.size, 0, 0, Math.PI * 2);
  1779. ctx.fillStyle = `rgba(80, 80, 80, ${p.alpha * (p.life / 2000)})`;
  1780. ctx.fill();
  1781.  
  1782. // Add some variation to the smoke puff
  1783. ctx.beginPath();
  1784. ctx.ellipse(p.size * 0.3, -p.size * 0.2, p.size * 0.6, p.size * 0.8, 0, 0, Math.PI * 2);
  1785. ctx.fillStyle = `rgba(80, 80, 80, ${p.alpha * 0.7 * (p.life / 2000)})`;
  1786. ctx.fill();
  1787. ctx.restore();
  1788. }
  1789. }
  1790. },
  1791. "ember": {
  1792. angle: p => Math.random() * Math.PI * 2,
  1793. alpha: p => 1,
  1794. speed: p => (Math.random() * 2 + 0.5) * Math.sqrt(p.size),
  1795. size: p => (Math.random() * 6 + 2) * p.size,
  1796. life: p => 1200 * Math.sqrt(p.size),
  1797. gravity: p => 0.3,
  1798. draw: (ctx, p) => {
  1799. p.speed *= 0.99; // 慢慢减速
  1800. p.x += Math.cos(p.angle) * p.speed;
  1801. p.y += Math.sin(p.angle) * p.speed + p.gravity;
  1802. p.life -= 3;
  1803. if (p.life > 0) {
  1804. const alpha = p.life / 800;
  1805. ctx.beginPath();
  1806. ctx.arc(p.x, p.y, p.size * (p.life / 800), 0, Math.PI * 2);
  1807. ctx.fillStyle = `${p.color.slice(0, -4)}%, ${alpha})`;
  1808. ctx.fill();
  1809.  
  1810. // 余烬偶尔产生的小火花
  1811. if (Math.random() < 0.03) {
  1812. ctx.beginPath();
  1813. ctx.arc(p.x, p.y, p.size * 1.5, 0, Math.PI * 2);
  1814. ctx.fillStyle = `hsla(30, 100%, 70%, ${alpha * 0.7})`;
  1815. ctx.fill();
  1816. }
  1817. }
  1818. }
  1819. },
  1820. "shockwave": {
  1821. size: p => 10 * p.size,
  1822. life: p => 800 * Math.sqrt(p.size),
  1823. draw: (ctx, p) => {
  1824. if (!p.maxSize) {
  1825. p.maxSize = p.size * (150 + Math.random() * 100) / 10;
  1826. }
  1827. p.size += (p.maxSize - p.size) * 0.1;
  1828. p.life -= 10;
  1829. if (p.life > 0) {
  1830. const alpha = p.life / 400;
  1831. ctx.beginPath();
  1832. ctx.strokeStyle = p.color;
  1833. ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
  1834. ctx.lineWidth = 5 * alpha;
  1835. ctx.stroke();
  1836. }
  1837. }
  1838. },
  1839. "smallParticle": {
  1840. angle: p => Math.random() * Math.PI * 2,
  1841. size: p => (Math.random() * 12 + 8) * p.size,
  1842. speed: p => (Math.random() * 6 + 2) * Math.sqrt(p.size),
  1843. gravity: p => 0.3 + Math.random() * 0.1,
  1844. life: p => 400 * p.size,
  1845. draw: (ctx, p) => {
  1846. p.size = p.size * (1 - p.life / 400);
  1847. p.x += Math.cos(p.angle) * p.speed;
  1848. p.y += Math.sin(p.angle) * p.speed + p.gravity;
  1849. p.life -= 3;
  1850. if (p.life > 0) {
  1851. ctx.beginPath();
  1852. ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
  1853. ctx.fillStyle = p.color;
  1854. ctx.fill();
  1855. }
  1856. }
  1857. },
  1858. "holyCross": {
  1859. x: p => p.x + (Math.random() - 0.5) * 60,
  1860. y: p => p.y + (Math.random() - 0.5) * 10,
  1861. size: p => (8 * Math.random() + 12) * p.size,
  1862. life: p => 1200 * Math.sqrt(p.size),
  1863. speed: p => 0,
  1864. gravity: p => -0.008 * Math.random() - 0.008,
  1865. draw: (ctx, p) => {
  1866. p.speed += p.gravity;
  1867. p.y += p.speed;
  1868. p.life -= 3;
  1869. if (p.life > 0) {
  1870. ctx.save();
  1871. ctx.translate(p.x, p.y);
  1872. ctx.fillStyle = p.color;
  1873. ctx.fillRect(-p.size / 2, -p.size * 2, p.size, p.size * 4);
  1874. ctx.fillRect(-p.size * 2, -p.size / 2, p.size * 4, p.size);
  1875. ctx.restore();
  1876. }
  1877. }
  1878. },
  1879. "leaf": {
  1880. // Made by HwiteCat
  1881. x: p => p.x + (Math.random() - 0.5) * 60,
  1882. y: p => p.y + (Math.random() - 0.5) * 10,
  1883. angle: p => Math.random() * Math.PI * 2,
  1884. size: p => (12 * Math.random() + 8) * p.size,
  1885. life: p => 1250 * p.size,
  1886. speed: p => (Math.random() * 3 + 1) * Math.sqrt(p.size),
  1887. gravity: p => 0.12,
  1888. draw: (ctx, p) => {
  1889. if (!p.rotation) p.rotation = Math.random() * Math.PI * 2;
  1890. if (!p.rotationSpeed) p.rotationSpeed = (Math.random() - 0.5) * 0.02;
  1891. if (!p.sway) p.sway = (Math.random() - 0.5) * 0.2;
  1892. if (!p.swaySpeed) p.swaySpeed = (Math.random() - 0.5) * 0.02;
  1893. p.speed *= 0.98;
  1894. p.x += Math.cos(p.angle) * p.speed;
  1895. p.y += Math.sin(p.angle) * p.speed + p.gravity;
  1896. p.life -= 3;
  1897. if (p.rotation !== undefined) {
  1898. p.rotation += p.rotationSpeed;
  1899. }
  1900. if (p.scale !== undefined) {
  1901. p.scale += p.scaleSpeed;
  1902. p.scale = Math.max(0.1, p.scale);
  1903. }
  1904. if (p.sway !== undefined) {
  1905. p.x += Math.sin(p.y * p.swaySpeed) * p.sway;
  1906. }
  1907. if (p.life > 0) {
  1908. ctx.save();
  1909. ctx.translate(p.x, p.y);
  1910. ctx.rotate(p.rotation);
  1911. ctx.scale(p.scale, 1);
  1912. ctx.beginPath();
  1913. ctx.moveTo(0, -p.size);
  1914. ctx.bezierCurveTo(p.size / 2, -p.size / 2, p.size / 2, 0, 0, p.size);
  1915. ctx.bezierCurveTo(-p.size / 2, 0, -p.size / 2, -p.size / 2, 0, -p.size);
  1916. ctx.fillStyle = p.color;
  1917. ctx.fill();
  1918. ctx.restore();
  1919. }
  1920. }
  1921. },
  1922. "slash": {
  1923. // Main slash effect
  1924. x: p => p.x,
  1925. y: p => p.y,
  1926. angle: p => Math.random() * Math.PI * 2,
  1927. size: p => 3 * p.size,
  1928. life: p => 300 * p.size,
  1929. draw: (ctx, p) => {
  1930. if (!p.length) p.length = p.size * (120 + Math.random() * 80); // More consistent length
  1931. if (!p.maxWidth) p.maxWidth = 1.5 * Math.sqrt(p.size); // Thinner slash
  1932. p.life -= 2; // Even slower fade
  1933.  
  1934. if (p.life > 0) {
  1935. const alpha = p.life / 300 * p.size;
  1936. ctx.save();
  1937. ctx.translate(p.x, p.y);
  1938. ctx.rotate(p.angle);
  1939.  
  1940. // Draw main slash line with improved tapered shape
  1941. ctx.beginPath();
  1942. ctx.moveTo(-p.length / 2, 0);
  1943. ctx.quadraticCurveTo(-p.length / 4, -p.maxWidth * 0.6, -p.length / 6, -p.maxWidth);
  1944. ctx.lineTo(p.length / 6, -p.maxWidth);
  1945. ctx.quadraticCurveTo(p.length / 4, -p.maxWidth * 0.6, p.length / 2, 0);
  1946. ctx.quadraticCurveTo(p.length / 4, p.maxWidth * 0.6, p.length / 6, p.maxWidth);
  1947. ctx.lineTo(-p.length / 6, p.maxWidth);
  1948. ctx.quadraticCurveTo(-p.length / 4, p.maxWidth * 0.6, -p.length / 2, 0);
  1949. ctx.closePath();
  1950. ctx.fillStyle = p.color.replace('0.9', alpha.toString());
  1951. ctx.fill();
  1952.  
  1953. // Enhanced glow effect
  1954. ctx.beginPath();
  1955. ctx.moveTo(-p.length / 2, 0);
  1956. ctx.quadraticCurveTo(-p.length / 4, -p.maxWidth * 0.8, -p.length / 6, -p.maxWidth * 1.5);
  1957. ctx.lineTo(p.length / 6, -p.maxWidth * 1.5);
  1958. ctx.quadraticCurveTo(p.length / 4, -p.maxWidth * 0.8, p.length / 2, 0);
  1959. ctx.quadraticCurveTo(p.length / 4, p.maxWidth * 0.8, p.length / 6, p.maxWidth * 1.5);
  1960. ctx.lineTo(-p.length / 6, p.maxWidth * 1.5);
  1961. ctx.quadraticCurveTo(-p.length / 4, p.maxWidth * 0.8, -p.length / 2, 0);
  1962. ctx.closePath();
  1963. ctx.fillStyle = p.color.replace('0.9', (alpha * 0.3).toString());
  1964. ctx.fill();
  1965. ctx.restore();
  1966. }
  1967. }
  1968. },
  1969. "slashParticle": {
  1970. // Enhanced particle effect for slash
  1971. x: p => p.x + (Math.random() - 0.5) * 15,
  1972. // Tighter initial spread
  1973. y: p => p.y + (Math.random() - 0.5) * 15,
  1974. angle: p => {
  1975. const baseAngle = p.parentAngle || Math.random() * Math.PI * 2;
  1976. return baseAngle + (Math.random() - 0.5) * 0.1; // Very small variation
  1977. },
  1978. size: p => (2 * Math.random() + 2) * p.size,
  1979. // Bigger particles
  1980. life: p => 600 * p.size,
  1981. // Adjusted for faster movement
  1982. speed: p => (Math.random() * 1 + 3) * Math.sqrt(p.size),
  1983. // Much faster speed
  1984. gravity: p => 0.02,
  1985. // Minimal gravity for more directional movement
  1986. draw: (ctx, p) => {
  1987. p.speed *= 0.998; // Very smooth deceleration
  1988. p.x += Math.cos(p.angle) * p.speed;
  1989. p.y += Math.sin(p.angle) * p.speed + p.gravity;
  1990. p.life -= 3;
  1991. if (p.life > 0) {
  1992. const alpha = p.life / 400;
  1993. ctx.save();
  1994. ctx.translate(p.x, p.y);
  1995. ctx.rotate(p.angle);
  1996.  
  1997. // Draw particle with more elongation in movement direction
  1998. ctx.beginPath();
  1999. ctx.moveTo(-p.size / 2, 0);
  2000. ctx.quadraticCurveTo(-p.size / 4, -p.size / 2, 0, -p.size * 1.2);
  2001. ctx.quadraticCurveTo(p.size / 4, -p.size / 2, p.size / 2, 0);
  2002. ctx.quadraticCurveTo(p.size / 4, p.size / 2, 0, p.size * 1.2);
  2003. ctx.quadraticCurveTo(-p.size / 4, p.size / 2, -p.size / 2, 0);
  2004. ctx.closePath();
  2005. ctx.fillStyle = p.color.replace('0.9', alpha.toString());
  2006. ctx.fill();
  2007.  
  2008. // Add small glow to particles
  2009. ctx.beginPath();
  2010. ctx.arc(0, 0, p.size * 1.2, 0, Math.PI * 2);
  2011. ctx.fillStyle = p.color.replace('0.9', (alpha * 0.3).toString());
  2012. ctx.fill();
  2013. ctx.restore();
  2014. }
  2015. }
  2016. },
  2017. "waterRipple": {
  2018. x: p => p.x,
  2019. y: p => p.y,
  2020. size: p => 3 * p.size,
  2021. life: p => 1200 * p.size,
  2022. draw: (ctx, p) => {
  2023. if (!p.ripples) {
  2024. p.ripples = [{
  2025. radius: 0,
  2026. opacity: 0.5,
  2027. width: 3,
  2028. speed: 0.7
  2029. },
  2030. // Fast, bright inner ripple
  2031. {
  2032. radius: 0,
  2033. opacity: 0.5,
  2034. width: 2,
  2035. speed: 0.5
  2036. },
  2037. // Medium ripple
  2038. {
  2039. radius: 0,
  2040. opacity: 0.5,
  2041. width: 1.5,
  2042. speed: 0.3
  2043. } // Slow, faint outer ripple
  2044. ];
  2045. }
  2046. p.life -= 1;
  2047.  
  2048. // Update each ripple
  2049. p.ripples.forEach((ripple, index) => {
  2050. // Expand the ripple
  2051. ripple.radius += ripple.speed;
  2052.  
  2053. // Calculate opacity based on radius
  2054. const maxRadius = 30 * p.size;
  2055. const fadeStart = maxRadius * 0.6;
  2056. if (ripple.radius > fadeStart) {
  2057. ripple.opacity *= 0.98; // Gradual fade out
  2058. }
  2059.  
  2060. // Draw the ripple if it's still visible
  2061. if (ripple.opacity > 0.05 && ripple.radius < maxRadius) {
  2062. ctx.beginPath();
  2063. ctx.strokeStyle = p.color.replace('0.8', ripple.opacity.toString());
  2064. ctx.lineWidth = ripple.width * (1 - ripple.radius / maxRadius);
  2065. ctx.arc(p.x, p.y, ripple.radius, 0, Math.PI * 2);
  2066. ctx.stroke();
  2067.  
  2068. // Add a second, fainter ring for more water-like effect
  2069. if (ripple.radius > 5) {
  2070. ctx.beginPath();
  2071. ctx.strokeStyle = p.color.replace('0.8', (ripple.opacity * 0.5).toString());
  2072. ctx.lineWidth = ripple.width * 0.5 * (1 - ripple.radius / maxRadius);
  2073. ctx.arc(p.x, p.y, ripple.radius - 2, 0, Math.PI * 2);
  2074. ctx.stroke();
  2075. }
  2076. }
  2077. });
  2078. }
  2079. },
  2080. "waterSplash": {
  2081. x: p => p.x,
  2082. y: p => p.y,
  2083. size: p => (2 * Math.random() + 5) * p.size,
  2084. // Smaller size
  2085. life: p => 800 * p.size,
  2086. draw: (ctx, p) => {
  2087. if (!p.initialized) {
  2088. p.initialized = true;
  2089. p.particles = [];
  2090. // Create particles in a circular pattern
  2091. const particleCount = 7; // More particles for better coverage
  2092. for (let i = 0; i < particleCount; i++) {
  2093. const angle = i / particleCount * Math.PI * 2;
  2094. // Add some random variation to the angle
  2095. const angleVariation = (Math.random() - 0.5) * 0.5;
  2096. const finalAngle = angle + angleVariation;
  2097.  
  2098. // Create size variation with smaller base size
  2099. const sizeVariation = Math.random() * 1.5 + 0.5; // Random multiplier between 0.5 and 2
  2100. const baseSize = (Math.random() * 0.8 + 0.4) * p.size; // Reduced base size
  2101.  
  2102. p.particles.push({
  2103. x: p.x,
  2104. y: p.y,
  2105. angle: finalAngle,
  2106. speed: (Math.random() * 1.5 + 1) * Math.sqrt(p.size),
  2107. size: baseSize * sizeVariation,
  2108. initialSize: baseSize * sizeVariation,
  2109. life: 800 * p.size,
  2110. gravity: 0.9 + (Math.random() * 0.2 - 0.1) // Slight gravity variation
  2111. });
  2112. }
  2113. }
  2114. p.life -= 2;
  2115.  
  2116. // Update and draw particles
  2117. p.particles.forEach(particle => {
  2118. particle.speed *= 0.98; // Deceleration
  2119. particle.x += Math.cos(particle.angle) * particle.speed;
  2120. particle.y += Math.sin(particle.angle) * particle.speed + particle.gravity;
  2121. particle.life -= 2;
  2122. const lifeRatio = particle.life / (800 * p.size);
  2123. const opacity = lifeRatio * 0.6; // More transparent
  2124. // More dramatic shrinking with cubic easing
  2125. particle.size = particle.initialSize * Math.pow(lifeRatio, 3);
  2126. if (particle.life > 0) {
  2127. ctx.beginPath();
  2128. ctx.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2);
  2129. ctx.fillStyle = p.color.replace('0.8', opacity.toString());
  2130. ctx.fill();
  2131. }
  2132. });
  2133. }
  2134. }
  2135. };
  2136.  
  2137. /*
  2138. projectEffect = {
  2139. speedFactor: 1, // 速度因子
  2140. trailLength: 50, // 尾迹长度
  2141. gravity: 0.2, // 重力
  2142. shake: true, // 是否震动
  2143. color: rgba(0, 0, 0, 0), // 强制颜色
  2144. onHit: { // 碰撞时的粒子效果
  2145. "smoke": 0,
  2146. },
  2147. draw: (ctx, p) => { // 绘制函数, ctx为canvas的上下文对象, p为Projectile对象
  2148.  
  2149. },
  2150. glow: (ctx, p) => { // 光晕绘制函数, ctx为canvas的上下文对象, p为Projectile对象,空则不绘制
  2151.  
  2152. },
  2153. }
  2154. */
  2155.  
  2156. const projectileEffectsMap = {
  2157. 'fireball': {
  2158. speedFactor: 1,
  2159. trailLength: 35,
  2160. shake: true,
  2161. onHit: {
  2162. "smoke": size => Math.min(Math.ceil(size * 4), 8),
  2163. "ember": size => Math.min(Math.ceil(size * 10), 40),
  2164. "shockwave": size => Math.min(Math.ceil(size), 4),
  2165. "smallParticle": size => Math.min(Math.ceil(size * 4), 10)
  2166. },
  2167. draw: (ctx, p) => {
  2168. ctx.beginPath();
  2169. ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
  2170. ctx.fillStyle = p.color;
  2171. ctx.fill();
  2172. },
  2173. glow: (ctx, p) => {
  2174. const gradient = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.size * 2);
  2175. gradient.addColorStop(0, `${p.color}`);
  2176. gradient.addColorStop(1, `${p.color}`);
  2177. ctx.fillStyle = gradient;
  2178. },
  2179. trail: (ctx, p, i) => {
  2180. const alpha = i / p.totalLength;
  2181. ctx.beginPath();
  2182. ctx.arc(p.x, p.y, p.size * alpha, 0, Math.PI * 2);
  2183. ctx.fillStyle = p.color.replace(/rgba\(([^,]+),([^,]+),([^,]+),[^)]+\)/, `rgba($1,$2,$3,${alpha})`);
  2184. ctx.fill();
  2185. }
  2186. },
  2187. 'nature': {
  2188. speedFactor: 1,
  2189. gravity: 0.1,
  2190. trailLength: 60,
  2191. shake: true,
  2192. onHit: {
  2193. "leaf": size => Math.min(Math.ceil(size * 14), 30)
  2194. },
  2195. draw: (ctx, p) => {
  2196. const size = p.size * 3;
  2197. p.rotation = Math.atan2(p.velocity.y, p.velocity.x) - Math.PI / 2;
  2198. ctx.save();
  2199. ctx.translate(p.x, p.y);
  2200. ctx.rotate(p.rotation);
  2201. ctx.scale(p.scale, 1);
  2202. ctx.beginPath();
  2203. ctx.moveTo(0, -size);
  2204. ctx.bezierCurveTo(size / 2, -size / 2, size / 2, 0, 0, size);
  2205. ctx.bezierCurveTo(-size / 2, 0, -size / 2, -size / 2, 0, -size);
  2206. ctx.fillStyle = p.color;
  2207. ctx.fill();
  2208. ctx.restore();
  2209. },
  2210. trail: (ctx, p, i) => {
  2211. const alpha = i / p.totalLength;
  2212. p.x = p.x + (Math.random() - 0.5) * 5;
  2213. p.y = p.y - (Math.random() - 0.5) * 1 + 0.02;
  2214. ctx.beginPath();
  2215. const lineWidth = p.size * Math.sqrt(alpha);
  2216. ctx.strokeStyle = `${p.color.replace(/rgba\(([^,]+),([^,]+),([^,]+),[^)]+\)/, `rgba($1,$2,$3,${alpha})`)}`;
  2217. ctx.lineWidth = lineWidth;
  2218. ctx.moveTo(p.x, p.y);
  2219. ctx.lineTo(p.x + (Math.random() - 0.5) * 20, p.y + (Math.random() - 0.5) * 20);
  2220. ctx.stroke();
  2221. ctx.fill();
  2222. }
  2223. },
  2224. 'slash': {
  2225. speedFactor: 2,
  2226. gravity: -0.2,
  2227. trailLength: 30,
  2228. shake: true,
  2229. onHit: {
  2230. "slash": size => Math.min(Math.ceil(size * 4), 8),
  2231. "slashParticle": size => Math.min(Math.ceil(size * 8), 20)
  2232. }
  2233. // draw: (ctx, p) => {
  2234. // ctx.beginPath();
  2235. // ctx.moveTo(p.x, p.y + p.size * 2);
  2236. // ctx.lineTo(p.x - p.size * 2, p.y - p.size * 2);
  2237. // ctx.lineTo(p.x + p.size * 2, p.y - p.size * 2);
  2238. // ctx.closePath();
  2239. // ctx.fillStyle = p.color;
  2240. // ctx.fill();
  2241. // }
  2242. },
  2243. 'water': {
  2244. speedFactor: 1.2,
  2245. trailLength: 60,
  2246. shake: true,
  2247. onHit: {
  2248. "waterRipple": size => Math.min(Math.ceil(size * 8), 12),
  2249. "waterSplash": size => Math.min(Math.ceil(size * 8), 20)
  2250. },
  2251. draw: (ctx, p) => {
  2252. ctx.beginPath();
  2253. ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
  2254. ctx.fillStyle = p.color;
  2255. ctx.fill();
  2256. },
  2257. trail: (ctx, p, i) => {
  2258. const alpha = i / p.totalLength;
  2259. p.x = p.x + (Math.random() - 0.5) * 5;
  2260. p.y = p.y - (Math.random() - 0.5) * 1;
  2261. ctx.beginPath();
  2262. ctx.arc(p.x, p.y, p.size * alpha, 0, Math.PI * 2);
  2263. ctx.fillStyle = p.color.replace(/rgba\(([^,]+),([^,]+),([^,]+),[^)]+\)/, `rgba($1,$2,$3,${alpha})`);
  2264. ctx.fill();
  2265. }
  2266. },
  2267. 'heal': {
  2268. trailLength: 60,
  2269. shake: false,
  2270. color: 'rgba(93, 212, 93, 0.8)',
  2271. onHit: {
  2272. "holyCross": size => Math.min(Math.ceil(size * 12), 10)
  2273. },
  2274. draw: (ctx, p) => {
  2275. ctx.beginPath();
  2276. ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
  2277. ctx.fillStyle = p.color;
  2278. ctx.fill();
  2279. }
  2280. },
  2281. 'range': {
  2282. speedFactor: 1.5,
  2283. gravity: 0.2,
  2284. trailLength: 30,
  2285. shake: true,
  2286. onHit: {
  2287. "shockwave": size => Math.min(Math.ceil(size), 4),
  2288. "slashParticle": size => Math.min(Math.ceil(size * 8), 20)
  2289. },
  2290. draw: (ctx, p) => {
  2291. ctx.beginPath();
  2292. ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
  2293. ctx.fillStyle = p.color;
  2294. ctx.fill();
  2295. },
  2296. glow: (ctx, p) => {
  2297. const gradient = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.size * 2);
  2298. gradient.addColorStop(0, `${p.color}`);
  2299. gradient.addColorStop(1, `${p.color}`);
  2300. ctx.fillStyle = gradient;
  2301. }
  2302. },
  2303. 'selfHeal': {
  2304. speedFactor: 10,
  2305. trailLength: 0,
  2306. gravity: 0,
  2307. shake: false,
  2308. color: 'rgba(93, 212, 93, 0.5)',
  2309. onHit: {
  2310. "holyCross": size => Math.min(Math.ceil(size * 12), 10)
  2311. },
  2312. draw: (ctx, p) => {}
  2313. },
  2314. 'selfManaRegen': {
  2315. speedFactor: 10,
  2316. trailLength: 0,
  2317. gravity: 0,
  2318. shake: false,
  2319. color: 'rgba(68, 120, 241, 0.8)',
  2320. onHit: {
  2321. "holyCross": size => Math.min(Math.ceil(size * 12), 10)
  2322. },
  2323. draw: (ctx, p) => {}
  2324. }
  2325. };
  2326.  
  2327. const abilityEffectsMap = {
  2328. 'autoAttack': 'slash',
  2329. 'default': 'fireball',
  2330. 'heal': 'heal',
  2331. '/abilities/fireball': "fireball",
  2332. '/abilities/firestorm': "fireball",
  2333. '/abilities/flame_blast': "fireball",
  2334. '/abilities/smoke_burst': "fireball",
  2335. '/abilities/aqua_arrow': "water",
  2336. '/abilities/frost_surge': "water",
  2337. '/abilities/ice_spear': "water",
  2338. '/abilities/mana_spring': "water",
  2339. '/abilities/water_strike': "water",
  2340. '/abilities/entangle': "nature",
  2341. '/abilities/natures_veil': "nature",
  2342. '/abilities/toxic_pollen': "nature",
  2343. '/abilities/penetrating_shot': "range",
  2344. '/abilities/pestilent_shot': "range",
  2345. '/abilities/steady_shot': "range",
  2346. '/abilities/quick_shot': "range",
  2347. '/abilities/rain_of_arrows': "range",
  2348. '/abilities/silencing_shot': "range",
  2349. '/abilities/crippling_slash': "slash",
  2350. '/abilities/penetrating_strike': "slash",
  2351. '/abilities/impale': "slash",
  2352. '/abilities/maim': "slash",
  2353. '/abilities/poke': "slash",
  2354. '/abilities/puncture': "slash",
  2355. '/abilities/scratch': "slash",
  2356. '/abilities/smack': "slash",
  2357. '/abilities/sweep': "slash",
  2358. '/abilities/stunning_blow': "slash"
  2359. };
  2360.  
  2361. const canvas = initTrackerCanvas();
  2362. const ctx = canvas.getContext('2d');
  2363. function initTrackerCanvas() {
  2364. const gamePanel = document.querySelector("body");
  2365. const canvas = document.createElement('canvas');
  2366. canvas.id = 'hitTrackerCanvas';
  2367. canvas.style.position = 'fixed';
  2368. canvas.style.top = '0';
  2369. canvas.style.left = '0';
  2370. canvas.style.pointerEvents = 'none';
  2371. canvas.style.zIndex = '200';
  2372. canvas.style.width = '100%';
  2373. canvas.style.height = '100%';
  2374. canvas.width = window.innerWidth;
  2375. canvas.height = window.innerHeight;
  2376. canvas.pointerEvents = 'none';
  2377. gamePanel.appendChild(canvas);
  2378. window.addEventListener('resize', () => {
  2379. canvas.width = window.innerWidth;
  2380. canvas.height = window.innerHeight;
  2381. });
  2382. return canvas;
  2383. }
  2384.  
  2385. // Update shake animation effect to ensure element returns to original position
  2386. function applyShakeEffect(element, intensity = 1, duration = 500) {
  2387. if (!element) return;
  2388.  
  2389. // Store the element's original position/transform
  2390. const originalTransform = element.style.transform || '';
  2391. const originalTransition = element.style.transition || '';
  2392. intensity *= settingsMap.shakeEffectScale.value || 1;
  2393.  
  2394. // Scale intensity based on size/damage
  2395. const scaledIntensity = Math.min(10, intensity);
  2396.  
  2397. // Apply CSS animation
  2398. element.style.transition = 'transform 50ms ease-in-out';
  2399. let shakeCount = 0;
  2400. const maxShakes = Math.ceil(intensity);
  2401. const shakeInterval = 50;
  2402. const interval = setInterval(() => {
  2403. if (shakeCount >= maxShakes) {
  2404. // Ensure element returns to original position
  2405. clearInterval(interval);
  2406. element.style.transform = originalTransform;
  2407. element.style.transition = originalTransition;
  2408. return;
  2409. }
  2410.  
  2411. // Random offset for shaking effect
  2412. const xOffset = (Math.random() - 0.5) * 2 * scaledIntensity;
  2413. const yOffset = (Math.random() - 0.5) * 2 * scaledIntensity;
  2414. element.style.transform = `${originalTransform} translate(${xOffset}px, ${yOffset}px)`;
  2415. shakeCount++;
  2416. }, shakeInterval);
  2417.  
  2418. // Additional safeguard: ensure element returns to original position after max duration
  2419. setTimeout(() => {
  2420. clearInterval(interval);
  2421. element.style.transform = 'translate(0, 0)';
  2422. element.style.transition = originalTransition;
  2423. }, shakeInterval * (maxShakes + 1)); // Slightly longer than maxShakes * interval time
  2424. }
  2425. function addDamageHPBar(element, damage) {
  2426. const hpBarContainer = element.querySelector(".HitpointsBar_hitpointsBar__2vIqC");
  2427. const hpBarFront = hpBarContainer.querySelector(".HitpointsBar_currentHp__5exLr");
  2428. // hpBarFront.style.zIndex = "1";
  2429. const hpBarValue = hpBarContainer.querySelector(".HitpointsBar_hpValue__xNp7m");
  2430. // hpBarValue.style.zIndex = "2";
  2431. const hpStat = hpBarValue.innerHTML.split("/");
  2432. const currentHp = parseInt(hpStat[0]);
  2433. const maxHp = parseInt(hpStat[1]);
  2434.  
  2435. // Insert a HpBar behind and set the color to red
  2436. const hpBarBack = document.createElement("div");
  2437. hpBarBack.className = "HitpointsBar_currentHp__5exLr HitTracker_hpDrop";
  2438. hpBarBack.style.background = "var(--color-warning)";
  2439. hpBarBack.style.position = "absolute";
  2440. hpBarBack.style.top = "0px";
  2441. hpBarBack.style.left = "0px";
  2442. // hpBarBack.style.zIndex = "1"; // Ensure the back bar is below the front bar
  2443. hpBarBack.style.width = `${hpBarFront.offsetWidth}px`;
  2444. hpBarBack.style.height = `${hpBarFront.offsetHeight}px`;
  2445. hpBarBack.style.transformOrigin = "left center";
  2446. hpBarBack.style.transform = `scaleX(${(currentHp + damage) / maxHp})`;
  2447. // add animation to drop down
  2448. hpBarBack.style.transition = "transform 0.5s ease-in-out";
  2449. hpBarFront.parentNode.insertBefore(hpBarBack, hpBarFront); // Insert the back bar before the front bar
  2450.  
  2451. const dropDelay = Math.ceil(settingsMap.damageHpBarDropDelay.value || 300);
  2452. setTimeout(() => {
  2453. hpBarBack.style.transform = `scaleX(0)`;
  2454. }, dropDelay);
  2455. setTimeout(() => {
  2456. hpBarBack.remove();
  2457. }, dropDelay + 500);
  2458. }
  2459.  
  2460. // 更新和渲染所有命中效果
  2461. function updateOnHits() {
  2462. // 遍历所有活跃的命中
  2463. for (let i = activeOnHitAnimation.length - 1; i >= 0; i--) {
  2464. const effect = activeOnHitAnimation[i];
  2465. effect.count++;
  2466. if (effect.count >= effect.maxCount) {
  2467. activeOnHitAnimation.splice(i, 1);
  2468. continue;
  2469. }
  2470. ctx.save();
  2471.  
  2472. // 更新各自效果
  2473. effect.effects.forEach((e, index) => {
  2474. e.draw(ctx, e);
  2475. });
  2476.  
  2477. // 伤害文本
  2478. if (effect.otherInfo.damage) {
  2479. const fontSizeScale = settingsMap.damageTextScale.value || 1;
  2480. const fontSizeLimit = settingsMap.damageTextSizeLimit.value || 70;
  2481. const fontAlpha = settingsMap.damageTextAlpha.value || 0.8;
  2482. const fontSize = Math.min(Math.max(14, Math.pow(effect.otherInfo.damage, 0.65) / 2 * fontSizeScale), fontSizeLimit);
  2483. const damageText = `${effect.otherInfo.damage}`;
  2484. ctx.font = `${fontSize}px Arial`;
  2485. ctx.textAlign = 'center';
  2486. ctx.textBaseline = 'middle';
  2487. const textSize = ctx.measureText(damageText);
  2488. const textPosition = {
  2489. x: effect.otherInfo.end.x - textSize.width / 2 + 5,
  2490. y: effect.otherInfo.end.y - 20
  2491. };
  2492.  
  2493. // border
  2494. ctx.strokeStyle = effect.color.replace(/rgba\(([^,]+),([^,]+),([^,]+),[^)]+\)/, `rgba($1,$2,$3,${fontAlpha})`);
  2495. ctx.lineWidth = 6;
  2496. ctx.strokeText(damageText, textPosition.x, textPosition.y);
  2497. // main
  2498. ctx.fillStyle = 'white';
  2499. ctx.fillText(damageText, textPosition.x, textPosition.y);
  2500. }
  2501. ctx.restore();
  2502. }
  2503. }
  2504. let fpsStatTime = new Date().getTime();
  2505. let fpsQueue = [];
  2506. let fps = 60;
  2507.  
  2508. // 动画循环
  2509. function animate() {
  2510. // 计算FPS
  2511. const now = Date.now();
  2512. const delta = now - fpsStatTime;
  2513. fpsStatTime = now;
  2514. const fpsNow = Math.round(1000 / delta);
  2515. fpsQueue.push(fpsNow);
  2516. if (fpsQueue.length > 30) {
  2517. fpsQueue.shift();
  2518. }
  2519. fps = Math.round(fpsQueue.reduce((a, b) => a + b) / fpsQueue.length);
  2520.  
  2521. // 完全清空画布
  2522. ctx.clearRect(0, 0, canvas.width, canvas.height);
  2523.  
  2524. // 更新并绘制所有弹丸
  2525. for (let i = projectiles.length - 1; i >= 0; i--) {
  2526. const proj = projectiles[i];
  2527. proj.update();
  2528. proj.draw(ctx);
  2529. if (proj.isArrived()) {
  2530. createOnHitEffect(proj); // 将弹丸大小传递给爆炸效果
  2531. projectiles.splice(i, 1);
  2532. } else if (proj.isOutOfBounds()) {
  2533. // 超出边界则移除弹丸,不产生爆炸效果
  2534. projectiles.splice(i, 1);
  2535. }
  2536. }
  2537.  
  2538. // 更新和渲染所有爆炸效果
  2539. updateOnHits();
  2540. requestAnimationFrame(animate);
  2541. }
  2542. class Projectile {
  2543. constructor(startX, startY, endX, endY, color, initialSpeed = 1, size = 10, otherInfo = {}) {
  2544. // 基础属性
  2545. this.x = startX;
  2546. this.y = startY;
  2547. this.start = {
  2548. x: startX,
  2549. y: startY
  2550. };
  2551. this.target = {
  2552. x: endX,
  2553. y: endY
  2554. };
  2555. this.otherInfo = otherInfo;
  2556. this.shakeApplied = false;
  2557. this.type = otherInfo.type || 'default';
  2558. this.effect = projectileEffectsMap[this.type] || projectileEffectsMap['fireball'];
  2559. this.doShake = this.effect.shake;
  2560.  
  2561. // 运动参数 - 向斜上方抛物线轨迹
  2562. this.gravity = this.effect.gravity || 0.2; // 重力加速度
  2563. this.gravity *= settingsMap.projectileHeightScale.value || 1; // 高度缩放因子
  2564.  
  2565. this.initialSpeed = initialSpeed * (this.effect.speedFactor || 1); // 初始速度参数
  2566. this.initialSpeed *= settingsMap.projectileSpeedScale.value || 1; // 速度缩放因子
  2567.  
  2568. // 计算水平距离和高度差
  2569. const dx = endX - startX;
  2570. const dy = endY - startY;
  2571.  
  2572. // 重新设计飞行时间计算,确保合理
  2573. // const timeInAir = distance / this.initialSpeed / 10;
  2574. let timeInAir = 80 / this.initialSpeed;
  2575.  
  2576. // FPS因子,确保在不同FPS下效果一致
  2577. const fpsFactor = Math.min(Math.max(160 / fps, 0.125), 8);
  2578. this.gravity *= fpsFactor;
  2579. timeInAir /= fpsFactor;
  2580.  
  2581. // 计算初始速度,修正公式确保能够到达目标
  2582. this.velocity = {
  2583. x: dx / timeInAir,
  2584. y: dy / timeInAir - this.gravity * timeInAir / 2
  2585. };
  2586.  
  2587. // 大小参数 (范围1-100)
  2588. this.sizeScale = Math.max(1, Math.min(100, size)) / 10; // 转换为比例因子
  2589.  
  2590. // 外观属性
  2591. this.size = 10 * this.sizeScale;
  2592. this.color = this.effect.color || color;
  2593.  
  2594. // 拖尾效果
  2595. this.trail = [];
  2596. this.maxTrailLength = Math.floor((this.effect.trailLength || 35) * Math.sqrt(this.sizeScale)); // 拖尾长度随大小增加
  2597. this.maxTrailLength *= settingsMap.projectileTrailLength.value || 1; // 拖尾缩放因子
  2598. }
  2599. update() {
  2600. // 更新速度 (考虑重力)
  2601. this.velocity.y += this.gravity;
  2602.  
  2603. // 更新位置
  2604. this.x += this.velocity.x;
  2605. this.y += this.velocity.y;
  2606.  
  2607. // 更新拖尾
  2608. if (this.effect.trailLength > 0) {
  2609. this.trail.push({
  2610. x: this.x,
  2611. y: this.y,
  2612. vX: this.velocity.x,
  2613. vY: this.velocity.y,
  2614. color: this.color,
  2615. size: this.size,
  2616. totalLength: Math.max(this.trail.length, 1)
  2617. });
  2618. }
  2619. if (this.trail.length > this.maxTrailLength) {
  2620. this.trail.shift();
  2621. }
  2622. }
  2623. draw(canvas) {
  2624. // 绘制拖尾
  2625. this.trail.forEach((pos, index) => {
  2626. if (this.effect.trail) {
  2627. this.effect.trail(canvas, pos, index);
  2628. } else {
  2629. projectileEffectsMap['fireball'].trail(canvas, pos, index);
  2630. }
  2631. });
  2632.  
  2633. // 绘制主体
  2634. if (this.effect.draw) {
  2635. this.effect.draw(canvas, this);
  2636. } else {
  2637. projectileEffectsMap['fireball'].draw(canvas, this);
  2638. }
  2639.  
  2640. // 添加光晕效果
  2641. if (this.effect.glow) {
  2642. this.effect.glow(canvas, this);
  2643. }
  2644. }
  2645. isArrived() {
  2646. // 判断是否到达目标点 (调整判定距离)
  2647. const arrivalDistance = 20;
  2648. const hasArrived = Math.hypot(this.x - this.target.x, this.y - this.target.y) < arrivalDistance;
  2649. if (hasArrived && this.doShake && !this.shakeApplied && this.otherInfo.endElement) {
  2650. const shakeIntensity = Math.min(this.sizeScale * 5, 10);
  2651. applyShakeEffect(this.otherInfo.endElement, shakeIntensity);
  2652. this.shakeApplied = true;
  2653. }
  2654. return hasArrived;
  2655. }
  2656. isOutOfBounds() {
  2657. return this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height;
  2658. }
  2659. }
  2660.  
  2661. // Projectiles管理
  2662. let projectiles = [];
  2663.  
  2664. // 存储所有活跃的爆炸效果
  2665. let activeOnHitAnimation = [];
  2666.  
  2667. // 爆炸效果函数
  2668. function createOnHitEffect(projectile) {
  2669. const x = projectile.x;
  2670. const y = projectile.y;
  2671. const size = projectile.size;
  2672. const color = projectile.color;
  2673. const otherInfo = projectile.otherInfo;
  2674.  
  2675. // Resize for onHit effect
  2676. const sizeScale = Math.max(1, Math.min(100, size)) / 20;
  2677. projectile.size = sizeScale;
  2678. const sizeFactor = settingsMap.onHitScale.value || 1;
  2679. const particleFactor = settingsMap.particleEffectRatio.value || 1;
  2680. const particleLifespanFactor = settingsMap.particleLifespanRatio.value || 1;
  2681. const effects = [];
  2682. const onHitEffect = projectile.effect.onHit;
  2683. for (const effectName in onHitEffect) {
  2684. const effect = onHitEffectsMap[effectName];
  2685. if (!effect) continue;
  2686. const effectCount = Math.ceil(onHitEffect[effectName](projectile.size) * particleFactor);
  2687. for (let i = 0; i < effectCount; i++) {
  2688. const effectSize = (effect.size ? effect.size(projectile) : Math.random() * 10 + 5) * sizeFactor;
  2689. const effectLife = (effect.life ? effect.life(projectile) : 1000) * particleLifespanFactor;
  2690. effects.push({
  2691. x: effect.x ? effect.x(projectile) : x,
  2692. y: effect.y ? effect.y(projectile) : y,
  2693. angle: effect.angle ? effect.angle(projectile) : Math.random() * Math.PI * 2,
  2694. alpha: effect.alpha ? effect.alpha(projectile) : 0.8,
  2695. size: effectSize,
  2696. speed: effect.speed ? effect.speed(projectile) : Math.random() * 5 + 2,
  2697. gravity: effect.gravity ? effect.gravity(projectile) : 0,
  2698. life: effectLife,
  2699. color: effect.color ? effect.color(projectile) : projectile.color,
  2700. draw: effect.draw ? effect.draw : (ctx, p) => {}
  2701. });
  2702. }
  2703. }
  2704.  
  2705. // 存储命中动画的活跃状态,用于跟踪
  2706. const onHitEffectData = {
  2707. effects: [...effects],
  2708. active: true,
  2709. count: 0,
  2710. maxCount: 120,
  2711. color: color,
  2712. otherInfo: otherInfo
  2713. };
  2714. activeOnHitAnimation.push(onHitEffectData);
  2715. }
  2716. function createProjectile(startElement, endElement, color, initialSpeed = 1, damage = 200, projectileType = 'default') {
  2717. if (!startElement || !endElement) {
  2718. return;
  2719. }
  2720. const combatUnitContainer = endElement.querySelector(".CombatUnit_splatsContainer__2xcc0");
  2721. if (!settingsMap.originalDamageDisplay.value) {
  2722. combatUnitContainer.style.visibility = "hidden";
  2723. }
  2724. const padding = 30;
  2725. const randomRange = {
  2726. x: Math.floor((Math.random() - 0.5) * (combatUnitContainer.offsetWidth - 2 * padding)),
  2727. y: Math.floor((Math.random() - 0.1) * (combatUnitContainer.offsetHeight - padding))
  2728. };
  2729. const projectileLimit = 30;
  2730. const start = getElementCenter(startElement);
  2731. const end = getElementCenter(endElement);
  2732. end.x = Math.floor(end.x + randomRange.x);
  2733. end.y = Math.floor(end.y + randomRange.y);
  2734. const size = Math.min(Math.max(Math.pow(damage + 200, 0.7) / 20, 4), 16);
  2735. projectileType = abilityEffectsMap[projectileType] || projectileType;
  2736. const otherInfo = {
  2737. type: projectileType,
  2738. start: start,
  2739. end: end,
  2740. damage: damage,
  2741. color: color,
  2742. startElement: startElement,
  2743. endElement: endElement
  2744. };
  2745. if (damage > 0) {
  2746. addDamageHPBar(endElement, damage);
  2747. }
  2748. const projectile = new Projectile(start.x, start.y, end.x, end.y, color, initialSpeed, size, otherInfo);
  2749. projectiles.push(projectile);
  2750. if (projectiles.length > projectileLimit) {
  2751. projectiles.shift();
  2752. }
  2753. }
  2754. function getElementCenter(element) {
  2755. const rect = element.getBoundingClientRect();
  2756. if (element.innerText.trim() === '') {
  2757. return {
  2758. x: rect.left + rect.width / 2,
  2759. y: rect.top
  2760. };
  2761. }
  2762. return {
  2763. x: rect.left + rect.width / 2,
  2764. y: rect.top + rect.height / 2
  2765. };
  2766. }
  2767.  
  2768. // #region Setting
  2769. waitForSetttins();
  2770. hookWS();
  2771.  
  2772. // #region Hook WS
  2773. function hookWS() {
  2774. const dataProperty = Object.getOwnPropertyDescriptor(MessageEvent.prototype, "data");
  2775. const oriGet = dataProperty.get;
  2776. dataProperty.get = hookedGet;
  2777. Object.defineProperty(MessageEvent.prototype, "data", dataProperty);
  2778. function hookedGet() {
  2779. const socket = this.currentTarget;
  2780. if (!(socket instanceof WebSocket)) {
  2781. return oriGet.call(this);
  2782. }
  2783. if (socket.url.indexOf("api.milkywayidle.com/ws") <= -1 && socket.url.indexOf("api-test.milkywayidle.com/ws") <= -1) {
  2784. return oriGet.call(this);
  2785. }
  2786. const message = oriGet.call(this);
  2787. Object.defineProperty(this, "data", {
  2788. value: message
  2789. }); // Anti-loop
  2790.  
  2791. return handleMessage(message);
  2792. }
  2793. }
  2794. let monstersHP = [];
  2795. let monstersMP = [];
  2796. let playersHP = [];
  2797. let playersMP = [];
  2798. let playersAbility = [];
  2799. function handleMessage(message) {
  2800. let obj = JSON.parse(message);
  2801. if (obj && obj.type === "new_battle") {
  2802. monstersHP = obj.monsters.map(monster => monster.currentHitpoints);
  2803. monstersMP = obj.monsters.map(monster => monster.currentManapoints);
  2804. playersHP = obj.players.map(player => player.currentHitpoints);
  2805. playersMP = obj.players.map(player => player.currentManapoints);
  2806. } else if (obj && obj.type === "battle_updated" && monstersHP.length) {
  2807. const mMap = obj.mMap;
  2808. const pMap = obj.pMap;
  2809. const monsterIndices = Object.keys(obj.mMap);
  2810. const playerIndices = Object.keys(obj.pMap);
  2811. let castMonster = -1;
  2812. monsterIndices.forEach(monsterIndex => {
  2813. if (mMap[monsterIndex].cMP < monstersMP[monsterIndex]) {
  2814. castMonster = monsterIndex;
  2815. }
  2816. monstersMP[monsterIndex] = mMap[monsterIndex].cMP;
  2817. });
  2818. let castPlayer = -1;
  2819. playerIndices.forEach(userIndex => {
  2820. if (pMap[userIndex].cMP < playersMP[userIndex]) {
  2821. castPlayer = userIndex;
  2822. }
  2823. if (pMap[userIndex].cMP > playersMP[userIndex]) {
  2824. registProjectile(userIndex, userIndex, pMap[userIndex].cMP - playersMP[userIndex], false, 'selfManaRegen', true);
  2825. }
  2826. playersMP[userIndex] = pMap[userIndex].cMP;
  2827. if (pMap[userIndex].abilityHrid) {
  2828. playersAbility[userIndex] = pMap[userIndex].abilityHrid;
  2829. }
  2830. });
  2831. monstersHP.forEach((mHP, mIndex) => {
  2832. const monster = mMap[mIndex];
  2833. if (monster) {
  2834. const hpDiff = mHP - monster.cHP;
  2835. monstersHP[mIndex] = monster.cHP;
  2836. if (hpDiff > 0 && playerIndices.length > 0) {
  2837. if (playerIndices.length > 1) {
  2838. playerIndices.forEach(userIndex => {
  2839. if (userIndex === castPlayer) {
  2840. registProjectile(userIndex, mIndex, hpDiff, false, playersAbility[userIndex]);
  2841. }
  2842. });
  2843. } else {
  2844. registProjectile(playerIndices[0], mIndex, hpDiff, false, playersAbility[playerIndices[0]]);
  2845. }
  2846. }
  2847. }
  2848. });
  2849. playersHP.forEach((pHP, pIndex) => {
  2850. const player = pMap[pIndex];
  2851. if (player) {
  2852. const hpDiff = pHP - player.cHP;
  2853. playersHP[pIndex] = player.cHP;
  2854. if (hpDiff > 0 && monsterIndices.length > 0) {
  2855. if (monsterIndices.length > 1) {
  2856. monsterIndices.forEach(monsterIndex => {
  2857. if (monsterIndex === castMonster) {
  2858. registProjectile(pIndex, monsterIndex, hpDiff, true, 'autoAttack');
  2859. }
  2860. });
  2861. } else {
  2862. registProjectile(pIndex, monsterIndices[0], hpDiff, true, 'autoAttack');
  2863. }
  2864. } else if (hpDiff < 0) {
  2865. if (castPlayer > -1) {
  2866. registProjectile(castPlayer, pIndex, -hpDiff, false, 'heal', true);
  2867. } else {
  2868. registProjectile(pIndex, pIndex, -hpDiff, false, 'selfHeal', true);
  2869. }
  2870. }
  2871. }
  2872. });
  2873. } else if (obj && obj.type === "battle_updated") {
  2874. const pMap = obj.pMap;
  2875. const playerIndices = Object.keys(obj.pMap);
  2876. playerIndices.forEach(userIndex => {
  2877. if (pMap[userIndex].abilityHrid) {
  2878. playersAbility[userIndex] = pMap[userIndex].abilityHrid;
  2879. }
  2880. });
  2881. playersHP.forEach((pHP, pIndex) => {
  2882. const player = pMap[pIndex];
  2883. if (player) {
  2884. const hpDiff = pHP - player.cHP;
  2885. playersHP[pIndex] = player.cHP;
  2886. if (hpDiff < 0) {
  2887. registProjectile(pIndex, pIndex, -hpDiff, false, 'selfHeal', true);
  2888. }
  2889. }
  2890. });
  2891. playersMP.forEach((pMP, pIndex) => {
  2892. const player = pMap[pIndex];
  2893. if (player) {
  2894. const mpDiff = pMP - player.pMP;
  2895. playersMP[pIndex] = player.pMP;
  2896. if (mpDiff < 0) {
  2897. registProjectile(pIndex, pIndex, -mpDiff, false, 'selfManaRegen', true);
  2898. }
  2899. }
  2900. });
  2901. }
  2902. return message;
  2903. }
  2904.  
  2905. // #region Main Logic
  2906.  
  2907. // 动画效果
  2908. function registProjectile(from, to, hpDiff, reversed = false, abilityHrid = 'default', toPlayer = false) {
  2909. if (reversed) {
  2910. if (!settingsMap.tracker6.isTrue) {
  2911. return null;
  2912. }
  2913. } else {
  2914. if (!settingsMap["tracker" + from].isTrue) {
  2915. return null;
  2916. }
  2917. }
  2918. if (["selfHeal", "selfManaRegen"].indexOf(abilityHrid) > -1 && !settingsMap.showSelfRegen.value) {
  2919. return null;
  2920. }
  2921. const container = document.querySelector(".BattlePanel_playersArea__vvwlB");
  2922. if (container && container.children.length > 0) {
  2923. const playersContainer = container.children[0];
  2924. const effectFrom = playersContainer.children[from];
  2925. const monsterContainer = document.querySelector(".BattlePanel_monstersArea__2dzrY").children[0];
  2926. const effectTo = toPlayer ? playersContainer.children[to] : monsterContainer.children[to];
  2927. const trackerSetting = reversed ? settingsMap[`tracker6`] : settingsMap["tracker" + from];
  2928. let lineColor = "rgba(" + trackerSetting.r + ", " + trackerSetting.g + ", " + trackerSetting.b + ", 1)";
  2929. if (!reversed) {
  2930. createProjectile(effectFrom, effectTo, lineColor, 1, hpDiff, abilityHrid);
  2931. } else {
  2932. createProjectile(effectTo, effectFrom, lineColor, 1, hpDiff, abilityHrid);
  2933. }
  2934. }
  2935. }
  2936.  
  2937. // 启动动画
  2938. animate();
  2939.  
  2940. })();