@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.esm.js
CHANGED
|
@@ -65,11 +65,7 @@ class ColorConversion {
|
|
|
65
65
|
!validPattern.test(greenValue.toString()) ||
|
|
66
66
|
!validPattern.test(blueValue.toString()))
|
|
67
67
|
throw new TypeError("输入错误的rgb颜色值");
|
|
68
|
-
let hexs = [
|
|
69
|
-
redValue.toString(16),
|
|
70
|
-
greenValue.toString(16),
|
|
71
|
-
blueValue.toString(16),
|
|
72
|
-
];
|
|
68
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
73
69
|
for (let index = 0; index < 3; index++)
|
|
74
70
|
if (hexs[index].length == 1)
|
|
75
71
|
hexs[index] = "0" + hexs[index];
|
|
@@ -117,10 +113,7 @@ class GBKEncoder {
|
|
|
117
113
|
this.#data = dataText.match(/..../g);
|
|
118
114
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
119
115
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
120
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
121
|
-
i.toString(16) +
|
|
122
|
-
"%" +
|
|
123
|
-
j.toString(16)).toUpperCase();
|
|
116
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
124
117
|
}
|
|
125
118
|
}
|
|
126
119
|
for (let key in this.#U2Ghash) {
|
|
@@ -248,9 +241,7 @@ const TryCatch = function (...args) {
|
|
|
248
241
|
callbackFunction = callback;
|
|
249
242
|
context = __context__ || this;
|
|
250
243
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
251
|
-
return result !== void 0
|
|
252
|
-
? result
|
|
253
|
-
: TryCatchCore;
|
|
244
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
254
245
|
},
|
|
255
246
|
};
|
|
256
247
|
/**
|
|
@@ -279,10 +270,7 @@ const TryCatch = function (...args) {
|
|
|
279
270
|
}
|
|
280
271
|
if (handleErrorFunc) {
|
|
281
272
|
if (typeof handleErrorFunc === "string") {
|
|
282
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
283
|
-
...args,
|
|
284
|
-
error,
|
|
285
|
-
]);
|
|
273
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
286
274
|
}
|
|
287
275
|
else {
|
|
288
276
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -370,10 +358,7 @@ class CommonUtil {
|
|
|
370
358
|
itemResult = objItem === 0;
|
|
371
359
|
break;
|
|
372
360
|
case "string":
|
|
373
|
-
itemResult =
|
|
374
|
-
objItem.trim() === "" ||
|
|
375
|
-
objItem === "null" ||
|
|
376
|
-
objItem === "undefined";
|
|
361
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
377
362
|
break;
|
|
378
363
|
case "boolean":
|
|
379
364
|
itemResult = !objItem;
|
|
@@ -414,8 +399,7 @@ class CommonUtil {
|
|
|
414
399
|
return null;
|
|
415
400
|
let clone = obj instanceof Array ? [] : {};
|
|
416
401
|
for (const [key, value] of Object.entries(obj)) {
|
|
417
|
-
clone[key] =
|
|
418
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
402
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
419
403
|
}
|
|
420
404
|
return clone;
|
|
421
405
|
}
|
|
@@ -1954,14 +1938,10 @@ class GMMenu {
|
|
|
1954
1938
|
// };
|
|
1955
1939
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1956
1940
|
menuOption.autoReload =
|
|
1957
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1958
|
-
? this.$default.autoReload
|
|
1959
|
-
: menuOption.autoReload;
|
|
1941
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1960
1942
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1961
1943
|
menuOption.isStoreValue =
|
|
1962
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1963
|
-
? this.$default.isStoreValue
|
|
1964
|
-
: menuOption.isStoreValue;
|
|
1944
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1965
1945
|
/**
|
|
1966
1946
|
* 用户点击菜单后的回调函数
|
|
1967
1947
|
* @param event
|
|
@@ -2014,8 +1994,7 @@ class GMMenu {
|
|
|
2014
1994
|
* @param menuKey 菜单-键key
|
|
2015
1995
|
*/
|
|
2016
1996
|
getMenuHandledOption(menuKey) {
|
|
2017
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2018
|
-
?.handleData;
|
|
1997
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2019
1998
|
},
|
|
2020
1999
|
};
|
|
2021
2000
|
constructor(details) {
|
|
@@ -2023,8 +2002,7 @@ class GMMenu {
|
|
|
2023
2002
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2024
2003
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2025
2004
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2026
|
-
this.MenuHandle.$default.autoReload =
|
|
2027
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2005
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2028
2006
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2029
2007
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2030
2008
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2256,8 +2234,7 @@ class Hooks {
|
|
|
2256
2234
|
_context = context || window;
|
|
2257
2235
|
_funcName = getFuncName(this);
|
|
2258
2236
|
_context["realFunc_" + _funcName] = this;
|
|
2259
|
-
if (_context[_funcName].prototype &&
|
|
2260
|
-
_context[_funcName].prototype.isHooked) {
|
|
2237
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2261
2238
|
console.log("Already has been hooked,unhook first");
|
|
2262
2239
|
return false;
|
|
2263
2240
|
}
|
|
@@ -2435,8 +2412,7 @@ class Httpx {
|
|
|
2435
2412
|
if (details.allowInterceptConfig != null) {
|
|
2436
2413
|
// 配置存在
|
|
2437
2414
|
// 细分处理是否拦截
|
|
2438
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2439
|
-
"boolean" &&
|
|
2415
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2440
2416
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2441
2417
|
// 设置了禁止拦截
|
|
2442
2418
|
return details;
|
|
@@ -2471,8 +2447,7 @@ class Httpx {
|
|
|
2471
2447
|
if (data.details.allowInterceptConfig != null) {
|
|
2472
2448
|
// 配置存在
|
|
2473
2449
|
// 细分处理是否拦截
|
|
2474
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2475
|
-
"boolean" &&
|
|
2450
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2476
2451
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2477
2452
|
// 设置了禁止拦截
|
|
2478
2453
|
return data;
|
|
@@ -2574,44 +2549,31 @@ class Httpx {
|
|
|
2574
2549
|
let requestOption = {
|
|
2575
2550
|
url: url,
|
|
2576
2551
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2577
|
-
timeout: userRequestOption.timeout ||
|
|
2578
|
-
|
|
2579
|
-
responseType: userRequestOption.responseType ||
|
|
2580
|
-
this.context.#defaultRequestOption.responseType,
|
|
2552
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2553
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2581
2554
|
/* 对象使用深拷贝 */
|
|
2582
2555
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2583
2556
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2584
|
-
redirect: userRequestOption.redirect ||
|
|
2585
|
-
this.context.#defaultRequestOption.redirect,
|
|
2557
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2586
2558
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2587
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2588
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2559
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2589
2560
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2590
|
-
nocache: userRequestOption.nocache ||
|
|
2591
|
-
|
|
2592
|
-
revalidate: userRequestOption.revalidate ||
|
|
2593
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2561
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2562
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2594
2563
|
/* 对象使用深拷贝 */
|
|
2595
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2599
|
-
anonymous: userRequestOption.anonymous ||
|
|
2600
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2564
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2565
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2566
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2601
2567
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2602
2568
|
/* 对象使用深拷贝 */
|
|
2603
2569
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2604
2570
|
allowInterceptConfig: {
|
|
2605
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2609
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2610
|
-
.allowInterceptConfig.afterResponseError,
|
|
2571
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2572
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2573
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2611
2574
|
},
|
|
2612
2575
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2613
|
-
password: userRequestOption.password ||
|
|
2614
|
-
this.context.#defaultRequestOption.password,
|
|
2576
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2615
2577
|
onabort(...args) {
|
|
2616
2578
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2617
2579
|
},
|
|
@@ -2659,14 +2621,12 @@ class Httpx {
|
|
|
2659
2621
|
if (typeof requestOption.headers === "object") {
|
|
2660
2622
|
if (typeof userRequestOption.headers === "object") {
|
|
2661
2623
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2662
|
-
if (keyName in requestOption.headers &&
|
|
2663
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2624
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2664
2625
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2665
2626
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2666
2627
|
}
|
|
2667
2628
|
else {
|
|
2668
|
-
requestOption.headers[keyName] =
|
|
2669
|
-
userRequestOption?.headers?.[keyName];
|
|
2629
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2670
2630
|
}
|
|
2671
2631
|
});
|
|
2672
2632
|
}
|
|
@@ -2679,8 +2639,7 @@ class Httpx {
|
|
|
2679
2639
|
/* 使用assign替换且添加 */
|
|
2680
2640
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2681
2641
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2682
|
-
if (keyName in requestOption.fetchInit &&
|
|
2683
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2642
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2684
2643
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2685
2644
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2686
2645
|
}
|
|
@@ -2694,8 +2653,7 @@ class Httpx {
|
|
|
2694
2653
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2695
2654
|
}
|
|
2696
2655
|
// 处理新的cookiePartition
|
|
2697
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2698
|
-
requestOption.cookiePartition != null) {
|
|
2656
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2699
2657
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2700
2658
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2701
2659
|
// topLevelSite必须是字符串
|
|
@@ -2717,8 +2675,7 @@ class Httpx {
|
|
|
2717
2675
|
}
|
|
2718
2676
|
else {
|
|
2719
2677
|
// 补充origin+/
|
|
2720
|
-
requestOption.url =
|
|
2721
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2678
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2722
2679
|
}
|
|
2723
2680
|
}
|
|
2724
2681
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2842,8 +2799,7 @@ class Httpx {
|
|
|
2842
2799
|
* fetch的请求配置
|
|
2843
2800
|
**/
|
|
2844
2801
|
let fetchRequestOption = {};
|
|
2845
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2846
|
-
option.data != null) {
|
|
2802
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2847
2803
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2848
2804
|
Reflect.deleteProperty(option, "data");
|
|
2849
2805
|
}
|
|
@@ -3124,8 +3080,7 @@ class Httpx {
|
|
|
3124
3080
|
if (typeof details?.onreadystatechange === "function") {
|
|
3125
3081
|
details.onreadystatechange.apply(this, argsResult);
|
|
3126
3082
|
}
|
|
3127
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3128
|
-
"function") {
|
|
3083
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3129
3084
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3130
3085
|
}
|
|
3131
3086
|
},
|
|
@@ -3154,8 +3109,7 @@ class Httpx {
|
|
|
3154
3109
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3155
3110
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3156
3111
|
}
|
|
3157
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3158
|
-
"function") {
|
|
3112
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3159
3113
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3160
3114
|
if (hookResult == null) {
|
|
3161
3115
|
return;
|
|
@@ -3211,9 +3165,7 @@ class Httpx {
|
|
|
3211
3165
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3212
3166
|
if (option.responseType === "stream" ||
|
|
3213
3167
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3214
|
-
fetchResponse.headers
|
|
3215
|
-
.get("Content-Type")
|
|
3216
|
-
.includes("text/event-stream"))) {
|
|
3168
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3217
3169
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3218
3170
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3219
3171
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3232,9 +3184,7 @@ class Httpx {
|
|
|
3232
3184
|
/** 数据编码 */
|
|
3233
3185
|
let encoding = "utf-8";
|
|
3234
3186
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3235
|
-
let charsetMatched = fetchResponse.headers
|
|
3236
|
-
.get("Content-Type")
|
|
3237
|
-
?.match(/charset=(.+)/);
|
|
3187
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3238
3188
|
if (charsetMatched) {
|
|
3239
3189
|
encoding = charsetMatched[1];
|
|
3240
3190
|
encoding = encoding.toLowerCase();
|
|
@@ -3256,13 +3206,11 @@ class Httpx {
|
|
|
3256
3206
|
response = new Blob([arrayBuffer]);
|
|
3257
3207
|
}
|
|
3258
3208
|
else if (option.responseType === "json" ||
|
|
3259
|
-
(typeof fetchResponseType === "string" &&
|
|
3260
|
-
fetchResponseType.includes("application/json"))) {
|
|
3209
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3261
3210
|
// response返回格式是JSON格式
|
|
3262
3211
|
response = commonUtil.toJSON(responseText);
|
|
3263
3212
|
}
|
|
3264
|
-
else if (option.responseType === "document" ||
|
|
3265
|
-
option.responseType == null) {
|
|
3213
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3266
3214
|
// response返回格式是文档格式
|
|
3267
3215
|
let parser = new DOMParser();
|
|
3268
3216
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3525,8 +3473,7 @@ class Httpx {
|
|
|
3525
3473
|
}
|
|
3526
3474
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3527
3475
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3528
|
-
if (requestResult != null &&
|
|
3529
|
-
typeof requestResult.abort === "function") {
|
|
3476
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3530
3477
|
abortFn = requestResult.abort;
|
|
3531
3478
|
}
|
|
3532
3479
|
});
|
|
@@ -4017,8 +3964,7 @@ class Log {
|
|
|
4017
3964
|
if (typeof __GM_info === "string") {
|
|
4018
3965
|
this.tag = __GM_info;
|
|
4019
3966
|
}
|
|
4020
|
-
else if (typeof __GM_info === "object" &&
|
|
4021
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3967
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4022
3968
|
this.tag = __GM_info.script.name;
|
|
4023
3969
|
}
|
|
4024
3970
|
this.#console = console;
|
|
@@ -4074,8 +4020,7 @@ class Log {
|
|
|
4074
4020
|
*/
|
|
4075
4021
|
checkClearConsole() {
|
|
4076
4022
|
this.#logCount++;
|
|
4077
|
-
if (this.#details.autoClearConsole &&
|
|
4078
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
4023
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4079
4024
|
this.#console.clear();
|
|
4080
4025
|
this.#logCount = 0;
|
|
4081
4026
|
}
|
|
@@ -5578,7 +5523,7 @@ class Utils {
|
|
|
5578
5523
|
this.windowApi = new WindowApi(option);
|
|
5579
5524
|
}
|
|
5580
5525
|
/** 版本号 */
|
|
5581
|
-
version = "2025.
|
|
5526
|
+
version = "2025.8.11";
|
|
5582
5527
|
addStyle(cssText) {
|
|
5583
5528
|
if (typeof cssText !== "string") {
|
|
5584
5529
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5701,13 +5646,9 @@ class Utils {
|
|
|
5701
5646
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5702
5647
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5703
5648
|
// 点击的x坐标
|
|
5704
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5705
|
-
? clickEvent.clientX
|
|
5706
|
-
: touchEvent.touches[0].clientX;
|
|
5649
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5707
5650
|
// 点击的y坐标
|
|
5708
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5709
|
-
? clickEvent.clientY
|
|
5710
|
-
: touchEvent.touches[0].clientY;
|
|
5651
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5711
5652
|
let {
|
|
5712
5653
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5713
5654
|
left: elementPosXLeft,
|
|
@@ -5870,9 +5811,7 @@ class Utils {
|
|
|
5870
5811
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5871
5812
|
let windowFind = this.windowApi.self.find;
|
|
5872
5813
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5873
|
-
if (strFound &&
|
|
5874
|
-
this.windowApi.self.getSelection &&
|
|
5875
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5814
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5876
5815
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5877
5816
|
}
|
|
5878
5817
|
if (!strFound) {
|
|
@@ -5975,9 +5914,7 @@ class Utils {
|
|
|
5975
5914
|
}
|
|
5976
5915
|
}
|
|
5977
5916
|
result = result.toFixed(2);
|
|
5978
|
-
result = addType
|
|
5979
|
-
? result + resultType.toString()
|
|
5980
|
-
: parseFloat(result.toString());
|
|
5917
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5981
5918
|
return result;
|
|
5982
5919
|
}
|
|
5983
5920
|
getNodeListValue(...args) {
|
|
@@ -6056,14 +5993,7 @@ class Utils {
|
|
|
6056
5993
|
if (text.length === 8) {
|
|
6057
5994
|
/* 该字符串只有时分秒 */
|
|
6058
5995
|
let today = new Date();
|
|
6059
|
-
text =
|
|
6060
|
-
today.getFullYear() +
|
|
6061
|
-
"-" +
|
|
6062
|
-
(today.getMonth() + 1) +
|
|
6063
|
-
"-" +
|
|
6064
|
-
today.getDate() +
|
|
6065
|
-
" " +
|
|
6066
|
-
text;
|
|
5996
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6067
5997
|
}
|
|
6068
5998
|
text = text.substring(0, 19);
|
|
6069
5999
|
text = text.replace(/-/g, "/");
|
|
@@ -6084,25 +6014,13 @@ class Utils {
|
|
|
6084
6014
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6085
6015
|
*/
|
|
6086
6016
|
getTransitionEndNameList() {
|
|
6087
|
-
return [
|
|
6088
|
-
"webkitTransitionEnd",
|
|
6089
|
-
"mozTransitionEnd",
|
|
6090
|
-
"MSTransitionEnd",
|
|
6091
|
-
"otransitionend",
|
|
6092
|
-
"transitionend",
|
|
6093
|
-
];
|
|
6017
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6094
6018
|
}
|
|
6095
6019
|
/**
|
|
6096
6020
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6097
6021
|
*/
|
|
6098
6022
|
getAnimationEndNameList() {
|
|
6099
|
-
return [
|
|
6100
|
-
"webkitAnimationEnd",
|
|
6101
|
-
"mozAnimationEnd",
|
|
6102
|
-
"MSAnimationEnd",
|
|
6103
|
-
"oanimationend",
|
|
6104
|
-
"animationend",
|
|
6105
|
-
];
|
|
6023
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6106
6024
|
}
|
|
6107
6025
|
getArrayLastValue(targetObj) {
|
|
6108
6026
|
return targetObj[targetObj.length - 1];
|
|
@@ -6206,10 +6124,8 @@ class Utils {
|
|
|
6206
6124
|
}
|
|
6207
6125
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6208
6126
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6209
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6210
|
-
|
|
6211
|
-
selector +=
|
|
6212
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6127
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6128
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6213
6129
|
}
|
|
6214
6130
|
else {
|
|
6215
6131
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6229,9 +6145,7 @@ class Utils {
|
|
|
6229
6145
|
return void 0;
|
|
6230
6146
|
}
|
|
6231
6147
|
if (result.length > 1) {
|
|
6232
|
-
if (result.length === 2 &&
|
|
6233
|
-
typeof result[0] === "object" &&
|
|
6234
|
-
typeof result[1] === "function") {
|
|
6148
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6235
6149
|
let data = result[0];
|
|
6236
6150
|
let handleDataFunc = result[1];
|
|
6237
6151
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6329,9 +6243,7 @@ class Utils {
|
|
|
6329
6243
|
return void 0;
|
|
6330
6244
|
}
|
|
6331
6245
|
if (result.length > 1) {
|
|
6332
|
-
if (result.length === 2 &&
|
|
6333
|
-
typeof result[0] === "object" &&
|
|
6334
|
-
typeof result[1] === "function") {
|
|
6246
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6335
6247
|
let data = result[0];
|
|
6336
6248
|
let handleDataFunc = result[1];
|
|
6337
6249
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6421,12 +6333,10 @@ class Utils {
|
|
|
6421
6333
|
getRandomValue(...args) {
|
|
6422
6334
|
let result = [...args];
|
|
6423
6335
|
if (result.length > 1) {
|
|
6424
|
-
if (result.length === 2 &&
|
|
6425
|
-
typeof result[0] === "number" &&
|
|
6426
|
-
typeof result[1] === "number") {
|
|
6336
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6427
6337
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6428
6338
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6429
|
-
return
|
|
6339
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6430
6340
|
}
|
|
6431
6341
|
else {
|
|
6432
6342
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6437,8 +6347,7 @@ class Utils {
|
|
|
6437
6347
|
if (Array.isArray(paramData)) {
|
|
6438
6348
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6439
6349
|
}
|
|
6440
|
-
else if (typeof paramData === "object" &&
|
|
6441
|
-
Object.keys(paramData).length > 0) {
|
|
6350
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6442
6351
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6443
6352
|
return paramData[paramObjDataKey];
|
|
6444
6353
|
}
|
|
@@ -6745,11 +6654,9 @@ class Utils {
|
|
|
6745
6654
|
let nearBottomHeight = 50;
|
|
6746
6655
|
let checkWindow = () => {
|
|
6747
6656
|
// 已滚动的距离
|
|
6748
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6749
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6657
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6750
6658
|
// 视窗高度
|
|
6751
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6752
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6659
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6753
6660
|
// 最大滚动距离
|
|
6754
6661
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6755
6662
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7038,8 +6945,7 @@ class Utils {
|
|
|
7038
6945
|
**/
|
|
7039
6946
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7040
6947
|
isThemeDark() {
|
|
7041
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7042
|
-
.matches;
|
|
6948
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7043
6949
|
}
|
|
7044
6950
|
/**
|
|
7045
6951
|
* 判断元素是否在页面中可见
|
|
@@ -7072,10 +6978,8 @@ class Utils {
|
|
|
7072
6978
|
else {
|
|
7073
6979
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7074
6980
|
if (inView) {
|
|
7075
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7076
|
-
|
|
7077
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7078
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6981
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6982
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7079
6983
|
result = !(domClientRect.right < 0 ||
|
|
7080
6984
|
domClientRect.left > viewportWidth ||
|
|
7081
6985
|
domClientRect.bottom < 0 ||
|
|
@@ -7099,8 +7003,7 @@ class Utils {
|
|
|
7099
7003
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7100
7004
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7101
7005
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7102
|
-
if (typeof objValueFunc === "function" &&
|
|
7103
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7006
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7104
7007
|
result = true;
|
|
7105
7008
|
}
|
|
7106
7009
|
else {
|
|
@@ -7122,8 +7025,7 @@ class Utils {
|
|
|
7122
7025
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7123
7026
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7124
7027
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7125
|
-
if (typeof objValueFunc === "function" &&
|
|
7126
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7028
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7127
7029
|
result = true;
|
|
7128
7030
|
}
|
|
7129
7031
|
else {
|
|
@@ -7360,13 +7262,11 @@ class Utils {
|
|
|
7360
7262
|
* 释放所有
|
|
7361
7263
|
*/
|
|
7362
7264
|
function releaseAll() {
|
|
7363
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7364
|
-
"undefined") {
|
|
7265
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7365
7266
|
/* 已存在 */
|
|
7366
7267
|
return;
|
|
7367
7268
|
}
|
|
7368
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7369
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7269
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7370
7270
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7371
7271
|
if (typeof value === "function") {
|
|
7372
7272
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7380,8 +7280,7 @@ class Utils {
|
|
|
7380
7280
|
Array.from(functionNameList).forEach((item) => {
|
|
7381
7281
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7382
7282
|
if (typeof value === "function") {
|
|
7383
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7384
|
-
"undefined") {
|
|
7283
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7385
7284
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7386
7285
|
}
|
|
7387
7286
|
if (item === value.name) {
|
|
@@ -7396,8 +7295,7 @@ class Utils {
|
|
|
7396
7295
|
* 恢复所有
|
|
7397
7296
|
*/
|
|
7398
7297
|
function recoveryAll() {
|
|
7399
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7400
|
-
"undefined") {
|
|
7298
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7401
7299
|
/* 未存在 */
|
|
7402
7300
|
return;
|
|
7403
7301
|
}
|
|
@@ -7408,8 +7306,7 @@ class Utils {
|
|
|
7408
7306
|
* 恢复单个
|
|
7409
7307
|
*/
|
|
7410
7308
|
function recoveryOne() {
|
|
7411
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7412
|
-
"undefined") {
|
|
7309
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7413
7310
|
/* 未存在 */
|
|
7414
7311
|
return;
|
|
7415
7312
|
}
|
|
@@ -7417,8 +7314,7 @@ class Utils {
|
|
|
7417
7314
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7418
7315
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7419
7316
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7420
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7421
|
-
.length === 0) {
|
|
7317
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7422
7318
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7423
7319
|
}
|
|
7424
7320
|
}
|
|
@@ -7675,8 +7571,7 @@ class Utils {
|
|
|
7675
7571
|
let copyStatus = false;
|
|
7676
7572
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7677
7573
|
console.log(requestPermissionStatus);
|
|
7678
|
-
if (this.hasClipboard() &&
|
|
7679
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7574
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7680
7575
|
try {
|
|
7681
7576
|
copyStatus = await this.copyDataByClipboard();
|
|
7682
7577
|
}
|
|
@@ -7837,11 +7732,8 @@ class Utils {
|
|
|
7837
7732
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7838
7733
|
return mouseEvent;
|
|
7839
7734
|
}
|
|
7840
|
-
let sliderElement = typeof selector === "string"
|
|
7841
|
-
|
|
7842
|
-
: selector;
|
|
7843
|
-
if (!(sliderElement instanceof Node) ||
|
|
7844
|
-
!(sliderElement instanceof Element)) {
|
|
7735
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7736
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7845
7737
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7846
7738
|
}
|
|
7847
7739
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7893,17 +7785,14 @@ class Utils {
|
|
|
7893
7785
|
}
|
|
7894
7786
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7895
7787
|
let UtilsContext = this;
|
|
7896
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7897
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7788
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7898
7789
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7899
7790
|
}
|
|
7900
7791
|
if (typeof sortByDesc !== "boolean") {
|
|
7901
7792
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7902
7793
|
}
|
|
7903
7794
|
let getObjValue = function (obj) {
|
|
7904
|
-
return typeof getPropertyValueFunc === "string"
|
|
7905
|
-
? obj[getPropertyValueFunc]
|
|
7906
|
-
: getPropertyValueFunc(obj);
|
|
7795
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7907
7796
|
};
|
|
7908
7797
|
/**
|
|
7909
7798
|
* 排序方法
|
|
@@ -7978,8 +7867,7 @@ class Utils {
|
|
|
7978
7867
|
if (Array.isArray(data)) {
|
|
7979
7868
|
data.sort(sortFunc);
|
|
7980
7869
|
}
|
|
7981
|
-
else if (data instanceof NodeList ||
|
|
7982
|
-
UtilsContext.isJQuery(data)) {
|
|
7870
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7983
7871
|
sortNodeFunc(data, getDataFunc);
|
|
7984
7872
|
result = getDataFunc();
|
|
7985
7873
|
}
|
|
@@ -8172,9 +8060,7 @@ class Utils {
|
|
|
8172
8060
|
let parent = UtilsContext.windowApi.document;
|
|
8173
8061
|
// 超时时间
|
|
8174
8062
|
let timeout = 0;
|
|
8175
|
-
if (typeof args[0] !== "string" &&
|
|
8176
|
-
!Array.isArray(args[0]) &&
|
|
8177
|
-
typeof args[0] !== "function") {
|
|
8063
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8178
8064
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8179
8065
|
}
|
|
8180
8066
|
if (args.length === 1) ;
|
|
@@ -8184,8 +8070,7 @@ class Utils {
|
|
|
8184
8070
|
// "div",10000
|
|
8185
8071
|
timeout = secondParam;
|
|
8186
8072
|
}
|
|
8187
|
-
else if (typeof secondParam === "object" &&
|
|
8188
|
-
secondParam instanceof Node) {
|
|
8073
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8189
8074
|
// "div",document
|
|
8190
8075
|
parent = secondParam;
|
|
8191
8076
|
}
|
|
@@ -8271,8 +8156,7 @@ class Utils {
|
|
|
8271
8156
|
// "div",10000
|
|
8272
8157
|
timeout = secondParam;
|
|
8273
8158
|
}
|
|
8274
|
-
else if (typeof secondParam === "object" &&
|
|
8275
|
-
secondParam instanceof Node) {
|
|
8159
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8276
8160
|
// "div",document
|
|
8277
8161
|
parent = secondParam;
|
|
8278
8162
|
}
|
|
@@ -8327,8 +8211,7 @@ class Utils {
|
|
|
8327
8211
|
// "div",10000
|
|
8328
8212
|
timeout = secondParam;
|
|
8329
8213
|
}
|
|
8330
|
-
else if (typeof secondParam === "object" &&
|
|
8331
|
-
secondParam instanceof Node) {
|
|
8214
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8332
8215
|
// "div",document
|
|
8333
8216
|
parent = secondParam;
|
|
8334
8217
|
}
|
|
@@ -8414,8 +8297,7 @@ class Utils {
|
|
|
8414
8297
|
// "div",10000
|
|
8415
8298
|
timeout = secondParam;
|
|
8416
8299
|
}
|
|
8417
|
-
else if (typeof secondParam === "object" &&
|
|
8418
|
-
secondParam instanceof Node) {
|
|
8300
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8419
8301
|
// "div",document
|
|
8420
8302
|
parent = secondParam;
|
|
8421
8303
|
}
|
|
@@ -8548,8 +8430,7 @@ class Utils {
|
|
|
8548
8430
|
return flag;
|
|
8549
8431
|
}
|
|
8550
8432
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8551
|
-
if (typeof getCallBack !== "function" &&
|
|
8552
|
-
typeof setCallBack !== "function") {
|
|
8433
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8553
8434
|
return;
|
|
8554
8435
|
}
|
|
8555
8436
|
if (typeof getCallBack === "function") {
|
|
@@ -8601,13 +8482,27 @@ class Utils {
|
|
|
8601
8482
|
return;
|
|
8602
8483
|
}
|
|
8603
8484
|
let handleResult = handler(target);
|
|
8604
|
-
if (handleResult &&
|
|
8605
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8606
|
-
handleResult.isFind) {
|
|
8485
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8607
8486
|
return handleResult.data;
|
|
8608
8487
|
}
|
|
8609
8488
|
return this.queryProperty(handleResult.data, handler);
|
|
8610
8489
|
}
|
|
8490
|
+
/**
|
|
8491
|
+
* 异步-深度获取对象属性
|
|
8492
|
+
* @param target 待获取的对象
|
|
8493
|
+
* @param handler 获取属性的回调
|
|
8494
|
+
*/
|
|
8495
|
+
async asyncQueryProperty(target, handler) {
|
|
8496
|
+
if (target == null) {
|
|
8497
|
+
// @ts-ignore
|
|
8498
|
+
return;
|
|
8499
|
+
}
|
|
8500
|
+
let handleResult = await handler(target);
|
|
8501
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8502
|
+
return handleResult.data;
|
|
8503
|
+
}
|
|
8504
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8505
|
+
}
|
|
8611
8506
|
/**
|
|
8612
8507
|
* 创建一个新的Utils实例
|
|
8613
8508
|
* @param option
|