@whitesev/utils 1.4.3 → 1.4.5

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.
@@ -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.2
465
- // @updateLog 修复了fetch请求的参数为Request类型时body类型不正确的bug。
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.2';
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.originalXhr.readyState !== 1) return;
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.11";
3065
+ version = "2024.6.16";
3064
3066
  addStyle(cssText) {
3065
3067
  if (typeof cssText !== "string") {
3066
3068
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");