@whitesev/utils 2.5.6 → 2.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -246,7 +246,7 @@ var Utils = (function () {
246
246
  throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
247
247
  }
248
248
  let cookies = this.windowApi.document.cookie.split(";");
249
- let findValue = void 0;
249
+ let findValue = undefined;
250
250
  for (const cookieItem of cookies) {
251
251
  let item = cookieItem.trim();
252
252
  let itemSplit = item.split("=");
@@ -1280,14 +1280,14 @@ var Utils = (function () {
1280
1280
  const option = menuOption[index];
1281
1281
  this.MenuHandle.$data.data.push({
1282
1282
  data: option,
1283
- id: void 0,
1283
+ id: undefined,
1284
1284
  });
1285
1285
  }
1286
1286
  }
1287
1287
  else {
1288
1288
  this.MenuHandle.$data.data.push({
1289
1289
  data: menuOption,
1290
- id: void 0,
1290
+ id: undefined,
1291
1291
  });
1292
1292
  }
1293
1293
  }
@@ -2415,13 +2415,13 @@ var Utils = (function () {
2415
2415
  status: fetchResponse.status,
2416
2416
  statusText: fetchResponse.statusText,
2417
2417
  // @ts-ignore
2418
- response: void 0,
2418
+ response: undefined,
2419
2419
  responseFetchHeaders: fetchResponse.headers,
2420
2420
  responseHeaders: "",
2421
2421
  // @ts-ignore
2422
- responseText: void 0,
2422
+ responseText: undefined,
2423
2423
  responseType: option.responseType,
2424
- responseXML: void 0,
2424
+ responseXML: undefined,
2425
2425
  };
2426
2426
  Object.assign(httpxResponse, option.context || {});
2427
2427
  // 把headers转为字符串
@@ -2533,30 +2533,30 @@ var Utils = (function () {
2533
2533
  * 默认配置
2534
2534
  */
2535
2535
  #defaultDetails = {
2536
- url: void 0,
2536
+ url: undefined,
2537
2537
  timeout: 5000,
2538
2538
  async: false,
2539
- responseType: void 0,
2540
- headers: void 0,
2541
- data: void 0,
2542
- redirect: void 0,
2543
- cookie: void 0,
2544
- cookiePartition: void 0,
2545
- binary: void 0,
2546
- nocache: void 0,
2547
- revalidate: void 0,
2548
- context: void 0,
2549
- overrideMimeType: void 0,
2550
- anonymous: void 0,
2551
- fetch: void 0,
2552
- fetchInit: void 0,
2539
+ responseType: undefined,
2540
+ headers: undefined,
2541
+ data: undefined,
2542
+ redirect: undefined,
2543
+ cookie: undefined,
2544
+ cookiePartition: undefined,
2545
+ binary: undefined,
2546
+ nocache: undefined,
2547
+ revalidate: undefined,
2548
+ context: undefined,
2549
+ overrideMimeType: undefined,
2550
+ anonymous: undefined,
2551
+ fetch: undefined,
2552
+ fetchInit: undefined,
2553
2553
  allowInterceptConfig: {
2554
2554
  beforeRequest: true,
2555
2555
  afterResponseSuccess: true,
2556
2556
  afterResponseError: true,
2557
2557
  },
2558
- user: void 0,
2559
- password: void 0,
2558
+ user: undefined,
2559
+ password: undefined,
2560
2560
  onabort() { },
2561
2561
  onerror() { },
2562
2562
  ontimeout() { },
@@ -3040,7 +3040,7 @@ var Utils = (function () {
3040
3040
  success: false,
3041
3041
  code: that.#statusCode.getFailed.code,
3042
3042
  msg: that.#statusCode.getFailed.msg,
3043
- data: void 0,
3043
+ data: undefined,
3044
3044
  });
3045
3045
  }
3046
3046
  else {
@@ -3050,7 +3050,7 @@ var Utils = (function () {
3050
3050
  let result = target.result;
3051
3051
  /* result 返回的是 {key: string, value: any} */
3052
3052
  /* 键值对存储 */
3053
- let data = result ? result.value : void 0;
3053
+ let data = result ? result.value : undefined;
3054
3054
  if (data == null) {
3055
3055
  resolve({
3056
3056
  success: true,
@@ -3077,7 +3077,7 @@ var Utils = (function () {
3077
3077
  success: false,
3078
3078
  code: that.#statusCode.getFailed.code,
3079
3079
  msg: that.#statusCode.getFailed.msg,
3080
- data: void 0,
3080
+ data: undefined,
3081
3081
  event: event,
3082
3082
  });
3083
3083
  };
@@ -3657,7 +3657,7 @@ var Utils = (function () {
3657
3657
  context = __context__ || this;
3658
3658
  let result = executeTryCatch(callbackFunction, handleError, context);
3659
3659
  // @ts-ignore
3660
- return result !== void 0 ? result : TryCatchCore;
3660
+ return result !== undefined ? result : TryCatchCore;
3661
3661
  },
3662
3662
  };
3663
3663
  /**
@@ -3668,7 +3668,7 @@ var Utils = (function () {
3668
3668
  * @returns 如果函数有返回值,则返回该返回值;否则返回 undefined。
3669
3669
  */
3670
3670
  function executeTryCatch(callback, handleErrorFunc, funcThis) {
3671
- let result = void 0;
3671
+ let result = undefined;
3672
3672
  try {
3673
3673
  if (typeof callback === "string") {
3674
3674
  (function () {
@@ -3736,7 +3736,7 @@ var Utils = (function () {
3736
3736
  */
3737
3737
  getStartsWith(key) {
3738
3738
  let allKeys = this.keys();
3739
- let result = void 0;
3739
+ let result = undefined;
3740
3740
  for (const keyName of allKeys) {
3741
3741
  if (String(keyName).startsWith(String(key))) {
3742
3742
  result = this.get(keyName);
@@ -3751,7 +3751,7 @@ var Utils = (function () {
3751
3751
  * @param val 值,默认为""
3752
3752
  */
3753
3753
  set(key, val) {
3754
- if (key === void 0) {
3754
+ if (key === undefined) {
3755
3755
  throw new Error("Utils.Dictionary().set 参数 key 不能为空");
3756
3756
  }
3757
3757
  Reflect.set(this.items, key, val);
@@ -4136,13 +4136,411 @@ var Utils = (function () {
4136
4136
  }
4137
4137
  }
4138
4138
 
4139
+ // ==UserScript==
4140
+ // @name ModuleRaid.js
4141
+ // @namespace http://tampermonkey.net/
4142
+ // @version 6.2.0
4143
+ // @description 检索调用webpackJsonp模块,可指定检索的window
4144
+ // @author empyrealtear
4145
+ // @license MIT
4146
+ // @original-script https://github.com/pixeldesu/moduleRaid
4147
+ // ==/UserScript==
4148
+
4149
+
4150
+ /**
4151
+ * Main moduleRaid class
4152
+ * @link https://scriptcat.org/zh-CN/script-show-page/2628
4153
+ */
4154
+ class ModuleRaid {
4155
+ /**
4156
+ * moduleRaid constructor
4157
+ *
4158
+ * @example
4159
+ * Constructing an instance without any arguments:
4160
+ * ```ts
4161
+ * const mR = new ModuleRaid()
4162
+ * ```
4163
+ *
4164
+ * Constructing an instance with the optional `opts` object:
4165
+ * ```ts
4166
+ * const mR = new ModuleRaid({ entrypoint: 'webpackChunk_custom_name' })
4167
+ * ```
4168
+ *
4169
+ * @param opts a object containing options to initialize moduleRaid with
4170
+ * - **opts:**
4171
+ * - _target_: the window object being searched for
4172
+ * - _entrypoint_: the Webpack entrypoint present on the global window object
4173
+ * - _debug_: whether debug mode is enabled or not
4174
+ * - _strict_: whether strict mode is enabled or not
4175
+ */
4176
+ constructor(opts) {
4177
+ /**
4178
+ * A random generated module ID we use for injecting into Webpack
4179
+ */
4180
+ this.moduleID = Math.random().toString(36).substring(7);
4181
+ /**
4182
+ * An array containing different argument injection methods for
4183
+ * Webpack (before version 4), and subsequently pulling out methods and modules
4184
+ * @internal
4185
+ */
4186
+ this.functionArguments = [
4187
+ [
4188
+ [0],
4189
+ [
4190
+ (_e, _t, i) => {
4191
+ this.modules = i.c;
4192
+ this.constructors = i.m;
4193
+ this.get = i;
4194
+ },
4195
+ ],
4196
+ ],
4197
+ [
4198
+ [1e3],
4199
+ {
4200
+ [this.moduleID]: (_e, _t, i) => {
4201
+ this.modules = i.c;
4202
+ this.constructors = i.m;
4203
+ this.get = i;
4204
+ },
4205
+ },
4206
+ [[this.moduleID]],
4207
+ ],
4208
+ ];
4209
+ /**
4210
+ * An array containing different argument injection methods for
4211
+ * Webpack (after version 4), and subsequently pulling out methods and modules
4212
+ * @internal
4213
+ */
4214
+ this.arrayArguments = [
4215
+ [
4216
+ [this.moduleID],
4217
+ {},
4218
+ (e) => {
4219
+ const mCac = e.m;
4220
+ Object.keys(mCac).forEach((mod) => {
4221
+ try {
4222
+ this.modules[mod] = e(mod);
4223
+ }
4224
+ catch (err) {
4225
+ this.log(`[arrayArguments/1] Failed to require(${mod}) with error:\n${err}\n${err.stack}`);
4226
+ }
4227
+ });
4228
+ this.get = e;
4229
+ },
4230
+ ],
4231
+ this.functionArguments[1],
4232
+ ];
4233
+ /**
4234
+ * Storage for the modules we extracted from Webpack
4235
+ */
4236
+ this.modules = {};
4237
+ /**
4238
+ * Storage for the constructors we extracted from Webpack
4239
+ */
4240
+ this.constructors = [];
4241
+ let options = {
4242
+ target: window,
4243
+ entrypoint: 'webpackJsonp',
4244
+ debug: false,
4245
+ strict: false,
4246
+ };
4247
+ if (typeof opts === 'object') {
4248
+ options = Object.assign(Object.assign({}, options), opts);
4249
+ }
4250
+ this.target = options.target;
4251
+ this.entrypoint = options.entrypoint;
4252
+ this.debug = options.debug;
4253
+ this.strict = options.strict;
4254
+ this.detectEntrypoint();
4255
+ this.fillModules();
4256
+ this.replaceGet();
4257
+ this.setupPushEvent();
4258
+ }
4259
+ /**
4260
+ * Debug logging method, outputs to the console when {@link ModuleRaid.debug} is true
4261
+ *
4262
+ * @param {*} message The message to be logged
4263
+ * @internal
4264
+ */
4265
+ log(message) {
4266
+ if (this.debug) {
4267
+ console.warn(`[moduleRaid] ${message}`);
4268
+ }
4269
+ }
4270
+ /**
4271
+ * Method to set an alternative getter if we weren't able to extract __webpack_require__
4272
+ * from Webpack
4273
+ * @internal
4274
+ */
4275
+ replaceGet() {
4276
+ if (this.get === null) {
4277
+ this.get = (key) => this.modules[key];
4278
+ }
4279
+ }
4280
+ /**
4281
+ * Method that will try to inject a module into Webpack or get modules
4282
+ * depending on it's success it might be more or less brute about it
4283
+ * @internal
4284
+ */
4285
+ fillModules() {
4286
+ if (typeof this.target[this.entrypoint] === 'function') {
4287
+ this.functionArguments.forEach((argument, index) => {
4288
+ try {
4289
+ if (this.modules && Object.keys(this.modules).length > 0)
4290
+ return;
4291
+ this.target[this.entrypoint](...argument);
4292
+ }
4293
+ catch (err) {
4294
+ this.log(`moduleRaid.functionArguments[${index}] failed:\n${err}\n${err.stack}`);
4295
+ }
4296
+ });
4297
+ }
4298
+ else {
4299
+ this.arrayArguments.forEach((argument, index) => {
4300
+ try {
4301
+ if (this.modules && Object.keys(this.modules).length > 0)
4302
+ return;
4303
+ this.target[this.entrypoint].push(argument);
4304
+ }
4305
+ catch (err) {
4306
+ this.log(`Pushing moduleRaid.arrayArguments[${index}] into ${this.entrypoint} failed:\n${err}\n${err.stack}`);
4307
+ }
4308
+ });
4309
+ }
4310
+ if (this.modules && Object.keys(this.modules).length == 0) {
4311
+ let moduleEnd = false;
4312
+ let moduleIterator = 0;
4313
+ if (typeof this.target[this.entrypoint] != 'function' || !this.target[this.entrypoint]([], [], [moduleIterator])) {
4314
+ throw Error('Unknown Webpack structure');
4315
+ }
4316
+ while (!moduleEnd) {
4317
+ try {
4318
+ this.modules[moduleIterator] = this.target[this.entrypoint]([], [], [moduleIterator]);
4319
+ moduleIterator++;
4320
+ }
4321
+ catch (err) {
4322
+ moduleEnd = true;
4323
+ }
4324
+ }
4325
+ }
4326
+ }
4327
+ /**
4328
+ * Method to hook into `window[this.entrypoint].push` adding a listener for new
4329
+ * chunks being pushed into Webpack
4330
+ *
4331
+ * @example
4332
+ * You can listen for newly pushed packages using the `moduleraid:webpack-push` event
4333
+ * on `document`
4334
+ *
4335
+ * ```ts
4336
+ * document.addEventListener('moduleraid:webpack-push', (e) => {
4337
+ * // e.detail contains the arguments push() was called with
4338
+ * console.log(e.detail)
4339
+ * })
4340
+ * ```
4341
+ * @internal
4342
+ */
4343
+ setupPushEvent() {
4344
+ const originalPush = this.target[this.entrypoint].push;
4345
+ this.target[this.entrypoint].push = (...args) => {
4346
+ const result = Reflect.apply(originalPush, this.target[this.entrypoint], args);
4347
+ document.dispatchEvent(new CustomEvent('moduleraid:webpack-push', { detail: args }));
4348
+ return result;
4349
+ };
4350
+ }
4351
+ /**
4352
+ * Method to try autodetecting a Webpack JSONP entrypoint based on common naming
4353
+ *
4354
+ * If the default entrypoint, or the entrypoint that's passed to the moduleRaid constructor
4355
+ * already matches, the method exits early
4356
+ *
4357
+ * If `options.strict` has been set in the constructor and the initial entrypoint cannot
4358
+ * be found, this method will error, demanding a strictly set entrypoint
4359
+ * @internal
4360
+ */
4361
+ detectEntrypoint() {
4362
+ if (this.target[this.entrypoint] != undefined) {
4363
+ return;
4364
+ }
4365
+ if (this.strict) {
4366
+ throw Error(`Strict mode is enabled and entrypoint at window.${this.entrypoint} couldn't be found. Please specify the correct one!`);
4367
+ }
4368
+ let windowObjects = Object.keys(this.target);
4369
+ windowObjects = windowObjects
4370
+ .filter((object) => object.toLowerCase().includes('chunk') || object.toLowerCase().includes('webpack'))
4371
+ .filter((object) => typeof this.target[object] === 'function' || Array.isArray(this.target[object]));
4372
+ if (windowObjects.length > 1) {
4373
+ throw Error(`Multiple possible endpoints have been detected, please create a new moduleRaid instance with a specific one:\n${windowObjects.join(', ')}`);
4374
+ }
4375
+ if (windowObjects.length === 0) {
4376
+ throw Error('No Webpack JSONP entrypoints could be detected');
4377
+ }
4378
+ this.log(`Entrypoint has been detected at window.${windowObjects[0]} and set for injection`);
4379
+ this.entrypoint = windowObjects[0];
4380
+ }
4381
+ /**
4382
+ * Recursive object-search function for modules
4383
+ *
4384
+ * @param object the object to search through
4385
+ * @param query the query the object keys/values are searched for
4386
+ * @returns boolean state of `object` containing `query` somewhere in it
4387
+ * @internal
4388
+ */
4389
+ searchObject(object, query) {
4390
+ for (const key in object) {
4391
+ const value = object[key];
4392
+ const lowerCaseQuery = query.toLowerCase();
4393
+ if (typeof value != 'object') {
4394
+ const lowerCaseKey = key.toString().toLowerCase();
4395
+ if (lowerCaseKey.includes(lowerCaseQuery))
4396
+ return true;
4397
+ if (typeof value != 'object') {
4398
+ const lowerCaseValue = value.toString().toLowerCase();
4399
+ if (lowerCaseValue.includes(lowerCaseQuery))
4400
+ return true;
4401
+ }
4402
+ else {
4403
+ if (this.searchObject(value, query))
4404
+ return true;
4405
+ }
4406
+ }
4407
+ }
4408
+ return false;
4409
+ }
4410
+ /**
4411
+ * Method to search through the module object, searching for the fitting content
4412
+ * if a string is supplied
4413
+ *
4414
+ * If query is supplied as a function, everything that returns true when passed
4415
+ * to the query function will be returned
4416
+ *
4417
+ * @example
4418
+ * With a string as query argument:
4419
+ * ```ts
4420
+ * const results = mR.findModule('feature')
4421
+ * // => Array of module results
4422
+ * ```
4423
+ *
4424
+ * With a function as query argument:
4425
+ * ```ts
4426
+ * const results = mR.findModule((module) => { typeof module === 'function' })
4427
+ * // => Array of module results
4428
+ * ```
4429
+ *
4430
+ * @param query query to search the module list for
4431
+ * @return a list of modules fitting the query
4432
+ */
4433
+ findModule(query) {
4434
+ const results = [];
4435
+ const modules = Object.keys(this.modules);
4436
+ if (modules.length === 0) {
4437
+ throw new Error('There are no modules to search through!');
4438
+ }
4439
+ modules.forEach((key) => {
4440
+ const module = this.modules[key.toString()];
4441
+ if (module === undefined)
4442
+ return;
4443
+ try {
4444
+ if (typeof query === 'string') {
4445
+ query = query.toLowerCase();
4446
+ switch (typeof module) {
4447
+ case 'string':
4448
+ if (module.toLowerCase().includes(query))
4449
+ results.push(module);
4450
+ break;
4451
+ case 'function':
4452
+ if (module.toString().toLowerCase().includes(query))
4453
+ results.push(module);
4454
+ break;
4455
+ case 'object':
4456
+ if (this.searchObject(module, query))
4457
+ results.push(module);
4458
+ break;
4459
+ }
4460
+ }
4461
+ else if (typeof query === 'function') {
4462
+ if (query(module))
4463
+ results.push(module);
4464
+ }
4465
+ else {
4466
+ throw new TypeError(`findModule can only find via string and function, ${typeof query} was passed`);
4467
+ }
4468
+ }
4469
+ catch (err) {
4470
+ this.log(`There was an error while searching through module '${key}':\n${err}\n${err.stack}`);
4471
+ }
4472
+ });
4473
+ return results;
4474
+ }
4475
+ /**
4476
+ * Method to search through the constructor array, searching for the fitting content
4477
+ * if a string is supplied
4478
+ *
4479
+ * If query is supplied as a function, everything that returns true when passed
4480
+ * to the query function will be returned
4481
+ *
4482
+ * @example
4483
+ * With a string as query argument:
4484
+ * ```ts
4485
+ * const results = mR.findConstructor('feature')
4486
+ * // => Array of constructor/module tuples
4487
+ * ```
4488
+ *
4489
+ * With a function as query argument:
4490
+ * ```ts
4491
+ * const results = mR.findConstructor((constructor) => { constructor.prototype.value !== undefined })
4492
+ * // => Array of constructor/module tuples
4493
+ * ```
4494
+ *
4495
+ * Accessing the resulting data:
4496
+ * ```ts
4497
+ * // With array destructuring (ES6)
4498
+ * const [constructor, module] = results[0]
4499
+ *
4500
+ * // ...or...
4501
+ *
4502
+ * // regular access
4503
+ * const constructor = results[0][0]
4504
+ * const module = results[0][1]
4505
+ * ```
4506
+ *
4507
+ * @param query query to search the constructor list for
4508
+ * @returns a list of constructor/module tuples fitting the query
4509
+ */
4510
+ findConstructor(query) {
4511
+ const results = [];
4512
+ const constructors = Object.keys(this.constructors);
4513
+ if (constructors.length === 0) {
4514
+ throw new Error('There are no constructors to search through!');
4515
+ }
4516
+ constructors.forEach((key) => {
4517
+ const constructor = this.constructors[key];
4518
+ try {
4519
+ if (typeof query === 'string') {
4520
+ query = query.toLowerCase();
4521
+ if (constructor.toString().toLowerCase().includes(query))
4522
+ results.push([this.constructors[key], this.modules[key]]);
4523
+ }
4524
+ else if (typeof query === 'function') {
4525
+ if (query(constructor))
4526
+ results.push([this.constructors[key], this.modules[key]]);
4527
+ }
4528
+ }
4529
+ catch (err) {
4530
+ this.log(`There was an error while searching through constructor '${key}':\n${err}\n${err.stack}`);
4531
+ }
4532
+ });
4533
+ return results;
4534
+ }
4535
+ }
4536
+
4139
4537
  class Utils {
4140
4538
  windowApi;
4141
4539
  constructor(option) {
4142
4540
  this.windowApi = new WindowApi(option);
4143
4541
  }
4144
4542
  /** 版本号 */
4145
- version = "2024.12.25";
4543
+ version = "2025.1.11";
4146
4544
  addStyle(cssText) {
4147
4545
  if (typeof cssText !== "string") {
4148
4546
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -4365,8 +4763,8 @@ var Utils = (function () {
4365
4763
  ColorConversion = ColorConversion;
4366
4764
  deepClone(obj) {
4367
4765
  let UtilsContext = this;
4368
- if (obj === void 0)
4369
- return void 0;
4766
+ if (obj === undefined)
4767
+ return undefined;
4370
4768
  if (obj === null)
4371
4769
  return null;
4372
4770
  let clone = obj instanceof Array ? [] : {};
@@ -5812,36 +6210,36 @@ var Utils = (function () {
5812
6210
  * + true 监听以 target 为根节点的整个子树。包括子树中所有节点的属性,而不仅仅是针对 target
5813
6211
  * + false (默认) 不生效
5814
6212
  */
5815
- subtree: void 0,
6213
+ subtree: undefined,
5816
6214
  /**
5817
6215
  * + true 监听 target 节点中发生的节点的新增与删除(同时,如果 subtree 为 true,会针对整个子树生效)
5818
6216
  * + false (默认) 不生效
5819
6217
  */
5820
- childList: void 0,
6218
+ childList: undefined,
5821
6219
  /**
5822
6220
  * + true 观察所有监听的节点属性值的变化。默认值为 true,当声明了 attributeFilter 或 attributeOldValue
5823
6221
  * + false (默认) 不生效
5824
6222
  */
5825
- attributes: void 0,
6223
+ attributes: undefined,
5826
6224
  /**
5827
6225
  * 一个用于声明哪些属性名会被监听的数组。如果不声明该属性,所有属性的变化都将触发通知
5828
6226
  */
5829
- attributeFilter: void 0,
6227
+ attributeFilter: undefined,
5830
6228
  /**
5831
6229
  * + true 记录上一次被监听的节点的属性变化;可查阅 MutationObserver 中的 Monitoring attribute values 了解关于观察属性变化和属性值记录的详情
5832
6230
  * + false (默认) 不生效
5833
6231
  */
5834
- attributeOldValue: void 0,
6232
+ attributeOldValue: undefined,
5835
6233
  /**
5836
6234
  * + true 监听声明的 target 节点上所有字符的变化。默认值为 true,如果声明了 characterDataOldValue
5837
6235
  * + false (默认) 不生效
5838
6236
  */
5839
- characterData: void 0,
6237
+ characterData: undefined,
5840
6238
  /**
5841
6239
  * + true 记录前一个被监听的节点中发生的文本变化
5842
6240
  * + false (默认) 不生效
5843
6241
  */
5844
- characterDataOldValue: void 0,
6242
+ characterDataOldValue: undefined,
5845
6243
  },
5846
6244
  immediate: false,
5847
6245
  };
@@ -6416,7 +6814,7 @@ var Utils = (function () {
6416
6814
  }
6417
6815
  return new Promise((resolve) => {
6418
6816
  setTimeout(() => {
6419
- resolve(void 0);
6817
+ resolve(undefined);
6420
6818
  }, delayTime);
6421
6819
  });
6422
6820
  }
@@ -6756,9 +7154,42 @@ var Utils = (function () {
6756
7154
  await UtilsContext.tryCatch(index, item).run(handleFunc);
6757
7155
  }));
6758
7156
  }
7157
+ wait(checkFn, timeout, parent) {
7158
+ const UtilsContext = this;
7159
+ let __timeout__ = typeof timeout === "number" ? timeout : 0;
7160
+ return new Promise((resolve) => {
7161
+ let observer = UtilsContext.mutationObserver(parent || UtilsContext.windowApi.document, {
7162
+ config: {
7163
+ subtree: true,
7164
+ childList: true,
7165
+ attributes: true,
7166
+ },
7167
+ immediate: true,
7168
+ callback(mutations, __observer__) {
7169
+ let result = checkFn();
7170
+ if (result.success) {
7171
+ // 取消观察器
7172
+ if (typeof __observer__?.disconnect === "function") {
7173
+ __observer__.disconnect();
7174
+ }
7175
+ resolve(result.data);
7176
+ }
7177
+ },
7178
+ });
7179
+ if (__timeout__ > 0) {
7180
+ setTimeout(() => {
7181
+ // 取消观察器
7182
+ if (typeof observer?.disconnect === "function") {
7183
+ observer.disconnect();
7184
+ }
7185
+ resolve(null);
7186
+ }, __timeout__);
7187
+ }
7188
+ });
7189
+ }
6759
7190
  waitNode(...args) {
6760
7191
  // 过滤掉undefined
6761
- args = args.filter((arg) => arg !== void 0);
7192
+ args = args.filter((arg) => arg !== undefined);
6762
7193
  let UtilsContext = this;
6763
7194
  // 选择器
6764
7195
  let selector = args[0];
@@ -6766,8 +7197,10 @@ var Utils = (function () {
6766
7197
  let parent = UtilsContext.windowApi.document;
6767
7198
  // 超时时间
6768
7199
  let timeout = 0;
6769
- if (typeof args[0] !== "string" && !Array.isArray(args[0])) {
6770
- throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]");
7200
+ if (typeof args[0] !== "string" &&
7201
+ !Array.isArray(args[0]) &&
7202
+ typeof args[0] !== "function") {
7203
+ throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
6771
7204
  }
6772
7205
  if (args.length === 1) ;
6773
7206
  else if (args.length === 2) {
@@ -6807,57 +7240,45 @@ var Utils = (function () {
6807
7240
  else {
6808
7241
  throw new TypeError("Utils.waitNode 参数个数错误");
6809
7242
  }
6810
- return new Promise((resolve) => {
6811
- function getNode() {
6812
- if (Array.isArray(selector)) {
6813
- let result = [];
6814
- for (let index = 0; index < selector.length; index++) {
6815
- let node = parent.querySelector(selector[index]);
6816
- if (node) {
6817
- result.push(node);
6818
- }
6819
- }
6820
- if (result.length === selector.length) {
6821
- return result;
7243
+ function getNode() {
7244
+ if (Array.isArray(selector)) {
7245
+ let result = [];
7246
+ for (let index = 0; index < selector.length; index++) {
7247
+ let node = parent.querySelector(selector[index]);
7248
+ if (node) {
7249
+ result.push(node);
6822
7250
  }
6823
7251
  }
6824
- else {
6825
- return parent.querySelector(selector);
7252
+ if (result.length === selector.length) {
7253
+ return result;
6826
7254
  }
6827
7255
  }
6828
- var observer = UtilsContext.mutationObserver(parent, {
6829
- config: {
6830
- subtree: true,
6831
- childList: true,
6832
- attributes: true,
6833
- },
6834
- callback() {
6835
- let node = getNode();
6836
- if (node) {
6837
- // 取消观察器
6838
- if (typeof observer?.disconnect === "function") {
6839
- observer.disconnect();
6840
- }
6841
- resolve(node);
6842
- return;
6843
- }
6844
- },
6845
- immediate: true,
6846
- });
6847
- if (timeout > 0) {
6848
- setTimeout(() => {
6849
- // 取消观察器
6850
- if (typeof observer?.disconnect === "function") {
6851
- observer.disconnect();
6852
- }
6853
- resolve(null);
6854
- }, timeout);
7256
+ else if (typeof selector === "function") {
7257
+ return selector();
6855
7258
  }
6856
- });
7259
+ else {
7260
+ return parent.querySelector(selector);
7261
+ }
7262
+ }
7263
+ return UtilsContext.wait(() => {
7264
+ let node = getNode();
7265
+ if (node) {
7266
+ return {
7267
+ success: true,
7268
+ data: node,
7269
+ };
7270
+ }
7271
+ else {
7272
+ return {
7273
+ success: false,
7274
+ data: node,
7275
+ };
7276
+ }
7277
+ }, timeout, parent);
6857
7278
  }
6858
7279
  waitAnyNode(...args) {
6859
7280
  // 过滤掉undefined
6860
- args = args.filter((arg) => arg !== void 0);
7281
+ args = args.filter((arg) => arg !== undefined);
6861
7282
  let UtilsContext = this;
6862
7283
  // 选择器
6863
7284
  let selectorList = args[0];
@@ -6913,7 +7334,7 @@ var Utils = (function () {
6913
7334
  }
6914
7335
  waitNodeList(...args) {
6915
7336
  // 过滤掉undefined
6916
- args = args.filter((arg) => arg !== void 0);
7337
+ args = args.filter((arg) => arg !== undefined);
6917
7338
  let UtilsContext = this;
6918
7339
  // 选择器数组
6919
7340
  let selector = args[0];
@@ -6962,61 +7383,45 @@ var Utils = (function () {
6962
7383
  else {
6963
7384
  throw new TypeError("Utils.waitNodeList 参数个数错误");
6964
7385
  }
6965
- return new Promise((resolve) => {
6966
- function getNodeList() {
6967
- if (Array.isArray(selector)) {
6968
- let result = [];
6969
- for (let index = 0; index < selector.length; index++) {
6970
- let nodeList = parent.querySelectorAll(selector[index]);
6971
- if (nodeList.length) {
6972
- result.push(nodeList);
6973
- }
6974
- }
6975
- if (result.length === selector.length) {
6976
- return result;
6977
- }
6978
- }
6979
- else {
6980
- let nodeList = parent.querySelectorAll(selector);
7386
+ function getNodeList() {
7387
+ if (Array.isArray(selector)) {
7388
+ let result = [];
7389
+ for (let index = 0; index < selector.length; index++) {
7390
+ let nodeList = parent.querySelectorAll(selector[index]);
6981
7391
  if (nodeList.length) {
6982
- return nodeList;
7392
+ result.push(nodeList);
6983
7393
  }
6984
7394
  }
7395
+ if (result.length === selector.length) {
7396
+ return result;
7397
+ }
6985
7398
  }
6986
- var observer = UtilsContext.mutationObserver(parent, {
6987
- config: {
6988
- subtree: true,
6989
- childList: true,
6990
- attributes: true,
6991
- },
6992
- callback() {
6993
- let node = getNodeList();
6994
- if (node) {
6995
- // 取消观察器
6996
- try {
6997
- observer.disconnect();
6998
- }
6999
- catch (error) { }
7000
- resolve(node);
7001
- return;
7002
- }
7003
- },
7004
- immediate: true,
7005
- });
7006
- if (timeout > 0) {
7007
- setTimeout(() => {
7008
- // 取消观察器
7009
- if (typeof observer?.disconnect === "function") {
7010
- observer.disconnect();
7011
- }
7012
- resolve(null);
7013
- }, timeout);
7399
+ else {
7400
+ let nodeList = parent.querySelectorAll(selector);
7401
+ if (nodeList.length) {
7402
+ return nodeList;
7403
+ }
7014
7404
  }
7015
- });
7405
+ }
7406
+ return UtilsContext.wait(() => {
7407
+ let node = getNodeList();
7408
+ if (node) {
7409
+ return {
7410
+ success: true,
7411
+ data: node,
7412
+ };
7413
+ }
7414
+ else {
7415
+ return {
7416
+ success: false,
7417
+ data: node,
7418
+ };
7419
+ }
7420
+ }, timeout, parent);
7016
7421
  }
7017
7422
  waitAnyNodeList(...args) {
7018
7423
  // 过滤掉undefined
7019
- args = args.filter((arg) => arg !== void 0);
7424
+ args = args.filter((arg) => arg !== undefined);
7020
7425
  let UtilsContext = this;
7021
7426
  // 选择器数组
7022
7427
  let selectorList = args[0];
@@ -7314,6 +7719,7 @@ var Utils = (function () {
7314
7719
  * > "测试"
7315
7720
  */
7316
7721
  Vue = Vue;
7722
+ ModuleRaid = ModuleRaid;
7317
7723
  }
7318
7724
  let utils = new Utils();
7319
7725