-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,46 @@ | ||
export async function viewerData(url: string, cookie: string): Promise<NovelData[]> { | ||
return new Promise((resolve, reject) => { | ||
GM_xmlhttpRequest({ | ||
method: "POST", | ||
url: `/proc/viewer_data/${url}`, | ||
data: "size=14", | ||
headers: { | ||
"Cookie": cookie, | ||
}, | ||
cookie: cookie, | ||
responseType: "json", | ||
anonymous: true, | ||
onload: ({response}) => { | ||
resolve((response as { c: string, s: { text: string }[] }).s.map(({text}) => { | ||
return { | ||
text: text, | ||
size: 11, | ||
align: "left" | ||
}; | ||
})) | ||
}, | ||
onerror: reject, | ||
}) | ||
}); | ||
import ky from "ky"; | ||
|
||
export async function viewerData(url: string, code?: () => void): Promise<NovelData[]> { | ||
// return new Promise((resolve, reject) => { | ||
// GM_xmlhttpRequest({ | ||
// method: "POST", | ||
// url: `/proc/viewer_data/${url}`, | ||
// data: "size=14", | ||
// headers: { | ||
// "Cookie": cookie, | ||
// }, | ||
// cookie: cookie, | ||
// responseType: "json", | ||
// anonymous: true, | ||
// onload: ({response}) => { | ||
// resolve((response as { c: string, s: { text: string }[] }).s.map(({text}) => { | ||
// return { | ||
// text: text, | ||
// size: 11, | ||
// align: "left" | ||
// }; | ||
// })) | ||
// }, | ||
// onerror: reject, | ||
// }) | ||
// }); | ||
|
||
// try { | ||
// const response = await ky.post(`/proc/viewer_data/${url}`, { | ||
// timeout: 5000, | ||
// searchParams: { | ||
// size: "14" | ||
// } | ||
// }).json<{ c: string, s: { text: string }[] }>(); | ||
// | ||
// return response.s.map(({text}) => { | ||
// return { | ||
// text: text, | ||
// size: 11, | ||
// align: "left" | ||
// }; | ||
// }); | ||
// } finally { | ||
// code?.(); | ||
// } | ||
try { | ||
const response = await ky.post(`/proc/viewer_data/${url}`, { | ||
timeout: 5000, | ||
searchParams: { | ||
size: "14" | ||
} | ||
}).json<{ c: string, s: { text: string }[] }>(); | ||
|
||
return response.s.map(({text}) => { | ||
return { | ||
text: text, | ||
size: 11, | ||
align: "left" | ||
}; | ||
}); | ||
} finally { | ||
code?.(); | ||
} | ||
} |