ajax-hooker 1.0.1 → 1.0.2

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/cjs/index.js CHANGED
@@ -4082,32 +4082,14 @@ const ajaxInterceptor = AjaxInterceptor.getInstance();
4082
4082
  ajaxInterceptor.inject();
4083
4083
  let count = 0;
4084
4084
  ajaxInterceptor.hook((request) => {
4085
- console.log(`%c${++count} twices-x200 pbx`, 'color: red', request.url);
4085
+ console.log(`%c${++count} twices-x200 pbx`, 'color: red', request);
4086
4086
  if (request.url === '/api/outer/ats-apply/website/jobs/v2') {
4087
4087
  const body = JSON.parse(request.body);
4088
4088
  body.keyword = '后端';
4089
4089
  request.body = JSON.stringify(body);
4090
4090
  }
4091
- if (request.type === 'fetch' &&
4092
- typeof request.url === 'string' &&
4093
- request.url.includes('/admin/article/paging')) {
4094
- console.log(request.body, 'request.body');
4095
- const body = JSON.parse(request.body);
4096
- body.pageSize = 2;
4097
- request.body = JSON.stringify(body);
4098
- }
4099
- if (request.url === 'https://jsonplaceholder.typicode.com/posts') {
4100
- console.log('bingo');
4101
- request.headers.kpi = '10000';
4102
- }
4103
4091
  request.response = async (response) => {
4104
- request.onStreamChunk = async (chunk) => {
4105
- console.log(request.url, 'request.url');
4106
- console.log(chunk.index, 'chunk.index');
4107
- console.log(chunk.text, 'chunk.text');
4108
- return chunk.text; // 返回翻译后的文本
4109
- };
4110
- console.log(request.url, 'request.url');
4092
+ console.log(response, 'response');
4111
4093
  if (request.url.includes('/portal/searchHome')) {
4112
4094
  const body = JSON.parse(request.body);
4113
4095
  console.log(request.body, 'req');
@@ -4130,17 +4112,6 @@ ajaxInterceptor.hook((request) => {
4130
4112
  }
4131
4113
  response.json.data = data;
4132
4114
  }
4133
- if (request.type === 'fetch' &&
4134
- response.bodyUsed &&
4135
- request.url.includes?.('/api/docs')) {
4136
- console.log('json Result', response.json);
4137
- response.json.data.content_updated_at = '2025-07-30T03:21:10.000Z';
4138
- }
4139
- if (request.type === 'fetch' &&
4140
- response.bodyUsed &&
4141
- (typeof request.url === 'object' || response.finalUrl.includes?.('next'))) {
4142
- console.log('youtubejson Result', response.text);
4143
- }
4144
4115
  };
4145
4116
  return request;
4146
4117
  });
package/dist/esm/index.js CHANGED
@@ -4080,32 +4080,14 @@ const ajaxInterceptor = AjaxInterceptor.getInstance();
4080
4080
  ajaxInterceptor.inject();
4081
4081
  let count = 0;
4082
4082
  ajaxInterceptor.hook((request) => {
4083
- console.log(`%c${++count} twices-x200 pbx`, 'color: red', request.url);
4083
+ console.log(`%c${++count} twices-x200 pbx`, 'color: red', request);
4084
4084
  if (request.url === '/api/outer/ats-apply/website/jobs/v2') {
4085
4085
  const body = JSON.parse(request.body);
4086
4086
  body.keyword = '后端';
4087
4087
  request.body = JSON.stringify(body);
4088
4088
  }
4089
- if (request.type === 'fetch' &&
4090
- typeof request.url === 'string' &&
4091
- request.url.includes('/admin/article/paging')) {
4092
- console.log(request.body, 'request.body');
4093
- const body = JSON.parse(request.body);
4094
- body.pageSize = 2;
4095
- request.body = JSON.stringify(body);
4096
- }
4097
- if (request.url === 'https://jsonplaceholder.typicode.com/posts') {
4098
- console.log('bingo');
4099
- request.headers.kpi = '10000';
4100
- }
4101
4089
  request.response = async (response) => {
4102
- request.onStreamChunk = async (chunk) => {
4103
- console.log(request.url, 'request.url');
4104
- console.log(chunk.index, 'chunk.index');
4105
- console.log(chunk.text, 'chunk.text');
4106
- return chunk.text; // 返回翻译后的文本
4107
- };
4108
- console.log(request.url, 'request.url');
4090
+ console.log(response, 'response');
4109
4091
  if (request.url.includes('/portal/searchHome')) {
4110
4092
  const body = JSON.parse(request.body);
4111
4093
  console.log(request.body, 'req');
@@ -4128,17 +4110,6 @@ ajaxInterceptor.hook((request) => {
4128
4110
  }
4129
4111
  response.json.data = data;
4130
4112
  }
4131
- if (request.type === 'fetch' &&
4132
- response.bodyUsed &&
4133
- request.url.includes?.('/api/docs')) {
4134
- console.log('json Result', response.json);
4135
- response.json.data.content_updated_at = '2025-07-30T03:21:10.000Z';
4136
- }
4137
- if (request.type === 'fetch' &&
4138
- response.bodyUsed &&
4139
- (typeof request.url === 'object' || response.finalUrl.includes?.('next'))) {
4140
- console.log('youtubejson Result', response.text);
4141
- }
4142
4113
  };
4143
4114
  return request;
4144
4115
  });