@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.amd.js +7 -5
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +7 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +7 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +7 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +7 -5
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +7 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/Utils.ts +1 -1
- package/src/ajaxHooker/ajaxHooker.js +6 -4
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/// <reference path="./index.d.ts" />
|
|
2
2
|
// @name ajaxHooker
|
|
3
3
|
// @author cxxjackie
|
|
4
|
-
// @version 1.4.
|
|
5
|
-
// @updateLog
|
|
4
|
+
// @version 1.4.3
|
|
5
|
+
// @updateLog 修复特殊情况下有部分请求头丢失的问题。
|
|
6
|
+
// @updateLog xhr事件增加currentTarget劫持。
|
|
6
7
|
// @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
|
|
7
8
|
|
|
8
9
|
const AjaxHooker = function () {
|
|
9
10
|
return function() {
|
|
10
11
|
'use strict';
|
|
11
|
-
const version = '1.4.
|
|
12
|
+
const version = '1.4.3';
|
|
12
13
|
const hookInst = {
|
|
13
14
|
hookFns: [],
|
|
14
15
|
filters: []
|
|
@@ -263,6 +264,7 @@ const AjaxHooker = function () {
|
|
|
263
264
|
dispatchEvent(e) {
|
|
264
265
|
e.stopImmediatePropagation = stopImmediatePropagation;
|
|
265
266
|
defineProp(e, 'target', () => this.proxyXhr);
|
|
267
|
+
defineProp(e, 'currentTarget', () => this.proxyXhr);
|
|
266
268
|
this.proxyEvents[e.type] && this.proxyEvents[e.type].forEach(fn => {
|
|
267
269
|
this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
|
|
268
270
|
});
|
|
@@ -272,7 +274,7 @@ const AjaxHooker = function () {
|
|
|
272
274
|
}
|
|
273
275
|
setRequestHeader(header, value) {
|
|
274
276
|
this.originalXhr.setRequestHeader(header, value);
|
|
275
|
-
if (this.
|
|
277
|
+
if (!this.request) return;
|
|
276
278
|
const headers = this.request.headers;
|
|
277
279
|
headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
|
|
278
280
|
}
|