fix: using random user agent for how long to beat

This commit is contained in:
Hydra 2024-05-03 10:13:07 +01:00
parent 5ae7815e03
commit 590ead9643
No known key found for this signature in database
6 changed files with 509 additions and 359 deletions

View file

@ -1,3 +1,5 @@
import UserAgent from "user-agents";
import type { Repack } from "@main/entity";
import { repackRepository } from "@main/repository";
@ -8,7 +10,13 @@ export const savePage = async (repacks: QueryDeepPartialEntity<Repack>[]) =>
repacks.map((repack) => repackRepository.insert(repack).catch(() => {}))
);
export const requestWebPage = async (url: string) =>
fetch(url, {
export const requestWebPage = async (url: string) => {
const userAgent = new UserAgent();
return fetch(url, {
method: "GET",
headers: {
"User-Agent": userAgent.toString(),
},
}).then((response) => response.text());
};