@whitesev/utils 2.7.2 → 2.7.3
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.
- package/dist/index.amd.js +98 -203
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +98 -203
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +98 -203
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +98 -203
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +98 -203
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +98 -203
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +30 -2
- package/dist/types/src/types/Event.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +4 -21
- package/dist/types/src/types/ajaxHooker.d.ts +1 -5
- package/package.json +1 -1
- package/src/ColorConversion.ts +5 -18
- package/src/CommonUtil.ts +8 -31
- package/src/DOMUtils.ts +9 -22
- package/src/Dictionary.ts +2 -7
- package/src/GBKEncoder.ts +1 -6
- package/src/Hooks.ts +1 -4
- package/src/Httpx.ts +102 -277
- package/src/LockFunction.ts +1 -3
- package/src/Log.ts +7 -23
- package/src/Progress.ts +2 -10
- package/src/TryCatch.ts +3 -11
- package/src/Utils.ts +209 -555
- package/src/UtilsCommon.ts +5 -9
- package/src/UtilsGMCookie.ts +1 -4
- package/src/UtilsGMMenu.ts +10 -29
- package/src/Vue.ts +2 -11
- package/src/indexedDB.ts +3 -12
- package/src/types/Event.d.ts +1 -2
- package/src/types/Httpx.d.ts +4 -21
- package/src/types/ajaxHooker.d.ts +1 -5
package/dist/index.system.js
CHANGED
|
@@ -70,11 +70,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
70
70
|
!validPattern.test(greenValue.toString()) ||
|
|
71
71
|
!validPattern.test(blueValue.toString()))
|
|
72
72
|
throw new TypeError("输入错误的rgb颜色值");
|
|
73
|
-
let hexs = [
|
|
74
|
-
redValue.toString(16),
|
|
75
|
-
greenValue.toString(16),
|
|
76
|
-
blueValue.toString(16),
|
|
77
|
-
];
|
|
73
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
78
74
|
for (let index = 0; index < 3; index++)
|
|
79
75
|
if (hexs[index].length == 1)
|
|
80
76
|
hexs[index] = "0" + hexs[index];
|
|
@@ -122,10 +118,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
122
118
|
this.#data = dataText.match(/..../g);
|
|
123
119
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
124
120
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
125
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
126
|
-
i.toString(16) +
|
|
127
|
-
"%" +
|
|
128
|
-
j.toString(16)).toUpperCase();
|
|
121
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
124
|
for (let key in this.#U2Ghash) {
|
|
@@ -253,9 +246,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
253
246
|
callbackFunction = callback;
|
|
254
247
|
context = __context__ || this;
|
|
255
248
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
256
|
-
return result !== void 0
|
|
257
|
-
? result
|
|
258
|
-
: TryCatchCore;
|
|
249
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
259
250
|
},
|
|
260
251
|
};
|
|
261
252
|
/**
|
|
@@ -284,10 +275,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
284
275
|
}
|
|
285
276
|
if (handleErrorFunc) {
|
|
286
277
|
if (typeof handleErrorFunc === "string") {
|
|
287
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
288
|
-
...args,
|
|
289
|
-
error,
|
|
290
|
-
]);
|
|
278
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
291
279
|
}
|
|
292
280
|
else {
|
|
293
281
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -375,10 +363,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
375
363
|
itemResult = objItem === 0;
|
|
376
364
|
break;
|
|
377
365
|
case "string":
|
|
378
|
-
itemResult =
|
|
379
|
-
objItem.trim() === "" ||
|
|
380
|
-
objItem === "null" ||
|
|
381
|
-
objItem === "undefined";
|
|
366
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
382
367
|
break;
|
|
383
368
|
case "boolean":
|
|
384
369
|
itemResult = !objItem;
|
|
@@ -419,8 +404,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
419
404
|
return null;
|
|
420
405
|
let clone = obj instanceof Array ? [] : {};
|
|
421
406
|
for (const [key, value] of Object.entries(obj)) {
|
|
422
|
-
clone[key] =
|
|
423
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
407
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
424
408
|
}
|
|
425
409
|
return clone;
|
|
426
410
|
}
|
|
@@ -1959,14 +1943,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
1959
1943
|
// };
|
|
1960
1944
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1961
1945
|
menuOption.autoReload =
|
|
1962
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1963
|
-
? this.$default.autoReload
|
|
1964
|
-
: menuOption.autoReload;
|
|
1946
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1965
1947
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1966
1948
|
menuOption.isStoreValue =
|
|
1967
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1968
|
-
? this.$default.isStoreValue
|
|
1969
|
-
: menuOption.isStoreValue;
|
|
1949
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1970
1950
|
/**
|
|
1971
1951
|
* 用户点击菜单后的回调函数
|
|
1972
1952
|
* @param event
|
|
@@ -2019,8 +1999,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2019
1999
|
* @param menuKey 菜单-键key
|
|
2020
2000
|
*/
|
|
2021
2001
|
getMenuHandledOption(menuKey) {
|
|
2022
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2023
|
-
?.handleData;
|
|
2002
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2024
2003
|
},
|
|
2025
2004
|
};
|
|
2026
2005
|
constructor(details) {
|
|
@@ -2028,8 +2007,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2028
2007
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2029
2008
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2030
2009
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2031
|
-
this.MenuHandle.$default.autoReload =
|
|
2032
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2010
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2033
2011
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2034
2012
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2035
2013
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2261,8 +2239,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2261
2239
|
_context = context || window;
|
|
2262
2240
|
_funcName = getFuncName(this);
|
|
2263
2241
|
_context["realFunc_" + _funcName] = this;
|
|
2264
|
-
if (_context[_funcName].prototype &&
|
|
2265
|
-
_context[_funcName].prototype.isHooked) {
|
|
2242
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2266
2243
|
console.log("Already has been hooked,unhook first");
|
|
2267
2244
|
return false;
|
|
2268
2245
|
}
|
|
@@ -2440,8 +2417,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2440
2417
|
if (details.allowInterceptConfig != null) {
|
|
2441
2418
|
// 配置存在
|
|
2442
2419
|
// 细分处理是否拦截
|
|
2443
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2444
|
-
"boolean" &&
|
|
2420
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2445
2421
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2446
2422
|
// 设置了禁止拦截
|
|
2447
2423
|
return details;
|
|
@@ -2476,8 +2452,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2476
2452
|
if (data.details.allowInterceptConfig != null) {
|
|
2477
2453
|
// 配置存在
|
|
2478
2454
|
// 细分处理是否拦截
|
|
2479
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2480
|
-
"boolean" &&
|
|
2455
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2481
2456
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2482
2457
|
// 设置了禁止拦截
|
|
2483
2458
|
return data;
|
|
@@ -2579,44 +2554,31 @@ System.register('Utils', [], (function (exports) {
|
|
|
2579
2554
|
let requestOption = {
|
|
2580
2555
|
url: url,
|
|
2581
2556
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2582
|
-
timeout: userRequestOption.timeout ||
|
|
2583
|
-
|
|
2584
|
-
responseType: userRequestOption.responseType ||
|
|
2585
|
-
this.context.#defaultRequestOption.responseType,
|
|
2557
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2558
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2586
2559
|
/* 对象使用深拷贝 */
|
|
2587
2560
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2588
2561
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2589
|
-
redirect: userRequestOption.redirect ||
|
|
2590
|
-
this.context.#defaultRequestOption.redirect,
|
|
2562
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2591
2563
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2592
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2593
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2564
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2594
2565
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2595
|
-
nocache: userRequestOption.nocache ||
|
|
2596
|
-
|
|
2597
|
-
revalidate: userRequestOption.revalidate ||
|
|
2598
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2566
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2567
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2599
2568
|
/* 对象使用深拷贝 */
|
|
2600
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2604
|
-
anonymous: userRequestOption.anonymous ||
|
|
2605
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2569
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2570
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2571
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2606
2572
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2607
2573
|
/* 对象使用深拷贝 */
|
|
2608
2574
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2609
2575
|
allowInterceptConfig: {
|
|
2610
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2614
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2615
|
-
.allowInterceptConfig.afterResponseError,
|
|
2576
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2577
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2578
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2616
2579
|
},
|
|
2617
2580
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2618
|
-
password: userRequestOption.password ||
|
|
2619
|
-
this.context.#defaultRequestOption.password,
|
|
2581
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2620
2582
|
onabort(...args) {
|
|
2621
2583
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2622
2584
|
},
|
|
@@ -2664,14 +2626,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
2664
2626
|
if (typeof requestOption.headers === "object") {
|
|
2665
2627
|
if (typeof userRequestOption.headers === "object") {
|
|
2666
2628
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2667
|
-
if (keyName in requestOption.headers &&
|
|
2668
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2629
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2669
2630
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2670
2631
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2671
2632
|
}
|
|
2672
2633
|
else {
|
|
2673
|
-
requestOption.headers[keyName] =
|
|
2674
|
-
userRequestOption?.headers?.[keyName];
|
|
2634
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2675
2635
|
}
|
|
2676
2636
|
});
|
|
2677
2637
|
}
|
|
@@ -2684,8 +2644,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2684
2644
|
/* 使用assign替换且添加 */
|
|
2685
2645
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2686
2646
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2687
|
-
if (keyName in requestOption.fetchInit &&
|
|
2688
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2647
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2689
2648
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2690
2649
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2691
2650
|
}
|
|
@@ -2699,8 +2658,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2699
2658
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2700
2659
|
}
|
|
2701
2660
|
// 处理新的cookiePartition
|
|
2702
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2703
|
-
requestOption.cookiePartition != null) {
|
|
2661
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2704
2662
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2705
2663
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2706
2664
|
// topLevelSite必须是字符串
|
|
@@ -2722,8 +2680,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2722
2680
|
}
|
|
2723
2681
|
else {
|
|
2724
2682
|
// 补充origin+/
|
|
2725
|
-
requestOption.url =
|
|
2726
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2683
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2727
2684
|
}
|
|
2728
2685
|
}
|
|
2729
2686
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2847,8 +2804,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
2847
2804
|
* fetch的请求配置
|
|
2848
2805
|
**/
|
|
2849
2806
|
let fetchRequestOption = {};
|
|
2850
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2851
|
-
option.data != null) {
|
|
2807
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2852
2808
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2853
2809
|
Reflect.deleteProperty(option, "data");
|
|
2854
2810
|
}
|
|
@@ -3129,8 +3085,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3129
3085
|
if (typeof details?.onreadystatechange === "function") {
|
|
3130
3086
|
details.onreadystatechange.apply(this, argsResult);
|
|
3131
3087
|
}
|
|
3132
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3133
|
-
"function") {
|
|
3088
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3134
3089
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3135
3090
|
}
|
|
3136
3091
|
},
|
|
@@ -3159,8 +3114,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3159
3114
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3160
3115
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3161
3116
|
}
|
|
3162
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3163
|
-
"function") {
|
|
3117
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3164
3118
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3165
3119
|
if (hookResult == null) {
|
|
3166
3120
|
return;
|
|
@@ -3216,9 +3170,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3216
3170
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3217
3171
|
if (option.responseType === "stream" ||
|
|
3218
3172
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3219
|
-
fetchResponse.headers
|
|
3220
|
-
.get("Content-Type")
|
|
3221
|
-
.includes("text/event-stream"))) {
|
|
3173
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3222
3174
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3223
3175
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3224
3176
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3237,9 +3189,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3237
3189
|
/** 数据编码 */
|
|
3238
3190
|
let encoding = "utf-8";
|
|
3239
3191
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3240
|
-
let charsetMatched = fetchResponse.headers
|
|
3241
|
-
.get("Content-Type")
|
|
3242
|
-
?.match(/charset=(.+)/);
|
|
3192
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3243
3193
|
if (charsetMatched) {
|
|
3244
3194
|
encoding = charsetMatched[1];
|
|
3245
3195
|
encoding = encoding.toLowerCase();
|
|
@@ -3261,13 +3211,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
3261
3211
|
response = new Blob([arrayBuffer]);
|
|
3262
3212
|
}
|
|
3263
3213
|
else if (option.responseType === "json" ||
|
|
3264
|
-
(typeof fetchResponseType === "string" &&
|
|
3265
|
-
fetchResponseType.includes("application/json"))) {
|
|
3214
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3266
3215
|
// response返回格式是JSON格式
|
|
3267
3216
|
response = commonUtil.toJSON(responseText);
|
|
3268
3217
|
}
|
|
3269
|
-
else if (option.responseType === "document" ||
|
|
3270
|
-
option.responseType == null) {
|
|
3218
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3271
3219
|
// response返回格式是文档格式
|
|
3272
3220
|
let parser = new DOMParser();
|
|
3273
3221
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3530,8 +3478,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
3530
3478
|
}
|
|
3531
3479
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3532
3480
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3533
|
-
if (requestResult != null &&
|
|
3534
|
-
typeof requestResult.abort === "function") {
|
|
3481
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3535
3482
|
abortFn = requestResult.abort;
|
|
3536
3483
|
}
|
|
3537
3484
|
});
|
|
@@ -4022,8 +3969,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4022
3969
|
if (typeof __GM_info === "string") {
|
|
4023
3970
|
this.tag = __GM_info;
|
|
4024
3971
|
}
|
|
4025
|
-
else if (typeof __GM_info === "object" &&
|
|
4026
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3972
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4027
3973
|
this.tag = __GM_info.script.name;
|
|
4028
3974
|
}
|
|
4029
3975
|
this.#console = console;
|
|
@@ -4079,8 +4025,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4079
4025
|
*/
|
|
4080
4026
|
checkClearConsole() {
|
|
4081
4027
|
this.#logCount++;
|
|
4082
|
-
if (this.#details.autoClearConsole &&
|
|
4083
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
4028
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4084
4029
|
this.#console.clear();
|
|
4085
4030
|
this.#logCount = 0;
|
|
4086
4031
|
}
|
|
@@ -5583,7 +5528,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5583
5528
|
this.windowApi = new WindowApi(option);
|
|
5584
5529
|
}
|
|
5585
5530
|
/** 版本号 */
|
|
5586
|
-
version = "2025.
|
|
5531
|
+
version = "2025.8.11";
|
|
5587
5532
|
addStyle(cssText) {
|
|
5588
5533
|
if (typeof cssText !== "string") {
|
|
5589
5534
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5706,13 +5651,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
5706
5651
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5707
5652
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5708
5653
|
// 点击的x坐标
|
|
5709
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5710
|
-
? clickEvent.clientX
|
|
5711
|
-
: touchEvent.touches[0].clientX;
|
|
5654
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5712
5655
|
// 点击的y坐标
|
|
5713
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5714
|
-
? clickEvent.clientY
|
|
5715
|
-
: touchEvent.touches[0].clientY;
|
|
5656
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5716
5657
|
let {
|
|
5717
5658
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5718
5659
|
left: elementPosXLeft,
|
|
@@ -5875,9 +5816,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5875
5816
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5876
5817
|
let windowFind = this.windowApi.self.find;
|
|
5877
5818
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5878
|
-
if (strFound &&
|
|
5879
|
-
this.windowApi.self.getSelection &&
|
|
5880
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5819
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5881
5820
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5882
5821
|
}
|
|
5883
5822
|
if (!strFound) {
|
|
@@ -5980,9 +5919,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5980
5919
|
}
|
|
5981
5920
|
}
|
|
5982
5921
|
result = result.toFixed(2);
|
|
5983
|
-
result = addType
|
|
5984
|
-
? result + resultType.toString()
|
|
5985
|
-
: parseFloat(result.toString());
|
|
5922
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5986
5923
|
return result;
|
|
5987
5924
|
}
|
|
5988
5925
|
getNodeListValue(...args) {
|
|
@@ -6061,14 +5998,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6061
5998
|
if (text.length === 8) {
|
|
6062
5999
|
/* 该字符串只有时分秒 */
|
|
6063
6000
|
let today = new Date();
|
|
6064
|
-
text =
|
|
6065
|
-
today.getFullYear() +
|
|
6066
|
-
"-" +
|
|
6067
|
-
(today.getMonth() + 1) +
|
|
6068
|
-
"-" +
|
|
6069
|
-
today.getDate() +
|
|
6070
|
-
" " +
|
|
6071
|
-
text;
|
|
6001
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6072
6002
|
}
|
|
6073
6003
|
text = text.substring(0, 19);
|
|
6074
6004
|
text = text.replace(/-/g, "/");
|
|
@@ -6089,25 +6019,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
6089
6019
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6090
6020
|
*/
|
|
6091
6021
|
getTransitionEndNameList() {
|
|
6092
|
-
return [
|
|
6093
|
-
"webkitTransitionEnd",
|
|
6094
|
-
"mozTransitionEnd",
|
|
6095
|
-
"MSTransitionEnd",
|
|
6096
|
-
"otransitionend",
|
|
6097
|
-
"transitionend",
|
|
6098
|
-
];
|
|
6022
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6099
6023
|
}
|
|
6100
6024
|
/**
|
|
6101
6025
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6102
6026
|
*/
|
|
6103
6027
|
getAnimationEndNameList() {
|
|
6104
|
-
return [
|
|
6105
|
-
"webkitAnimationEnd",
|
|
6106
|
-
"mozAnimationEnd",
|
|
6107
|
-
"MSAnimationEnd",
|
|
6108
|
-
"oanimationend",
|
|
6109
|
-
"animationend",
|
|
6110
|
-
];
|
|
6028
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6111
6029
|
}
|
|
6112
6030
|
getArrayLastValue(targetObj) {
|
|
6113
6031
|
return targetObj[targetObj.length - 1];
|
|
@@ -6211,10 +6129,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
6211
6129
|
}
|
|
6212
6130
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6213
6131
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6214
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6215
|
-
|
|
6216
|
-
selector +=
|
|
6217
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6132
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6133
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6218
6134
|
}
|
|
6219
6135
|
else {
|
|
6220
6136
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6234,9 +6150,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6234
6150
|
return void 0;
|
|
6235
6151
|
}
|
|
6236
6152
|
if (result.length > 1) {
|
|
6237
|
-
if (result.length === 2 &&
|
|
6238
|
-
typeof result[0] === "object" &&
|
|
6239
|
-
typeof result[1] === "function") {
|
|
6153
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6240
6154
|
let data = result[0];
|
|
6241
6155
|
let handleDataFunc = result[1];
|
|
6242
6156
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6334,9 +6248,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6334
6248
|
return void 0;
|
|
6335
6249
|
}
|
|
6336
6250
|
if (result.length > 1) {
|
|
6337
|
-
if (result.length === 2 &&
|
|
6338
|
-
typeof result[0] === "object" &&
|
|
6339
|
-
typeof result[1] === "function") {
|
|
6251
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6340
6252
|
let data = result[0];
|
|
6341
6253
|
let handleDataFunc = result[1];
|
|
6342
6254
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6426,12 +6338,10 @@ System.register('Utils', [], (function (exports) {
|
|
|
6426
6338
|
getRandomValue(...args) {
|
|
6427
6339
|
let result = [...args];
|
|
6428
6340
|
if (result.length > 1) {
|
|
6429
|
-
if (result.length === 2 &&
|
|
6430
|
-
typeof result[0] === "number" &&
|
|
6431
|
-
typeof result[1] === "number") {
|
|
6341
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6432
6342
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6433
6343
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6434
|
-
return
|
|
6344
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6435
6345
|
}
|
|
6436
6346
|
else {
|
|
6437
6347
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6442,8 +6352,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6442
6352
|
if (Array.isArray(paramData)) {
|
|
6443
6353
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6444
6354
|
}
|
|
6445
|
-
else if (typeof paramData === "object" &&
|
|
6446
|
-
Object.keys(paramData).length > 0) {
|
|
6355
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6447
6356
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6448
6357
|
return paramData[paramObjDataKey];
|
|
6449
6358
|
}
|
|
@@ -6750,11 +6659,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
6750
6659
|
let nearBottomHeight = 50;
|
|
6751
6660
|
let checkWindow = () => {
|
|
6752
6661
|
// 已滚动的距离
|
|
6753
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6754
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6662
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6755
6663
|
// 视窗高度
|
|
6756
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6757
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6664
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6758
6665
|
// 最大滚动距离
|
|
6759
6666
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6760
6667
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7043,8 +6950,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7043
6950
|
**/
|
|
7044
6951
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7045
6952
|
isThemeDark() {
|
|
7046
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7047
|
-
.matches;
|
|
6953
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7048
6954
|
}
|
|
7049
6955
|
/**
|
|
7050
6956
|
* 判断元素是否在页面中可见
|
|
@@ -7077,10 +6983,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7077
6983
|
else {
|
|
7078
6984
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7079
6985
|
if (inView) {
|
|
7080
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7081
|
-
|
|
7082
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7083
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6986
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6987
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7084
6988
|
result = !(domClientRect.right < 0 ||
|
|
7085
6989
|
domClientRect.left > viewportWidth ||
|
|
7086
6990
|
domClientRect.bottom < 0 ||
|
|
@@ -7104,8 +7008,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7104
7008
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7105
7009
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7106
7010
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7107
|
-
if (typeof objValueFunc === "function" &&
|
|
7108
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7011
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7109
7012
|
result = true;
|
|
7110
7013
|
}
|
|
7111
7014
|
else {
|
|
@@ -7127,8 +7030,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7127
7030
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7128
7031
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7129
7032
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7130
|
-
if (typeof objValueFunc === "function" &&
|
|
7131
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7033
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7132
7034
|
result = true;
|
|
7133
7035
|
}
|
|
7134
7036
|
else {
|
|
@@ -7365,13 +7267,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
7365
7267
|
* 释放所有
|
|
7366
7268
|
*/
|
|
7367
7269
|
function releaseAll() {
|
|
7368
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7369
|
-
"undefined") {
|
|
7270
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7370
7271
|
/* 已存在 */
|
|
7371
7272
|
return;
|
|
7372
7273
|
}
|
|
7373
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7374
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7274
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7375
7275
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7376
7276
|
if (typeof value === "function") {
|
|
7377
7277
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7385,8 +7285,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7385
7285
|
Array.from(functionNameList).forEach((item) => {
|
|
7386
7286
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7387
7287
|
if (typeof value === "function") {
|
|
7388
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7389
|
-
"undefined") {
|
|
7288
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7390
7289
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7391
7290
|
}
|
|
7392
7291
|
if (item === value.name) {
|
|
@@ -7401,8 +7300,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7401
7300
|
* 恢复所有
|
|
7402
7301
|
*/
|
|
7403
7302
|
function recoveryAll() {
|
|
7404
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7405
|
-
"undefined") {
|
|
7303
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7406
7304
|
/* 未存在 */
|
|
7407
7305
|
return;
|
|
7408
7306
|
}
|
|
@@ -7413,8 +7311,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7413
7311
|
* 恢复单个
|
|
7414
7312
|
*/
|
|
7415
7313
|
function recoveryOne() {
|
|
7416
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7417
|
-
"undefined") {
|
|
7314
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7418
7315
|
/* 未存在 */
|
|
7419
7316
|
return;
|
|
7420
7317
|
}
|
|
@@ -7422,8 +7319,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7422
7319
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7423
7320
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7424
7321
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7425
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7426
|
-
.length === 0) {
|
|
7322
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7427
7323
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7428
7324
|
}
|
|
7429
7325
|
}
|
|
@@ -7680,8 +7576,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7680
7576
|
let copyStatus = false;
|
|
7681
7577
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7682
7578
|
console.log(requestPermissionStatus);
|
|
7683
|
-
if (this.hasClipboard() &&
|
|
7684
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7579
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7685
7580
|
try {
|
|
7686
7581
|
copyStatus = await this.copyDataByClipboard();
|
|
7687
7582
|
}
|
|
@@ -7842,11 +7737,8 @@ System.register('Utils', [], (function (exports) {
|
|
|
7842
7737
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7843
7738
|
return mouseEvent;
|
|
7844
7739
|
}
|
|
7845
|
-
let sliderElement = typeof selector === "string"
|
|
7846
|
-
|
|
7847
|
-
: selector;
|
|
7848
|
-
if (!(sliderElement instanceof Node) ||
|
|
7849
|
-
!(sliderElement instanceof Element)) {
|
|
7740
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7741
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7850
7742
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7851
7743
|
}
|
|
7852
7744
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7898,17 +7790,14 @@ System.register('Utils', [], (function (exports) {
|
|
|
7898
7790
|
}
|
|
7899
7791
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7900
7792
|
let UtilsContext = this;
|
|
7901
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7902
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7793
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7903
7794
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7904
7795
|
}
|
|
7905
7796
|
if (typeof sortByDesc !== "boolean") {
|
|
7906
7797
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7907
7798
|
}
|
|
7908
7799
|
let getObjValue = function (obj) {
|
|
7909
|
-
return typeof getPropertyValueFunc === "string"
|
|
7910
|
-
? obj[getPropertyValueFunc]
|
|
7911
|
-
: getPropertyValueFunc(obj);
|
|
7800
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7912
7801
|
};
|
|
7913
7802
|
/**
|
|
7914
7803
|
* 排序方法
|
|
@@ -7983,8 +7872,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
7983
7872
|
if (Array.isArray(data)) {
|
|
7984
7873
|
data.sort(sortFunc);
|
|
7985
7874
|
}
|
|
7986
|
-
else if (data instanceof NodeList ||
|
|
7987
|
-
UtilsContext.isJQuery(data)) {
|
|
7875
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7988
7876
|
sortNodeFunc(data, getDataFunc);
|
|
7989
7877
|
result = getDataFunc();
|
|
7990
7878
|
}
|
|
@@ -8177,9 +8065,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8177
8065
|
let parent = UtilsContext.windowApi.document;
|
|
8178
8066
|
// 超时时间
|
|
8179
8067
|
let timeout = 0;
|
|
8180
|
-
if (typeof args[0] !== "string" &&
|
|
8181
|
-
!Array.isArray(args[0]) &&
|
|
8182
|
-
typeof args[0] !== "function") {
|
|
8068
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8183
8069
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8184
8070
|
}
|
|
8185
8071
|
if (args.length === 1) ;
|
|
@@ -8189,8 +8075,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8189
8075
|
// "div",10000
|
|
8190
8076
|
timeout = secondParam;
|
|
8191
8077
|
}
|
|
8192
|
-
else if (typeof secondParam === "object" &&
|
|
8193
|
-
secondParam instanceof Node) {
|
|
8078
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8194
8079
|
// "div",document
|
|
8195
8080
|
parent = secondParam;
|
|
8196
8081
|
}
|
|
@@ -8276,8 +8161,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8276
8161
|
// "div",10000
|
|
8277
8162
|
timeout = secondParam;
|
|
8278
8163
|
}
|
|
8279
|
-
else if (typeof secondParam === "object" &&
|
|
8280
|
-
secondParam instanceof Node) {
|
|
8164
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8281
8165
|
// "div",document
|
|
8282
8166
|
parent = secondParam;
|
|
8283
8167
|
}
|
|
@@ -8332,8 +8216,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8332
8216
|
// "div",10000
|
|
8333
8217
|
timeout = secondParam;
|
|
8334
8218
|
}
|
|
8335
|
-
else if (typeof secondParam === "object" &&
|
|
8336
|
-
secondParam instanceof Node) {
|
|
8219
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8337
8220
|
// "div",document
|
|
8338
8221
|
parent = secondParam;
|
|
8339
8222
|
}
|
|
@@ -8419,8 +8302,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8419
8302
|
// "div",10000
|
|
8420
8303
|
timeout = secondParam;
|
|
8421
8304
|
}
|
|
8422
|
-
else if (typeof secondParam === "object" &&
|
|
8423
|
-
secondParam instanceof Node) {
|
|
8305
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8424
8306
|
// "div",document
|
|
8425
8307
|
parent = secondParam;
|
|
8426
8308
|
}
|
|
@@ -8553,8 +8435,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
8553
8435
|
return flag;
|
|
8554
8436
|
}
|
|
8555
8437
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8556
|
-
if (typeof getCallBack !== "function" &&
|
|
8557
|
-
typeof setCallBack !== "function") {
|
|
8438
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8558
8439
|
return;
|
|
8559
8440
|
}
|
|
8560
8441
|
if (typeof getCallBack === "function") {
|
|
@@ -8606,13 +8487,27 @@ System.register('Utils', [], (function (exports) {
|
|
|
8606
8487
|
return;
|
|
8607
8488
|
}
|
|
8608
8489
|
let handleResult = handler(target);
|
|
8609
|
-
if (handleResult &&
|
|
8610
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8611
|
-
handleResult.isFind) {
|
|
8490
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8612
8491
|
return handleResult.data;
|
|
8613
8492
|
}
|
|
8614
8493
|
return this.queryProperty(handleResult.data, handler);
|
|
8615
8494
|
}
|
|
8495
|
+
/**
|
|
8496
|
+
* 异步-深度获取对象属性
|
|
8497
|
+
* @param target 待获取的对象
|
|
8498
|
+
* @param handler 获取属性的回调
|
|
8499
|
+
*/
|
|
8500
|
+
async asyncQueryProperty(target, handler) {
|
|
8501
|
+
if (target == null) {
|
|
8502
|
+
// @ts-ignore
|
|
8503
|
+
return;
|
|
8504
|
+
}
|
|
8505
|
+
let handleResult = await handler(target);
|
|
8506
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8507
|
+
return handleResult.data;
|
|
8508
|
+
}
|
|
8509
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8510
|
+
}
|
|
8616
8511
|
/**
|
|
8617
8512
|
* 创建一个新的Utils实例
|
|
8618
8513
|
* @param option
|