@whitesev/utils 1.4.3 → 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.esm.js CHANGED
@@ -458,13 +458,14 @@ class UtilsGMCookie {
458
458
  /// <reference path="./index.d.ts" />
459
459
  // @name ajaxHooker
460
460
  // @author cxxjackie
461
- // @version 1.4.2
462
- // @updateLog 修复了fetch请求的参数为Request类型时body类型不正确的bug。
461
+ // @version 1.4.3
462
+ // @updateLog 修复特殊情况下有部分请求头丢失的问题。
463
+ // @updateLog xhr事件增加currentTarget劫持。
463
464
  // @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
464
465
 
465
466
  const AjaxHooker = function () {
466
467
  return function() {
467
- const version = '1.4.2';
468
+ const version = '1.4.3';
468
469
  const hookInst = {
469
470
  hookFns: [],
470
471
  filters: []
@@ -719,6 +720,7 @@ const AjaxHooker = function () {
719
720
  dispatchEvent(e) {
720
721
  e.stopImmediatePropagation = stopImmediatePropagation;
721
722
  defineProp(e, 'target', () => this.proxyXhr);
723
+ defineProp(e, 'currentTarget', () => this.proxyXhr);
722
724
  this.proxyEvents[e.type] && this.proxyEvents[e.type].forEach(fn => {
723
725
  this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
724
726
  });
@@ -728,7 +730,7 @@ const AjaxHooker = function () {
728
730
  }
729
731
  setRequestHeader(header, value) {
730
732
  this.originalXhr.setRequestHeader(header, value);
731
- if (this.originalXhr.readyState !== 1) return;
733
+ if (!this.request) return;
732
734
  const headers = this.request.headers;
733
735
  headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
734
736
  }
@@ -3057,7 +3059,7 @@ class Utils {
3057
3059
  UtilsCore.init(option);
3058
3060
  }
3059
3061
  /** 版本号 */
3060
- version = "2024.6.11";
3062
+ version = "2024.6.14";
3061
3063
  addStyle(cssText) {
3062
3064
  if (typeof cssText !== "string") {
3063
3065
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");