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