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