|

楼主 |
发表于 昨天 20:25
|
显示全部楼层
IP属地: 山西阳泉
上面的脚本不行就试试下边这个
- (function () {
- const OldSend = XMLHttpRequest.prototype.send;
- XMLHttpRequest.prototype.send = function (body) {
- try {
- // 只处理字符串类型的 body(JSON 一般是字符串)
- if (typeof body === 'string') {
- console.log('[XHR Hook] 原始 body:', body);
- // 有些站点会把 JSON 再包一层引号或前后多字符,这里做个宽松处理
- let raw = body;
- let prefix = '';
- let suffix = '';
- // 去掉可能外面包的一层单引号
- if (raw.startsWith("'") && raw.endsWith("'")) {
- raw = raw.slice(1, -1);
- }
- // 再尝试解析 JSON
- let data = JSON.parse(raw);
- // === 关键修改逻辑:把 configuration.duration 从 "1" 改成 "10" ===
- if (data.configuration && data.configuration.duration) {
- console.log('[XHR Hook] 找到 configuration.duration:', data.configuration.duration);
- data.configuration.duration = '5000';
- console.log('[XHR Hook] 已改为:', data.configuration.duration);
- }
- // 重新序列化
- let newRaw = JSON.stringify(data);
- // 如果一开始外面是单引号包裹的,这里再包回去(视你现场抓到的 body 而定)
- let newBody = newRaw;
- console.log('[XHR Hook] 修改后 body:', newBody);
- return OldSend.call(this, newBody);
- }
- } catch (e) {
- console.warn('[XHR Hook] 处理 body 失败,按原样发送:', e);
- }
- // 非字符串 body 或解析失败时,原样发送
- return OldSend.call(this, body);
- };
- console.log('[XHR Hook] 已安装:后续所有 XHR 字符串 body 会尝试把 configuration.duration 改为 "10"');
- })();
复制代码 |
|