diff --git a/electron-builder.yml b/electron-builder.yml index 0eb1979410..cd5178fca3 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -13,7 +13,6 @@ asarUnpack: - build/win_icon.ico - build/icon-dark.png - build/icon-light.png - - build/webviewPreload.js - build/bin/**/* - '!build/bin/legendary.LICENSE' diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index dce2d866a4..b403513c35 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -324,14 +324,14 @@ "gamemode": "Feral GameMode applies automatic and temporary tweaks to the system when running games. Enabling may improve performance.", "gamescope": { "additionalOptions": "Additional commandline flags to pass into gamescope.", + "forceGrabCursor": "Always use relative mouse mode instead of flipping dependent on cursor visibility. (Useful for when applications keep losing focus)", "fpsLimiter": "The amount of frames gamescope should limit to. E.g. 60", "fpsLimiterNoFocus": "The frame rate limit gamescope should limit per second if the game is not focused.", "gameHeight": "The height resolution used by the game. A 16:9 aspect ratio is assumed by gamescope.", "gameWidth": "The width resolution used by the game. A 16:9 aspect ratio is assumed by gamescope.", "upscaleHeight": "The height resolution used by gamescope. A 16:9 aspect ratio is assumed.", "upscaleMethod": "The upscaling method gamescope should use.", - "upscaleWidth": "The width resolution used by gamescope. A 16:9 aspect ratio is assumed.", - "forceGrabCursor": "Always use relative mouse mode instead of flipping dependent on cursor visibility. (Useful for when applications keep losing focus)" + "upscaleWidth": "The width resolution used by gamescope. A 16:9 aspect ratio is assumed." }, "general": "Sync with EGL if you have a working installation of the Epic Games Launcher elsewhere and want to import your games to avoid downloading them again.", "mangohud": "MangoHUD is an overlay that displays and monitors FPS, temperatures, CPU/GPU load and other system resources.", @@ -653,9 +653,9 @@ "fsync": "Enable Fsync", "gamemode": "Use GameMode (Feral Game Mode needs to be installed)", "gamescope": { + "enableForceGrabCursor": "Enable Force Grab Cursor", "enableLimiter": "Enable FPS Limiter", "enableUpscaling": "Enables Upscaling", - "enableForceGrabCursor": "Enable Force Grab Cursor", "missingMsg": "We could not found gamescope on the PATH. Install it or add it to the PATH." }, "hideChangelogsOnStartup": "Don't show changelogs on Startup", diff --git a/public/webviewPreload.js b/public/webviewPreload.js deleted file mode 100644 index 9074deced9..0000000000 --- a/public/webviewPreload.js +++ /dev/null @@ -1,9 +0,0 @@ -const { ipcRenderer } = require('electron') - -window.onload = () => { - const content = document.body.innerText - if (content.match(/"authorizationCode":/)) { - const json = JSON.parse(document.querySelector('pre').innerText) - ipcRenderer.sendToHost('processEpicLoginCode', json.authorizationCode) - } -} diff --git a/src/backend/api/misc.ts b/src/backend/api/misc.ts index 695f81ad2e..4452401804 100644 --- a/src/backend/api/misc.ts +++ b/src/backend/api/misc.ts @@ -107,8 +107,6 @@ export const getGOGLinuxInstallersLangs = async (appName: string) => ipcRenderer.invoke('getGOGLinuxInstallersLangs', appName) export const getAlternativeWine = async () => ipcRenderer.invoke('getAlternativeWine') -export const getLocalPeloadPath = async () => - ipcRenderer.invoke('getLocalPeloadPath') export const getShellPath = async (saveLocation: string) => ipcRenderer.invoke('getShellPath', saveLocation) export const callTool = async (toolArgs: Tools) => diff --git a/src/backend/main.ts b/src/backend/main.ts index 55f94e12fd..bbaafb94bc 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -80,7 +80,6 @@ import { wineprefixFAQ, customThemesWikiLink, createNecessaryFolders, - fixAsarPath, isSnap, isWindows, isMac @@ -772,9 +771,6 @@ ipcMain.handle('login', async (event, sid) => LegendaryUser.login(sid)) ipcMain.handle('authGOG', async (event, code) => GOGUser.login(code)) ipcMain.handle('logoutLegendary', LegendaryUser.logout) ipcMain.on('logoutGOG', GOGUser.logout) -ipcMain.handle('getLocalPeloadPath', async () => { - return fixAsarPath(join('file://', publicDir, 'webviewPreload.js')) -}) ipcMain.handle('getAmazonLoginData', NileUser.getLoginData) ipcMain.handle('authAmazon', async (event, data) => NileUser.login(data)) diff --git a/src/common/typedefs/ipcBridge.d.ts b/src/common/typedefs/ipcBridge.d.ts index 5d9a13e25e..e3b58970f3 100644 --- a/src/common/typedefs/ipcBridge.d.ts +++ b/src/common/typedefs/ipcBridge.d.ts @@ -202,7 +202,6 @@ interface AsyncIPCFunctions { logoutLegendary: () => Promise logoutAmazon: () => Promise getAlternativeWine: () => Promise - getLocalPeloadPath: () => Promise readConfig: (config_class: 'library' | 'user') => Promise requestSettings: (appName: string) => Promise writeConfig: (args: { appName: string; config: Partial }) => void diff --git a/src/frontend/screens/WebView/index.tsx b/src/frontend/screens/WebView/index.tsx index 34d28e09d6..eafe315070 100644 --- a/src/frontend/screens/WebView/index.tsx +++ b/src/frontend/screens/WebView/index.tsx @@ -61,7 +61,7 @@ export default function WebView() { lang = 'pt-BR' } - const epicLoginUrl = 'https://legendary.gl/epiclogin' + const epicLoginUrl = 'https://www.epicgames.com/id/login?responseType=code' const epicStore = `https://www.epicgames.com/store/${lang}/` const gogStore = `https://af.gog.com?as=1838482841` @@ -103,27 +103,6 @@ export default function WebView() { } } - const isEpicLogin = runner === 'legendary' && startUrl === epicLoginUrl - const [preloadPath, setPreloadPath] = useState('') - - useEffect(() => { - let mounted = true - const fetchLocalPreloadPath = async () => { - const path = await window.api.getLocalPeloadPath() - if (mounted) { - setPreloadPath(path) - } - } - - if (isEpicLogin) { - fetchLocalPreloadPath() - } - - return () => { - mounted = false - } - }, [isEpicLogin]) - useEffect(() => { if (pathname !== '/loginweb/nile') return console.log('Loading amazon login data') @@ -169,26 +148,7 @@ export default function WebView() { useLayoutEffect(() => { const webview = webviewRef.current - if (webview && ((preloadPath && isEpicLogin) || !isEpicLogin)) { - const onIpcMessage = async (event: unknown) => { - const e = event as { channel: string; args: string[] } - if (e.channel === 'processEpicLoginCode') { - try { - setLoading({ - refresh: true, - message: t('status.logging', 'Logging In...') - }) - await epic.login(e.args[0]) - handleSuccessfulLogin() - } catch (error) { - console.error(error) - window.api.logError(String(error)) - } - } - } - - webview.addEventListener('ipc-message', onIpcMessage) - + if (webview) { const loadstop = async () => { setLoading({ ...loading, refresh: false }) // Ignore the login handling if not on login page @@ -199,14 +159,12 @@ export default function WebView() { if (pageUrl.match(gogEmbedRegExp)) { const parsedURL = new URL(pageUrl) const code = parsedURL.searchParams.get('code') - setLoading({ - refresh: true, - message: t('status.logging', 'Logging In...') - }) if (code) { - gog.login(code).then(() => { - handleSuccessfulLogin() + setLoading({ + refresh: true, + message: t('status.logging', 'Logging In...') }) + gog.login(code).then(() => handleSuccessfulLogin()) } } } else if (runner === 'nile') { @@ -218,6 +176,19 @@ export default function WebView() { if (code) { handleAmazonLogin(code) } + } else if (runner == 'legendary') { + const pageUrl = webview.getURL() + const parsedUrl = new URL(pageUrl) + if (parsedUrl.hostname === 'localhost') { + const code = parsedUrl.searchParams.get('code') + if (code) { + setLoading({ + refresh: true, + message: t('status.logging', 'Logging In...') + }) + epic.login(code).then(() => handleSuccessfulLogin()) + } + } } } @@ -255,14 +226,13 @@ export default function WebView() { webview.addEventListener('page-title-updated', updateConnectivity) return () => { - webview.removeEventListener('ipc-message', onIpcMessage) webview.removeEventListener('dom-ready', loadstop) webview.removeEventListener('did-fail-load', onerror) webview.removeEventListener('page-title-updated', updateConnectivity) } } return - }, [webviewRef.current, preloadPath, amazonLoginData, runner]) + }, [webviewRef.current, amazonLoginData, runner]) useEffect(() => { const webview = webviewRef.current @@ -299,7 +269,11 @@ export default function WebView() { useState(false) useEffect(() => { - if (startUrl.match(/epicgames\.com/) && !epic.username) { + if ( + startUrl.match(/epicgames\.com/) && + startUrl.indexOf('/id/login') < 0 && + !epic.username + ) { setShowLoginWarningFor('epic') } else if ( startUrl.match(/gog\.com/) && @@ -318,9 +292,10 @@ export default function WebView() { setShowLoginWarningFor(null) } - if (!preloadPath && isEpicLogin) { - return <> - } + const userAgent = + startUrl === epicLoginUrl + ? 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) EpicGamesLauncher' + : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/200.0 HeroicGamesLauncher' return (
@@ -338,8 +313,7 @@ export default function WebView() { partition="persist:epicstore" src={startUrl} allowpopups={trueAsStr} - useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/200.0" - {...(preloadPath ? { preload: preloadPath } : {})} + useragent={userAgent} /> {showLoginWarningFor && (