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