@whitesev/utils 2.7.2 → 2.7.4
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 +197 -350
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +197 -350
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +197 -350
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +197 -350
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +197 -350
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +197 -350
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +30 -2
- package/dist/types/src/WindowApi.d.ts +4 -0
- 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/WindowApi.d.ts +4 -0
- 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 +213 -559
- 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/WindowApi.ts +16 -0
- package/src/ajaxHooker/ajaxHooker.js +78 -142
- 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/WindowApi.d.ts +4 -0
- package/src/types/ajaxHooker.d.ts +1 -5
package/dist/index.umd.js
CHANGED
|
@@ -71,11 +71,7 @@
|
|
|
71
71
|
!validPattern.test(greenValue.toString()) ||
|
|
72
72
|
!validPattern.test(blueValue.toString()))
|
|
73
73
|
throw new TypeError("输入错误的rgb颜色值");
|
|
74
|
-
let hexs = [
|
|
75
|
-
redValue.toString(16),
|
|
76
|
-
greenValue.toString(16),
|
|
77
|
-
blueValue.toString(16),
|
|
78
|
-
];
|
|
74
|
+
let hexs = [redValue.toString(16), greenValue.toString(16), blueValue.toString(16)];
|
|
79
75
|
for (let index = 0; index < 3; index++)
|
|
80
76
|
if (hexs[index].length == 1)
|
|
81
77
|
hexs[index] = "0" + hexs[index];
|
|
@@ -123,10 +119,7 @@
|
|
|
123
119
|
this.#data = dataText.match(/..../g);
|
|
124
120
|
for (let i = 0x81; i <= 0xfe; i++) {
|
|
125
121
|
for (let j = 0x40; j <= 0xfe; j++) {
|
|
126
|
-
this.#U2Ghash[this.#data[index++]] = ("%" +
|
|
127
|
-
i.toString(16) +
|
|
128
|
-
"%" +
|
|
129
|
-
j.toString(16)).toUpperCase();
|
|
122
|
+
this.#U2Ghash[this.#data[index++]] = ("%" + i.toString(16) + "%" + j.toString(16)).toUpperCase();
|
|
130
123
|
}
|
|
131
124
|
}
|
|
132
125
|
for (let key in this.#U2Ghash) {
|
|
@@ -254,9 +247,7 @@
|
|
|
254
247
|
callbackFunction = callback;
|
|
255
248
|
context = __context__ || this;
|
|
256
249
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
257
|
-
return result !== void 0
|
|
258
|
-
? result
|
|
259
|
-
: TryCatchCore;
|
|
250
|
+
return result !== void 0 ? result : TryCatchCore;
|
|
260
251
|
},
|
|
261
252
|
};
|
|
262
253
|
/**
|
|
@@ -285,10 +276,7 @@
|
|
|
285
276
|
}
|
|
286
277
|
if (handleErrorFunc) {
|
|
287
278
|
if (typeof handleErrorFunc === "string") {
|
|
288
|
-
result = new Function(handleErrorFunc).apply(funcThis, [
|
|
289
|
-
...args,
|
|
290
|
-
error,
|
|
291
|
-
]);
|
|
279
|
+
result = new Function(handleErrorFunc).apply(funcThis, [...args, error]);
|
|
292
280
|
}
|
|
293
281
|
else {
|
|
294
282
|
result = handleErrorFunc.apply(funcThis, [...args, error]);
|
|
@@ -376,10 +364,7 @@
|
|
|
376
364
|
itemResult = objItem === 0;
|
|
377
365
|
break;
|
|
378
366
|
case "string":
|
|
379
|
-
itemResult =
|
|
380
|
-
objItem.trim() === "" ||
|
|
381
|
-
objItem === "null" ||
|
|
382
|
-
objItem === "undefined";
|
|
367
|
+
itemResult = objItem.trim() === "" || objItem === "null" || objItem === "undefined";
|
|
383
368
|
break;
|
|
384
369
|
case "boolean":
|
|
385
370
|
itemResult = !objItem;
|
|
@@ -420,8 +405,7 @@
|
|
|
420
405
|
return null;
|
|
421
406
|
let clone = obj instanceof Array ? [] : {};
|
|
422
407
|
for (const [key, value] of Object.entries(obj)) {
|
|
423
|
-
clone[key] =
|
|
424
|
-
typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
408
|
+
clone[key] = typeof value === "object" ? UtilsContext.deepClone(value) : value;
|
|
425
409
|
}
|
|
426
410
|
return clone;
|
|
427
411
|
}
|
|
@@ -739,13 +723,13 @@
|
|
|
739
723
|
// ==UserScript==
|
|
740
724
|
// @name ajaxHooker
|
|
741
725
|
// @author cxxjackie
|
|
742
|
-
// @version 1.4.
|
|
726
|
+
// @version 1.4.8
|
|
743
727
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
744
728
|
// @license GNU LGPL-3.0
|
|
745
729
|
// ==/UserScript==
|
|
746
730
|
|
|
747
731
|
const ajaxHooker = function () {
|
|
748
|
-
const version = "1.4.
|
|
732
|
+
const version = "1.4.8";
|
|
749
733
|
const hookInst = {
|
|
750
734
|
hookFns: [],
|
|
751
735
|
filters: [],
|
|
@@ -774,11 +758,7 @@
|
|
|
774
758
|
const emptyFn = () => {};
|
|
775
759
|
const errorFn = (e) => console.error(e);
|
|
776
760
|
function isThenable(obj) {
|
|
777
|
-
return (
|
|
778
|
-
obj &&
|
|
779
|
-
["object", "function"].includes(typeof obj) &&
|
|
780
|
-
typeof obj.then === "function"
|
|
781
|
-
);
|
|
761
|
+
return obj && ["object", "function"].includes(typeof obj) && typeof obj.then === "function";
|
|
782
762
|
}
|
|
783
763
|
function catchError(fn, ...args) {
|
|
784
764
|
try {
|
|
@@ -816,8 +796,7 @@
|
|
|
816
796
|
const [header, value] = line.split(/(?<=^[^:]+)\s*:\s*/);
|
|
817
797
|
if (!value) continue;
|
|
818
798
|
const lheader = header.toLowerCase();
|
|
819
|
-
headers[lheader] =
|
|
820
|
-
lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
799
|
+
headers[lheader] = lheader in headers ? `${headers[lheader]}, ${value}` : value;
|
|
821
800
|
}
|
|
822
801
|
break;
|
|
823
802
|
case "[object Headers]":
|
|
@@ -855,11 +834,9 @@
|
|
|
855
834
|
!filters.find((obj) => {
|
|
856
835
|
switch (true) {
|
|
857
836
|
case obj.type && obj.type !== type:
|
|
858
|
-
case getType(obj.url) === "[object String]" &&
|
|
859
|
-
!url.includes(obj.url):
|
|
837
|
+
case getType(obj.url) === "[object String]" && !url.includes(obj.url):
|
|
860
838
|
case getType(obj.url) === "[object RegExp]" && !obj.url.test(url):
|
|
861
|
-
case obj.method &&
|
|
862
|
-
obj.method.toUpperCase() !== method.toUpperCase():
|
|
839
|
+
case obj.method && obj.method.toUpperCase() !== method.toUpperCase():
|
|
863
840
|
case "async" in obj && obj.async !== async:
|
|
864
841
|
return false;
|
|
865
842
|
}
|
|
@@ -872,8 +849,7 @@
|
|
|
872
849
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
873
850
|
if (this.shouldFilter(filters)) return;
|
|
874
851
|
hookFns.forEach((fn) => {
|
|
875
|
-
if (getType(fn) === "[object Function]")
|
|
876
|
-
catchError(fn, this.request);
|
|
852
|
+
if (getType(fn) === "[object Function]") catchError(fn, this.request);
|
|
877
853
|
});
|
|
878
854
|
for (const key in this.request) {
|
|
879
855
|
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
@@ -886,93 +862,72 @@
|
|
|
886
862
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
887
863
|
if (this.shouldFilter(filters)) return;
|
|
888
864
|
promises.push(
|
|
889
|
-
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
(val) => (this.request[key] = val),
|
|
898
|
-
() => this._recoverRequestKey(key)
|
|
899
|
-
)
|
|
865
|
+
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(() => {
|
|
866
|
+
const requestKeys = [];
|
|
867
|
+
for (const key in this.request) !ignoreKeys.has(key) && requestKeys.push(key);
|
|
868
|
+
return Promise.all(
|
|
869
|
+
requestKeys.map((key) =>
|
|
870
|
+
Promise.resolve(this.request[key]).then(
|
|
871
|
+
(val) => (this.request[key] = val),
|
|
872
|
+
() => this._recoverRequestKey(key)
|
|
900
873
|
)
|
|
901
|
-
)
|
|
902
|
-
|
|
903
|
-
)
|
|
874
|
+
)
|
|
875
|
+
);
|
|
876
|
+
})
|
|
904
877
|
);
|
|
905
878
|
});
|
|
906
879
|
return Promise.all(promises);
|
|
907
880
|
}
|
|
908
881
|
waitForResponseKeys(response) {
|
|
909
|
-
const responseKeys =
|
|
910
|
-
this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
882
|
+
const responseKeys = this.request.type === "xhr" ? xhrResponses : fetchResponses;
|
|
911
883
|
if (!this.request.async) {
|
|
912
884
|
if (getType(this.request.response) === "[object Function]") {
|
|
913
885
|
catchError(this.request.response, response);
|
|
914
886
|
responseKeys.forEach((key) => {
|
|
915
|
-
if (
|
|
916
|
-
"get" in getDescriptor(response, key) ||
|
|
917
|
-
isThenable(response[key])
|
|
918
|
-
) {
|
|
887
|
+
if ("get" in getDescriptor(response, key) || isThenable(response[key])) {
|
|
919
888
|
delete response[key];
|
|
920
889
|
}
|
|
921
890
|
});
|
|
922
891
|
}
|
|
923
892
|
return new SyncThenable();
|
|
924
893
|
}
|
|
925
|
-
return Promise.resolve(catchError(this.request.response, response)).then(
|
|
926
|
-
(
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
)
|
|
894
|
+
return Promise.resolve(catchError(this.request.response, response)).then(() =>
|
|
895
|
+
Promise.all(
|
|
896
|
+
responseKeys.map((key) => {
|
|
897
|
+
const descriptor = getDescriptor(response, key);
|
|
898
|
+
if (descriptor && "value" in descriptor) {
|
|
899
|
+
return Promise.resolve(descriptor.value).then(
|
|
900
|
+
(val) => (response[key] = val),
|
|
901
|
+
() => delete response[key]
|
|
902
|
+
);
|
|
903
|
+
} else {
|
|
904
|
+
delete response[key];
|
|
905
|
+
}
|
|
906
|
+
})
|
|
907
|
+
)
|
|
940
908
|
);
|
|
941
909
|
}
|
|
942
910
|
}
|
|
943
911
|
const proxyHandler = {
|
|
944
912
|
get(target, prop) {
|
|
945
913
|
const descriptor = getDescriptor(target, prop);
|
|
946
|
-
if (
|
|
947
|
-
descriptor &&
|
|
948
|
-
!descriptor.configurable &&
|
|
949
|
-
!descriptor.writable &&
|
|
950
|
-
!descriptor.get
|
|
951
|
-
)
|
|
914
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.get)
|
|
952
915
|
return target[prop];
|
|
953
916
|
const ah = target.__ajaxHooker;
|
|
954
917
|
if (ah && ah.proxyProps) {
|
|
955
918
|
if (prop in ah.proxyProps) {
|
|
956
919
|
const pDescriptor = ah.proxyProps[prop];
|
|
957
920
|
if ("get" in pDescriptor) return pDescriptor.get();
|
|
958
|
-
if (typeof pDescriptor.value === "function")
|
|
959
|
-
return pDescriptor.value.bind(ah);
|
|
921
|
+
if (typeof pDescriptor.value === "function") return pDescriptor.value.bind(ah);
|
|
960
922
|
return pDescriptor.value;
|
|
961
923
|
}
|
|
962
|
-
if (typeof target[prop] === "function")
|
|
963
|
-
return target[prop].bind(target);
|
|
924
|
+
if (typeof target[prop] === "function") return target[prop].bind(target);
|
|
964
925
|
}
|
|
965
926
|
return target[prop];
|
|
966
927
|
},
|
|
967
928
|
set(target, prop, value) {
|
|
968
929
|
const descriptor = getDescriptor(target, prop);
|
|
969
|
-
if (
|
|
970
|
-
descriptor &&
|
|
971
|
-
!descriptor.configurable &&
|
|
972
|
-
!descriptor.writable &&
|
|
973
|
-
!descriptor.set
|
|
974
|
-
)
|
|
975
|
-
return true;
|
|
930
|
+
if (descriptor && !descriptor.configurable && !descriptor.writable && !descriptor.set) return true;
|
|
976
931
|
const ah = target.__ajaxHooker;
|
|
977
932
|
if (ah && ah.proxyProps && prop in ah.proxyProps) {
|
|
978
933
|
const pDescriptor = ah.proxyProps[prop];
|
|
@@ -994,11 +949,7 @@
|
|
|
994
949
|
proxyEvents: {},
|
|
995
950
|
});
|
|
996
951
|
xhr.addEventListener("readystatechange", (e) => {
|
|
997
|
-
if (
|
|
998
|
-
ah.proxyXhr.readyState === 4 &&
|
|
999
|
-
ah.request &&
|
|
1000
|
-
typeof ah.request.response === "function"
|
|
1001
|
-
) {
|
|
952
|
+
if (ah.proxyXhr.readyState === 4 && ah.request && typeof ah.request.response === "function") {
|
|
1002
953
|
const response = {
|
|
1003
954
|
finalUrl: ah.proxyXhr.responseURL,
|
|
1004
955
|
status: ah.proxyXhr.status,
|
|
@@ -1021,18 +972,16 @@
|
|
|
1021
972
|
}
|
|
1022
973
|
);
|
|
1023
974
|
}
|
|
1024
|
-
ah.resThenable = new AHRequest(ah.request)
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
975
|
+
ah.resThenable = new AHRequest(ah.request).waitForResponseKeys(response).then(() => {
|
|
976
|
+
for (const key of xhrResponses) {
|
|
977
|
+
ah.proxyProps[key] = {
|
|
978
|
+
get: () => {
|
|
979
|
+
if (!(key in response)) response[key] = tempValues[key];
|
|
980
|
+
return response[key];
|
|
981
|
+
},
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
});
|
|
1036
985
|
}
|
|
1037
986
|
ah.dispatchEvent(e);
|
|
1038
987
|
});
|
|
@@ -1045,13 +994,7 @@
|
|
|
1045
994
|
set: (val) => ah.addEvent(onEvt, val),
|
|
1046
995
|
};
|
|
1047
996
|
}
|
|
1048
|
-
for (const method of [
|
|
1049
|
-
"setRequestHeader",
|
|
1050
|
-
"addEventListener",
|
|
1051
|
-
"removeEventListener",
|
|
1052
|
-
"open",
|
|
1053
|
-
"send",
|
|
1054
|
-
]) {
|
|
997
|
+
for (const method of ["setRequestHeader", "addEventListener", "removeEventListener", "open", "send"]) {
|
|
1055
998
|
ah.proxyProps[method] = { value: ah[method] };
|
|
1056
999
|
}
|
|
1057
1000
|
}
|
|
@@ -1060,8 +1003,7 @@
|
|
|
1060
1003
|
if (type.startsWith("on")) {
|
|
1061
1004
|
this.proxyEvents[type] = typeof event === "function" ? event : null;
|
|
1062
1005
|
} else {
|
|
1063
|
-
if (typeof event === "object" && event !== null)
|
|
1064
|
-
event = event.handleEvent;
|
|
1006
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1065
1007
|
if (typeof event !== "function") return;
|
|
1066
1008
|
this.proxyEvents[type] = this.proxyEvents[type] || new Set();
|
|
1067
1009
|
this.proxyEvents[type].add(event);
|
|
@@ -1071,8 +1013,7 @@
|
|
|
1071
1013
|
if (type.startsWith("on")) {
|
|
1072
1014
|
this.proxyEvents[type] = null;
|
|
1073
1015
|
} else {
|
|
1074
|
-
if (typeof event === "object" && event !== null)
|
|
1075
|
-
event = event.handleEvent;
|
|
1016
|
+
if (typeof event === "object" && event !== null) event = event.handleEvent;
|
|
1076
1017
|
this.proxyEvents[type] && this.proxyEvents[type].delete(event);
|
|
1077
1018
|
}
|
|
1078
1019
|
}
|
|
@@ -1083,9 +1024,7 @@
|
|
|
1083
1024
|
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1084
1025
|
this.proxyEvents[e.type] &&
|
|
1085
1026
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1086
|
-
this.resThenable.then(
|
|
1087
|
-
() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e)
|
|
1088
|
-
);
|
|
1027
|
+
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
1089
1028
|
});
|
|
1090
1029
|
if (e.ajaxHooker_isStopped) return;
|
|
1091
1030
|
const onEvent = this.proxyEvents["on" + e.type];
|
|
@@ -1095,8 +1034,7 @@
|
|
|
1095
1034
|
this.originalXhr.setRequestHeader(header, value);
|
|
1096
1035
|
if (!this.request) return;
|
|
1097
1036
|
const headers = this.request.headers;
|
|
1098
|
-
headers[header] =
|
|
1099
|
-
header in headers ? `${headers[header]}, ${value}` : value;
|
|
1037
|
+
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
1100
1038
|
}
|
|
1101
1039
|
addEventListener(...args) {
|
|
1102
1040
|
if (xhrAsyncEvents.includes(args[0])) {
|
|
@@ -1125,13 +1063,7 @@
|
|
|
1125
1063
|
};
|
|
1126
1064
|
this.openArgs = args;
|
|
1127
1065
|
this.resThenable = new SyncThenable();
|
|
1128
|
-
[
|
|
1129
|
-
"responseURL",
|
|
1130
|
-
"readyState",
|
|
1131
|
-
"status",
|
|
1132
|
-
"statusText",
|
|
1133
|
-
...xhrResponses,
|
|
1134
|
-
].forEach((key) => {
|
|
1066
|
+
["responseURL", "readyState", "status", "statusText", ...xhrResponses].forEach((key) => {
|
|
1135
1067
|
delete this.proxyProps[key];
|
|
1136
1068
|
});
|
|
1137
1069
|
return this.originalXhr.open(method, url, async, ...args);
|
|
@@ -1168,15 +1100,12 @@
|
|
|
1168
1100
|
}
|
|
1169
1101
|
function fakeXHR() {
|
|
1170
1102
|
const xhr = new winAh.realXHR();
|
|
1171
|
-
if ("__ajaxHooker" in xhr)
|
|
1172
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1103
|
+
if ("__ajaxHooker" in xhr) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1173
1104
|
xhr.__ajaxHooker = new XhrHooker(xhr);
|
|
1174
1105
|
return xhr.__ajaxHooker.proxyXhr;
|
|
1175
1106
|
}
|
|
1176
1107
|
fakeXHR.prototype = win.XMLHttpRequest.prototype;
|
|
1177
|
-
Object.keys(win.XMLHttpRequest).forEach(
|
|
1178
|
-
(key) => (fakeXHR[key] = win.XMLHttpRequest[key])
|
|
1179
|
-
);
|
|
1108
|
+
Object.keys(win.XMLHttpRequest).forEach((key) => (fakeXHR[key] = win.XMLHttpRequest[key]));
|
|
1180
1109
|
function fakeFetch(url, options = {}) {
|
|
1181
1110
|
if (!url) return winAh.realFetch.call(win, url, options);
|
|
1182
1111
|
return new Promise(async (resolve, reject) => {
|
|
@@ -1242,18 +1171,22 @@
|
|
|
1242
1171
|
status: res.status,
|
|
1243
1172
|
responseHeaders: parseHeaders(res.headers),
|
|
1244
1173
|
};
|
|
1245
|
-
|
|
1246
|
-
(
|
|
1247
|
-
(
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1174
|
+
if (res.ok) {
|
|
1175
|
+
fetchResponses.forEach(
|
|
1176
|
+
(key) =>
|
|
1177
|
+
(res[key] = function () {
|
|
1178
|
+
if (key in response) return Promise.resolve(response[key]);
|
|
1179
|
+
return resProto[key].call(this).then((val) => {
|
|
1180
|
+
response[key] = val;
|
|
1181
|
+
return req
|
|
1182
|
+
.waitForResponseKeys(response)
|
|
1183
|
+
.then(() => (key in response ? response[key] : val));
|
|
1184
|
+
});
|
|
1185
|
+
})
|
|
1186
|
+
);
|
|
1187
|
+
} else {
|
|
1188
|
+
catchError(request.response, response);
|
|
1189
|
+
}
|
|
1257
1190
|
}
|
|
1258
1191
|
resolve(res);
|
|
1259
1192
|
}, reject);
|
|
@@ -1275,8 +1208,7 @@
|
|
|
1275
1208
|
realFetchClone: resProto.clone,
|
|
1276
1209
|
hookInsts: new Set(),
|
|
1277
1210
|
};
|
|
1278
|
-
if (winAh.version !== version)
|
|
1279
|
-
console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1211
|
+
if (winAh.version !== version) console.warn("检测到不同版本的ajaxHooker,可能发生冲突!");
|
|
1280
1212
|
win.XMLHttpRequest = winAh.fakeXHR;
|
|
1281
1213
|
win.fetch = winAh.fakeFetch;
|
|
1282
1214
|
resProto.clone = winAh.fakeFetchClone;
|
|
@@ -1284,37 +1216,25 @@
|
|
|
1284
1216
|
// 针对头条、抖音 secsdk.umd.js 的兼容性处理
|
|
1285
1217
|
class AHFunction extends Function {
|
|
1286
1218
|
call(thisArg, ...args) {
|
|
1287
|
-
if (
|
|
1288
|
-
thisArg &&
|
|
1289
|
-
thisArg.__ajaxHooker &&
|
|
1290
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1291
|
-
) {
|
|
1219
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1292
1220
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1293
1221
|
}
|
|
1294
1222
|
return Reflect.apply(this, thisArg, args);
|
|
1295
1223
|
}
|
|
1296
1224
|
apply(thisArg, args) {
|
|
1297
|
-
if (
|
|
1298
|
-
thisArg &&
|
|
1299
|
-
thisArg.__ajaxHooker &&
|
|
1300
|
-
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1301
|
-
) {
|
|
1225
|
+
if (thisArg && thisArg.__ajaxHooker && thisArg.__ajaxHooker.proxyXhr === thisArg) {
|
|
1302
1226
|
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1303
1227
|
}
|
|
1304
1228
|
return Reflect.apply(this, thisArg, args || []);
|
|
1305
1229
|
}
|
|
1306
1230
|
}
|
|
1307
1231
|
function hookSecsdk(csrf) {
|
|
1308
|
-
Object.setPrototypeOf(
|
|
1309
|
-
csrf.nativeXMLHttpRequestSetRequestHeader,
|
|
1310
|
-
AHFunction.prototype
|
|
1311
|
-
);
|
|
1232
|
+
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSetRequestHeader, AHFunction.prototype);
|
|
1312
1233
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestOpen, AHFunction.prototype);
|
|
1313
1234
|
Object.setPrototypeOf(csrf.nativeXMLHttpRequestSend, AHFunction.prototype);
|
|
1314
1235
|
}
|
|
1315
1236
|
if (win.secsdk) {
|
|
1316
|
-
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
|
|
1317
|
-
hookSecsdk(win.secsdk.csrf);
|
|
1237
|
+
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen) hookSecsdk(win.secsdk.csrf);
|
|
1318
1238
|
} else {
|
|
1319
1239
|
defineProp(win, "secsdk", emptyFn, (secsdk) => {
|
|
1320
1240
|
delete win.secsdk;
|
|
@@ -1960,14 +1880,10 @@
|
|
|
1960
1880
|
// };
|
|
1961
1881
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1962
1882
|
menuOption.autoReload =
|
|
1963
|
-
typeof menuOption.autoReload !== "boolean"
|
|
1964
|
-
? this.$default.autoReload
|
|
1965
|
-
: menuOption.autoReload;
|
|
1883
|
+
typeof menuOption.autoReload !== "boolean" ? this.$default.autoReload : menuOption.autoReload;
|
|
1966
1884
|
/* 点击菜单后触发callback后的网页是否存储值 */
|
|
1967
1885
|
menuOption.isStoreValue =
|
|
1968
|
-
typeof menuOption.isStoreValue !== "boolean"
|
|
1969
|
-
? this.$default.isStoreValue
|
|
1970
|
-
: menuOption.isStoreValue;
|
|
1886
|
+
typeof menuOption.isStoreValue !== "boolean" ? this.$default.isStoreValue : menuOption.isStoreValue;
|
|
1971
1887
|
/**
|
|
1972
1888
|
* 用户点击菜单后的回调函数
|
|
1973
1889
|
* @param event
|
|
@@ -2020,8 +1936,7 @@
|
|
|
2020
1936
|
* @param menuKey 菜单-键key
|
|
2021
1937
|
*/
|
|
2022
1938
|
getMenuHandledOption(menuKey) {
|
|
2023
|
-
return this.$data.data.find((item) => item.handleData.key === menuKey)
|
|
2024
|
-
?.handleData;
|
|
1939
|
+
return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
|
|
2025
1940
|
},
|
|
2026
1941
|
};
|
|
2027
1942
|
constructor(details) {
|
|
@@ -2029,8 +1944,7 @@
|
|
|
2029
1944
|
this.GM_Api.setValue = details.GM_setValue;
|
|
2030
1945
|
this.GM_Api.registerMenuCommand = details.GM_registerMenuCommand;
|
|
2031
1946
|
this.GM_Api.unregisterMenuCommand = details.GM_unregisterMenuCommand;
|
|
2032
|
-
this.MenuHandle.$default.autoReload =
|
|
2033
|
-
typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
1947
|
+
this.MenuHandle.$default.autoReload = typeof details.autoReload === "boolean" ? details.autoReload : true;
|
|
2034
1948
|
for (const keyName of Object.keys(this.GM_Api)) {
|
|
2035
1949
|
if (typeof this.GM_Api[keyName] !== "function") {
|
|
2036
1950
|
throw new Error(`Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`);
|
|
@@ -2262,8 +2176,7 @@
|
|
|
2262
2176
|
_context = context || window;
|
|
2263
2177
|
_funcName = getFuncName(this);
|
|
2264
2178
|
_context["realFunc_" + _funcName] = this;
|
|
2265
|
-
if (_context[_funcName].prototype &&
|
|
2266
|
-
_context[_funcName].prototype.isHooked) {
|
|
2179
|
+
if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
|
|
2267
2180
|
console.log("Already has been hooked,unhook first");
|
|
2268
2181
|
return false;
|
|
2269
2182
|
}
|
|
@@ -2441,8 +2354,7 @@
|
|
|
2441
2354
|
if (details.allowInterceptConfig != null) {
|
|
2442
2355
|
// 配置存在
|
|
2443
2356
|
// 细分处理是否拦截
|
|
2444
|
-
if (typeof details.allowInterceptConfig.afterResponseSuccess ===
|
|
2445
|
-
"boolean" &&
|
|
2357
|
+
if (typeof details.allowInterceptConfig.afterResponseSuccess === "boolean" &&
|
|
2446
2358
|
!details.allowInterceptConfig.afterResponseSuccess) {
|
|
2447
2359
|
// 设置了禁止拦截
|
|
2448
2360
|
return details;
|
|
@@ -2477,8 +2389,7 @@
|
|
|
2477
2389
|
if (data.details.allowInterceptConfig != null) {
|
|
2478
2390
|
// 配置存在
|
|
2479
2391
|
// 细分处理是否拦截
|
|
2480
|
-
if (typeof data.details.allowInterceptConfig.afterResponseError ===
|
|
2481
|
-
"boolean" &&
|
|
2392
|
+
if (typeof data.details.allowInterceptConfig.afterResponseError === "boolean" &&
|
|
2482
2393
|
!data.details.allowInterceptConfig.afterResponseError) {
|
|
2483
2394
|
// 设置了禁止拦截
|
|
2484
2395
|
return data;
|
|
@@ -2580,44 +2491,31 @@
|
|
|
2580
2491
|
let requestOption = {
|
|
2581
2492
|
url: url,
|
|
2582
2493
|
method: (method || "GET").toString().toUpperCase().trim(),
|
|
2583
|
-
timeout: userRequestOption.timeout ||
|
|
2584
|
-
|
|
2585
|
-
responseType: userRequestOption.responseType ||
|
|
2586
|
-
this.context.#defaultRequestOption.responseType,
|
|
2494
|
+
timeout: userRequestOption.timeout || this.context.#defaultRequestOption.timeout,
|
|
2495
|
+
responseType: userRequestOption.responseType || this.context.#defaultRequestOption.responseType,
|
|
2587
2496
|
/* 对象使用深拷贝 */
|
|
2588
2497
|
headers: commonUtil.deepClone(this.context.#defaultRequestOption.headers),
|
|
2589
2498
|
data: userRequestOption.data || this.context.#defaultRequestOption.data,
|
|
2590
|
-
redirect: userRequestOption.redirect ||
|
|
2591
|
-
this.context.#defaultRequestOption.redirect,
|
|
2499
|
+
redirect: userRequestOption.redirect || this.context.#defaultRequestOption.redirect,
|
|
2592
2500
|
cookie: userRequestOption.cookie || this.context.#defaultRequestOption.cookie,
|
|
2593
|
-
cookiePartition: userRequestOption.cookiePartition ||
|
|
2594
|
-
this.context.#defaultRequestOption.cookiePartition,
|
|
2501
|
+
cookiePartition: userRequestOption.cookiePartition || this.context.#defaultRequestOption.cookiePartition,
|
|
2595
2502
|
binary: userRequestOption.binary || this.context.#defaultRequestOption.binary,
|
|
2596
|
-
nocache: userRequestOption.nocache ||
|
|
2597
|
-
|
|
2598
|
-
revalidate: userRequestOption.revalidate ||
|
|
2599
|
-
this.context.#defaultRequestOption.revalidate,
|
|
2503
|
+
nocache: userRequestOption.nocache || this.context.#defaultRequestOption.nocache,
|
|
2504
|
+
revalidate: userRequestOption.revalidate || this.context.#defaultRequestOption.revalidate,
|
|
2600
2505
|
/* 对象使用深拷贝 */
|
|
2601
|
-
context: commonUtil.deepClone(userRequestOption.context ||
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
this.context.#defaultRequestOption.overrideMimeType,
|
|
2605
|
-
anonymous: userRequestOption.anonymous ||
|
|
2606
|
-
this.context.#defaultRequestOption.anonymous,
|
|
2506
|
+
context: commonUtil.deepClone(userRequestOption.context || this.context.#defaultRequestOption.context),
|
|
2507
|
+
overrideMimeType: userRequestOption.overrideMimeType || this.context.#defaultRequestOption.overrideMimeType,
|
|
2508
|
+
anonymous: userRequestOption.anonymous || this.context.#defaultRequestOption.anonymous,
|
|
2607
2509
|
fetch: userRequestOption.fetch || this.context.#defaultRequestOption.fetch,
|
|
2608
2510
|
/* 对象使用深拷贝 */
|
|
2609
2511
|
fetchInit: commonUtil.deepClone(this.context.#defaultRequestOption.fetchInit),
|
|
2610
2512
|
allowInterceptConfig: {
|
|
2611
|
-
beforeRequest: this.context.#defaultRequestOption
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
.allowInterceptConfig.afterResponseSuccess,
|
|
2615
|
-
afterResponseError: this.context.#defaultRequestOption
|
|
2616
|
-
.allowInterceptConfig.afterResponseError,
|
|
2513
|
+
beforeRequest: this.context.#defaultRequestOption.allowInterceptConfig.beforeRequest,
|
|
2514
|
+
afterResponseSuccess: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseSuccess,
|
|
2515
|
+
afterResponseError: this.context.#defaultRequestOption.allowInterceptConfig.afterResponseError,
|
|
2617
2516
|
},
|
|
2618
2517
|
user: userRequestOption.user || this.context.#defaultRequestOption.user,
|
|
2619
|
-
password: userRequestOption.password ||
|
|
2620
|
-
this.context.#defaultRequestOption.password,
|
|
2518
|
+
password: userRequestOption.password || this.context.#defaultRequestOption.password,
|
|
2621
2519
|
onabort(...args) {
|
|
2622
2520
|
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2623
2521
|
},
|
|
@@ -2665,14 +2563,12 @@
|
|
|
2665
2563
|
if (typeof requestOption.headers === "object") {
|
|
2666
2564
|
if (typeof userRequestOption.headers === "object") {
|
|
2667
2565
|
Object.keys(userRequestOption.headers).forEach((keyName, index) => {
|
|
2668
|
-
if (keyName in requestOption.headers &&
|
|
2669
|
-
userRequestOption.headers?.[keyName] == null) {
|
|
2566
|
+
if (keyName in requestOption.headers && userRequestOption.headers?.[keyName] == null) {
|
|
2670
2567
|
/* 在默认的header中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2671
2568
|
Reflect.deleteProperty(requestOption.headers, keyName);
|
|
2672
2569
|
}
|
|
2673
2570
|
else {
|
|
2674
|
-
requestOption.headers[keyName] =
|
|
2675
|
-
userRequestOption?.headers?.[keyName];
|
|
2571
|
+
requestOption.headers[keyName] = userRequestOption?.headers?.[keyName];
|
|
2676
2572
|
}
|
|
2677
2573
|
});
|
|
2678
2574
|
}
|
|
@@ -2685,8 +2581,7 @@
|
|
|
2685
2581
|
/* 使用assign替换且添加 */
|
|
2686
2582
|
if (typeof userRequestOption.fetchInit === "object") {
|
|
2687
2583
|
Object.keys(userRequestOption.fetchInit).forEach((keyName, index) => {
|
|
2688
|
-
if (keyName in requestOption.fetchInit &&
|
|
2689
|
-
userRequestOption.fetchInit[keyName] == null) {
|
|
2584
|
+
if (keyName in requestOption.fetchInit && userRequestOption.fetchInit[keyName] == null) {
|
|
2690
2585
|
/* 在默认的fetchInit中存在,且设置它新的值为空,那么就是默认的值 */
|
|
2691
2586
|
Reflect.deleteProperty(requestOption.fetchInit, keyName);
|
|
2692
2587
|
}
|
|
@@ -2700,8 +2595,7 @@
|
|
|
2700
2595
|
Reflect.set(requestOption, "fetchInit", userRequestOption.fetchInit);
|
|
2701
2596
|
}
|
|
2702
2597
|
// 处理新的cookiePartition
|
|
2703
|
-
if (typeof requestOption.cookiePartition === "object" &&
|
|
2704
|
-
requestOption.cookiePartition != null) {
|
|
2598
|
+
if (typeof requestOption.cookiePartition === "object" && requestOption.cookiePartition != null) {
|
|
2705
2599
|
if (Reflect.has(requestOption.cookiePartition, "topLevelSite") &&
|
|
2706
2600
|
typeof requestOption.cookiePartition.topLevelSite !== "string") {
|
|
2707
2601
|
// topLevelSite必须是字符串
|
|
@@ -2723,8 +2617,7 @@
|
|
|
2723
2617
|
}
|
|
2724
2618
|
else {
|
|
2725
2619
|
// 补充origin+/
|
|
2726
|
-
requestOption.url =
|
|
2727
|
-
globalThis.location.origin + "/" + requestOption.url;
|
|
2620
|
+
requestOption.url = globalThis.location.origin + "/" + requestOption.url;
|
|
2728
2621
|
}
|
|
2729
2622
|
}
|
|
2730
2623
|
if (requestOption.fetchInit && !requestOption.fetch) {
|
|
@@ -2848,8 +2741,7 @@
|
|
|
2848
2741
|
* fetch的请求配置
|
|
2849
2742
|
**/
|
|
2850
2743
|
let fetchRequestOption = {};
|
|
2851
|
-
if ((option.method === "GET" || option.method === "HEAD") &&
|
|
2852
|
-
option.data != null) {
|
|
2744
|
+
if ((option.method === "GET" || option.method === "HEAD") && option.data != null) {
|
|
2853
2745
|
/* GET 或 HEAD 方法的请求不能包含 body 信息 */
|
|
2854
2746
|
Reflect.deleteProperty(option, "data");
|
|
2855
2747
|
}
|
|
@@ -3130,8 +3022,7 @@
|
|
|
3130
3022
|
if (typeof details?.onreadystatechange === "function") {
|
|
3131
3023
|
details.onreadystatechange.apply(this, argsResult);
|
|
3132
3024
|
}
|
|
3133
|
-
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3134
|
-
"function") {
|
|
3025
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange === "function") {
|
|
3135
3026
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3136
3027
|
}
|
|
3137
3028
|
},
|
|
@@ -3160,8 +3051,7 @@
|
|
|
3160
3051
|
if (this.context.#defaultInitOption.logDetails) {
|
|
3161
3052
|
console.log("[Httpx-HttpxRequest.request] 请求前的配置👇", details);
|
|
3162
3053
|
}
|
|
3163
|
-
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack ===
|
|
3164
|
-
"function") {
|
|
3054
|
+
if (typeof this.context.HttpxRequestHook.beforeRequestCallBack === "function") {
|
|
3165
3055
|
let hookResult = await this.context.HttpxRequestHook.beforeRequestCallBack(details);
|
|
3166
3056
|
if (hookResult == null) {
|
|
3167
3057
|
return;
|
|
@@ -3217,9 +3107,7 @@
|
|
|
3217
3107
|
/* 如果需要stream,且获取到的是stream,那直接返回 */
|
|
3218
3108
|
if (option.responseType === "stream" ||
|
|
3219
3109
|
(fetchResponse.headers.has("Content-Type") &&
|
|
3220
|
-
fetchResponse.headers
|
|
3221
|
-
.get("Content-Type")
|
|
3222
|
-
.includes("text/event-stream"))) {
|
|
3110
|
+
fetchResponse.headers.get("Content-Type").includes("text/event-stream"))) {
|
|
3223
3111
|
Reflect.set(httpxResponse, "isStream", true);
|
|
3224
3112
|
Reflect.set(httpxResponse, "response", fetchResponse.body);
|
|
3225
3113
|
Reflect.deleteProperty(httpxResponse, "responseText");
|
|
@@ -3238,9 +3126,7 @@
|
|
|
3238
3126
|
/** 数据编码 */
|
|
3239
3127
|
let encoding = "utf-8";
|
|
3240
3128
|
if (fetchResponse.headers.has("Content-Type")) {
|
|
3241
|
-
let charsetMatched = fetchResponse.headers
|
|
3242
|
-
.get("Content-Type")
|
|
3243
|
-
?.match(/charset=(.+)/);
|
|
3129
|
+
let charsetMatched = fetchResponse.headers.get("Content-Type")?.match(/charset=(.+)/);
|
|
3244
3130
|
if (charsetMatched) {
|
|
3245
3131
|
encoding = charsetMatched[1];
|
|
3246
3132
|
encoding = encoding.toLowerCase();
|
|
@@ -3262,13 +3148,11 @@
|
|
|
3262
3148
|
response = new Blob([arrayBuffer]);
|
|
3263
3149
|
}
|
|
3264
3150
|
else if (option.responseType === "json" ||
|
|
3265
|
-
(typeof fetchResponseType === "string" &&
|
|
3266
|
-
fetchResponseType.includes("application/json"))) {
|
|
3151
|
+
(typeof fetchResponseType === "string" && fetchResponseType.includes("application/json"))) {
|
|
3267
3152
|
// response返回格式是JSON格式
|
|
3268
3153
|
response = commonUtil.toJSON(responseText);
|
|
3269
3154
|
}
|
|
3270
|
-
else if (option.responseType === "document" ||
|
|
3271
|
-
option.responseType == null) {
|
|
3155
|
+
else if (option.responseType === "document" || option.responseType == null) {
|
|
3272
3156
|
// response返回格式是文档格式
|
|
3273
3157
|
let parser = new DOMParser();
|
|
3274
3158
|
response = parser.parseFromString(responseText, "text/html");
|
|
@@ -3531,8 +3415,7 @@
|
|
|
3531
3415
|
}
|
|
3532
3416
|
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3533
3417
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3534
|
-
if (requestResult != null &&
|
|
3535
|
-
typeof requestResult.abort === "function") {
|
|
3418
|
+
if (requestResult != null && typeof requestResult.abort === "function") {
|
|
3536
3419
|
abortFn = requestResult.abort;
|
|
3537
3420
|
}
|
|
3538
3421
|
});
|
|
@@ -4023,8 +3906,7 @@
|
|
|
4023
3906
|
if (typeof __GM_info === "string") {
|
|
4024
3907
|
this.tag = __GM_info;
|
|
4025
3908
|
}
|
|
4026
|
-
else if (typeof __GM_info === "object" &&
|
|
4027
|
-
typeof __GM_info?.script?.name === "string") {
|
|
3909
|
+
else if (typeof __GM_info === "object" && typeof __GM_info?.script?.name === "string") {
|
|
4028
3910
|
this.tag = __GM_info.script.name;
|
|
4029
3911
|
}
|
|
4030
3912
|
this.#console = console;
|
|
@@ -4080,8 +3962,7 @@
|
|
|
4080
3962
|
*/
|
|
4081
3963
|
checkClearConsole() {
|
|
4082
3964
|
this.#logCount++;
|
|
4083
|
-
if (this.#details.autoClearConsole &&
|
|
4084
|
-
this.#logCount > this.#details.logMaxCount) {
|
|
3965
|
+
if (this.#details.autoClearConsole && this.#logCount > this.#details.logMaxCount) {
|
|
4085
3966
|
this.#console.clear();
|
|
4086
3967
|
this.#logCount = 0;
|
|
4087
3968
|
}
|
|
@@ -4490,6 +4371,10 @@
|
|
|
4490
4371
|
globalThis: globalThis,
|
|
4491
4372
|
self: self,
|
|
4492
4373
|
top: top,
|
|
4374
|
+
setTimeout: globalThis.setTimeout,
|
|
4375
|
+
setInterval: globalThis.setInterval,
|
|
4376
|
+
clearTimeout: globalThis.clearTimeout,
|
|
4377
|
+
clearInterval: globalThis.clearInterval,
|
|
4493
4378
|
};
|
|
4494
4379
|
/** 使用的配置 */
|
|
4495
4380
|
api;
|
|
@@ -4522,6 +4407,18 @@
|
|
|
4522
4407
|
get top() {
|
|
4523
4408
|
return this.api.top;
|
|
4524
4409
|
}
|
|
4410
|
+
get setTimeout() {
|
|
4411
|
+
return this.api.setTimeout;
|
|
4412
|
+
}
|
|
4413
|
+
get setInterval() {
|
|
4414
|
+
return this.api.setInterval;
|
|
4415
|
+
}
|
|
4416
|
+
get clearTimeout() {
|
|
4417
|
+
return this.api.clearTimeout;
|
|
4418
|
+
}
|
|
4419
|
+
get clearInterval() {
|
|
4420
|
+
return this.api.clearInterval;
|
|
4421
|
+
}
|
|
4525
4422
|
}
|
|
4526
4423
|
|
|
4527
4424
|
const VueUtils = {
|
|
@@ -4997,7 +4894,7 @@
|
|
|
4997
4894
|
};
|
|
4998
4895
|
|
|
4999
4896
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5000
|
-
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(
|
|
4897
|
+
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,()=>{n(),t.close(),u.delete(o)}),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise(t=>{e.set(a,[r(n,u,i,e,t,a),t])})},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
5001
4898
|
|
|
5002
4899
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5003
4900
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5584,7 +5481,7 @@
|
|
|
5584
5481
|
this.windowApi = new WindowApi(option);
|
|
5585
5482
|
}
|
|
5586
5483
|
/** 版本号 */
|
|
5587
|
-
version = "2025.
|
|
5484
|
+
version = "2025.8.21";
|
|
5588
5485
|
addStyle(cssText) {
|
|
5589
5486
|
if (typeof cssText !== "string") {
|
|
5590
5487
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5707,13 +5604,9 @@
|
|
|
5707
5604
|
let touchEvent = UtilsContext.windowApi.window.event;
|
|
5708
5605
|
let $click = clickEvent?.composedPath()?.[0];
|
|
5709
5606
|
// 点击的x坐标
|
|
5710
|
-
let clickPosX = clickEvent?.clientX != null
|
|
5711
|
-
? clickEvent.clientX
|
|
5712
|
-
: touchEvent.touches[0].clientX;
|
|
5607
|
+
let clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
|
|
5713
5608
|
// 点击的y坐标
|
|
5714
|
-
let clickPosY = clickEvent?.clientY != null
|
|
5715
|
-
? clickEvent.clientY
|
|
5716
|
-
: touchEvent.touches[0].clientY;
|
|
5609
|
+
let clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
|
|
5717
5610
|
let {
|
|
5718
5611
|
/* 要检测的元素的相对屏幕的横坐标最左边 */
|
|
5719
5612
|
left: elementPosXLeft,
|
|
@@ -5876,9 +5769,7 @@
|
|
|
5876
5769
|
/* CODE FOR BROWSERS THAT SUPPORT window.find */
|
|
5877
5770
|
let windowFind = this.windowApi.self.find;
|
|
5878
5771
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5879
|
-
if (strFound &&
|
|
5880
|
-
this.windowApi.self.getSelection &&
|
|
5881
|
-
!this.windowApi.self.getSelection().anchorNode) {
|
|
5772
|
+
if (strFound && this.windowApi.self.getSelection && !this.windowApi.self.getSelection().anchorNode) {
|
|
5882
5773
|
strFound = windowFind(str, caseSensitive, true, true, false);
|
|
5883
5774
|
}
|
|
5884
5775
|
if (!strFound) {
|
|
@@ -5981,9 +5872,7 @@
|
|
|
5981
5872
|
}
|
|
5982
5873
|
}
|
|
5983
5874
|
result = result.toFixed(2);
|
|
5984
|
-
result = addType
|
|
5985
|
-
? result + resultType.toString()
|
|
5986
|
-
: parseFloat(result.toString());
|
|
5875
|
+
result = addType ? result + resultType.toString() : parseFloat(result.toString());
|
|
5987
5876
|
return result;
|
|
5988
5877
|
}
|
|
5989
5878
|
getNodeListValue(...args) {
|
|
@@ -6062,14 +5951,7 @@
|
|
|
6062
5951
|
if (text.length === 8) {
|
|
6063
5952
|
/* 该字符串只有时分秒 */
|
|
6064
5953
|
let today = new Date();
|
|
6065
|
-
text =
|
|
6066
|
-
today.getFullYear() +
|
|
6067
|
-
"-" +
|
|
6068
|
-
(today.getMonth() + 1) +
|
|
6069
|
-
"-" +
|
|
6070
|
-
today.getDate() +
|
|
6071
|
-
" " +
|
|
6072
|
-
text;
|
|
5954
|
+
text = today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + " " + text;
|
|
6073
5955
|
}
|
|
6074
5956
|
text = text.substring(0, 19);
|
|
6075
5957
|
text = text.replace(/-/g, "/");
|
|
@@ -6090,25 +5972,13 @@
|
|
|
6090
5972
|
* 获取 transitionend 的在各个浏览器的兼容名
|
|
6091
5973
|
*/
|
|
6092
5974
|
getTransitionEndNameList() {
|
|
6093
|
-
return [
|
|
6094
|
-
"webkitTransitionEnd",
|
|
6095
|
-
"mozTransitionEnd",
|
|
6096
|
-
"MSTransitionEnd",
|
|
6097
|
-
"otransitionend",
|
|
6098
|
-
"transitionend",
|
|
6099
|
-
];
|
|
5975
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
6100
5976
|
}
|
|
6101
5977
|
/**
|
|
6102
5978
|
* 获取 animationend 的在各个浏览器的兼容名
|
|
6103
5979
|
*/
|
|
6104
5980
|
getAnimationEndNameList() {
|
|
6105
|
-
return [
|
|
6106
|
-
"webkitAnimationEnd",
|
|
6107
|
-
"mozAnimationEnd",
|
|
6108
|
-
"MSAnimationEnd",
|
|
6109
|
-
"oanimationend",
|
|
6110
|
-
"animationend",
|
|
6111
|
-
];
|
|
5981
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
6112
5982
|
}
|
|
6113
5983
|
getArrayLastValue(targetObj) {
|
|
6114
5984
|
return targetObj[targetObj.length - 1];
|
|
@@ -6212,10 +6082,8 @@
|
|
|
6212
6082
|
}
|
|
6213
6083
|
/* 如果有多个相同类型的兄弟元素,则需要添加索引 */
|
|
6214
6084
|
if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
|
|
6215
|
-
let index = Array.prototype.indexOf.call(element.parentElement.children, element) +
|
|
6216
|
-
|
|
6217
|
-
selector +=
|
|
6218
|
-
" > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6085
|
+
let index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
|
|
6086
|
+
selector += " > " + element.tagName.toLowerCase() + ":nth-child(" + index + ")";
|
|
6219
6087
|
}
|
|
6220
6088
|
else {
|
|
6221
6089
|
selector += " > " + element.tagName.toLowerCase();
|
|
@@ -6235,9 +6103,7 @@
|
|
|
6235
6103
|
return void 0;
|
|
6236
6104
|
}
|
|
6237
6105
|
if (result.length > 1) {
|
|
6238
|
-
if (result.length === 2 &&
|
|
6239
|
-
typeof result[0] === "object" &&
|
|
6240
|
-
typeof result[1] === "function") {
|
|
6106
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6241
6107
|
let data = result[0];
|
|
6242
6108
|
let handleDataFunc = result[1];
|
|
6243
6109
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6335,9 +6201,7 @@
|
|
|
6335
6201
|
return void 0;
|
|
6336
6202
|
}
|
|
6337
6203
|
if (result.length > 1) {
|
|
6338
|
-
if (result.length === 2 &&
|
|
6339
|
-
typeof result[0] === "object" &&
|
|
6340
|
-
typeof result[1] === "function") {
|
|
6204
|
+
if (result.length === 2 && typeof result[0] === "object" && typeof result[1] === "function") {
|
|
6341
6205
|
let data = result[0];
|
|
6342
6206
|
let handleDataFunc = result[1];
|
|
6343
6207
|
Object.keys(data).forEach((keyName) => {
|
|
@@ -6427,12 +6291,10 @@
|
|
|
6427
6291
|
getRandomValue(...args) {
|
|
6428
6292
|
let result = [...args];
|
|
6429
6293
|
if (result.length > 1) {
|
|
6430
|
-
if (result.length === 2 &&
|
|
6431
|
-
typeof result[0] === "number" &&
|
|
6432
|
-
typeof result[1] === "number") {
|
|
6294
|
+
if (result.length === 2 && typeof result[0] === "number" && typeof result[1] === "number") {
|
|
6433
6295
|
let leftNumber = result[0] > result[1] ? result[1] : result[0];
|
|
6434
6296
|
let rightNumber = result[0] > result[1] ? result[0] : result[1];
|
|
6435
|
-
return
|
|
6297
|
+
return Math.round(Math.random() * (rightNumber - leftNumber)) + leftNumber;
|
|
6436
6298
|
}
|
|
6437
6299
|
else {
|
|
6438
6300
|
return result[Math.floor(Math.random() * result.length)];
|
|
@@ -6443,8 +6305,7 @@
|
|
|
6443
6305
|
if (Array.isArray(paramData)) {
|
|
6444
6306
|
return paramData[Math.floor(Math.random() * paramData.length)];
|
|
6445
6307
|
}
|
|
6446
|
-
else if (typeof paramData === "object" &&
|
|
6447
|
-
Object.keys(paramData).length > 0) {
|
|
6308
|
+
else if (typeof paramData === "object" && Object.keys(paramData).length > 0) {
|
|
6448
6309
|
let paramObjDataKey = Object.keys(paramData)[Math.floor(Math.random() * Object.keys(paramData).length)];
|
|
6449
6310
|
return paramData[paramObjDataKey];
|
|
6450
6311
|
}
|
|
@@ -6751,11 +6612,9 @@
|
|
|
6751
6612
|
let nearBottomHeight = 50;
|
|
6752
6613
|
let checkWindow = () => {
|
|
6753
6614
|
// 已滚动的距离
|
|
6754
|
-
let scrollTop = this.windowApi.window.pageYOffset ||
|
|
6755
|
-
this.windowApi.document.documentElement.scrollTop;
|
|
6615
|
+
let scrollTop = this.windowApi.window.pageYOffset || this.windowApi.document.documentElement.scrollTop;
|
|
6756
6616
|
// 视窗高度
|
|
6757
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
6758
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6617
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
6759
6618
|
// 最大滚动距离
|
|
6760
6619
|
let maxScrollHeight = this.windowApi.document.documentElement.scrollHeight - nearBottomHeight;
|
|
6761
6620
|
return scrollTop + viewportHeight >= maxScrollHeight;
|
|
@@ -7044,8 +6903,7 @@
|
|
|
7044
6903
|
**/
|
|
7045
6904
|
isNull = commonUtil.isNull.bind(commonUtil);
|
|
7046
6905
|
isThemeDark() {
|
|
7047
|
-
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)")
|
|
7048
|
-
.matches;
|
|
6906
|
+
return this.windowApi.globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
7049
6907
|
}
|
|
7050
6908
|
/**
|
|
7051
6909
|
* 判断元素是否在页面中可见
|
|
@@ -7078,10 +6936,8 @@
|
|
|
7078
6936
|
else {
|
|
7079
6937
|
let domClientRect = domItem.getBoundingClientRect();
|
|
7080
6938
|
if (inView) {
|
|
7081
|
-
let viewportWidth = this.windowApi.window.innerWidth ||
|
|
7082
|
-
|
|
7083
|
-
let viewportHeight = this.windowApi.window.innerHeight ||
|
|
7084
|
-
this.windowApi.document.documentElement.clientHeight;
|
|
6939
|
+
let viewportWidth = this.windowApi.window.innerWidth || this.windowApi.document.documentElement.clientWidth;
|
|
6940
|
+
let viewportHeight = this.windowApi.window.innerHeight || this.windowApi.document.documentElement.clientHeight;
|
|
7085
6941
|
result = !(domClientRect.right < 0 ||
|
|
7086
6942
|
domClientRect.left > viewportWidth ||
|
|
7087
6943
|
domClientRect.bottom < 0 ||
|
|
@@ -7105,8 +6961,7 @@
|
|
|
7105
6961
|
for (const key in Object.values(this.windowApi.top.window.via)) {
|
|
7106
6962
|
if (Reflect.has(this.windowApi.top.window.via, key)) {
|
|
7107
6963
|
let objValueFunc = this.windowApi.top.window.via[key];
|
|
7108
|
-
if (typeof objValueFunc === "function" &&
|
|
7109
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
6964
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7110
6965
|
result = true;
|
|
7111
6966
|
}
|
|
7112
6967
|
else {
|
|
@@ -7128,8 +6983,7 @@
|
|
|
7128
6983
|
for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
|
|
7129
6984
|
if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
|
|
7130
6985
|
let objValueFunc = this.windowApi.top.window.mbrowser[key];
|
|
7131
|
-
if (typeof objValueFunc === "function" &&
|
|
7132
|
-
UtilsContext.isNativeFunc(objValueFunc)) {
|
|
6986
|
+
if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
|
|
7133
6987
|
result = true;
|
|
7134
6988
|
}
|
|
7135
6989
|
else {
|
|
@@ -7366,13 +7220,11 @@
|
|
|
7366
7220
|
* 释放所有
|
|
7367
7221
|
*/
|
|
7368
7222
|
function releaseAll() {
|
|
7369
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] !==
|
|
7370
|
-
"undefined") {
|
|
7223
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
|
|
7371
7224
|
/* 已存在 */
|
|
7372
7225
|
return;
|
|
7373
7226
|
}
|
|
7374
|
-
UtilsContext.windowApi.window[needReleaseKey] =
|
|
7375
|
-
UtilsContext.deepClone(needReleaseObject);
|
|
7227
|
+
UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
|
|
7376
7228
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7377
7229
|
if (typeof value === "function") {
|
|
7378
7230
|
needReleaseObject[value.name] = () => { };
|
|
@@ -7386,8 +7238,7 @@
|
|
|
7386
7238
|
Array.from(functionNameList).forEach((item) => {
|
|
7387
7239
|
Object.values(needReleaseObject).forEach((value) => {
|
|
7388
7240
|
if (typeof value === "function") {
|
|
7389
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7390
|
-
"undefined") {
|
|
7241
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7391
7242
|
UtilsContext.windowApi.window[needReleaseKey] = {};
|
|
7392
7243
|
}
|
|
7393
7244
|
if (item === value.name) {
|
|
@@ -7402,8 +7253,7 @@
|
|
|
7402
7253
|
* 恢复所有
|
|
7403
7254
|
*/
|
|
7404
7255
|
function recoveryAll() {
|
|
7405
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7406
|
-
"undefined") {
|
|
7256
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7407
7257
|
/* 未存在 */
|
|
7408
7258
|
return;
|
|
7409
7259
|
}
|
|
@@ -7414,8 +7264,7 @@
|
|
|
7414
7264
|
* 恢复单个
|
|
7415
7265
|
*/
|
|
7416
7266
|
function recoveryOne() {
|
|
7417
|
-
if (typeof UtilsContext.windowApi.window[needReleaseKey] ===
|
|
7418
|
-
"undefined") {
|
|
7267
|
+
if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
|
|
7419
7268
|
/* 未存在 */
|
|
7420
7269
|
return;
|
|
7421
7270
|
}
|
|
@@ -7423,8 +7272,7 @@
|
|
|
7423
7272
|
if (UtilsContext.windowApi.window[needReleaseKey][item]) {
|
|
7424
7273
|
needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
|
|
7425
7274
|
Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
|
|
7426
|
-
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey])
|
|
7427
|
-
.length === 0) {
|
|
7275
|
+
if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
|
|
7428
7276
|
Reflect.deleteProperty(window, needReleaseKey);
|
|
7429
7277
|
}
|
|
7430
7278
|
}
|
|
@@ -7681,8 +7529,7 @@
|
|
|
7681
7529
|
let copyStatus = false;
|
|
7682
7530
|
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7683
7531
|
console.log(requestPermissionStatus);
|
|
7684
|
-
if (this.hasClipboard() &&
|
|
7685
|
-
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7532
|
+
if (this.hasClipboard() && (this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7686
7533
|
try {
|
|
7687
7534
|
copyStatus = await this.copyDataByClipboard();
|
|
7688
7535
|
}
|
|
@@ -7843,11 +7690,8 @@
|
|
|
7843
7690
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
7844
7691
|
return mouseEvent;
|
|
7845
7692
|
}
|
|
7846
|
-
let sliderElement = typeof selector === "string"
|
|
7847
|
-
|
|
7848
|
-
: selector;
|
|
7849
|
-
if (!(sliderElement instanceof Node) ||
|
|
7850
|
-
!(sliderElement instanceof Element)) {
|
|
7693
|
+
let sliderElement = typeof selector === "string" ? domUtils.selector(selector) : selector;
|
|
7694
|
+
if (!(sliderElement instanceof Node) || !(sliderElement instanceof Element)) {
|
|
7851
7695
|
throw new Error("Utils.dragSlider 参数selector 必须为Node/Element类型");
|
|
7852
7696
|
}
|
|
7853
7697
|
let rect = sliderElement.getBoundingClientRect(), x0 = rect.x || rect.left, y0 = rect.y || rect.top, x1 = x0 + offsetX, y1 = y0;
|
|
@@ -7899,17 +7743,14 @@
|
|
|
7899
7743
|
}
|
|
7900
7744
|
sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
|
|
7901
7745
|
let UtilsContext = this;
|
|
7902
|
-
if (typeof getPropertyValueFunc !== "function" &&
|
|
7903
|
-
typeof getPropertyValueFunc !== "string") {
|
|
7746
|
+
if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
|
|
7904
7747
|
throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
|
|
7905
7748
|
}
|
|
7906
7749
|
if (typeof sortByDesc !== "boolean") {
|
|
7907
7750
|
throw new Error("Utils.sortListByProperty 参数 sortByDesc 必须为 boolean 类型");
|
|
7908
7751
|
}
|
|
7909
7752
|
let getObjValue = function (obj) {
|
|
7910
|
-
return typeof getPropertyValueFunc === "string"
|
|
7911
|
-
? obj[getPropertyValueFunc]
|
|
7912
|
-
: getPropertyValueFunc(obj);
|
|
7753
|
+
return typeof getPropertyValueFunc === "string" ? obj[getPropertyValueFunc] : getPropertyValueFunc(obj);
|
|
7913
7754
|
};
|
|
7914
7755
|
/**
|
|
7915
7756
|
* 排序方法
|
|
@@ -7984,8 +7825,7 @@
|
|
|
7984
7825
|
if (Array.isArray(data)) {
|
|
7985
7826
|
data.sort(sortFunc);
|
|
7986
7827
|
}
|
|
7987
|
-
else if (data instanceof NodeList ||
|
|
7988
|
-
UtilsContext.isJQuery(data)) {
|
|
7828
|
+
else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
|
|
7989
7829
|
sortNodeFunc(data, getDataFunc);
|
|
7990
7830
|
result = getDataFunc();
|
|
7991
7831
|
}
|
|
@@ -8178,9 +8018,7 @@
|
|
|
8178
8018
|
let parent = UtilsContext.windowApi.document;
|
|
8179
8019
|
// 超时时间
|
|
8180
8020
|
let timeout = 0;
|
|
8181
|
-
if (typeof args[0] !== "string" &&
|
|
8182
|
-
!Array.isArray(args[0]) &&
|
|
8183
|
-
typeof args[0] !== "function") {
|
|
8021
|
+
if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
|
|
8184
8022
|
throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
|
|
8185
8023
|
}
|
|
8186
8024
|
if (args.length === 1) ;
|
|
@@ -8190,8 +8028,7 @@
|
|
|
8190
8028
|
// "div",10000
|
|
8191
8029
|
timeout = secondParam;
|
|
8192
8030
|
}
|
|
8193
|
-
else if (typeof secondParam === "object" &&
|
|
8194
|
-
secondParam instanceof Node) {
|
|
8031
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8195
8032
|
// "div",document
|
|
8196
8033
|
parent = secondParam;
|
|
8197
8034
|
}
|
|
@@ -8277,8 +8114,7 @@
|
|
|
8277
8114
|
// "div",10000
|
|
8278
8115
|
timeout = secondParam;
|
|
8279
8116
|
}
|
|
8280
|
-
else if (typeof secondParam === "object" &&
|
|
8281
|
-
secondParam instanceof Node) {
|
|
8117
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8282
8118
|
// "div",document
|
|
8283
8119
|
parent = secondParam;
|
|
8284
8120
|
}
|
|
@@ -8333,8 +8169,7 @@
|
|
|
8333
8169
|
// "div",10000
|
|
8334
8170
|
timeout = secondParam;
|
|
8335
8171
|
}
|
|
8336
|
-
else if (typeof secondParam === "object" &&
|
|
8337
|
-
secondParam instanceof Node) {
|
|
8172
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8338
8173
|
// "div",document
|
|
8339
8174
|
parent = secondParam;
|
|
8340
8175
|
}
|
|
@@ -8420,8 +8255,7 @@
|
|
|
8420
8255
|
// "div",10000
|
|
8421
8256
|
timeout = secondParam;
|
|
8422
8257
|
}
|
|
8423
|
-
else if (typeof secondParam === "object" &&
|
|
8424
|
-
secondParam instanceof Node) {
|
|
8258
|
+
else if (typeof secondParam === "object" && secondParam instanceof Node) {
|
|
8425
8259
|
// "div",document
|
|
8426
8260
|
parent = secondParam;
|
|
8427
8261
|
}
|
|
@@ -8554,8 +8388,7 @@
|
|
|
8554
8388
|
return flag;
|
|
8555
8389
|
}
|
|
8556
8390
|
watchObject(target, propertyName, getCallBack, setCallBack) {
|
|
8557
|
-
if (typeof getCallBack !== "function" &&
|
|
8558
|
-
typeof setCallBack !== "function") {
|
|
8391
|
+
if (typeof getCallBack !== "function" && typeof setCallBack !== "function") {
|
|
8559
8392
|
return;
|
|
8560
8393
|
}
|
|
8561
8394
|
if (typeof getCallBack === "function") {
|
|
@@ -8607,13 +8440,27 @@
|
|
|
8607
8440
|
return;
|
|
8608
8441
|
}
|
|
8609
8442
|
let handleResult = handler(target);
|
|
8610
|
-
if (handleResult &&
|
|
8611
|
-
typeof handleResult.isFind === "boolean" &&
|
|
8612
|
-
handleResult.isFind) {
|
|
8443
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8613
8444
|
return handleResult.data;
|
|
8614
8445
|
}
|
|
8615
8446
|
return this.queryProperty(handleResult.data, handler);
|
|
8616
8447
|
}
|
|
8448
|
+
/**
|
|
8449
|
+
* 异步-深度获取对象属性
|
|
8450
|
+
* @param target 待获取的对象
|
|
8451
|
+
* @param handler 获取属性的回调
|
|
8452
|
+
*/
|
|
8453
|
+
async asyncQueryProperty(target, handler) {
|
|
8454
|
+
if (target == null) {
|
|
8455
|
+
// @ts-ignore
|
|
8456
|
+
return;
|
|
8457
|
+
}
|
|
8458
|
+
let handleResult = await handler(target);
|
|
8459
|
+
if (handleResult && typeof handleResult.isFind === "boolean" && handleResult.isFind) {
|
|
8460
|
+
return handleResult.data;
|
|
8461
|
+
}
|
|
8462
|
+
return await this.asyncQueryProperty(handleResult.data, handler);
|
|
8463
|
+
}
|
|
8617
8464
|
/**
|
|
8618
8465
|
* 创建一个新的Utils实例
|
|
8619
8466
|
* @param option
|
|
@@ -8718,7 +8565,7 @@
|
|
|
8718
8565
|
return setTimeout$1(callback, timeout);
|
|
8719
8566
|
}
|
|
8720
8567
|
catch (error) {
|
|
8721
|
-
return
|
|
8568
|
+
return this.windowApi.setTimeout(callback, timeout);
|
|
8722
8569
|
}
|
|
8723
8570
|
}
|
|
8724
8571
|
/**
|
|
@@ -8734,7 +8581,7 @@
|
|
|
8734
8581
|
catch (error) {
|
|
8735
8582
|
}
|
|
8736
8583
|
finally {
|
|
8737
|
-
|
|
8584
|
+
this.windowApi.clearTimeout(timeId);
|
|
8738
8585
|
}
|
|
8739
8586
|
}
|
|
8740
8587
|
/**
|
|
@@ -8747,7 +8594,7 @@
|
|
|
8747
8594
|
return setInterval(callback, timeout);
|
|
8748
8595
|
}
|
|
8749
8596
|
catch (error) {
|
|
8750
|
-
return
|
|
8597
|
+
return this.windowApi.setInterval(callback, timeout);
|
|
8751
8598
|
}
|
|
8752
8599
|
}
|
|
8753
8600
|
/**
|
|
@@ -8763,7 +8610,7 @@
|
|
|
8763
8610
|
catch (error) {
|
|
8764
8611
|
}
|
|
8765
8612
|
finally {
|
|
8766
|
-
|
|
8613
|
+
this.windowApi.clearInterval(timeId);
|
|
8767
8614
|
}
|
|
8768
8615
|
}
|
|
8769
8616
|
/**
|