mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: adjustments
This commit is contained in:
parent
523d711b49
commit
330dd9c218
2 changed files with 10 additions and 10 deletions
|
@ -6,7 +6,7 @@ import { registerEvent } from "../register-event";
|
||||||
import { searchGames, searchRepacks } from "../helpers/search-games";
|
import { searchGames, searchRepacks } from "../helpers/search-games";
|
||||||
import { formatName } from "@main/helpers";
|
import { formatName } from "@main/helpers";
|
||||||
|
|
||||||
let gamesList = new Array<Steam250Game>();
|
let gamesList: Steam250Game[] = [];
|
||||||
let nextGameIndex = 0;
|
let nextGameIndex = 0;
|
||||||
|
|
||||||
const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
|
const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
|
@ -24,15 +24,15 @@ const getRandomGame = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
const repacks = searchRepacks(formatName(game.title));
|
const repacks = searchRepacks(formatName(game.title));
|
||||||
|
|
||||||
if (repacks.length) {
|
if (repacks.length) {
|
||||||
const results = await searchGames({ query: game.title });
|
const catalogueResults = await searchGames({ query: game.title });
|
||||||
|
|
||||||
if (results.length) {
|
if (catalogueResults.length) {
|
||||||
resultObjectId = results[0].objectID;
|
resultObjectId = catalogueResults[0].objectID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextGameIndex += 1;
|
nextGameIndex += 1;
|
||||||
|
|
||||||
if (nextGameIndex == gamesList.length - 1) {
|
if (nextGameIndex == gamesList.length) {
|
||||||
nextGameIndex = 0;
|
nextGameIndex = 0;
|
||||||
gamesList = shuffle(gamesList);
|
gamesList = shuffle(gamesList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,17 @@ export const requestSteam250 = async (path: string) => {
|
||||||
const { window } = new JSDOM(response.data);
|
const { window } = new JSDOM(response.data);
|
||||||
const { document } = window;
|
const { document } = window;
|
||||||
|
|
||||||
return Array.from(document.querySelectorAll(".appline .title a")).map(
|
return Array.from(document.querySelectorAll(".appline .title a"))
|
||||||
($title: HTMLAnchorElement) => {
|
.map(($title: HTMLAnchorElement) => {
|
||||||
const steamGameUrl = $title.href;
|
const steamGameUrl = $title.href;
|
||||||
if (!steamGameUrl) return null;
|
if (!steamGameUrl) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: $title.textContent,
|
title: $title.textContent,
|
||||||
objectID: steamGameUrl.split("/").pop(),
|
objectID: steamGameUrl.split("/").pop(),
|
||||||
};
|
} as Steam250Game;
|
||||||
}
|
})
|
||||||
);
|
.filter((game) => game != null);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue