-
Notifications
You must be signed in to change notification settings - Fork 0
/
inject.js
35 lines (30 loc) · 960 Bytes
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
window.fetch = patch(window.fetch)
function patch (fn) {
return async function (...args) {
const result = await fn(...args);
const cloned = result.clone()
if (cloned.url.includes('api-prod-dot-lotum-wordblitz.appspot.com/game/list')) {
const data = await cloned.json()
const boards = [data.daily.board]
for (const game of data.openGames) {
boards.push(
game.rounds[0].board,
game.rounds[1].board,
game.rounds[2].board
)
}
window.dispatchEvent(new CustomEvent("onBoardData", { detail: boards }))
}
if (cloned.url.includes('api-prod-dot-lotum-wordblitz.appspot.com/game/create')) {
const data = await cloned.json()
window.dispatchEvent(new CustomEvent("onBoardData", {
detail: [
data.game.rounds[0].board,
data.game.rounds[1].board,
data.game.rounds[2].board
]
}))
}
return result
}
}