@whitesev/utils 1.4.2 → 1.4.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 +12 -5
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +12 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +12 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +12 -5
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +12 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Utils.d.ts +10 -0
- package/package.json +1 -1
- package/src/Utils.ts +26 -1
- package/src/ajaxHooker/ajaxHooker.js +6 -4
package/dist/index.umd.js
CHANGED
|
@@ -464,13 +464,14 @@
|
|
|
464
464
|
/// <reference path="./index.d.ts" />
|
|
465
465
|
// @name ajaxHooker
|
|
466
466
|
// @author cxxjackie
|
|
467
|
-
// @version 1.4.
|
|
468
|
-
// @updateLog
|
|
467
|
+
// @version 1.4.3
|
|
468
|
+
// @updateLog 修复特殊情况下有部分请求头丢失的问题。
|
|
469
|
+
// @updateLog xhr事件增加currentTarget劫持。
|
|
469
470
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
470
471
|
|
|
471
472
|
const AjaxHooker = function () {
|
|
472
473
|
return function() {
|
|
473
|
-
const version = '1.4.
|
|
474
|
+
const version = '1.4.3';
|
|
474
475
|
const hookInst = {
|
|
475
476
|
hookFns: [],
|
|
476
477
|
filters: []
|
|
@@ -725,6 +726,7 @@
|
|
|
725
726
|
dispatchEvent(e) {
|
|
726
727
|
e.stopImmediatePropagation = stopImmediatePropagation;
|
|
727
728
|
defineProp(e, 'target', () => this.proxyXhr);
|
|
729
|
+
defineProp(e, 'currentTarget', () => this.proxyXhr);
|
|
728
730
|
this.proxyEvents[e.type] && this.proxyEvents[e.type].forEach(fn => {
|
|
729
731
|
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
730
732
|
});
|
|
@@ -734,7 +736,7 @@
|
|
|
734
736
|
}
|
|
735
737
|
setRequestHeader(header, value) {
|
|
736
738
|
this.originalXhr.setRequestHeader(header, value);
|
|
737
|
-
if (this.
|
|
739
|
+
if (!this.request) return;
|
|
738
740
|
const headers = this.request.headers;
|
|
739
741
|
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
740
742
|
}
|
|
@@ -3063,7 +3065,7 @@
|
|
|
3063
3065
|
UtilsCore.init(option);
|
|
3064
3066
|
}
|
|
3065
3067
|
/** 版本号 */
|
|
3066
|
-
version = "2024.6.
|
|
3068
|
+
version = "2024.6.14";
|
|
3067
3069
|
addStyle(cssText) {
|
|
3068
3070
|
if (typeof cssText !== "string") {
|
|
3069
3071
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -4662,6 +4664,7 @@
|
|
|
4662
4664
|
*/
|
|
4663
4665
|
characterDataOldValue: void 0,
|
|
4664
4666
|
},
|
|
4667
|
+
immediate: false,
|
|
4665
4668
|
};
|
|
4666
4669
|
observer_config = UtilsContext.assign(default_obverser_config, observer_config);
|
|
4667
4670
|
let windowMutationObserver = window.MutationObserver ||
|
|
@@ -4690,6 +4693,10 @@
|
|
|
4690
4693
|
/* 未知 */
|
|
4691
4694
|
console.error("Utils.mutationObserver 未知参数", arguments);
|
|
4692
4695
|
}
|
|
4696
|
+
if (observer_config.immediate) {
|
|
4697
|
+
/* 主动触发一次 */
|
|
4698
|
+
observer_config.callback([], mutationObserver);
|
|
4699
|
+
}
|
|
4693
4700
|
return mutationObserver;
|
|
4694
4701
|
}
|
|
4695
4702
|
/**
|