@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.iife.js
CHANGED
|
@@ -68,11 +68,7 @@ var Utils = (function () {
|
|
|
68
68
|
!validPattern.test(greenValue.toString()) ||
|
|
69
69
|
!validPattern.test(blueValue.toString()))
|
|
70
70
|
throw new TypeError("输入错误的rgb颜色值");
|
|
71
|
-
let hexs = [
|
|
72
|
-
redValue.toString(16),
|
|
73
|
-
greenValue.toString(16),
|
|
74
|
-
blueValue.toString(16),
|
|
75
|
-
];
|
|
71
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
76
72
|
for (let index = 0; index < 3; index++)
|
|
77
73
|
if (hexs[index].length == 1)
|
|
78
74
|
hexs[index] = "0" + hexs[index];
|
|
@@ -120,10 +116,7 @@ var Utils = (function () {
|
|
|
120
116
|
this.#data = dataText.match(/..../g);
|
|
121
117
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
122
118
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
123
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
124
|
-
i.toString(16) +
|
|
125
|
-
"%" +
|
|
126
|
-
j.toString(16)).toUpperCase();
|
|
119
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
127
120
|
}
|
|
128
121
|
}
|
|
129
122
|
for (let key in this.#U2Ghash) {
|
|
@@ -251,9 +244,7 @@ var Utils = (function () {
|
|
|
251
244
|
callbackFunction = callback;
|
|
252
245
|
context = __context__ || this;
|
|
253
246
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
254
|
-
return result !== void 0
|
|
255
|
-
? result
|
|
256
|
-
: TryCatchCore;
|
|
247
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
257
248
|
},
|
|
258
249
|
};
|
|
259
250
|
/**
|
|
@@ -282,10 +273,7 @@ var Utils = (function () {
|
|
|
282
273
|
}
|
|
283
274
|
if (handleErrorFunc) {
|
|
284
275
|
if (typeof handleErrorFunc === "string") {
|
|
285
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
286
|
-
...args,
|
|
287
|
-
error,
|
|
288
|
-
]);
|
|
276
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
289
277
|
}
|
|
290
278
|
else {
|
|
291
279
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -373,10 +361,7 @@ var Utils = (function () {
|
|
|
373
361
|
itemResult = objItem === 0;
|
|
374
362
|
break;
|
|
375
363
|
case "string":
|
|
376
|
-
itemResult =
|
|
377
|
-
objItem.trim() === "" ||
|
|
378
|
-
objItem === "null" ||
|
|
379
|
-
objItem === "undefined";
|
|
364
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
380
365
|
break;
|
|
381
366
|
case "boolean":
|
|
382
367
|
itemResult = !objItem;
|
|
@@ -417,8 +402,7 @@ var Utils = (function () {
|
|
|
417
402
|
return null;
|
|
418
403
|
let clone = obj instanceof Array ? [] : {};
|
|
419
404
|
for (const [key, value] of Object.entries(obj)) {
|
|
420
|
-
clone[key] =
|
|
421
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
405
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
422
406
|
}
|
|
423
407
|
return clone;
|
|
424
408
|
}
|
|
@@ -1957,14 +1941,10 @@ var Utils = (function () {
|
|
|
1957
1941
|
// };
|
|
1958
1942
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1959
1943
|
menuOption.autoReload =
|
|
1960
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1961
|
-
? this.$default.autoReload
|
|
1962
|
-
: menuOption.autoReload;
|
|
1944
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1963
1945
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1964
1946
|
menuOption.isStoreValue =
|
|
1965
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1966
|
-
? this.$default.isStoreValue
|
|
1967
|
-
: menuOption.isStoreValue;
|
|
1947
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1968
1948
|
/**
|
|
1969
1949
|
* 用户点击菜单后的回调函数
|
|
1970
1950
|
* @param event
|
|
@@ -2017,8 +1997,7 @@ var Utils = (function () {
|
|
|
2017
1997
|
* @param menuKey 菜单-键key
|
|
2018
1998
|
*/
|
|
2019
1999
|
getMenuHandledOption(menuKey) {
|
|
2020
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2021
|
-
?.handleData;
|
|
2000
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2022
2001
|
},
|
|
2023
2002
|
};
|
|
2024
2003
|
constructor(details) {
|
|
@@ -2026,8 +2005,7 @@ var Utils = (function () {
|
|
|
2026
2005
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2027
2006
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2028
2007
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2029
|
-
this.MenuHandle.$default.autoReload =
|
|
2030
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2008
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2031
2009
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2032
2010
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2033
2011
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2259,8 +2237,7 @@ var Utils = (function () {
|
|
|
2259
2237
|
_context = context || window;
|
|
2260
2238
|
_funcName = getFuncName(this);
|
|
2261
2239
|
_context["realFunc_" + _funcName] = this;
|
|
2262
|
-
if (_context[_funcName].prototype &&
|
|
2263
|
-
_context[_funcName].prototype.isHooked) {
|
|
2240
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2264
2241
|
console.log("Already has been hooked,unhook first");
|
|
2265
2242
|
return false;
|
|
2266
2243
|
}
|
|
@@ -2438,8 +2415,7 @@ var Utils = (function () {
|
|
|
2438
2415
|
if (details.allowInterceptConfig != null) {
|
|
2439
2416
|
// 配置存在
|
|
2440
2417
|
// 细分处理是否拦截
|
|
2441
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2442
|
-
"boolean" &&
|
|
2418
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2443
2419
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2444
2420
|
// 设置了禁止拦截
|
|
2445
2421
|
return details;
|
|
@@ -2474,8 +2450,7 @@ var Utils = (function () {
|
|
|
2474
2450
|
if (data.details.allowInterceptConfig != null) {
|
|
2475
2451
|
// 配置存在
|
|
2476
2452
|
// 细分处理是否拦截
|
|
2477
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2478
|
-
"boolean" &&
|
|
2453
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2479
2454
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2480
2455
|
// 设置了禁止拦截
|
|
2481
2456
|
return data;
|
|
@@ -2577,44 +2552,31 @@ var Utils = (function () {
|
|
|
2577
2552
|
let requestOption = {
|
|
2578
2553
|
url: url,
|
|
2579
2554
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2580
|
-
timeout: userRequestOption.timeout ||
|
|
2581
|
-
|
|
2582
|
-
responseType: userRequestOption.responseType ||
|
|
2583
|
-
this.context.#defaultRequestOption.responseType,
|
|
2555
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2556
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2584
2557
|
/* 对象使用深拷贝 */
|
|
2585
2558
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2586
2559
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2587
|
-
redirect: userRequestOption.redirect ||
|
|
2588
|
-
this.context.#defaultRequestOption.redirect,
|
|
2560
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2589
2561
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2590
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2591
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2562
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2592
2563
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2593
|
-
nocache: userRequestOption.nocache ||
|
|
2594
|
-
|
|
2595
|
-
revalidate: userRequestOption.revalidate ||
|
|
2596
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2564
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2565
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2597
2566
|
/* 对象使用深拷贝 */
|
|
2598
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2602
|
-
anonymous: userRequestOption.anonymous ||
|
|
2603
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2567
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2568
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2569
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2604
2570
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2605
2571
|
/* 对象使用深拷贝 */
|
|
2606
2572
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2607
2573
|
allowInterceptConfig: {
|
|
2608
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2612
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2613
|
-
.allowInterceptConfig.afterResponseError,
|
|
2574
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2575
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2576
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2614
2577
|
},
|
|
2615
2578
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2616
|
-
password: userRequestOption.password ||
|
|
2617
|
-
this.context.#defaultRequestOption.password,
|
|
2579
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2618
2580
|
onabort(...args) {
|
|
2619
2581
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2620
2582
|
},
|
|
@@ -2662,14 +2624,12 @@ var Utils = (function () {
|
|
|
2662
2624
|
if (typeof requestOption.headers === "object") {
|
|
2663
2625
|
if (typeof userRequestOption.headers === "object") {
|
|
2664
2626
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2665
|
-
if (keyName in requestOption.headers &&
|
|
2666
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2627
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2667
2628
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2668
2629
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2669
2630
|
}
|
|
2670
2631
|
else {
|
|
2671
|
-
requestOption.headers[keyName] =
|
|
2672
|
-
userRequestOption?.headers?.[keyName];
|
|
2632
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2673
2633
|
}
|
|
2674
2634
|
});
|
|
2675
2635
|
}
|
|
@@ -2682,8 +2642,7 @@ var Utils = (function () {
|
|
|
2682
2642
|
/* 使用assign替换且添加 */
|
|
2683
2643
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2684
2644
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2685
|
-
if (keyName in requestOption.fetchInit &&
|
|
2686
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2645
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2687
2646
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2688
2647
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2689
2648
|
}
|
|
@@ -2697,8 +2656,7 @@ var Utils = (function () {
|
|
|
2697
2656
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2698
2657
|
}
|
|
2699
2658
|
// 处理新的cookiePartition
|
|
2700
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2701
|
-
requestOption.cookiePartition != null) {
|
|
2659
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2702
2660
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2703
2661
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2704
2662
|
// topLevelSite必须是字符串
|
|
@@ -2720,8 +2678,7 @@ var Utils = (function () {
|
|
|
2720
2678
|
}
|
|
2721
2679
|
else {
|
|
2722
2680
|
// 补充origin+/
|
|
2723
|
-
requestOption.url =
|
|
2724
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2681
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2725
2682
|
}
|
|
2726
2683
|
}
|
|
2727
2684
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2845,8 +2802,7 @@ var Utils = (function () {
|
|
|
2845
2802
|
* fetch的请求配置
|
|
2846
2803
|
**/
|
|
2847
2804
|
let fetchRequestOption = {};
|
|
2848
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2849
|
-
option.data != null) {
|
|
2805
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2850
2806
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2851
2807
|
Reflect.deleteProperty(option, "data");
|
|
2852
2808
|
}
|
|
@@ -3127,8 +3083,7 @@ var Utils = (function () {
|
|
|
3127
3083
|
if (typeof details?.onreadystatechange === "function") {
|
|
3128
3084
|
details.onreadystatechange.apply(this, argsResult);
|
|
3129
3085
|
}
|
|
3130
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3131
|
-
"function") {
|
|
3086
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3132
3087
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3133
3088
|
}
|
|
3134
3089
|
},
|
|
@@ -3157,8 +3112,7 @@ var Utils = (function () {
|
|
|
3157
3112
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3158
3113
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3159
3114
|
}
|
|
3160
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3161
|
-
"function") {
|
|
3115
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3162
3116
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3163
3117
|
if (hookResult == null) {
|
|
3164
3118
|
return;
|
|
@@ -3214,9 +3168,7 @@ var Utils = (function () {
|
|
|
3214
3168
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3215
3169
|
if (option.responseType === "stream" ||
|
|
3216
3170
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3217
|
-
fetchResponse.headers
|
|
3218
|
-
.get("Content-Type")
|
|
3219
|
-
.includes("text/event-stream"))) {
|
|
3171
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3220
3172
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3221
3173
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3222
3174
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3235,9 +3187,7 @@ var Utils = (function () {
|
|
|
3235
3187
|
/** 数据编码 */
|
|
3236
3188
|
let encoding = "utf-8";
|
|
3237
3189
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3238
|
-
let charsetMatched = fetchResponse.headers
|
|
3239
|
-
.get("Content-Type")
|
|
3240
|
-
?.match(/charset=(.+)/);
|
|
3190
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3241
3191
|
if (charsetMatched) {
|
|
3242
3192
|
encoding = charsetMatched[1];
|
|
3243
3193
|
encoding = encoding.toLowerCase();
|
|
@@ -3259,13 +3209,11 @@ var Utils = (function () {
|
|
|
3259
3209
|
response = new Blob([arrayBuffer]);
|
|
3260
3210
|
}
|
|
3261
3211
|
else if (option.responseType === "json" ||
|
|
3262
|
-
(typeof fetchResponseType === "string" &&
|
|
3263
|
-
fetchResponseType.includes("application/json"))) {
|
|
3212
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3264
3213
|
// response返回格式是JSON格式
|
|
3265
3214
|
response = commonUtil.toJSON(responseText);
|
|
3266
3215
|
}
|
|
3267
|
-
else if (option.responseType === "document" ||
|
|
3268
|
-
option.responseType == null) {
|
|
3216
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3269
3217
|
// response返回格式是文档格式
|
|
3270
3218
|
let parser = new DOMParser();
|
|
3271
3219
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3528,8 +3476,7 @@ var Utils = (function () {
|
|
|
3528
3476
|
}
|
|
3529
3477
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3530
3478
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3531
|
-
if (requestResult != null &&
|
|
3532
|
-
typeof requestResult.abort === "function") {
|
|
3479
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3533
3480
|
abortFn = requestResult.abort;
|
|
3534
3481
|
}
|
|
3535
3482
|
});
|
|
@@ -4020,8 +3967,7 @@ var Utils = (function () {
|
|
|
4020
3967
|
if (typeof __GM_info === "string") {
|
|
4021
3968
|
this.tag = __GM_info;
|
|
4022
3969
|
}
|
|
4023
|
-
else if (typeof __GM_info === "object" &&
|
|
4024
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3970
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4025
3971
|
this.tag = __GM_info.script.name;
|
|
4026
3972
|
}
|
|
4027
3973
|
this.#console = console;
|
|
@@ -4077,8 +4023,7 @@ var Utils = (function () {
|
|
|
4077
4023
|
*/
|
|
4078
4024
|
checkClearConsole() {
|
|
4079
4025
|
this.#logCount++;
|
|
4080
|
-
if (this.#details.autoClearConsole &&
|
|
4081
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
4026
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4082
4027
|
this.#console.clear();
|
|
4083
4028
|
this.#logCount = 0;
|
|
4084
4029
|
}
|
|
@@ -5581,7 +5526,7 @@ var Utils = (function () {
|
|
|
5581
5526
|
this.windowApi = new WindowApi(option);
|
|
5582
5527
|
}
|
|
5583
5528
|
/** 版本号 */
|
|
5584
|
-
version = "2025.
|
|
5529
|
+
version = "2025.8.11";
|
|
5585
5530
|
addStyle(cssText) {
|
|
5586
5531
|
if (typeof cssText !== "string") {
|
|
5587
5532
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5704,13 +5649,9 @@ var Utils = (function () {
|
|
|
5704
5649
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5705
5650
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5706
5651
|
// 点击的x坐标
|
|
5707
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5708
|
-
? clickEvent.clientX
|
|
5709
|
-
: touchEvent.touches[0].clientX;
|
|
5652
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5710
5653
|
// 点击的y坐标
|
|
5711
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5712
|
-
? clickEvent.clientY
|
|
5713
|
-
: touchEvent.touches[0].clientY;
|
|
5654
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5714
5655
|
let {
|
|
5715
5656
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5716
5657
|
left: elementPosXLeft,
|
|
@@ -5873,9 +5814,7 @@ var Utils = (function () {
|
|
|
5873
5814
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5874
5815
|
let windowFind = this.windowApi.self.find;
|
|
5875
5816
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5876
|
-
if (strFound &&
|
|
5877
|
-
this.windowApi.self.getSelection &&
|
|
5878
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5817
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5879
5818
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5880
5819
|
}
|
|
5881
5820
|
if (!strFound) {
|
|
@@ -5978,9 +5917,7 @@ var Utils = (function () {
|
|
|
5978
5917
|
}
|
|
5979
5918
|
}
|
|
5980
5919
|
result = result.toFixed(2);
|
|
5981
|
-
result = addType
|
|
5982
|
-
? result + resultType.toString()
|
|
5983
|
-
: parseFloat(result.toString());
|
|
5920
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5984
5921
|
return result;
|
|
5985
5922
|
}
|
|
5986
5923
|
getNodeListValue(...args) {
|
|
@@ -6059,14 +5996,7 @@ var Utils = (function () {
|
|
|
6059
5996
|
if (text.length === 8) {
|
|
6060
5997
|
/* 该字符串只有时分秒 */
|
|
6061
5998
|
let today = new Date();
|
|
6062
|
-
text =
|
|
6063
|
-
today.getFullYear() +
|
|
6064
|
-
"-" +
|
|
6065
|
-
(today.getMonth() + 1) +
|
|
6066
|
-
"-" +
|
|
6067
|
-
today.getDate() +
|
|
6068
|
-
" " +
|
|
6069
|
-
text;
|
|
5999
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6070
6000
|
}
|
|
6071
6001
|
text = text.substring(0, 19);
|
|
6072
6002
|
text = text.replace(/-/g, "/");
|
|
@@ -6087,25 +6017,13 @@ var Utils = (function () {
|
|
|
6087
6017
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6088
6018
|
*/
|
|
6089
6019
|
getTransitionEndNameList() {
|
|
6090
|
-
return [
|
|
6091
|
-
"webkitTransitionEnd",
|
|
6092
|
-
"mozTransitionEnd",
|
|
6093
|
-
"MSTransitionEnd",
|
|
6094
|
-
"otransitionend",
|
|
6095
|
-
"transitionend",
|
|
6096
|
-
];
|
|
6020
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6097
6021
|
}
|
|
6098
6022
|
/**
|
|
6099
6023
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6100
6024
|
*/
|
|
6101
6025
|
getAnimationEndNameList() {
|
|
6102
|
-
return [
|
|
6103
|
-
"webkitAnimationEnd",
|
|
6104
|
-
"mozAnimationEnd",
|
|
6105
|
-
"MSAnimationEnd",
|
|
6106
|
-
"oanimationend",
|
|
6107
|
-
"animationend",
|
|
6108
|
-
];
|
|
6026
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6109
6027
|
}
|
|
6110
6028
|
getArrayLastValue(targetObj) {
|
|
6111
6029
|
return targetObj[targetObj.length - 1];
|
|
@@ -6209,10 +6127,8 @@ var Utils = (function () {
|
|
|
6209
6127
|
}
|
|
6210
6128
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6211
6129
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6212
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6213
|
-
|
|
6214
|
-
selector +=
|
|
6215
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6130
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6131
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6216
6132
|
}
|
|
6217
6133
|
else {
|
|
6218
6134
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6232,9 +6148,7 @@ var Utils = (function () {
|
|
|
6232
6148
|
return void 0;
|
|
6233
6149
|
}
|
|
6234
6150
|
if (result.length > 1) {
|
|
6235
|
-
if (result.length === 2 &&
|
|
6236
|
-
typeof result[0] === "object" &&
|
|
6237
|
-
typeof result[1] === "function") {
|
|
6151
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6238
6152
|
let data = result[0];
|
|
6239
6153
|
let handleDataFunc = result[1];
|
|
6240
6154
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6332,9 +6246,7 @@ var Utils = (function () {
|
|
|
6332
6246
|
return void 0;
|
|
6333
6247
|
}
|
|
6334
6248
|
if (result.length > 1) {
|
|
6335
|
-
if (result.length === 2 &&
|
|
6336
|
-
typeof result[0] === "object" &&
|
|
6337
|
-
typeof result[1] === "function") {
|
|
6249
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6338
6250
|
let data = result[0];
|
|
6339
6251
|
let handleDataFunc = result[1];
|
|
6340
6252
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6424,12 +6336,10 @@ var Utils = (function () {
|
|
|
6424
6336
|
getRandomValue(...args) {
|
|
6425
6337
|
let result = [...args];
|
|
6426
6338
|
if (result.length > 1) {
|
|
6427
|
-
if (result.length === 2 &&
|
|
6428
|
-
typeof result[0] === "number" &&
|
|
6429
|
-
typeof result[1] === "number") {
|
|
6339
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6430
6340
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6431
6341
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6432
|
-
return
|
|
6342
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6433
6343
|
}
|
|
6434
6344
|
else {
|
|
6435
6345
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6440,8 +6350,7 @@ var Utils = (function () {
|
|
|
6440
6350
|
if (Array.isArray(paramData)) {
|
|
6441
6351
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6442
6352
|
}
|
|
6443
|
-
else if (typeof paramData === "object" &&
|
|
6444
|
-
Object.keys(paramData).length > 0) {
|
|
6353
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6445
6354
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6446
6355
|
return paramData[paramObjDataKey];
|
|
6447
6356
|
}
|
|
@@ -6748,11 +6657,9 @@ var Utils = (function () {
|
|
|
6748
6657
|
let nearBottomHeight = 50;
|
|
6749
6658
|
let checkWindow = () => {
|
|
6750
6659
|
// 已滚动的距离
|
|
6751
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6752
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6660
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6753
6661
|
// 视窗高度
|
|
6754
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6755
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6662
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6756
6663
|
// 最大滚动距离
|
|
6757
6664
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6758
6665
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7041,8 +6948,7 @@ var Utils = (function () {
|
|
|
7041
6948
|
**/
|
|
7042
6949
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7043
6950
|
isThemeDark() {
|
|
7044
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7045
|
-
.matches;
|
|
6951
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7046
6952
|
}
|
|
7047
6953
|
/**
|
|
7048
6954
|
* 判断元素是否在页面中可见
|
|
@@ -7075,10 +6981,8 @@ var Utils = (function () {
|
|
|
7075
6981
|
else {
|
|
7076
6982
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7077
6983
|
if (inView) {
|
|
7078
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7079
|
-
|
|
7080
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7081
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6984
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6985
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7082
6986
|
result = !(domClientRect.right < 0 ||
|
|
7083
6987
|
domClientRect.left > viewportWidth ||
|
|
7084
6988
|
domClientRect.bottom < 0 ||
|
|
@@ -7102,8 +7006,7 @@ var Utils = (function () {
|
|
|
7102
7006
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7103
7007
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7104
7008
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7105
|
-
if (typeof objValueFunc === "function" &&
|
|
7106
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7009
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7107
7010
|
result = true;
|
|
7108
7011
|
}
|
|
7109
7012
|
else {
|
|
@@ -7125,8 +7028,7 @@ var Utils = (function () {
|
|
|
7125
7028
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7126
7029
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7127
7030
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7128
|
-
if (typeof objValueFunc === "function" &&
|
|
7129
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7031
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7130
7032
|
result = true;
|
|
7131
7033
|
}
|
|
7132
7034
|
else {
|
|
@@ -7363,13 +7265,11 @@ var Utils = (function () {
|
|
|
7363
7265
|
* 释放所有
|
|
7364
7266
|
*/
|
|
7365
7267
|
function releaseAll() {
|
|
7366
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7367
|
-
"undefined") {
|
|
7268
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7368
7269
|
/* 已存在 */
|
|
7369
7270
|
return;
|
|
7370
7271
|
}
|
|
7371
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7372
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7272
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7373
7273
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7374
7274
|
if (typeof value === "function") {
|
|
7375
7275
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7383,8 +7283,7 @@ var Utils = (function () {
|
|
|
7383
7283
|
Array.from(functionNameList).forEach((item) => {
|
|
7384
7284
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7385
7285
|
if (typeof value === "function") {
|
|
7386
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7387
|
-
"undefined") {
|
|
7286
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7388
7287
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7389
7288
|
}
|
|
7390
7289
|
if (item === value.name) {
|
|
@@ -7399,8 +7298,7 @@ var Utils = (function () {
|
|
|
7399
7298
|
* 恢复所有
|
|
7400
7299
|
*/
|
|
7401
7300
|
function recoveryAll() {
|
|
7402
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7403
|
-
"undefined") {
|
|
7301
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7404
7302
|
/* 未存在 */
|
|
7405
7303
|
return;
|
|
7406
7304
|
}
|
|
@@ -7411,8 +7309,7 @@ var Utils = (function () {
|
|
|
7411
7309
|
* 恢复单个
|
|
7412
7310
|
*/
|
|
7413
7311
|
function recoveryOne() {
|
|
7414
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7415
|
-
"undefined") {
|
|
7312
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7416
7313
|
/* 未存在 */
|
|
7417
7314
|
return;
|
|
7418
7315
|
}
|
|
@@ -7420,8 +7317,7 @@ var Utils = (function () {
|
|
|
7420
7317
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7421
7318
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7422
7319
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7423
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7424
|
-
.length === 0) {
|
|
7320
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7425
7321
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7426
7322
|
}
|
|
7427
7323
|
}
|
|
@@ -7678,8 +7574,7 @@ var Utils = (function () {
|
|
|
7678
7574
|
let copyStatus = false;
|
|
7679
7575
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7680
7576
|
console.log(requestPermissionStatus);
|
|
7681
|
-
if (this.hasClipboard() &&
|
|
7682
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7577
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7683
7578
|
try {
|
|
7684
7579
|
copyStatus = await this.copyDataByClipboard();
|
|
7685
7580
|
}
|
|
@@ -7840,11 +7735,8 @@ var Utils = (function () {
|
|
|
7840
7735
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7841
7736
|
return mouseEvent;
|
|
7842
7737
|
}
|
|
7843
|
-
let sliderElement = typeof selector === "string"
|
|
7844
|
-
|
|
7845
|
-
: selector;
|
|
7846
|
-
if (!(sliderElement instanceof Node) ||
|
|
7847
|
-
!(sliderElement instanceof Element)) {
|
|
7738
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7739
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7848
7740
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7849
7741
|
}
|
|
7850
7742
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7896,17 +7788,14 @@ var Utils = (function () {
|
|
|
7896
7788
|
}
|
|
7897
7789
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7898
7790
|
let UtilsContext = this;
|
|
7899
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7900
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7791
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7901
7792
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7902
7793
|
}
|
|
7903
7794
|
if (typeof sortByDesc !== "boolean") {
|
|
7904
7795
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7905
7796
|
}
|
|
7906
7797
|
let getObjValue = function (obj) {
|
|
7907
|
-
return typeof getPropertyValueFunc === "string"
|
|
7908
|
-
? obj[getPropertyValueFunc]
|
|
7909
|
-
: getPropertyValueFunc(obj);
|
|
7798
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7910
7799
|
};
|
|
7911
7800
|
/**
|
|
7912
7801
|
* 排序方法
|
|
@@ -7981,8 +7870,7 @@ var Utils = (function () {
|
|
|
7981
7870
|
if (Array.isArray(data)) {
|
|
7982
7871
|
data.sort(sortFunc);
|
|
7983
7872
|
}
|
|
7984
|
-
else if (data instanceof NodeList ||
|
|
7985
|
-
UtilsContext.isJQuery(data)) {
|
|
7873
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7986
7874
|
sortNodeFunc(data, getDataFunc);
|
|
7987
7875
|
result = getDataFunc();
|
|
7988
7876
|
}
|
|
@@ -8175,9 +8063,7 @@ var Utils = (function () {
|
|
|
8175
8063
|
let parent = UtilsContext.windowApi.document;
|
|
8176
8064
|
// 超时时间
|
|
8177
8065
|
let timeout = 0;
|
|
8178
|
-
if (typeof args[0] !== "string" &&
|
|
8179
|
-
!Array.isArray(args[0]) &&
|
|
8180
|
-
typeof args[0] !== "function") {
|
|
8066
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8181
8067
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8182
8068
|
}
|
|
8183
8069
|
if (args.length === 1) ;
|
|
@@ -8187,8 +8073,7 @@ var Utils = (function () {
|
|
|
8187
8073
|
// "div",10000
|
|
8188
8074
|
timeout = secondParam;
|
|
8189
8075
|
}
|
|
8190
|
-
else if (typeof secondParam === "object" &&
|
|
8191
|
-
secondParam instanceof Node) {
|
|
8076
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8192
8077
|
// "div",document
|
|
8193
8078
|
parent = secondParam;
|
|
8194
8079
|
}
|
|
@@ -8274,8 +8159,7 @@ var Utils = (function () {
|
|
|
8274
8159
|
// "div",10000
|
|
8275
8160
|
timeout = secondParam;
|
|
8276
8161
|
}
|
|
8277
|
-
else if (typeof secondParam === "object" &&
|
|
8278
|
-
secondParam instanceof Node) {
|
|
8162
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8279
8163
|
// "div",document
|
|
8280
8164
|
parent = secondParam;
|
|
8281
8165
|
}
|
|
@@ -8330,8 +8214,7 @@ var Utils = (function () {
|
|
|
8330
8214
|
// "div",10000
|
|
8331
8215
|
timeout = secondParam;
|
|
8332
8216
|
}
|
|
8333
|
-
else if (typeof secondParam === "object" &&
|
|
8334
|
-
secondParam instanceof Node) {
|
|
8217
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8335
8218
|
// "div",document
|
|
8336
8219
|
parent = secondParam;
|
|
8337
8220
|
}
|
|
@@ -8417,8 +8300,7 @@ var Utils = (function () {
|
|
|
8417
8300
|
// "div",10000
|
|
8418
8301
|
timeout = secondParam;
|
|
8419
8302
|
}
|
|
8420
|
-
else if (typeof secondParam === "object" &&
|
|
8421
|
-
secondParam instanceof Node) {
|
|
8303
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8422
8304
|
// "div",document
|
|
8423
8305
|
parent = secondParam;
|
|
8424
8306
|
}
|
|
@@ -8551,8 +8433,7 @@ var Utils = (function () {
|
|
|
8551
8433
|
return flag;
|
|
8552
8434
|
}
|
|
8553
8435
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8554
|
-
if (typeof getCallBack !== "function" &&
|
|
8555
|
-
typeof setCallBack !== "function") {
|
|
8436
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8556
8437
|
return;
|
|
8557
8438
|
}
|
|
8558
8439
|
if (typeof getCallBack === "function") {
|
|
@@ -8604,13 +8485,27 @@ var Utils = (function () {
|
|
|
8604
8485
|
return;
|
|
8605
8486
|
}
|
|
8606
8487
|
let handleResult = handler(target);
|
|
8607
|
-
if (handleResult &&
|
|
8608
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8609
|
-
handleResult.isFind) {
|
|
8488
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8610
8489
|
return handleResult.data;
|
|
8611
8490
|
}
|
|
8612
8491
|
return this.queryProperty(handleResult.data, handler);
|
|
8613
8492
|
}
|
|
8493
|
+
/**
|
|
8494
|
+
* 异步-深度获取对象属性
|
|
8495
|
+
* @param target 待获取的对象
|
|
8496
|
+
* @param handler 获取属性的回调
|
|
8497
|
+
*/
|
|
8498
|
+
async asyncQueryProperty(target, handler) {
|
|
8499
|
+
if (target == null) {
|
|
8500
|
+
// @ts-ignore
|
|
8501
|
+
return;
|
|
8502
|
+
}
|
|
8503
|
+
let handleResult = await handler(target);
|
|
8504
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8505
|
+
return handleResult.data;
|
|
8506
|
+
}
|
|
8507
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8508
|
+
}
|
|
8614
8509
|
/**
|
|
8615
8510
|
* 创建一个新的Utils实例
|
|
8616
8511
|
* @param option
|