Skip to content

Commit 4fcdb13

Browse files
committed
bson
1 parent e792e9f commit 4fcdb13

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

core.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ const parse = string => {
1212
return JSON.parse(string)
1313
}
1414

15+
const parseBSON = data => {
16+
const chunks = data.split('}{"code":')
17+
if (chunks.length === 1) {
18+
return data
19+
}
20+
return chunks.map((chunk, index) => {
21+
if (index === 0) {
22+
return chunk + '}'
23+
}
24+
return '{"code":' + chunk
25+
})[1]
26+
}
27+
1528
class DDAtHome extends EventEmitter {
1629
constructor(url, { PING_INTERVAL = 1000 * 30, INTERVAL = 480, start = true, wsLimit = Infinity } = {}) {
1730
super()
@@ -37,7 +50,13 @@ class DDAtHome extends EventEmitter {
3750
this.emit('url', url)
3851
const time = Date.now()
3952
const opts = { headers: { Cookie: '_uuid=;rpdid=', 'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/105.0.5195.100 Mobile/15E148 Safari/604.1' } }
40-
const data = await fetch(url, opts).then(w => w.text()).catch(() => JSON.stringify({ code: 233 }))
53+
const dataRaw = await fetch(url, opts).then(w => w.text()).catch(() => JSON.stringify({ code: 233 }))
54+
const data = parseBSON(dataRaw)
55+
console.log(dataRaw)
56+
if (data !== dataRaw) {
57+
const diff = dataRaw.length - data.length
58+
this.emit('log', 'BSON', diff)
59+
}
4160
const result = this.secureSend(JSON.stringify({
4261
key,
4362
data

0 commit comments

Comments
 (0)