@whitesev/utils 2.6.0 → 2.6.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/dist/index.amd.js +56 -6
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +56 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +56 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +56 -6
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +56 -6
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +56 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +1 -1
- package/dist/types/src/UtilsGMCookie.d.ts +3 -4
- package/package.json +1 -1
- package/src/Utils.ts +2 -2
- package/src/UtilsGMCookie.ts +4 -6
- package/src/ajaxHooker/ajaxHooker.js +54 -4
package/dist/index.umd.js
CHANGED
|
@@ -466,14 +466,13 @@
|
|
|
466
466
|
|
|
467
467
|
// @name ajaxHooker
|
|
468
468
|
// @author cxxjackie
|
|
469
|
-
// @version 1.4.
|
|
470
|
-
// @updateLog
|
|
471
|
-
// @updateLog xhr事件增加currentTarget劫持。
|
|
469
|
+
// @version 1.4.4
|
|
470
|
+
// @updateLog 修复头条、抖音部分站点下this引用错误的问题。
|
|
472
471
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
473
472
|
|
|
474
473
|
const AjaxHooker = function () {
|
|
475
474
|
return (function () {
|
|
476
|
-
const version = "1.4.
|
|
475
|
+
const version = "1.4.4";
|
|
477
476
|
const hookInst = {
|
|
478
477
|
hookFns: [],
|
|
479
478
|
filters: [],
|
|
@@ -1007,6 +1006,57 @@
|
|
|
1007
1006
|
win.fetch = winAh.fakeFetch;
|
|
1008
1007
|
resProto.clone = winAh.fakeFetchClone;
|
|
1009
1008
|
winAh.hookInsts.add(hookInst);
|
|
1009
|
+
// 针对头条、抖音 secsdk.umd.js 的兼容性处理
|
|
1010
|
+
class AHFunction {
|
|
1011
|
+
call(thisArg, ...args) {
|
|
1012
|
+
if (
|
|
1013
|
+
thisArg &&
|
|
1014
|
+
thisArg.__ajaxHooker &&
|
|
1015
|
+
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1016
|
+
) {
|
|
1017
|
+
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1018
|
+
}
|
|
1019
|
+
return Reflect.apply(this, thisArg, args);
|
|
1020
|
+
}
|
|
1021
|
+
apply(thisArg, args) {
|
|
1022
|
+
if (
|
|
1023
|
+
thisArg &&
|
|
1024
|
+
thisArg.__ajaxHooker &&
|
|
1025
|
+
thisArg.__ajaxHooker.proxyXhr === thisArg
|
|
1026
|
+
) {
|
|
1027
|
+
thisArg = thisArg.__ajaxHooker.originalXhr;
|
|
1028
|
+
}
|
|
1029
|
+
return Reflect.apply(this, thisArg, args || []);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
function hookSecsdk(csrf) {
|
|
1033
|
+
Object.setPrototypeOf(
|
|
1034
|
+
csrf.nativeXMLHttpRequestSetRequestHeader,
|
|
1035
|
+
AHFunction.prototype
|
|
1036
|
+
);
|
|
1037
|
+
Object.setPrototypeOf(
|
|
1038
|
+
csrf.nativeXMLHttpRequestOpen,
|
|
1039
|
+
AHFunction.prototype
|
|
1040
|
+
);
|
|
1041
|
+
Object.setPrototypeOf(
|
|
1042
|
+
csrf.nativeXMLHttpRequestSend,
|
|
1043
|
+
AHFunction.prototype
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
if (win.secsdk) {
|
|
1047
|
+
if (win.secsdk.csrf && win.secsdk.csrf.nativeXMLHttpRequestOpen)
|
|
1048
|
+
hookSecsdk(win.secsdk.csrf);
|
|
1049
|
+
} else {
|
|
1050
|
+
defineProp(win, "secsdk", emptyFn, (secsdk) => {
|
|
1051
|
+
delete win.secsdk;
|
|
1052
|
+
win.secsdk = secsdk;
|
|
1053
|
+
defineProp(secsdk, "csrf", emptyFn, (csrf) => {
|
|
1054
|
+
delete secsdk.csrf;
|
|
1055
|
+
secsdk.csrf = csrf;
|
|
1056
|
+
if (csrf.nativeXMLHttpRequestOpen) hookSecsdk(csrf);
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1010
1060
|
return {
|
|
1011
1061
|
hook: (fn) => hookInst.hookFns.push(fn),
|
|
1012
1062
|
filter: (arr) => {
|
|
@@ -4991,7 +5041,7 @@
|
|
|
4991
5041
|
this.windowApi = new WindowApi(option);
|
|
4992
5042
|
}
|
|
4993
5043
|
/** 版本号 */
|
|
4994
|
-
version = "2025.
|
|
5044
|
+
version = "2025.3.24";
|
|
4995
5045
|
addStyle(cssText) {
|
|
4996
5046
|
if (typeof cssText !== "string") {
|
|
4997
5047
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -5111,7 +5161,7 @@
|
|
|
5111
5161
|
* ajax劫持库,支持xhr和fetch劫持。
|
|
5112
5162
|
* + 来源:https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
5113
5163
|
* + 作者:cxxjackie
|
|
5114
|
-
* + 版本:1.4.
|
|
5164
|
+
* + 版本:1.4.4
|
|
5115
5165
|
* + 旧版本:1.2.4
|
|
5116
5166
|
* + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
|
|
5117
5167
|
* @param useOldVersion 是否使用旧版本,默认false
|