@whitesev/utils 2.7.0 → 2.7.2
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/README.md +19 -19
- package/dist/index.amd.js +205 -235
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +205 -235
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +205 -235
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +205 -235
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +205 -235
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +205 -235
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/ColorConversion.d.ts +3 -8
- package/dist/types/src/Dictionary.d.ts +21 -14
- package/dist/types/src/GBKEncoder.d.ts +1 -2
- package/dist/types/src/Hooks.d.ts +1 -2
- package/dist/types/src/Httpx.d.ts +45 -46
- package/dist/types/src/LockFunction.d.ts +1 -2
- package/dist/types/src/Log.d.ts +1 -2
- package/dist/types/src/Progress.d.ts +1 -2
- package/dist/types/src/Utils.d.ts +1 -1
- package/dist/types/src/UtilsGMMenu.d.ts +1 -2
- package/dist/types/src/WindowApi.d.ts +1 -2
- package/dist/types/src/indexedDB.d.ts +1 -2
- package/dist/types/src/types/Httpx.d.ts +73 -67
- package/dist/types/src/types/env.d.ts +2 -0
- package/dist/types/src/types/global.d.ts +3 -0
- package/package.json +1 -1
- package/src/ColorConversion.ts +14 -25
- package/src/DOMUtils.ts +14 -16
- package/src/Dictionary.ts +39 -35
- package/src/GBKEncoder.ts +8 -12
- package/src/Hooks.ts +1 -3
- package/src/Httpx.ts +194 -174
- package/src/LockFunction.ts +3 -3
- package/src/Log.ts +1 -3
- package/src/Progress.ts +1 -3
- package/src/TryCatch.ts +4 -4
- package/src/Utils.ts +29 -45
- package/src/UtilsGMMenu.ts +19 -22
- package/src/Vue.ts +4 -7
- package/src/WindowApi.ts +2 -5
- package/src/ajaxHooker/ajaxHooker.js +35 -21
- package/src/indexedDB.ts +8 -8
- package/src/types/Httpx.d.ts +73 -67
- package/src/types/env.d.ts +2 -0
- package/src/types/global.d.ts +3 -0
package/dist/index.amd.js
CHANGED
|
@@ -17,14 +17,13 @@ define((function () { 'use strict';
|
|
|
17
17
|
/**
|
|
18
18
|
* 16进制颜色转rgba
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* 例如:`#ff0000` 转为 `rgba(123,123,123, 0.4)`
|
|
21
21
|
* @param hex
|
|
22
22
|
* @param opacity
|
|
23
23
|
*/
|
|
24
24
|
hexToRgba(hex, opacity) {
|
|
25
25
|
if (!this.isHex(hex)) {
|
|
26
|
-
|
|
27
|
-
throw new TypeError("输入错误的hex", hex);
|
|
26
|
+
throw new TypeError("输入错误的hex:" + hex);
|
|
28
27
|
}
|
|
29
28
|
return hex && hex.replace(/\s+/g, "").length === 7
|
|
30
29
|
? "rgba(" +
|
|
@@ -41,19 +40,16 @@ define((function () { 'use strict';
|
|
|
41
40
|
/**
|
|
42
41
|
* hex转rgb
|
|
43
42
|
* @param str
|
|
44
|
-
* @returns
|
|
45
43
|
*/
|
|
46
44
|
hexToRgb(str) {
|
|
47
45
|
if (!this.isHex(str)) {
|
|
48
|
-
|
|
49
|
-
throw new TypeError("输入错误的hex", str);
|
|
46
|
+
throw new TypeError("输入错误的hex:" + str);
|
|
50
47
|
}
|
|
51
48
|
/* replace替换查找的到的字符串 */
|
|
52
49
|
str = str.replace("#", "");
|
|
53
50
|
/* match得到查询数组 */
|
|
54
51
|
let hxs = str.match(/../g);
|
|
55
52
|
for (let index = 0; index < 3; index++) {
|
|
56
|
-
// @ts-ignore
|
|
57
53
|
hxs[index] = parseInt(hxs[index], 16);
|
|
58
54
|
}
|
|
59
55
|
return hxs;
|
|
@@ -63,7 +59,6 @@ define((function () { 'use strict';
|
|
|
63
59
|
* @param redValue
|
|
64
60
|
* @param greenValue
|
|
65
61
|
* @param blueValue
|
|
66
|
-
* @returns
|
|
67
62
|
*/
|
|
68
63
|
rgbToHex(redValue, greenValue, blueValue) {
|
|
69
64
|
/* 验证输入的rgb值是否合法 */
|
|
@@ -86,38 +81,30 @@ define((function () { 'use strict';
|
|
|
86
81
|
* 获取颜色变暗或亮
|
|
87
82
|
* @param color 颜色
|
|
88
83
|
* @param level 0~1.0
|
|
89
|
-
* @returns
|
|
90
84
|
*/
|
|
91
85
|
getDarkColor(color, level) {
|
|
92
86
|
if (!this.isHex(color)) {
|
|
93
|
-
|
|
94
|
-
throw new TypeError("输入错误的hex", color);
|
|
87
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
95
88
|
}
|
|
96
89
|
let rgbc = this.hexToRgb(color);
|
|
97
90
|
for (let index = 0; index < 3; index++) {
|
|
98
|
-
// @ts-ignore
|
|
99
91
|
rgbc[index] = Math.floor(rgbc[index] * (1 - level));
|
|
100
92
|
}
|
|
101
|
-
// @ts-ignore
|
|
102
93
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
103
94
|
}
|
|
104
95
|
/**
|
|
105
96
|
* 获取颜色变亮
|
|
106
97
|
* @param color 颜色
|
|
107
98
|
* @param level 0~1.0
|
|
108
|
-
* @returns
|
|
109
99
|
*/
|
|
110
100
|
getLightColor(color, level) {
|
|
111
101
|
if (!this.isHex(color)) {
|
|
112
|
-
|
|
113
|
-
throw new TypeError("输入错误的hex", color);
|
|
102
|
+
throw new TypeError("输入错误的hex:" + color);
|
|
114
103
|
}
|
|
115
104
|
let rgbc = this.hexToRgb(color);
|
|
116
105
|
for (let index = 0; index < 3; index++) {
|
|
117
|
-
// @ts-ignore
|
|
118
106
|
rgbc[index] = Math.floor((255 - rgbc[index]) * level + rgbc[index]);
|
|
119
107
|
}
|
|
120
|
-
// @ts-ignore
|
|
121
108
|
return this.rgbToHex(rgbc[0], rgbc[1], rgbc[2]);
|
|
122
109
|
}
|
|
123
110
|
}
|
|
@@ -205,20 +192,20 @@ define((function () { 'use strict';
|
|
|
205
192
|
* @param str
|
|
206
193
|
*/
|
|
207
194
|
decode(str) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
195
|
+
let GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
|
|
196
|
+
let UTFMatcher = /%[0-9A-F]{2}/;
|
|
197
|
+
// let gbk = true;
|
|
198
|
+
let utf = true;
|
|
199
|
+
const that = this;
|
|
213
200
|
while (utf) {
|
|
214
201
|
let gbkMatch = str.match(GBKMatcher);
|
|
215
202
|
let utfMatch = str.match(UTFMatcher);
|
|
203
|
+
// gbk = Boolean(gbkMatch);
|
|
216
204
|
utf = Boolean(utfMatch);
|
|
217
205
|
if (gbkMatch && gbkMatch in that.#G2Uhash) {
|
|
218
206
|
str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
|
|
219
207
|
}
|
|
220
208
|
else {
|
|
221
|
-
// @ts-ignore
|
|
222
209
|
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
223
210
|
}
|
|
224
211
|
}
|
|
@@ -249,7 +236,6 @@ define((function () { 'use strict';
|
|
|
249
236
|
* @param handler
|
|
250
237
|
*/
|
|
251
238
|
error(handler) {
|
|
252
|
-
// @ts-ignore
|
|
253
239
|
handleError = handler;
|
|
254
240
|
return TryCatchCore;
|
|
255
241
|
},
|
|
@@ -264,8 +250,9 @@ define((function () { 'use strict';
|
|
|
264
250
|
callbackFunction = callback;
|
|
265
251
|
context = __context__ || this;
|
|
266
252
|
let result = executeTryCatch(callbackFunction, handleError, context);
|
|
267
|
-
|
|
268
|
-
|
|
253
|
+
return result !== void 0
|
|
254
|
+
? result
|
|
255
|
+
: TryCatchCore;
|
|
269
256
|
},
|
|
270
257
|
};
|
|
271
258
|
/**
|
|
@@ -748,13 +735,13 @@ define((function () { 'use strict';
|
|
|
748
735
|
// ==UserScript==
|
|
749
736
|
// @name ajaxHooker
|
|
750
737
|
// @author cxxjackie
|
|
751
|
-
// @version 1.4.
|
|
738
|
+
// @version 1.4.7
|
|
752
739
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
753
740
|
// @license GNU LGPL-3.0
|
|
754
741
|
// ==/UserScript==
|
|
755
742
|
|
|
756
743
|
const ajaxHooker = function () {
|
|
757
|
-
const version = "1.4.
|
|
744
|
+
const version = "1.4.7";
|
|
758
745
|
const hookInst = {
|
|
759
746
|
hookFns: [],
|
|
760
747
|
filters: [],
|
|
@@ -764,20 +751,18 @@ define((function () { 'use strict';
|
|
|
764
751
|
const resProto = win.Response.prototype;
|
|
765
752
|
const xhrResponses = ["response", "responseText", "responseXML"];
|
|
766
753
|
const fetchResponses = ["arrayBuffer", "blob", "formData", "json", "text"];
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
"headers",
|
|
770
|
-
"body",
|
|
771
|
-
"mode",
|
|
772
|
-
"credentials",
|
|
754
|
+
const xhrExtraProps = ["responseType", "timeout", "withCredentials"];
|
|
755
|
+
const fetchExtraProps = [
|
|
773
756
|
"cache",
|
|
757
|
+
"credentials",
|
|
758
|
+
"integrity",
|
|
759
|
+
"keepalive",
|
|
760
|
+
"mode",
|
|
761
|
+
"priority",
|
|
774
762
|
"redirect",
|
|
775
763
|
"referrer",
|
|
776
764
|
"referrerPolicy",
|
|
777
|
-
"integrity",
|
|
778
|
-
"keepalive",
|
|
779
765
|
"signal",
|
|
780
|
-
"priority",
|
|
781
766
|
];
|
|
782
767
|
const xhrAsyncEvents = ["readystatechange", "load", "loadend"];
|
|
783
768
|
const getType = {}.toString.call.bind({}.toString);
|
|
@@ -855,6 +840,10 @@ define((function () { 'use strict';
|
|
|
855
840
|
this.request = request;
|
|
856
841
|
this.requestClone = { ...this.request };
|
|
857
842
|
}
|
|
843
|
+
_recoverRequestKey(key) {
|
|
844
|
+
if (key in this.requestClone) this.request[key] = this.requestClone[key];
|
|
845
|
+
else delete this.request[key];
|
|
846
|
+
}
|
|
858
847
|
shouldFilter(filters) {
|
|
859
848
|
const { type, url, method, async } = this.request;
|
|
860
849
|
return (
|
|
@@ -875,7 +864,6 @@ define((function () { 'use strict';
|
|
|
875
864
|
);
|
|
876
865
|
}
|
|
877
866
|
waitForRequestKeys() {
|
|
878
|
-
const requestKeys = ["url", "method", "abort", "headers", "data"];
|
|
879
867
|
if (!this.request.async) {
|
|
880
868
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
881
869
|
if (this.shouldFilter(filters)) return;
|
|
@@ -883,27 +871,31 @@ define((function () { 'use strict';
|
|
|
883
871
|
if (getType(fn) === "[object Function]")
|
|
884
872
|
catchError(fn, this.request);
|
|
885
873
|
});
|
|
886
|
-
|
|
887
|
-
if (isThenable(this.request[key]))
|
|
888
|
-
|
|
889
|
-
});
|
|
874
|
+
for (const key in this.request) {
|
|
875
|
+
if (isThenable(this.request[key])) this._recoverRequestKey(key);
|
|
876
|
+
}
|
|
890
877
|
});
|
|
891
878
|
return new SyncThenable();
|
|
892
879
|
}
|
|
893
880
|
const promises = [];
|
|
881
|
+
const ignoreKeys = new Set(["type", "async", "response"]);
|
|
894
882
|
win.__ajaxHooker.hookInsts.forEach(({ hookFns, filters }) => {
|
|
895
883
|
if (this.shouldFilter(filters)) return;
|
|
896
884
|
promises.push(
|
|
897
885
|
Promise.all(hookFns.map((fn) => catchError(fn, this.request))).then(
|
|
898
|
-
() =>
|
|
899
|
-
|
|
886
|
+
() => {
|
|
887
|
+
const requestKeys = [];
|
|
888
|
+
for (const key in this.request)
|
|
889
|
+
!ignoreKeys.has(key) && requestKeys.push(key);
|
|
890
|
+
return Promise.all(
|
|
900
891
|
requestKeys.map((key) =>
|
|
901
892
|
Promise.resolve(this.request[key]).then(
|
|
902
893
|
(val) => (this.request[key] = val),
|
|
903
|
-
() =>
|
|
894
|
+
() => this._recoverRequestKey(key)
|
|
904
895
|
)
|
|
905
896
|
)
|
|
906
|
-
)
|
|
897
|
+
);
|
|
898
|
+
}
|
|
907
899
|
)
|
|
908
900
|
);
|
|
909
901
|
});
|
|
@@ -1084,6 +1076,7 @@ define((function () { 'use strict';
|
|
|
1084
1076
|
e.stopImmediatePropagation = stopImmediatePropagation;
|
|
1085
1077
|
defineProp(e, "target", () => this.proxyXhr);
|
|
1086
1078
|
defineProp(e, "currentTarget", () => this.proxyXhr);
|
|
1079
|
+
defineProp(e, "srcElement", () => this.proxyXhr);
|
|
1087
1080
|
this.proxyEvents[e.type] &&
|
|
1088
1081
|
this.proxyEvents[e.type].forEach((fn) => {
|
|
1089
1082
|
this.resThenable.then(
|
|
@@ -1161,6 +1154,9 @@ define((function () { 'use strict';
|
|
|
1161
1154
|
for (const header in request.headers) {
|
|
1162
1155
|
xhr.setRequestHeader(header, request.headers[header]);
|
|
1163
1156
|
}
|
|
1157
|
+
for (const prop of xhrExtraProps) {
|
|
1158
|
+
if (prop in request) xhr[prop] = request[prop];
|
|
1159
|
+
}
|
|
1164
1160
|
xhr.send(request.data);
|
|
1165
1161
|
}
|
|
1166
1162
|
});
|
|
@@ -1182,8 +1178,10 @@ define((function () { 'use strict';
|
|
|
1182
1178
|
return new Promise(async (resolve, reject) => {
|
|
1183
1179
|
const init = {};
|
|
1184
1180
|
if (getType(url) === "[object Request]") {
|
|
1185
|
-
|
|
1181
|
+
init.method = url.method;
|
|
1182
|
+
init.headers = url.headers;
|
|
1186
1183
|
if (url.body) init.body = await url.arrayBuffer();
|
|
1184
|
+
for (const prop of fetchExtraProps) init[prop] = url[prop];
|
|
1187
1185
|
url = url.url;
|
|
1188
1186
|
}
|
|
1189
1187
|
url = url.toString();
|
|
@@ -1230,6 +1228,9 @@ define((function () { 'use strict';
|
|
|
1230
1228
|
init.method = request.method;
|
|
1231
1229
|
init.headers = request.headers;
|
|
1232
1230
|
init.body = request.data;
|
|
1231
|
+
for (const prop of fetchExtraProps) {
|
|
1232
|
+
if (prop in request) init[prop] = request[prop];
|
|
1233
|
+
}
|
|
1233
1234
|
winAh.realFetch.call(win, request.url, init).then((res) => {
|
|
1234
1235
|
if (typeof request.response === "function") {
|
|
1235
1236
|
const response = {
|
|
@@ -1935,25 +1936,24 @@ define((function () { 'use strict';
|
|
|
1935
1936
|
let defaultEnable = Boolean(this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable));
|
|
1936
1937
|
/** 油猴菜单上显示的文本 */
|
|
1937
1938
|
let showText = menuOption.showText(menuOption.text, defaultEnable);
|
|
1938
|
-
//
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
});
|
|
1939
|
+
// const GMMenuOptions = {
|
|
1940
|
+
// /**
|
|
1941
|
+
// * 菜单的id
|
|
1942
|
+
// */
|
|
1943
|
+
// id: menuOption.id,
|
|
1944
|
+
// /**
|
|
1945
|
+
// * 点击菜单项后是否应关闭弹出菜单
|
|
1946
|
+
// */
|
|
1947
|
+
// autoClose: menuOption.autoClose,
|
|
1948
|
+
// /**
|
|
1949
|
+
// * 菜单项的可选访问键
|
|
1950
|
+
// */
|
|
1951
|
+
// accessKey: menuOption.accessKey,
|
|
1952
|
+
// /**
|
|
1953
|
+
// * 菜单项的鼠标悬浮上的工具提示
|
|
1954
|
+
// */
|
|
1955
|
+
// title: menuOption.title,
|
|
1956
|
+
// };
|
|
1957
1957
|
/* 点击菜单后触发callback后的网页是否刷新 */
|
|
1958
1958
|
menuOption.autoReload =
|
|
1959
1959
|
typeof menuOption.autoReload !== "boolean"
|
|
@@ -2531,7 +2531,9 @@ define((function () { 'use strict';
|
|
|
2531
2531
|
* 对请求的参数进行合并处理
|
|
2532
2532
|
*/
|
|
2533
2533
|
handleBeforeRequestOptionArgs(...args) {
|
|
2534
|
-
let option = {
|
|
2534
|
+
let option = {
|
|
2535
|
+
url: void 0,
|
|
2536
|
+
};
|
|
2535
2537
|
if (typeof args[0] === "string") {
|
|
2536
2538
|
/* 传入的是url,转为配置 */
|
|
2537
2539
|
let url = args[0];
|
|
@@ -2555,7 +2557,7 @@ define((function () { 'use strict';
|
|
|
2555
2557
|
* @param method 当前请求方法,默认get
|
|
2556
2558
|
* @param userRequestOption 用户的请求配置
|
|
2557
2559
|
* @param resolve promise回调
|
|
2558
|
-
* @param reject 抛出错误回调
|
|
2560
|
+
* @param reject promise抛出错误回调
|
|
2559
2561
|
*/
|
|
2560
2562
|
getRequestOption(method, userRequestOption, resolve, reject) {
|
|
2561
2563
|
let that = this;
|
|
@@ -2613,25 +2615,25 @@ define((function () { 'use strict';
|
|
|
2613
2615
|
password: userRequestOption.password ||
|
|
2614
2616
|
this.context.#defaultRequestOption.password,
|
|
2615
2617
|
onabort(...args) {
|
|
2616
|
-
that.context.
|
|
2618
|
+
that.context.HttpxResponseCallBack.onAbort(userRequestOption, resolve, reject, args);
|
|
2617
2619
|
},
|
|
2618
2620
|
onerror(...args) {
|
|
2619
|
-
that.context.
|
|
2621
|
+
that.context.HttpxResponseCallBack.onError(userRequestOption, resolve, reject, args);
|
|
2620
2622
|
},
|
|
2621
2623
|
onloadstart(...args) {
|
|
2622
|
-
that.context.
|
|
2624
|
+
that.context.HttpxResponseCallBack.onLoadStart(userRequestOption, args);
|
|
2623
2625
|
},
|
|
2624
2626
|
onprogress(...args) {
|
|
2625
|
-
that.context.
|
|
2627
|
+
that.context.HttpxResponseCallBack.onProgress(userRequestOption, args);
|
|
2626
2628
|
},
|
|
2627
2629
|
onreadystatechange(...args) {
|
|
2628
|
-
that.context.
|
|
2630
|
+
that.context.HttpxResponseCallBack.onReadyStateChange(userRequestOption, args);
|
|
2629
2631
|
},
|
|
2630
2632
|
ontimeout(...args) {
|
|
2631
|
-
that.context.
|
|
2633
|
+
that.context.HttpxResponseCallBack.onTimeout(userRequestOption, resolve, reject, args);
|
|
2632
2634
|
},
|
|
2633
2635
|
onload(...args) {
|
|
2634
|
-
that.context.
|
|
2636
|
+
that.context.HttpxResponseCallBack.onLoad(userRequestOption, resolve, reject, args);
|
|
2635
2637
|
},
|
|
2636
2638
|
};
|
|
2637
2639
|
// 补全allowInterceptConfig参数
|
|
@@ -2743,7 +2745,6 @@ define((function () { 'use strict';
|
|
|
2743
2745
|
else if (typeof requestOption.data === "object") {
|
|
2744
2746
|
isHandler = true;
|
|
2745
2747
|
// URLSearchParams参数可以转普通的string:string,包括FormData
|
|
2746
|
-
// @ts-ignore
|
|
2747
2748
|
let searchParams = new URLSearchParams(requestOption.data);
|
|
2748
2749
|
urlSearch = searchParams.toString();
|
|
2749
2750
|
}
|
|
@@ -2798,9 +2799,7 @@ define((function () { 'use strict';
|
|
|
2798
2799
|
else if (ContentType.includes("application/x-www-form-urlencoded")) {
|
|
2799
2800
|
// application/x-www-form-urlencoded
|
|
2800
2801
|
if (typeof requestOption.data === "object") {
|
|
2801
|
-
requestOption.data = new URLSearchParams(
|
|
2802
|
-
// @ts-ignore
|
|
2803
|
-
requestOption.data).toString();
|
|
2802
|
+
requestOption.data = new URLSearchParams(requestOption.data).toString();
|
|
2804
2803
|
}
|
|
2805
2804
|
}
|
|
2806
2805
|
else if (ContentType.includes("multipart/form-data")) {
|
|
@@ -2820,7 +2819,7 @@ define((function () { 'use strict';
|
|
|
2820
2819
|
},
|
|
2821
2820
|
/**
|
|
2822
2821
|
* 处理发送请求的配置,去除值为undefined、空function的值
|
|
2823
|
-
* @param option
|
|
2822
|
+
* @param option 请求配置
|
|
2824
2823
|
*/
|
|
2825
2824
|
removeRequestNullOption(option) {
|
|
2826
2825
|
Object.keys(option).forEach((keyName) => {
|
|
@@ -2832,13 +2831,13 @@ define((function () { 'use strict';
|
|
|
2832
2831
|
}
|
|
2833
2832
|
});
|
|
2834
2833
|
if (commonUtil.isNull(option.url)) {
|
|
2835
|
-
throw new TypeError(`Utils.Httpx 参数
|
|
2834
|
+
throw new TypeError(`Utils.Httpx 参数url不能为空:${option.url}`);
|
|
2836
2835
|
}
|
|
2837
2836
|
return option;
|
|
2838
2837
|
},
|
|
2839
2838
|
/**
|
|
2840
2839
|
* 处理fetch的配置
|
|
2841
|
-
* @param option
|
|
2840
|
+
* @param option 请求配置
|
|
2842
2841
|
*/
|
|
2843
2842
|
handleFetchOption(option) {
|
|
2844
2843
|
/**
|
|
@@ -2891,21 +2890,21 @@ define((function () { 'use strict';
|
|
|
2891
2890
|
};
|
|
2892
2891
|
},
|
|
2893
2892
|
};
|
|
2894
|
-
|
|
2893
|
+
HttpxResponseCallBack = {
|
|
2895
2894
|
context: this,
|
|
2896
2895
|
/**
|
|
2897
2896
|
* onabort请求被取消-触发
|
|
2898
2897
|
* @param details 配置
|
|
2899
|
-
* @param resolve 回调
|
|
2900
|
-
* @param reject
|
|
2898
|
+
* @param resolve promise回调
|
|
2899
|
+
* @param reject promise抛出错误回调
|
|
2901
2900
|
* @param argsResult 返回的参数列表
|
|
2902
2901
|
*/
|
|
2903
2902
|
async onAbort(details, resolve, reject, argsResult) {
|
|
2904
2903
|
// console.log(argsResult);
|
|
2905
|
-
if (
|
|
2904
|
+
if (typeof details?.onabort === "function") {
|
|
2906
2905
|
details.onabort.apply(this, argsResult);
|
|
2907
2906
|
}
|
|
2908
|
-
else if (
|
|
2907
|
+
else if (typeof this.context.#defaultRequestOption?.onabort === "function") {
|
|
2909
2908
|
this.context.#defaultRequestOption.onabort.apply(this, argsResult);
|
|
2910
2909
|
}
|
|
2911
2910
|
let response = argsResult;
|
|
@@ -2914,11 +2913,11 @@ define((function () { 'use strict';
|
|
|
2914
2913
|
}
|
|
2915
2914
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2916
2915
|
type: "onabort",
|
|
2917
|
-
error: new
|
|
2916
|
+
error: new Error("request canceled"),
|
|
2918
2917
|
response: null,
|
|
2919
2918
|
details: details,
|
|
2920
2919
|
})) == null) {
|
|
2921
|
-
// reject(new
|
|
2920
|
+
// reject(new Error("response is intercept with onabort"));
|
|
2922
2921
|
return;
|
|
2923
2922
|
}
|
|
2924
2923
|
resolve({
|
|
@@ -2931,93 +2930,83 @@ define((function () { 'use strict';
|
|
|
2931
2930
|
});
|
|
2932
2931
|
},
|
|
2933
2932
|
/**
|
|
2934
|
-
*
|
|
2933
|
+
* ontimeout请求超时-触发
|
|
2935
2934
|
* @param details 配置
|
|
2936
2935
|
* @param resolve 回调
|
|
2937
2936
|
* @param reject 抛出错误
|
|
2938
2937
|
* @param argsResult 返回的参数列表
|
|
2939
2938
|
*/
|
|
2940
|
-
async
|
|
2939
|
+
async onTimeout(details, resolve, reject, argsResult) {
|
|
2941
2940
|
// console.log(argsResult);
|
|
2942
|
-
if ("
|
|
2943
|
-
|
|
2941
|
+
if (typeof details?.ontimeout === "function") {
|
|
2942
|
+
// 执行配置中的ontime回调
|
|
2943
|
+
details.ontimeout.apply(this, argsResult);
|
|
2944
2944
|
}
|
|
2945
|
-
else if (
|
|
2946
|
-
|
|
2945
|
+
else if (typeof this.context.#defaultRequestOption?.ontimeout === "function") {
|
|
2946
|
+
// 执行默认配置的ontime回调
|
|
2947
|
+
this.context.#defaultRequestOption.ontimeout.apply(this, argsResult);
|
|
2947
2948
|
}
|
|
2949
|
+
// 获取响应结果
|
|
2948
2950
|
let response = argsResult;
|
|
2949
2951
|
if (response.length) {
|
|
2950
2952
|
response = response[0];
|
|
2951
2953
|
}
|
|
2954
|
+
// 执行错误回调的钩子
|
|
2952
2955
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2953
|
-
type: "
|
|
2954
|
-
error: new
|
|
2956
|
+
type: "ontimeout",
|
|
2957
|
+
error: new Error("request timeout"),
|
|
2955
2958
|
response: response,
|
|
2956
2959
|
details: details,
|
|
2957
2960
|
})) == null) {
|
|
2958
|
-
// reject(new
|
|
2961
|
+
// reject(new Error("response is intercept with ontimeout"));
|
|
2959
2962
|
return;
|
|
2960
2963
|
}
|
|
2961
2964
|
resolve({
|
|
2962
2965
|
data: response,
|
|
2963
2966
|
details: details,
|
|
2964
|
-
msg: "
|
|
2967
|
+
msg: "请求超时",
|
|
2965
2968
|
status: false,
|
|
2966
|
-
statusCode:
|
|
2967
|
-
type: "
|
|
2969
|
+
statusCode: 0,
|
|
2970
|
+
type: "ontimeout",
|
|
2968
2971
|
});
|
|
2969
2972
|
},
|
|
2970
2973
|
/**
|
|
2971
|
-
*
|
|
2974
|
+
* onerror请求异常-触发
|
|
2972
2975
|
* @param details 配置
|
|
2973
2976
|
* @param resolve 回调
|
|
2974
2977
|
* @param reject 抛出错误
|
|
2975
2978
|
* @param argsResult 返回的参数列表
|
|
2976
2979
|
*/
|
|
2977
|
-
async
|
|
2980
|
+
async onError(details, resolve, reject, argsResult) {
|
|
2978
2981
|
// console.log(argsResult);
|
|
2979
|
-
if ("
|
|
2980
|
-
details.
|
|
2982
|
+
if (typeof details?.onerror === "function") {
|
|
2983
|
+
details.onerror.apply(this, argsResult);
|
|
2981
2984
|
}
|
|
2982
|
-
else if (
|
|
2983
|
-
this.context.#defaultRequestOption.
|
|
2985
|
+
else if (typeof this.context.#defaultRequestOption?.onerror === "function") {
|
|
2986
|
+
this.context.#defaultRequestOption.onerror.apply(this, argsResult);
|
|
2984
2987
|
}
|
|
2985
2988
|
let response = argsResult;
|
|
2986
2989
|
if (response.length) {
|
|
2987
2990
|
response = response[0];
|
|
2988
2991
|
}
|
|
2989
2992
|
if ((await this.context.HttpxResponseHook.errorResponseCallBack({
|
|
2990
|
-
type: "
|
|
2991
|
-
error: new
|
|
2992
|
-
response:
|
|
2993
|
+
type: "onerror",
|
|
2994
|
+
error: new Error("request error"),
|
|
2995
|
+
response: response,
|
|
2993
2996
|
details: details,
|
|
2994
2997
|
})) == null) {
|
|
2995
|
-
// reject(new
|
|
2998
|
+
// reject(new Error("response is intercept with onerror"));
|
|
2996
2999
|
return;
|
|
2997
3000
|
}
|
|
2998
3001
|
resolve({
|
|
2999
3002
|
data: response,
|
|
3000
3003
|
details: details,
|
|
3001
|
-
msg: "
|
|
3004
|
+
msg: "请求异常",
|
|
3002
3005
|
status: false,
|
|
3003
|
-
statusCode:
|
|
3004
|
-
type: "
|
|
3006
|
+
statusCode: response["status"],
|
|
3007
|
+
type: "onerror",
|
|
3005
3008
|
});
|
|
3006
3009
|
},
|
|
3007
|
-
/**
|
|
3008
|
-
* onloadstart请求开始-触发
|
|
3009
|
-
* @param details 配置
|
|
3010
|
-
* @param argsResult 返回的参数列表
|
|
3011
|
-
*/
|
|
3012
|
-
onLoadStart(details, argsResult) {
|
|
3013
|
-
// console.log(argsResult);
|
|
3014
|
-
if ("onloadstart" in details) {
|
|
3015
|
-
details.onloadstart.apply(this, argsResult);
|
|
3016
|
-
}
|
|
3017
|
-
else if ("onloadstart" in this.context.#defaultRequestOption) {
|
|
3018
|
-
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3019
|
-
}
|
|
3020
|
-
},
|
|
3021
3010
|
/**
|
|
3022
3011
|
* onload加载完毕-触发
|
|
3023
3012
|
* @param details 请求的配置
|
|
@@ -3097,7 +3086,7 @@ define((function () { 'use strict';
|
|
|
3097
3086
|
/* 状态码2xx都是成功的 */
|
|
3098
3087
|
if (Math.floor(originResponse.status / 100) === 2) {
|
|
3099
3088
|
if ((await this.context.HttpxResponseHook.successResponseCallBack(originResponse, details)) == null) {
|
|
3100
|
-
// reject(new
|
|
3089
|
+
// reject(new Error("response is intercept with onloada"));
|
|
3101
3090
|
return;
|
|
3102
3091
|
}
|
|
3103
3092
|
resolve({
|
|
@@ -3110,21 +3099,21 @@ define((function () { 'use strict';
|
|
|
3110
3099
|
});
|
|
3111
3100
|
}
|
|
3112
3101
|
else {
|
|
3113
|
-
this.context.
|
|
3102
|
+
this.context.HttpxResponseCallBack.onError(details, resolve, reject, argsResult);
|
|
3114
3103
|
}
|
|
3115
3104
|
},
|
|
3116
3105
|
/**
|
|
3117
|
-
*
|
|
3106
|
+
* onloadstart请求开始-触发
|
|
3118
3107
|
* @param details 配置
|
|
3119
3108
|
* @param argsResult 返回的参数列表
|
|
3120
3109
|
*/
|
|
3121
|
-
|
|
3110
|
+
onLoadStart(details, argsResult) {
|
|
3122
3111
|
// console.log(argsResult);
|
|
3123
|
-
if ("
|
|
3124
|
-
details.
|
|
3112
|
+
if (typeof details?.onloadstart === "function") {
|
|
3113
|
+
details.onloadstart.apply(this, argsResult);
|
|
3125
3114
|
}
|
|
3126
|
-
else if (
|
|
3127
|
-
this.context.#defaultRequestOption.
|
|
3115
|
+
else if (typeof this.context.#defaultRequestOption?.onloadstart === "function") {
|
|
3116
|
+
this.context.#defaultRequestOption.onloadstart.apply(this, argsResult);
|
|
3128
3117
|
}
|
|
3129
3118
|
},
|
|
3130
3119
|
/**
|
|
@@ -3134,13 +3123,28 @@ define((function () { 'use strict';
|
|
|
3134
3123
|
*/
|
|
3135
3124
|
onReadyStateChange(details, argsResult) {
|
|
3136
3125
|
// console.log(argsResult);
|
|
3137
|
-
if (
|
|
3126
|
+
if (typeof details?.onreadystatechange === "function") {
|
|
3138
3127
|
details.onreadystatechange.apply(this, argsResult);
|
|
3139
3128
|
}
|
|
3140
|
-
else if (
|
|
3129
|
+
else if (typeof this.context.#defaultRequestOption?.onreadystatechange ===
|
|
3130
|
+
"function") {
|
|
3141
3131
|
this.context.#defaultRequestOption.onreadystatechange.apply(this, argsResult);
|
|
3142
3132
|
}
|
|
3143
3133
|
},
|
|
3134
|
+
/**
|
|
3135
|
+
* onprogress上传进度-触发
|
|
3136
|
+
* @param details 配置
|
|
3137
|
+
* @param argsResult 返回的参数列表
|
|
3138
|
+
*/
|
|
3139
|
+
onProgress(details, argsResult) {
|
|
3140
|
+
// console.log(argsResult);
|
|
3141
|
+
if (typeof details?.onprogress === "function") {
|
|
3142
|
+
details.onprogress.apply(this, argsResult);
|
|
3143
|
+
}
|
|
3144
|
+
else if (typeof this.context.#defaultRequestOption?.onprogress === "function") {
|
|
3145
|
+
this.context.#defaultRequestOption.onprogress.apply(this, argsResult);
|
|
3146
|
+
}
|
|
3147
|
+
},
|
|
3144
3148
|
};
|
|
3145
3149
|
HttpxRequest = {
|
|
3146
3150
|
context: this,
|
|
@@ -3190,15 +3194,12 @@ define((function () { 'use strict';
|
|
|
3190
3194
|
isFetch: true,
|
|
3191
3195
|
finalUrl: fetchResponse.url,
|
|
3192
3196
|
readyState: 4,
|
|
3193
|
-
// @ts-ignore
|
|
3194
3197
|
status: fetchResponse.status,
|
|
3195
3198
|
statusText: fetchResponse.statusText,
|
|
3196
|
-
|
|
3197
|
-
response: void 0,
|
|
3199
|
+
response: "",
|
|
3198
3200
|
responseFetchHeaders: fetchResponse.headers,
|
|
3199
3201
|
responseHeaders: "",
|
|
3200
|
-
|
|
3201
|
-
responseText: void 0,
|
|
3202
|
+
responseText: "",
|
|
3202
3203
|
responseType: option.responseType,
|
|
3203
3204
|
responseXML: void 0,
|
|
3204
3205
|
};
|
|
@@ -3271,9 +3272,9 @@ define((function () { 'use strict';
|
|
|
3271
3272
|
// 转为XML结构
|
|
3272
3273
|
let parser = new DOMParser();
|
|
3273
3274
|
responseXML = parser.parseFromString(responseText, "text/xml");
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3275
|
+
httpxResponse.response = response;
|
|
3276
|
+
httpxResponse.responseText = responseText;
|
|
3277
|
+
httpxResponse.responseXML = responseXML;
|
|
3277
3278
|
// 执行回调
|
|
3278
3279
|
option.onload(httpxResponse);
|
|
3279
3280
|
})
|
|
@@ -3454,7 +3455,7 @@ define((function () { 'use strict';
|
|
|
3454
3455
|
}
|
|
3455
3456
|
/**
|
|
3456
3457
|
* GET 请求
|
|
3457
|
-
* @param url
|
|
3458
|
+
* @param url 请求的url
|
|
3458
3459
|
* @param details 配置
|
|
3459
3460
|
*/
|
|
3460
3461
|
get(...args) {
|
|
@@ -3520,27 +3521,22 @@ define((function () { 'use strict';
|
|
|
3520
3521
|
/** 取消请求 */
|
|
3521
3522
|
let abortFn = null;
|
|
3522
3523
|
let promise = new globalThis.Promise(async (resolve, reject) => {
|
|
3523
|
-
let requestOption = this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject);
|
|
3524
|
+
let requestOption = (this.HttpxRequestOption.getRequestOption(useRequestOption.method, useRequestOption, resolve, reject));
|
|
3524
3525
|
if (typeof beforeRequestOption === "function") {
|
|
3525
|
-
// @ts-ignore
|
|
3526
3526
|
beforeRequestOption(requestOption);
|
|
3527
3527
|
}
|
|
3528
|
-
|
|
3529
|
-
requestOption =
|
|
3530
|
-
this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3528
|
+
requestOption = this.HttpxRequestOption.removeRequestNullOption(requestOption);
|
|
3531
3529
|
const requestResult = await this.HttpxRequest.request(requestOption);
|
|
3532
3530
|
if (requestResult != null &&
|
|
3533
3531
|
typeof requestResult.abort === "function") {
|
|
3534
3532
|
abortFn = requestResult.abort;
|
|
3535
3533
|
}
|
|
3536
3534
|
});
|
|
3537
|
-
// @ts-ignore
|
|
3538
3535
|
promise.abort = () => {
|
|
3539
3536
|
if (typeof abortFn === "function") {
|
|
3540
3537
|
abortFn();
|
|
3541
3538
|
}
|
|
3542
3539
|
};
|
|
3543
|
-
// @ts-ignore
|
|
3544
3540
|
return promise;
|
|
3545
3541
|
}
|
|
3546
3542
|
}
|
|
@@ -3550,8 +3546,7 @@ define((function () { 'use strict';
|
|
|
3550
3546
|
#storeName;
|
|
3551
3547
|
#dbVersion;
|
|
3552
3548
|
/* websql的版本号,由于ios的问题,版本号的写法不一样 */
|
|
3553
|
-
//
|
|
3554
|
-
#slqVersion = "1";
|
|
3549
|
+
// #slqVersion = "1";
|
|
3555
3550
|
/* 监听IndexDB */
|
|
3556
3551
|
#indexedDB = window.indexedDB ||
|
|
3557
3552
|
window.mozIndexedDB ||
|
|
@@ -3559,8 +3554,7 @@ define((function () { 'use strict';
|
|
|
3559
3554
|
window.msIndexedDB;
|
|
3560
3555
|
/* 缓存数据库,避免同一个页面重复创建和销毁 */
|
|
3561
3556
|
#db = {};
|
|
3562
|
-
//
|
|
3563
|
-
#store = null;
|
|
3557
|
+
// #store: IDBObjectStore = null as any;
|
|
3564
3558
|
/** 状态码 */
|
|
3565
3559
|
#statusCode = {
|
|
3566
3560
|
operationSuccess: {
|
|
@@ -3605,7 +3599,7 @@ define((function () { 'use strict';
|
|
|
3605
3599
|
txn = this.#db[dbName].transaction(this.#storeName, "readwrite");
|
|
3606
3600
|
/* IndexDB的读写权限 */
|
|
3607
3601
|
store = txn.objectStore(this.#storeName);
|
|
3608
|
-
this.#store = store;
|
|
3602
|
+
// this.#store = store;
|
|
3609
3603
|
return store;
|
|
3610
3604
|
}
|
|
3611
3605
|
/**
|
|
@@ -4330,12 +4324,40 @@ define((function () { 'use strict';
|
|
|
4330
4324
|
}
|
|
4331
4325
|
|
|
4332
4326
|
class UtilsDictionary {
|
|
4333
|
-
items
|
|
4327
|
+
items;
|
|
4334
4328
|
constructor(key, value) {
|
|
4329
|
+
this.items = {};
|
|
4335
4330
|
if (key != null) {
|
|
4336
4331
|
this.set(key, value);
|
|
4337
4332
|
}
|
|
4338
4333
|
}
|
|
4334
|
+
/**
|
|
4335
|
+
* 获取字典的长度,同this.size
|
|
4336
|
+
*/
|
|
4337
|
+
get length() {
|
|
4338
|
+
return this.size();
|
|
4339
|
+
}
|
|
4340
|
+
/**
|
|
4341
|
+
* 迭代器
|
|
4342
|
+
*/
|
|
4343
|
+
get entries() {
|
|
4344
|
+
let that = this;
|
|
4345
|
+
return function* () {
|
|
4346
|
+
let itemKeys = Object.keys(that.getItems());
|
|
4347
|
+
for (const keyName of itemKeys) {
|
|
4348
|
+
yield [keyName, that.get(keyName)];
|
|
4349
|
+
}
|
|
4350
|
+
};
|
|
4351
|
+
}
|
|
4352
|
+
/**
|
|
4353
|
+
* 是否可遍历
|
|
4354
|
+
*/
|
|
4355
|
+
get [Symbol.iterator]() {
|
|
4356
|
+
let that = this;
|
|
4357
|
+
return function () {
|
|
4358
|
+
return that.entries();
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4339
4361
|
/**
|
|
4340
4362
|
* 检查是否有某一个键
|
|
4341
4363
|
* @param key 键
|
|
@@ -4436,7 +4458,6 @@ define((function () { 'use strict';
|
|
|
4436
4458
|
* 返回字典本身
|
|
4437
4459
|
*/
|
|
4438
4460
|
getItems() {
|
|
4439
|
-
// @ts-ignore
|
|
4440
4461
|
return this.items;
|
|
4441
4462
|
}
|
|
4442
4463
|
/**
|
|
@@ -4446,38 +4467,15 @@ define((function () { 'use strict';
|
|
|
4446
4467
|
concat(data) {
|
|
4447
4468
|
this.items = commonUtil.assign(this.items, data.getItems());
|
|
4448
4469
|
}
|
|
4470
|
+
/**
|
|
4471
|
+
* 迭代字典
|
|
4472
|
+
* @param callbackfn 回调函数
|
|
4473
|
+
*/
|
|
4449
4474
|
forEach(callbackfn) {
|
|
4450
4475
|
for (const key in this.getItems()) {
|
|
4451
4476
|
callbackfn(this.get(key), key, this.getItems());
|
|
4452
4477
|
}
|
|
4453
4478
|
}
|
|
4454
|
-
/**
|
|
4455
|
-
* 获取字典的长度,同this.size
|
|
4456
|
-
*/
|
|
4457
|
-
get length() {
|
|
4458
|
-
return this.size();
|
|
4459
|
-
}
|
|
4460
|
-
/**
|
|
4461
|
-
* 迭代器
|
|
4462
|
-
*/
|
|
4463
|
-
get entries() {
|
|
4464
|
-
let that = this;
|
|
4465
|
-
return function* () {
|
|
4466
|
-
let itemKeys = Object.keys(that.getItems());
|
|
4467
|
-
for (const keyName of itemKeys) {
|
|
4468
|
-
yield [keyName, that.get(keyName)];
|
|
4469
|
-
}
|
|
4470
|
-
};
|
|
4471
|
-
}
|
|
4472
|
-
/**
|
|
4473
|
-
* 是否可遍历
|
|
4474
|
-
*/
|
|
4475
|
-
get [Symbol.iterator]() {
|
|
4476
|
-
let that = this;
|
|
4477
|
-
return function () {
|
|
4478
|
-
return that.entries();
|
|
4479
|
-
};
|
|
4480
|
-
}
|
|
4481
4479
|
}
|
|
4482
4480
|
|
|
4483
4481
|
class WindowApi {
|
|
@@ -4503,7 +4501,6 @@ define((function () { 'use strict';
|
|
|
4503
4501
|
if (!option) {
|
|
4504
4502
|
option = Object.assign({}, this.defaultApi);
|
|
4505
4503
|
}
|
|
4506
|
-
// @ts-ignore
|
|
4507
4504
|
this.api = Object.assign({}, option);
|
|
4508
4505
|
}
|
|
4509
4506
|
get document() {
|
|
@@ -4561,11 +4558,10 @@ define((function () { 'use strict';
|
|
|
4561
4558
|
deps = [];
|
|
4562
4559
|
active = true;
|
|
4563
4560
|
fn;
|
|
4564
|
-
//
|
|
4565
|
-
scheduler;
|
|
4561
|
+
// private scheduler;
|
|
4566
4562
|
constructor(fn, scheduler) {
|
|
4567
4563
|
this.fn = fn;
|
|
4568
|
-
this.scheduler = scheduler;
|
|
4564
|
+
// this.scheduler = scheduler;
|
|
4569
4565
|
}
|
|
4570
4566
|
run(cb) {
|
|
4571
4567
|
if (!this.active) {
|
|
@@ -4632,8 +4628,7 @@ define((function () { 'use strict';
|
|
|
4632
4628
|
reactive(target) {
|
|
4633
4629
|
const that = this;
|
|
4634
4630
|
if (!(typeof target === "object" && target !== null)) {
|
|
4635
|
-
|
|
4636
|
-
return;
|
|
4631
|
+
return void 0;
|
|
4637
4632
|
}
|
|
4638
4633
|
if (VueUtils.isReactive(target)) {
|
|
4639
4634
|
return target;
|
|
@@ -4703,7 +4698,6 @@ define((function () { 'use strict';
|
|
|
4703
4698
|
toRefs(object) {
|
|
4704
4699
|
const result = VueUtils.isArray(object) ? new Array(object.length) : {};
|
|
4705
4700
|
for (let key in object) {
|
|
4706
|
-
// @ts-ignore
|
|
4707
4701
|
result[key] = this.toRef(object, key);
|
|
4708
4702
|
}
|
|
4709
4703
|
return result;
|
|
@@ -4999,7 +4993,7 @@ define((function () { 'use strict';
|
|
|
4999
4993
|
};
|
|
5000
4994
|
|
|
5001
4995
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
5002
|
-
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),
|
|
4996
|
+
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
|
|
5003
4997
|
|
|
5004
4998
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
5005
4999
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -5431,7 +5425,6 @@ define((function () { 'use strict';
|
|
|
5431
5425
|
let text = textMatch[2];
|
|
5432
5426
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5433
5427
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5434
|
-
// @ts-ignore
|
|
5435
5428
|
return ($ele?.textContent || $ele?.innerText)?.includes(text);
|
|
5436
5429
|
});
|
|
5437
5430
|
}
|
|
@@ -5449,7 +5442,6 @@ define((function () { 'use strict';
|
|
|
5449
5442
|
let regexp = new RegExp(pattern, flags);
|
|
5450
5443
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5451
5444
|
return Array.from(parent.querySelectorAll(selector)).filter(($ele) => {
|
|
5452
|
-
// @ts-ignore
|
|
5453
5445
|
return Boolean(($ele?.textContent || $ele?.innerText)?.match(regexp));
|
|
5454
5446
|
});
|
|
5455
5447
|
}
|
|
@@ -5495,7 +5487,6 @@ define((function () { 'use strict';
|
|
|
5495
5487
|
let textMatch = selector.match(/:contains\(("|')(.*)("|')\)$/i);
|
|
5496
5488
|
let text = textMatch[2];
|
|
5497
5489
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5498
|
-
// @ts-ignore
|
|
5499
5490
|
let content = $el?.textContent || $el?.innerText;
|
|
5500
5491
|
if (typeof content !== "string") {
|
|
5501
5492
|
content = "";
|
|
@@ -5515,7 +5506,6 @@ define((function () { 'use strict';
|
|
|
5515
5506
|
}
|
|
5516
5507
|
let regexp = new RegExp(pattern, flags);
|
|
5517
5508
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5518
|
-
// @ts-ignore
|
|
5519
5509
|
let content = $el?.textContent || $el?.innerText;
|
|
5520
5510
|
if (typeof content !== "string") {
|
|
5521
5511
|
content = "";
|
|
@@ -5546,7 +5536,6 @@ define((function () { 'use strict';
|
|
|
5546
5536
|
selector = selector.replace(/:contains\(("|')(.*)("|')\)$/gi, "");
|
|
5547
5537
|
let $closest = $el?.closest(selector);
|
|
5548
5538
|
if ($closest) {
|
|
5549
|
-
// @ts-ignore
|
|
5550
5539
|
let content = $el?.textContent || $el?.innerText;
|
|
5551
5540
|
if (typeof content === "string" && content.includes(text)) {
|
|
5552
5541
|
return $closest;
|
|
@@ -5569,7 +5558,6 @@ define((function () { 'use strict';
|
|
|
5569
5558
|
selector = selector.replace(/:regexp\(("|')(.*)("|')\)$/gi, "");
|
|
5570
5559
|
let $closest = $el?.closest(selector);
|
|
5571
5560
|
if ($closest) {
|
|
5572
|
-
// @ts-ignore
|
|
5573
5561
|
let content = $el?.textContent || $el?.innerText;
|
|
5574
5562
|
if (typeof content === "string" && content.match(regexp)) {
|
|
5575
5563
|
return $closest;
|
|
@@ -5592,7 +5580,7 @@ define((function () { 'use strict';
|
|
|
5592
5580
|
this.windowApi = new WindowApi(option);
|
|
5593
5581
|
}
|
|
5594
5582
|
/** 版本号 */
|
|
5595
|
-
version = "2025.
|
|
5583
|
+
version = "2025.7.29";
|
|
5596
5584
|
addStyle(cssText) {
|
|
5597
5585
|
if (typeof cssText !== "string") {
|
|
5598
5586
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5676,7 +5664,7 @@ define((function () { 'use strict';
|
|
|
5676
5664
|
* ajax劫持库,支持xhr和fetch劫持。
|
|
5677
5665
|
* + 来源:https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
5678
5666
|
* + 作者:cxxjackie
|
|
5679
|
-
* + 版本:1.4.
|
|
5667
|
+
* + 版本:1.4.7
|
|
5680
5668
|
* + 旧版本:1.2.4
|
|
5681
5669
|
* + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
|
|
5682
5670
|
* @param useOldVersion 是否使用旧版本,默认false
|
|
@@ -5689,7 +5677,7 @@ define((function () { 'use strict';
|
|
|
5689
5677
|
return ajaxHooker();
|
|
5690
5678
|
}
|
|
5691
5679
|
};
|
|
5692
|
-
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view =
|
|
5680
|
+
canvasClickByPosition(canvasElement, clientX = 0, clientY = 0, view = this.windowApi.window) {
|
|
5693
5681
|
if (!(canvasElement instanceof HTMLCanvasElement)) {
|
|
5694
5682
|
throw new Error("Utils.canvasClickByPosition 参数canvasElement必须是canvas元素");
|
|
5695
5683
|
}
|
|
@@ -5700,7 +5688,6 @@ define((function () { 'use strict';
|
|
|
5700
5688
|
cancelable: true,
|
|
5701
5689
|
clientX: clientX,
|
|
5702
5690
|
clientY: clientY,
|
|
5703
|
-
// @ts-ignore
|
|
5704
5691
|
view: view,
|
|
5705
5692
|
detail: 1,
|
|
5706
5693
|
};
|
|
@@ -6207,12 +6194,10 @@ define((function () { 'use strict';
|
|
|
6207
6194
|
}
|
|
6208
6195
|
getElementSelector(element) {
|
|
6209
6196
|
let UtilsContext = this;
|
|
6210
|
-
// @ts-ignore
|
|
6211
6197
|
if (!element)
|
|
6212
|
-
return;
|
|
6213
|
-
// @ts-ignore
|
|
6198
|
+
return void 0;
|
|
6214
6199
|
if (!element.parentElement)
|
|
6215
|
-
return;
|
|
6200
|
+
return void 0;
|
|
6216
6201
|
/* 如果元素有id属性,则直接返回id选择器 */
|
|
6217
6202
|
if (element.id)
|
|
6218
6203
|
return "#" + element.id;
|
|
@@ -6243,8 +6228,7 @@ define((function () { 'use strict';
|
|
|
6243
6228
|
let result = [...args];
|
|
6244
6229
|
let newResult = [];
|
|
6245
6230
|
if (result.length === 0) {
|
|
6246
|
-
|
|
6247
|
-
return;
|
|
6231
|
+
return void 0;
|
|
6248
6232
|
}
|
|
6249
6233
|
if (result.length > 1) {
|
|
6250
6234
|
if (result.length === 2 &&
|
|
@@ -6284,7 +6268,6 @@ define((function () { 'use strict';
|
|
|
6284
6268
|
// 当前页面最大的z-index
|
|
6285
6269
|
let zIndex = 0;
|
|
6286
6270
|
// 当前的最大z-index的元素,调试使用
|
|
6287
|
-
// @ts-ignore
|
|
6288
6271
|
let maxZIndexNode = null;
|
|
6289
6272
|
/**
|
|
6290
6273
|
* 元素是否可见
|
|
@@ -6345,8 +6328,7 @@ define((function () { 'use strict';
|
|
|
6345
6328
|
let result = [...args];
|
|
6346
6329
|
let newResult = [];
|
|
6347
6330
|
if (result.length === 0) {
|
|
6348
|
-
|
|
6349
|
-
return;
|
|
6331
|
+
return void 0;
|
|
6350
6332
|
}
|
|
6351
6333
|
if (result.length > 1) {
|
|
6352
6334
|
if (result.length === 2 &&
|
|
@@ -6820,7 +6802,6 @@ define((function () { 'use strict';
|
|
|
6820
6802
|
}
|
|
6821
6803
|
isJQuery(target) {
|
|
6822
6804
|
let result = false;
|
|
6823
|
-
// @ts-ignore
|
|
6824
6805
|
if (typeof jQuery === "object" && target instanceof jQuery) {
|
|
6825
6806
|
result = true;
|
|
6826
6807
|
}
|
|
@@ -7601,29 +7582,27 @@ define((function () { 'use strict';
|
|
|
7601
7582
|
EventTarget.prototype.addEventListener = function (...args) {
|
|
7602
7583
|
let type = args[0];
|
|
7603
7584
|
let callback = args[1];
|
|
7604
|
-
//
|
|
7605
|
-
args[2];
|
|
7585
|
+
// let options = args[2];
|
|
7606
7586
|
if (filter(type)) {
|
|
7607
7587
|
if (typeof callback === "function") {
|
|
7608
7588
|
args[1] = function (event) {
|
|
7609
7589
|
callback.call(this, trustEvent(event));
|
|
7610
7590
|
};
|
|
7611
7591
|
}
|
|
7612
|
-
else if (typeof callback === "object" &&
|
|
7613
|
-
"handleEvent" in callback) {
|
|
7592
|
+
else if (typeof callback === "object" && "handleEvent" in callback) {
|
|
7614
7593
|
let oldHandleEvent = callback["handleEvent"];
|
|
7615
7594
|
args[1]["handleEvent"] = function (event) {
|
|
7616
7595
|
if (event == null) {
|
|
7617
7596
|
return;
|
|
7618
7597
|
}
|
|
7619
7598
|
try {
|
|
7620
|
-
|
|
7599
|
+
// Proxy对象使用instanceof会报错
|
|
7600
|
+
// 这里故意尝试一下,如果报错,则说明是Proxy对象
|
|
7621
7601
|
event instanceof Proxy;
|
|
7622
7602
|
oldHandleEvent.call(this, trustEvent(event));
|
|
7623
7603
|
}
|
|
7624
7604
|
catch (error) {
|
|
7625
|
-
|
|
7626
|
-
event["isTrusted"] = isTrustValue;
|
|
7605
|
+
Reflect.set(event, "isTrusted", isTrustValue);
|
|
7627
7606
|
}
|
|
7628
7607
|
};
|
|
7629
7608
|
}
|
|
@@ -7696,8 +7675,8 @@ define((function () { 'use strict';
|
|
|
7696
7675
|
}
|
|
7697
7676
|
async init() {
|
|
7698
7677
|
let copyStatus = false;
|
|
7699
|
-
|
|
7700
|
-
|
|
7678
|
+
let requestPermissionStatus = await this.requestClipboardPermission();
|
|
7679
|
+
console.log(requestPermissionStatus);
|
|
7701
7680
|
if (this.hasClipboard() &&
|
|
7702
7681
|
(this.hasClipboardWrite() || this.hasClipboardWriteText())) {
|
|
7703
7682
|
try {
|
|
@@ -7715,11 +7694,8 @@ define((function () { 'use strict';
|
|
|
7715
7694
|
this.destroy();
|
|
7716
7695
|
}
|
|
7717
7696
|
destroy() {
|
|
7718
|
-
// @ts-ignore
|
|
7719
7697
|
this.#resolve = null;
|
|
7720
|
-
// @ts-ignore
|
|
7721
7698
|
this.#copyData = null;
|
|
7722
|
-
// @ts-ignore
|
|
7723
7699
|
this.#copyDataType = null;
|
|
7724
7700
|
}
|
|
7725
7701
|
isText() {
|
|
@@ -7763,7 +7739,6 @@ define((function () { 'use strict';
|
|
|
7763
7739
|
if (navigator.permissions && navigator.permissions.query) {
|
|
7764
7740
|
navigator.permissions
|
|
7765
7741
|
.query({
|
|
7766
|
-
// @ts-ignore
|
|
7767
7742
|
name: "clipboard-write",
|
|
7768
7743
|
})
|
|
7769
7744
|
.then((permissionStatus) => {
|
|
@@ -7859,7 +7834,6 @@ define((function () { 'use strict';
|
|
|
7859
7834
|
dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
|
|
7860
7835
|
let UtilsContext = this;
|
|
7861
7836
|
function initMouseEvent(eventName, offSetX, offSetY) {
|
|
7862
|
-
// @ts-ignore
|
|
7863
7837
|
let win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
|
|
7864
7838
|
let mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
|
|
7865
7839
|
mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
|
|
@@ -8018,7 +7992,6 @@ define((function () { 'use strict';
|
|
|
8018
7992
|
}
|
|
8019
7993
|
stringToRegular(targetString, flags = "ig") {
|
|
8020
7994
|
let reg;
|
|
8021
|
-
// @ts-ignore
|
|
8022
7995
|
flags = flags.toLowerCase();
|
|
8023
7996
|
if (typeof targetString === "string") {
|
|
8024
7997
|
reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
|
|
@@ -8111,10 +8084,8 @@ define((function () { 'use strict';
|
|
|
8111
8084
|
*/
|
|
8112
8085
|
searchParamStrToObj(searhParamsStr) {
|
|
8113
8086
|
if (typeof searhParamsStr !== "string") {
|
|
8114
|
-
// @ts-ignore
|
|
8115
8087
|
return {};
|
|
8116
8088
|
}
|
|
8117
|
-
// @ts-ignore
|
|
8118
8089
|
return Object.fromEntries(new URLSearchParams(searhParamsStr));
|
|
8119
8090
|
}
|
|
8120
8091
|
/**
|
|
@@ -8817,7 +8788,6 @@ define((function () { 'use strict';
|
|
|
8817
8788
|
function requestPermissionsWithClipboard() {
|
|
8818
8789
|
navigator.permissions
|
|
8819
8790
|
.query({
|
|
8820
|
-
// @ts-ignore
|
|
8821
8791
|
name: "clipboard-read",
|
|
8822
8792
|
})
|
|
8823
8793
|
.then((permissionStatus) => {
|