From d75f4e6863f2913b83b5fd47af376f8a8fef69c1 Mon Sep 17 00:00:00 2001
From: Jebzou <22751386+Jebzou@users.noreply.github.com>
Date: Fri, 15 Nov 2024 17:48:03 +0100
Subject: [PATCH 1/6] Enable extension support
---
Browser/Browser.csproj | 5 ++++-
Browser/CefSharpBrowser/CefSharpViewModel.cs | 1 +
Browser/WebView2Browser/WebView2ViewModel.cs | 4 +++-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Browser/Browser.csproj b/Browser/Browser.csproj
index 207c1628e..0c49f6c74 100644
--- a/Browser/Browser.csproj
+++ b/Browser/Browser.csproj
@@ -39,7 +39,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
@@ -95,4 +95,7 @@
+
+
+
\ No newline at end of file
diff --git a/Browser/CefSharpBrowser/CefSharpViewModel.cs b/Browser/CefSharpBrowser/CefSharpViewModel.cs
index 73137fc7b..315a10fdb 100644
--- a/Browser/CefSharpBrowser/CefSharpViewModel.cs
+++ b/Browser/CefSharpBrowser/CefSharpViewModel.cs
@@ -133,6 +133,7 @@ protected override void InitializeAsync()
}
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
+ CefSharpSettings.RuntimeStyle = CefRuntimeStyle.Chrome;
Cef.Initialize(settings, false, (IBrowserProcessHandler?)null);
CustomRequestHandler requestHandler = new(Configuration);
diff --git a/Browser/WebView2Browser/WebView2ViewModel.cs b/Browser/WebView2Browser/WebView2ViewModel.cs
index 0af87f159..20b234948 100644
--- a/Browser/WebView2Browser/WebView2ViewModel.cs
+++ b/Browser/WebView2Browser/WebView2ViewModel.cs
@@ -221,8 +221,10 @@ protected override async void InitializeAsync()
var corewebviewoptions = new CoreWebView2EnvironmentOptions
{
- AdditionalBrowserArguments = string.Join(" ", browserArgs)
+ AdditionalBrowserArguments = string.Join(" ", browserArgs),
+ AreBrowserExtensionsEnabled = true,
};
+
var env = await CoreWebView2Environment.CreateAsync(null, userDataFolder: BrowserCachePath, options: corewebviewoptions);
Environment = env;
From a2e334061ee2475aacea266ef5cdca4d186a7fd4 Mon Sep 17 00:00:00 2001
From: Jebzou <22751386+Jebzou@users.noreply.github.com>
Date: Fri, 15 Nov 2024 19:03:05 +0100
Subject: [PATCH 2/6] Custom extension manager
---
.../CefOp/CustomRequestHandler.cs | 2 +-
.../ExtraBrowser/ExtraBrowserWindow.xaml | 8 +-
.../ExtraBrowser/ExtraBrowserWindow.xaml.cs | 6 ++
Browser/FormBrowserTranslationViewModel.cs | 3 +
Browser/Properties/Resources.en.resx | 9 +++
Browser/Properties/Resources.resx | 63 ++++++++-------
.../Extensions/ExtensionManagerWindow.xaml | 51 +++++++++++++
.../Extensions/ExtensionManagerWindow.xaml.cs | 42 ++++++++++
.../Extensions/ExtensionViewModel.cs | 76 +++++++++++++++++++
.../ExtraBrowser/ExtraBrowserWindow.xaml | 8 +-
.../ExtraBrowser/ExtraBrowserWindow.xaml.cs | 7 ++
11 files changed, 245 insertions(+), 30 deletions(-)
create mode 100644 Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml
create mode 100644 Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs
create mode 100644 Browser/WebView2Browser/Extensions/ExtensionViewModel.cs
diff --git a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
index 5b9044f88..e8426ee2d 100644
--- a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
+++ b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
@@ -21,7 +21,7 @@ public CustomRequestHandler(BrowserConfiguration browserConfiguration)
{
BrowserConfiguration = browserConfiguration;
}
-
+
///
/// 戻る/進む操作をブロックします。
///
diff --git a/Browser/CefSharpBrowser/ExtraBrowser/ExtraBrowserWindow.xaml b/Browser/CefSharpBrowser/ExtraBrowser/ExtraBrowserWindow.xaml
index f04fce7ee..c3643a608 100644
--- a/Browser/CefSharpBrowser/ExtraBrowser/ExtraBrowserWindow.xaml
+++ b/Browser/CefSharpBrowser/ExtraBrowser/ExtraBrowserWindow.xaml
@@ -42,6 +42,7 @@
+
+
Resources.Forward;
public string DmmPoints => Resources.DmmPoints;
public string AkashiList => Resources.AkashiList;
+ public string ExtensionManager => Resources.ExtensionManager;
+ public string AddExtension => Resources.AddExtension;
+ public string RemoveExtension => Resources.RemoveExtension;
public string WebView2NotFound => Resources.WebView2NotFound;
public string WebView2DownloadComplete => Resources.WebView2DownloadComplete;
diff --git a/Browser/Properties/Resources.en.resx b/Browser/Properties/Resources.en.resx
index 7b3bded66..1846512e8 100644
--- a/Browser/Properties/Resources.en.resx
+++ b/Browser/Properties/Resources.en.resx
@@ -364,4 +364,13 @@ Would you like to refresh?
Failed to apply browser font.
+
+ Extension manager
+
+
+ Add extension
+
+
+ Remove extension
+
\ No newline at end of file
diff --git a/Browser/Properties/Resources.resx b/Browser/Properties/Resources.resx
index 9e9e3a3bf..595229a88 100644
--- a/Browser/Properties/Resources.resx
+++ b/Browser/Properties/Resources.resx
@@ -1,17 +1,17 @@
-
@@ -391,4 +391,13 @@ Microsoft Visual C++ 2019 Redistributableが必要です。
ブラウザフォントの適用に失敗しました。
+
+ ??? (Extension manager)
+
+
+ ??? (Add extension)
+
+
+ ??? (Remove extension)
+
\ No newline at end of file
diff --git a/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml b/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml
new file mode 100644
index 000000000..2871dc431
--- /dev/null
+++ b/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs b/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs
new file mode 100644
index 000000000..2da5f46a9
--- /dev/null
+++ b/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
+using CommunityToolkit.Mvvm.DependencyInjection;
+using Jot;
+using Microsoft.Web.WebView2.Core;
+using Microsoft.Web.WebView2.Wpf;
+
+namespace Browser.WebView2Browser.Extensions;
+
+public partial class ExtensionManagerWindow
+{
+ public Tracker Tracker { get; }
+
+ private WebView2 Browser { get; }
+ private ExtensionManagerViewModel ViewModel { get; }
+
+ public ExtensionManagerWindow(WebView2 browser)
+ {
+ Tracker = Ioc.Default.GetRequiredService();
+
+ Browser = browser;
+ ViewModel = new(Browser);
+ DataContext = ViewModel;
+
+ InitializeComponent();
+ ViewModel.InitializeAsync();
+
+ Loaded += (_, _) =>
+ {
+ StartJotTracking();
+ };
+ }
+
+ private void StartJotTracking()
+ {
+ Tracker.Track(this);
+ }
+}
diff --git a/Browser/WebView2Browser/Extensions/ExtensionViewModel.cs b/Browser/WebView2Browser/Extensions/ExtensionViewModel.cs
new file mode 100644
index 000000000..aa3264cec
--- /dev/null
+++ b/Browser/WebView2Browser/Extensions/ExtensionViewModel.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Threading.Tasks;
+using System.Windows;
+using CommunityToolkit.Mvvm.DependencyInjection;
+using CommunityToolkit.Mvvm.Input;
+using Microsoft.Web.WebView2.Core;
+using Microsoft.Web.WebView2.Wpf;
+
+namespace Browser.WebView2Browser.Extensions;
+
+public partial class ExtensionManagerViewModel
+{
+ private WebView2 Browser { get; }
+ public FormBrowserTranslationViewModel FormBrowser { get; }
+
+ public ObservableCollection Extensions { get; } = [];
+
+ public ExtensionManagerViewModel(WebView2 browser)
+ {
+ Browser = browser;
+ FormBrowser = Ioc.Default.GetRequiredService();
+ }
+
+ public async Task InitializeAsync()
+ {
+ await Browser.EnsureCoreWebView2Async(WebView2ViewModel.Environment);
+
+ await RefreshList();
+ }
+
+ private async Task RefreshList()
+ {
+ Extensions.Clear();
+
+ foreach (CoreWebView2BrowserExtension extension in await Browser.CoreWebView2.Profile.GetBrowserExtensionsAsync())
+ {
+ Extensions.Add(extension);
+ }
+ }
+
+ [RelayCommand]
+ private async Task AddExtension()
+ {
+ System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new()
+ {
+ RootFolder = Environment.SpecialFolder.Desktop,
+ };
+
+ if (folderBrowserDialog.ShowDialog() is not System.Windows.Forms.DialogResult.OK) return;
+
+ try
+ {
+ await Browser.CoreWebView2.Profile.AddBrowserExtensionAsync(folderBrowserDialog.SelectedPath);
+ await RefreshList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, FormBrowser.Title, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ [RelayCommand]
+ private async Task RemoveExtension(CoreWebView2BrowserExtension extension)
+ {
+ try
+ {
+ await extension.RemoveAsync();
+ await RefreshList();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, FormBrowser.Title, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+}
diff --git a/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml b/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml
index d16b96822..fef9ded67 100644
--- a/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml
+++ b/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml
@@ -41,6 +41,7 @@
+
+
Date: Fri, 15 Nov 2024 19:10:44 +0100
Subject: [PATCH 3/6] fixes
---
Browser/Browser.csproj | 3 ---
Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs | 2 +-
.../WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml.cs | 1 -
3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/Browser/Browser.csproj b/Browser/Browser.csproj
index 0c49f6c74..293b64ac9 100644
--- a/Browser/Browser.csproj
+++ b/Browser/Browser.csproj
@@ -95,7 +95,4 @@
-
-
-
\ No newline at end of file
diff --git a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
index e8426ee2d..5b9044f88 100644
--- a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
+++ b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
@@ -21,7 +21,7 @@ public CustomRequestHandler(BrowserConfiguration browserConfiguration)
{
BrowserConfiguration = browserConfiguration;
}
-
+
///
/// 戻る/進む操作をブロックします。
///
diff --git a/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml.cs b/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml.cs
index 5d84b45d2..5ff376e4f 100644
--- a/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml.cs
+++ b/Browser/WebView2Browser/ExtraBrowser/ExtraBrowserWindow.xaml.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
From cbab6d848be75fbe2cc0330b41ff2879824464e1 Mon Sep 17 00:00:00 2001
From: Jebzou <22751386+Jebzou@users.noreply.github.com>
Date: Sat, 16 Nov 2024 08:50:07 +0100
Subject: [PATCH 4/6] attempts to make cefsharp work
---
Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs | 10 ++++++++++
Browser/CefSharpBrowser/CefSharpViewModel.cs | 5 +++++
2 files changed, 15 insertions(+)
diff --git a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
index 5b9044f88..7c97fa754 100644
--- a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
+++ b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
@@ -31,6 +31,16 @@ protected override bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser brow
{
return true;
}
+
+ /*
+ this results in a loop of redirections
+ if (isRedirect && request.Url.Contains("https://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/"))
+ {
+ browserControl.Load("http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/");
+ return false;
+ }
+ */
+
return base.OnBeforeBrowse(browserControl, browser, frame, request, userGesture, isRedirect);
}
diff --git a/Browser/CefSharpBrowser/CefSharpViewModel.cs b/Browser/CefSharpBrowser/CefSharpViewModel.cs
index 315a10fdb..621ca89c9 100644
--- a/Browser/CefSharpBrowser/CefSharpViewModel.cs
+++ b/Browser/CefSharpBrowser/CefSharpViewModel.cs
@@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms.Integration;
@@ -110,6 +111,10 @@ protected override void InitializeAsync()
settings.CefCommandLineArgs.Add("proxy-server", ProxySettings);
settings.CefCommandLineArgs.Add("enable-features", "EnableDrDc");
+
+ // This should work, but it doesn't, game seems to load main.js, then user settings, then hungs up with no error in console
+ settings.CefCommandLineArgs.Add("--unsafely-treat-insecure-origin-as-secure", "http://dmm.com,http://osapi.dmm.com,http://203.104.209.23,http://203.104.209.7,http://203.104.209.71,http://203.104.209.87,http://125.6.184.215,http://203.104.209.183,http://203.104.209.150,http://203.104.209.134,http://203.104.209.167,http://203.104.209.199,http://125.6.189.7,http://125.6.189.39,http://125.6.189.71,http://125.6.189.103,http://125.6.189.135,http://125.6.189.167,http://125.6.189.215,http://125.6.189.247,http://203.104.209.23,http://203.104.209.39,http://203.104.209.55,http://203.104.209.102");
+
// prevent CEF from taking over media keys
if (settings.CefCommandLineArgs.ContainsKey("disable-features"))
{
From 34811894fe291a8b579f364875d9a69b5072557b Mon Sep 17 00:00:00 2001
From: Jebzou <22751386+Jebzou@users.noreply.github.com>
Date: Wed, 22 Oct 2025 18:17:53 +0200
Subject: [PATCH 5/6] Fusion
---
.../CefOp/CustomRequestHandler.cs | 9 -
Browser/Properties/Resources.resx | 266 +++++++++---------
2 files changed, 133 insertions(+), 142 deletions(-)
diff --git a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
index 7c97fa754..7cfc28c57 100644
--- a/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
+++ b/Browser/CefSharpBrowser/CefOp/CustomRequestHandler.cs
@@ -32,15 +32,6 @@ protected override bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser brow
return true;
}
- /*
- this results in a loop of redirections
- if (isRedirect && request.Url.Contains("https://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/"))
- {
- browserControl.Load("http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/");
- return false;
- }
- */
-
return base.OnBeforeBrowse(browserControl, browser, frame, request, userGesture, isRedirect);
}
diff --git a/Browser/Properties/Resources.resx b/Browser/Properties/Resources.resx
index ee23bddcd..a4434b528 100644
--- a/Browser/Properties/Resources.resx
+++ b/Browser/Properties/Resources.resx
@@ -1,6 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
下(&B)
-
+
非表示(&I)
-
+
左(&L)
-
+
右(&R)
-
+
上(&T)
-
+
キャッシュを無視して更新(&C)
-
+
Go to Login Page
-
+
現在:
-
+
スタイルシートの適用に失敗しました。
-
+
ログインページへ移動します。
よろしいですか?
-
+
その他
-
+
現在: ぴったり
-
+
再読み込みします。
よろしいですか?
-
+
スクリーンショットの撮影に失敗しました。
-
+
クリップボードにコピー(&C)
-
+
ミュート
-
+
更新
-
+
スクリーンショット
-
+
ズーム
-
+
七四式電子観測儀 ブラウザ
-
+
var element = document.getElementById('welcome'); element.parentNode.removeChild(element);
-
+
var element = document.getElementById('page-popup'); element.parentNode.removeChild(element);
-
+
確認
-
+
キャッシュを無視して再読み込みします。
よろしいですか?
-
+
ツールメニューを表示
-
+
開発者ツールを開く
-
+
現在: ぴったり
-
+
キャッシュを削除
-
+
ブラウザの描画プロセスが
-
+
正常に終了しませんでした。
-
+
何者かによって殺害されました。
-
+
クラッシュしました。
-
+
謎の死を遂げました。
-
+
再読み込みすると復帰します。
-
+
本当にキャッシュをクリアするのですか?
-
+
ブラウザ再起動確認
-
+
スクリーンショット(&S)
-
+
直前のスクリーンショット(&P)
-
+
保存フォルダを開く(&O)
-
+
音量(&V)
-
+
ミュート(&M)
-
+
更新(&R)
-
+
ログインページへ移動(&L)
-
+
移動(&N)...
-
+
スタイルシートを適用する
-
+
配置(&A)
-
+
スクリーンショットをまだ撮影していません。
-
+
ブラウザのコンポーネントを読み込めませんでした。
Microsoft Visual C++ 2019 Redistributableが必要です。
ダウンロードページを開きますか?
(vc_redist.x64.exeをインストールしてください)
-
+
CefSharpロードエラー
-
+
DMMによるページ更新ダイアログの非表示に失敗しました。
-
+
艦これが読み込まれていないため、スクリーンショットを撮ることはできません。
-
+
スクリーンショットを {0} に保存しました。
-
+
スクリーンショットの保存に失敗しました。
-
+
スクリーンショットをクリップボードにコピーしました。
-
+
スクリーンショットのクリップボードへのコピーに失敗しました。
-
+
スクリーンショット {0} をクリップボードにコピーしました。
-
+
ズーム(&Z)
-
+
ファイル(_F)
-
+
バック
-
+
フォワード
-
+
DMMポイント
-
+
明石リスト
-
+
WebView2 が見つかりません。ダウンロードを開始します。
-
+
WebView2のダウンロードが完了しました。インストールを開始します。
-
+
WebView2のインストールが完了しました。
-
+
パーミッションがないため、vulkan の回避策を適用できない。七四式を管理者として実行すると、回避策が機能します。
-
+
古いバージョンのWebView2が検出されました。最新版をダウンロードします。
-
+
WebView2をインストールしようとしたときにエラーが発生しました。WebView2を手動でインストールしてください。
-
+
キャッシュの削除処理が終了しました。
-
+
進撃を断る設定のセルに進もうとしています。
再読み込みしますか?
-
+
ブラウザフォントの適用に失敗しました。
-
+
??? (Extension manager)
-
+
??? (Add extension)
-
+
??? (Remove extension)
\ No newline at end of file
From a888bf7473cd022e8ec6e908a6c066ec7f003289 Mon Sep 17 00:00:00 2001
From: Jebzou <22751386+Jebzou@users.noreply.github.com>
Date: Wed, 22 Oct 2025 19:04:10 +0200
Subject: [PATCH 6/6] sonar
---
.../WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs b/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs
index 2da5f46a9..4cf0a105a 100644
--- a/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs
+++ b/Browser/WebView2Browser/Extensions/ExtensionManagerWindow.xaml.cs
@@ -27,7 +27,9 @@ public ExtensionManagerWindow(WebView2 browser)
DataContext = ViewModel;
InitializeComponent();
+#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
ViewModel.InitializeAsync();
+#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
Loaded += (_, _) =>
{