diff --git a/electron/appInfo.js b/electron/appInfo.js index 4937129..a21460d 100644 --- a/electron/appInfo.js +++ b/electron/appInfo.js @@ -1,4 +1,4 @@ const appName = "EZPPLauncher"; -const appVersion = "2.1.6"; +const appVersion = "2.1.7"; module.exports = { appName, appVersion }; diff --git a/electron/imageUtil.js b/electron/imageUtil.js index 065f45e..2f6f9b8 100644 --- a/electron/imageUtil.js +++ b/electron/imageUtil.js @@ -1,6 +1,12 @@ async function checkImageExists(url) { try { - const response = await fetch(url, { method: "HEAD" }); + const response = await fetch(url, { + method: "HEAD", + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, + }); if (!response.ok) { return false; } diff --git a/electron/osuUtil.js b/electron/osuUtil.js index e116608..f2f0118 100644 --- a/electron/osuUtil.js +++ b/electron/osuUtil.js @@ -152,7 +152,12 @@ function getUserConfig(osuPath) { } async function getUpdateFiles(releaseStream) { - const releaseData = await fetch(checkUpdateURL + releaseStream); + const releaseData = await fetch(checkUpdateURL + releaseStream, { + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, + }); return releaseData.ok ? await releaseData.json() : undefined; } @@ -244,6 +249,10 @@ async function getEZPPLauncherUpdateFiles(osuPath) { const filesToDownload = []; const updateFilesRequest = await fetch(ezppLauncherUpdateList, { method: "PATCH", + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, }); const updateFiles = await updateFilesRequest.json(); for (const updateFile of updateFiles) { @@ -272,23 +281,34 @@ async function downloadEZPPLauncherUpdateFiles(osuPath, updateFiles, allFiles) { const startDownload = async () => { //NOTE: delete files that are not in the updateFiles array - const foldersToPrune = allFiles.map(file => path.dirname(path.join(osuPath, ...file.folder.split("/"), file.name))).filter((folder, index, self) => self.indexOf(folder) === index); + const foldersToPrune = allFiles.map((file) => + path.dirname(path.join(osuPath, ...file.folder.split("/"), file.name)) + ).filter((folder, index, self) => self.indexOf(folder) === index); for (const pruneFolder of foldersToPrune) { //NOTE: check if the folder is not the osu root folder. - if (path.basename(pruneFolder) == "osu!") + if (path.basename(pruneFolder) == "osu!") { continue; + } if (fs.existsSync(pruneFolder)) { for (const files of await fs.promises.readdir(pruneFolder)) { const filePath = path.join(pruneFolder, files); - const validFolder = allFiles.find(file => path.dirname(filePath).endsWith(file.folder)); + const validFolder = allFiles.find((file) => + path.dirname(filePath).endsWith(file.folder) + ); if (!validFolder) { - if (allFiles.find(file => file.name == path.basename(filePath)) === undefined) { + if ( + allFiles.find((file) => file.name == path.basename(filePath)) === + undefined + ) { eventEmitter.emit("data", { fileName: path.basename(filePath), }); try { - await fs.promises.rm(filePath, { recursive: true, force: true }); - } catch { } + await fs.promises.rm(filePath, { + recursive: true, + force: true, + }); + } catch {} } } } diff --git a/electron/updateCheck.js b/electron/updateCheck.js index 0dd035c..bc67bb8 100644 --- a/electron/updateCheck.js +++ b/electron/updateCheck.js @@ -10,7 +10,12 @@ const releasesUrl = module.exports = { updateAvailable: async () => { try { - const latestRelease = await fetch(repoApiUrl); + const latestRelease = await fetch(repoApiUrl, { + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, + }); const json = await latestRelease.json(); if (json.length <= 0) return false; return { diff --git a/main.js b/main.js index 4cd0cce..b50f05b 100644 --- a/main.js +++ b/main.js @@ -76,6 +76,12 @@ function startOsuStatus() { try { const currentUserInfo = await fetch( `https://api.ez-pp.farm/get_player_info?name=${currentUser.username}&scope=info`, + { + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, + }, ); const currentUserInfoJson = await currentUserInfo.json(); if ( @@ -116,7 +122,14 @@ function startOsuStatus() { const windowTitle = firstInstance.processTitle; lastOsuStatus = windowTitle; const currentStatusRequest = await fetch( - "https://api.ez-pp.farm/v1/get_player_status?name=" + currentUser.username, + "https://api.ez-pp.farm/v1/get_player_status?name=" + + currentUser.username, + { + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, + }, ); const currentStatus = await currentStatusRequest.json(); @@ -127,7 +140,14 @@ function startOsuStatus() { const currentModeString = gamemodes[currentMode]; const currentInfoRequest = await fetch( - "https://api.ez-pp.farm/v1/get_player_info?name=" + currentUser.username + "&scope=all", + "https://api.ez-pp.farm/v1/get_player_info?name=" + + currentUser.username + "&scope=all", + { + headers: { + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", + }, + }, ); const currentInfo = await currentInfoRequest.json(); let currentUsername = currentInfo.player.info.name; @@ -237,7 +257,7 @@ function registerIPCPipes() { }; } const timeout = new AbortController(); - const timeoutId = setTimeout(() => timeout.abort(), 8000); + const timeoutId = setTimeout(() => timeout.abort(), 1000 * 10); logger.log(`Logging in with user ${args.username}...`); try { const fetchResult = await fetch("https://ez-pp.farm/login/check", { @@ -249,6 +269,8 @@ function registerIPCPipes() { }), headers: { "Content-Type": "application/json", + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", }, }); @@ -268,7 +290,7 @@ function registerIPCPipes() { return result; } logger.log( - `Login failed for user ${username}.\nResponse:\n${await fetchResult + `Login failed for user ${args.username}.\nResponse:\n${await fetchResult .text()}`, ); return { @@ -317,6 +339,8 @@ function registerIPCPipes() { }), headers: { "Content-Type": "application/json", + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", }, }); @@ -384,7 +408,7 @@ function registerIPCPipes() { } if (key == "logging") { - logger.enabled = logging; + logger.enabled = value; } if (typeof value == "boolean") { @@ -432,8 +456,9 @@ function registerIPCPipes() { ipcMain.handle("ezpplauncher:checkUpdate", async (e) => { const updateInfo = await updateAvailable(); - if (updateInfo.update) + if (updateInfo.update) { mainWindow.webContents.send("ezpplauncher:update", updateInfo.release); + } }); ipcMain.handle("ezpplauncher:exitAndUpdate", async (e) => { @@ -529,8 +554,9 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total) - })...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ + formatBytes(data.total) + })...`, }); }); await updateDownloader.startDownload(); @@ -557,13 +583,15 @@ function registerIPCPipes() { status: "Looking for patcher updates...", }); await new Promise((res) => setTimeout(res, 1000)); - const [patchFiles, allUpdateFiles] = await getEZPPLauncherUpdateFiles(osuPath); + const [patchFiles, allUpdateFiles] = await getEZPPLauncherUpdateFiles( + osuPath, + ); if (patchFiles.length > 0) { logger.log("EZPPLauncher updates found."); const patcherDownloader = await downloadEZPPLauncherUpdateFiles( osuPath, patchFiles, - allUpdateFiles + allUpdateFiles, ); let errored = false; patcherDownloader.eventEmitter.on("error", (data) => { @@ -584,8 +612,9 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded) - }/${formatBytes(data.total)})...`, + status: `Downloading ${data.fileName}(${ + formatBytes(data.loaded) + }/${formatBytes(data.total)})...`, }); }); patcherDownloader.eventEmitter.on("delete", (data) => { @@ -728,7 +757,8 @@ function registerIPCPipes() { const osuGameplayFile = path.join(osuPath, "osu!gameplay.dll"); if (isWritable(osuUIFile) && isWritable(osuGameplayFile)) { logger.log( - `Cleanup complete, took ${((performance.now() - timeStart) / 1000).toFixed(3) + `Cleanup complete, took ${ + ((performance.now() - timeStart) / 1000).toFixed(3) } seconds.`, ); clearInterval(cleanup); diff --git a/package.json b/package.json index 0c313d0..abbd099 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ezpplauncher-next", - "version": "2.1.6", + "version": "2.1.7", "description": "EZPPLauncher rewritten with Svelte.", "private": false, "license": "MIT", diff --git a/rollup.config.js b/rollup.config.js index e1987ea..8a9191d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -69,6 +69,7 @@ export default { resolve({ browser: true, dedupe: ["svelte"], + exportConditions: ["svelte"], }), typescript({ sourceMap: !production, diff --git a/src/App.svelte b/src/App.svelte index be07f01..0e4d6eb 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,20 +1,16 @@