Skip to content

Commit 10ac223

Browse files
authored
fix: change user-agent at runtime (#4478)
* fix: change user-agent at runtime * cleanup: remove console log
1 parent 99d0003 commit 10ac223

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/frontend/screens/WebView/index.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ export default function WebView() {
151151
if (webview) {
152152
const loadstop = async () => {
153153
setLoading({ ...loading, refresh: false })
154+
const userAgent =
155+
startUrl === epicLoginUrl
156+
? 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) EpicGamesLauncher'
157+
: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/200.0'
158+
if (webview.getUserAgent() != userAgent) {
159+
webview.setUserAgent(userAgent)
160+
}
154161
// Ignore the login handling if not on login page
155162
if (!runner) {
156163
return
@@ -292,11 +299,6 @@ export default function WebView() {
292299
setShowLoginWarningFor(null)
293300
}
294301

295-
const userAgent =
296-
startUrl === epicLoginUrl
297-
? 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) EpicGamesLauncher'
298-
: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/200.0 HeroicGamesLauncher'
299-
300302
return (
301303
<div className="WebView">
302304
{webviewRef.current && (
@@ -313,7 +315,6 @@ export default function WebView() {
313315
partition="persist:epicstore"
314316
src={startUrl}
315317
allowpopups={trueAsStr}
316-
useragent={userAgent}
317318
/>
318319
{showLoginWarningFor && (
319320
<LoginWarning

0 commit comments

Comments
 (0)