Skip to content

Commit

Permalink
perf: 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
duan602728596 committed May 14, 2024
1 parent 54c62a6 commit 9804d5c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions packages/qqtools/src/components/basic/WebSocket2/Websocket2.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ script.
* Fix Pocket 48's verification problem for UA and client-type.
*/
(function() {
function objectSome(obj, callback) {
let result = false;

for (const key in obj) {
if (obj.hasOwnProperty(key)) {
result = callback(key, obj[key]);

if (result) break;
}
}

return result;
}

globalThis.WebSocket2 = WebSocket;

WebSocket2.prototype.$_SEND = WebSocket2.prototype.send;
Expand All @@ -16,10 +30,15 @@ script.
data = JSON.parse(message);
} catch {}

if (data && data?.SER === 1 && data?.Q?.[0]?.v) {
data.Q[0].v['3'] = 2;
data.Q[0].v['42'] = 'PocketFans201807/24020203';
arguments[0] = `3:::${ JSON.stringify(data) }`;
if (data && data?.SER === 1 && data?.Q?.length) {
for (const Q of data.Q) {
if (/Property/i.test(Q.t) && Q.v && objectSome(Q.v, (k, v) => /Electron/i.test(v))) {
Q.v['3'] = 2;
Q.v['42'] = 'PocketFans201807/24020203';
arguments[0] = `3:::${JSON.stringify(data)}`;
break;
}
}
}
}

Expand Down

0 comments on commit 9804d5c

Please sign in to comment.