diff --git a/i18n/en-US/manager.json b/i18n/en-US/manager.json index 777bf30..6a8f5fe 100644 --- a/i18n/en-US/manager.json +++ b/i18n/en-US/manager.json @@ -21,6 +21,7 @@ "useHttpServer": "User http server(avoid certificate error)", "serverToPlay": "Server to play (0 is China server, 1 is Japan server, 2 is America server)", "proxyUrl": "Proxy server address (leave it empty if you don't want to use it)", + "userAgent": "Useragent", "userLibPath": "'User Library' Path", "localVersion": "Version", "isManagerHide": "Re-open the launcher when the game quit", diff --git a/i18n/ja-JP/manager.json b/i18n/ja-JP/manager.json index 5dd1336..2d267a9 100644 --- a/i18n/ja-JP/manager.json +++ b/i18n/ja-JP/manager.json @@ -17,6 +17,7 @@ "useHttpServer": "http サービスを使用する(証明書エラーがない)", "serverToPlay": "ゲームサーバー(0は中国サーバー、1は日本サーバー、2は米国サーバー)", "proxyUrl": "プロキシサーバーアドレス(プロキシを使用しない場合は空白のままにします)", + "userAgent": "ユーザーエージェント", "userLibPath": "ユーザライブラリディレクトリ", "localVersion": "バージョン", "isManagerHide": "ゲーム終了後、管理画面に戻る", diff --git a/i18n/ko/manager.json b/i18n/ko/manager.json index bcc54fa..7151e11 100644 --- a/i18n/ko/manager.json +++ b/i18n/ko/manager.json @@ -21,6 +21,7 @@ "useHttpServer": "\uc0ac\uc6a9\uc790 HTTP \uc11c\ubc84(\uc778\uc99d\uc11c \uc624\ub958 \ud68c\ud53c)", "serverToPlay": "\ud50c\ub808\uc774\ud560 \uc11c\ubc84 (0 : \uc911\uad6d \uc11c\ubc84, 1 : \uc77c\ubcf8 \uc11c\ubc84, 2 : \ubbf8\uad6d \uc11c\ubc84)", "proxyUrl": "\ud504\ub85d\uc2dc \uc11c\ubc84 \uc8fc\uc18c (\uc0ac\uc6a9\ud558\uc9c0 \uc54a\uc73c\ub824\uba74 \ube48\uce78\uc73c\ub85c \ub458 \uac83)", + "userAgent": "\uc0ac\uc6a9\uc790\u0020\uc5d0\uc774\uc804\ud2b8", "userLibPath": "'\uc0ac\uc6a9\uc790 \ub77c\uc774\ube0c\ub7ec\ub9ac' \uacbd\ub85c", "localVersion": "\ubc84\uc804", "isManagerHide": "\uac8c\uc784 \uc885\ub8cc \ud6c4 \ub7f0\ucc98 \uc7ac\uc2e4\ud589", diff --git a/i18n/zh-CN/manager.json b/i18n/zh-CN/manager.json index 112a0a1..66f0c15 100644 --- a/i18n/zh-CN/manager.json +++ b/i18n/zh-CN/manager.json @@ -17,6 +17,7 @@ "useHttpServer": "使用 http 服务器(不存在证书错误)", "serverToPlay": "游戏服务器(0为国服,1为日服,2为美服)", "proxyUrl": "代理服务器地址(留空为不使用代理)", + "userAgent": "用户代理", "userLibPath": "用户库目录", "localVersion": "版本", "isManagerHide": "退出游戏后回到管理器界面", diff --git a/i18n/zh-TW/manager.json b/i18n/zh-TW/manager.json index 3d85419..89deb27 100644 --- a/i18n/zh-TW/manager.json +++ b/i18n/zh-TW/manager.json @@ -21,6 +21,7 @@ "useHttpServer": "\u4f7f\u7528 http \u670d\u52d9\u5668\uff08\u4e0d\u5b58\u5728\u8b49\u66f8\u932f\u8aa4\uff09", "serverToPlay": "\u904a\u6232\u4f3a\u670d\u5668\uff080\u70ba\u570b\u4f3a\uff0c1\u70ba\u65e5\u4f3a\uff0c2\u70ba\u7f8e\u4f3a\uff09", "proxyUrl": "\u4ee3\u7406\u4f3a\u670d\u5668\u5730\u5740\uff08\u7559\u7a7a\u70ba\u4e0d\u4f7f\u7528\u4ee3\u7406\uff09", + "userAgent": "\u7528\u6236\u4ee3\u7406", "userLibPath": "\u8cc7\u6599\u593e\u76ee\u9304", "localVersion": "\u7248\u672c", "isManagerHide": "\u9000\u51fa\u904a\u6232\u5f8c\uff0c\u8fd4\u56de\u6a94\u6848\u7e3d\u7ba1", diff --git a/src/bin/main/mainLoader.ts b/src/bin/main/mainLoader.ts index 68b412f..c271e3b 100644 --- a/src/bin/main/mainLoader.ts +++ b/src/bin/main/mainLoader.ts @@ -105,7 +105,8 @@ function getLocalUrlWithParams(url: string) { function redirectGameWindow(url: string, gameWindow: Electron.WebviewTag) { const localUrl = getLocalUrlWithParams(url) console.log('[Majsoul Plus] Redirect Target:' + localUrl) - gameWindow.loadURL(localUrl) + + gameWindow.loadURL(localUrl, {userAgent: navigator.userAgent}) } function scaleWindow(percent = scalePercent) { @@ -152,6 +153,8 @@ ipcRenderer.on( if (partition) { mainWindow.partition = partition } + + mainWindow.useragent = navigator.userAgent mainWindow.src = url mainWindowBox.style.width = '100vw' mainWindowBox.style.height = '100vh' diff --git a/src/config.ts b/src/config.ts index a5da68d..112913f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -13,7 +13,8 @@ const defaultWindowConfig: MajsoulPlus.UserWindowConfig = { renderingMultiple: 100, isKioskModeOn: false, isNoBorder: false, - isManagerHide: false + isManagerHide: false, + userAgent: Global.HttpGetUserAgent } const defaultUpdateConfig: MajsoulPlus.UserUpdateConfig = { diff --git a/src/majsoul_plus.d.ts b/src/majsoul_plus.d.ts index d476741..19057d8 100644 --- a/src/majsoul_plus.d.ts +++ b/src/majsoul_plus.d.ts @@ -12,6 +12,7 @@ declare namespace MajsoulPlus { isKioskModeOn: boolean isNoBorder: boolean isManagerHide: boolean + userAgent: string } export interface UserUpdateConfig { diff --git a/src/manager/pages/Setting.ts b/src/manager/pages/Setting.ts index e1882af..4064428 100644 --- a/src/manager/pages/Setting.ts +++ b/src/manager/pages/Setting.ts @@ -66,7 +66,7 @@ class Setting { index }), string: () => { - if (item === 'proxyUrl') { + if (item === 'proxyUrl' || item === 'userAgent') { this.renderTextSectionItem({ settingInner, section, diff --git a/src/utils.ts b/src/utils.ts index d31702e..662d9e7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -118,7 +118,7 @@ export async function getRemoteSource( const remoteUrl = getRemoteUrl(url) const resp = await fetch(remoteUrl, { headers: { - 'User-Agent': Global.HttpGetUserAgent + 'User-Agent': UserConfigs.window.userAgent } }) @@ -261,7 +261,7 @@ export async function getRemoteOrCachedFile( export async function fetchAnySite(url: string, encoding = 'binary') { const resp = await fetch(url, { headers: { - 'User-Agent': Global.HttpGetUserAgent + 'User-Agent': UserConfigs.window.userAgent } }) return (await resp.buffer()).toString(encoding) diff --git a/src/windows/game.ts b/src/windows/game.ts index d9d932b..68feda8 100644 --- a/src/windows/game.ts +++ b/src/windows/game.ts @@ -160,11 +160,12 @@ export function newGameWindow(id: number) { window.show() }) + // 设置 GameWindow 的 userAgent - window.webContents.userAgent = Global.HttpGetUserAgent + window.webContents.userAgent = UserConfigs.window.userAgent // 载入本地启动器 - window.loadURL('file://' + path.join(__dirname, '../bin/main/index.html')) + window.loadURL('file://' + path.join(__dirname, '../bin/main/index.html'), {userAgent: UserConfigs.window.userAgent}) // 在 debug 启动环境下打开开发者工具 if (process.env.NODE_ENV === 'development') {