Merge pull request #315 from wabbajack-tools/remove-webview

Remove Webview, swap to CefSharp
This commit is contained in:
Timothy Baldridge 2020-01-02 20:27:20 -08:00 committed by GitHub
commit 96ad1d6130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 256 additions and 259 deletions

View File

@ -5,5 +5,6 @@
<Workers>0</Workers> <Workers>0</Workers>
<Scope>MethodLevel</Scope> <Scope>MethodLevel</Scope>
</Parallelize> </Parallelize>
<DisableAppDomain>True</DisableAppDomain>
</MSTest> </MSTest>
</RunSettings> </RunSettings>

View File

@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" /> <PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />

View File

@ -2,6 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -59,6 +59,32 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<NoWarn>CS1998</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<WarningsAsErrors>CS4014</WarningsAsErrors>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>CS1998</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<WarningsAsErrors>CS4014</WarningsAsErrors>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

View File

@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Reactive" Version="4.3.2" /> <PackageReference Include="System.Reactive" Version="4.3.2" />

View File

@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="7z.dll.gz" /> <None Remove="7z.dll.gz" />

View File

@ -3,18 +3,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Alphaleonis.Win32.Filesystem; using Alphaleonis.Win32.Filesystem;
using MongoDB.Bson.Serialization.Attributes;
using Wabbajack.Lib.Validation; using Wabbajack.Lib.Validation;
namespace Wabbajack.Lib.Downloaders namespace Wabbajack.Lib.Downloaders
{ {
/// <summary>
/// Base for all abstract downloaders
/// </summary>
[BsonDiscriminator(RootClass = true)]
[BsonKnownTypes(typeof(HTTPDownloader.State), typeof(GameFileSourceDownloader.State), typeof(GoogleDriveDownloader.State),
typeof(LoversLabDownloader.State), typeof(ManualDownloader.State), typeof(MediaFireDownloader.State), typeof(MegaDownloader.State),
typeof(ModDBDownloader.State), typeof(NexusDownloader.State), typeof(SteamWorkshopDownloader.State))]
public abstract class AbstractDownloadState public abstract class AbstractDownloadState
{ {

View File

@ -15,7 +15,7 @@ using Wabbajack.Common;
using Wabbajack.Lib.LibCefHelpers; using Wabbajack.Lib.LibCefHelpers;
using Wabbajack.Lib.NexusApi; using Wabbajack.Lib.NexusApi;
using Wabbajack.Lib.Validation; using Wabbajack.Lib.Validation;
using Xilium.CefGlue.Common; using Wabbajack.Lib.WebAutomation;
using File = Alphaleonis.Win32.Filesystem.File; using File = Alphaleonis.Win32.Filesystem.File;
namespace Wabbajack.Lib.Downloaders namespace Wabbajack.Lib.Downloaders
@ -64,16 +64,15 @@ namespace Wabbajack.Lib.Downloaders
_authedClient = (await GetAuthedClient()) ?? throw new Exception("not logged into LL, TODO"); _authedClient = (await GetAuthedClient()) ?? throw new Exception("not logged into LL, TODO");
} }
public static async Task<Helpers.Cookie[]> GetAndCacheLoversLabCookies(BaseCefBrowser browser, Action<string> updateStatus, CancellationToken cancel) public static async Task<Helpers.Cookie[]> GetAndCacheLoversLabCookies(IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
{ {
updateStatus("Please Log Into Lovers Lab"); updateStatus("Please Log Into Lovers Lab");
browser.Address = "https://www.loverslab.com/login"; await browser.NavigateTo(new Uri("https://www.loverslab.com/login"));
async Task<bool> CleanAds() async Task<bool> CleanAds()
{ {
try try
{ {
await browser.EvaluateJavaScript<string>( await browser.EvaluateJavaScript(
"document.querySelectorAll(\".ll_adblock\").forEach(function (itm) { itm.innerHTML = \"\";});"); "document.querySelectorAll(\".ll_adblock\").forEach(function (itm) { itm.innerHTML = \"\";});");
} }
catch (Exception ex) catch (Exception ex)
@ -87,7 +86,7 @@ namespace Wabbajack.Lib.Downloaders
{ {
cancel.ThrowIfCancellationRequested(); cancel.ThrowIfCancellationRequested();
await CleanAds(); await CleanAds();
cookies = (await Helpers.GetCookies("loverslab.com")); cookies = (await browser.GetCookies("loverslab.com"));
if (cookies.FirstOrDefault(c => c.Name == "ips4_member_id") != null) if (cookies.FirstOrDefault(c => c.Name == "ips4_member_id") != null)
break; break;
await Task.Delay(500, cancel); await Task.Delay(500, cancel);

View File

@ -1,3 +1,4 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> <Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ReactiveUI /> <ReactiveUI />
<ModuleInit />
</Weavers> </Weavers>

View File

@ -5,6 +5,7 @@
<xs:complexType> <xs:complexType>
<xs:all> <xs:all>
<xs:element name="ReactiveUI" minOccurs="0" maxOccurs="1" type="xs:anyType" /> <xs:element name="ReactiveUI" minOccurs="0" maxOccurs="1" type="xs:anyType" />
<xs:element name="ModuleInit" minOccurs="0" maxOccurs="1" type="xs:anyType" />
</xs:all> </xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean"> <xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation> <xs:annotation>

View File

@ -8,42 +8,38 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Alphaleonis.Win32.Filesystem; using Alphaleonis.Win32.Filesystem;
using CefSharp;
using CefSharp.OffScreen;
using Wabbajack.Common; using Wabbajack.Common;
using Xilium.CefGlue;
namespace Wabbajack.Lib.LibCefHelpers namespace Wabbajack.Lib.LibCefHelpers
{ {
public static class Helpers public static class Helpers
{ {
private static readonly Task _initTask;
/// <summary> /// <summary>
/// We bundle the cef libs inside the .exe, we need to extract them before loading any wpf code that requires them /// We bundle the cef libs inside the .exe, we need to extract them before loading any wpf code that requires them
/// </summary> /// </summary>
private static async Task ExtractLibs() private static void ExtractLibs()
{ {
if (File.Exists("cefglue.7z") && File.Exists("libcef.dll")) return; if (File.Exists("cefsharp.7z") && File.Exists("libcef.dll")) return;
using (var fs = File.OpenWrite("cefglue.7z")) using (var fs = File.OpenWrite("cefsharp.7z"))
using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wabbajack.Lib.LibCefHelpers.cefglue.7z")) using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wabbajack.Lib.LibCefHelpers.cefsharp.7z"))
{ {
rs.CopyTo(fs); rs.CopyTo(fs);
Utils.Log("Extracting libCef files"); Utils.Log("Extracting libCef files");
} }
using (var wq = new WorkQueue(1)) using (var wq = new WorkQueue(1))
{ {
await FileExtractor.ExtractAll(wq, "cefglue.7z", "."); FileExtractor.ExtractAll(wq, "cefsharp.7z", ".").Wait();
} }
} }
static Helpers() static Helpers()
{ {
_initTask = Task.Run(ExtractLibs); ExtractLibs();
} //if (!Cef.IsInitialized)
// Cef.Initialize(new CefSettings { MultiThreadedMessageLoop = true });
public static Task Initialize()
{
return _initTask;
} }
public static HttpClient GetClient(IEnumerable<Cookie> cookies, string referer) public static HttpClient GetClient(IEnumerable<Cookie> cookies, string referer)
@ -69,7 +65,7 @@ namespace Wabbajack.Lib.LibCefHelpers
public static async Task<Cookie[]> GetCookies(string domainEnding) public static async Task<Cookie[]> GetCookies(string domainEnding)
{ {
var manager = CefCookieManager.GetGlobal(null); var manager = Cef.GetGlobalCookieManager();
var visitor = new CookieVisitor(); var visitor = new CookieVisitor();
if (!manager.VisitAllCookies(visitor)) if (!manager.VisitAllCookies(visitor))
return new Cookie[0]; return new Cookie[0];
@ -78,13 +74,18 @@ namespace Wabbajack.Lib.LibCefHelpers
return (await visitor.Task).Where(c => c.Domain.EndsWith(domainEnding)).ToArray(); return (await visitor.Task).Where(c => c.Domain.EndsWith(domainEnding)).ToArray();
} }
private class CookieVisitor : CefCookieVisitor private class CookieVisitor : ICookieVisitor
{ {
TaskCompletionSource<List<Cookie>> _source = new TaskCompletionSource<List<Cookie>>(); TaskCompletionSource<List<Cookie>> _source = new TaskCompletionSource<List<Cookie>>();
public Task<List<Cookie>> Task => _source.Task; public Task<List<Cookie>> Task => _source.Task;
public List<Cookie> Cookies { get; } = new List<Cookie>(); public List<Cookie> Cookies { get; } = new List<Cookie>();
protected override bool Visit(CefCookie cookie, int count, int total, out bool delete) public void Dispose()
{
_source.SetResult(Cookies);
}
public bool Visit(CefSharp.Cookie cookie, int count, int total, ref bool deleteCookie)
{ {
Cookies.Add(new Cookie Cookies.Add(new Cookie
{ {
@ -95,15 +96,9 @@ namespace Wabbajack.Lib.LibCefHelpers
}); });
if (count == total) if (count == total)
_source.SetResult(Cookies); _source.SetResult(Cookies);
delete = false; deleteCookie = false;
return true; return true;
} }
protected override void Dispose(bool disposing)
{
if (disposing)
_source.SetResult(Cookies);
}
} }
public class Cookie public class Cookie
@ -113,5 +108,18 @@ namespace Wabbajack.Lib.LibCefHelpers
public string Domain { get; set; } public string Domain { get; set; }
public string Path { get; set; } public string Path { get; set; }
} }
public static void Init()
{
// does nothing, but kicks off the static constructor
}
}
public static class ModuleInitializer
{
public static void Initialize()
{
Helpers.Init();
}
} }
} }

View File

@ -1,7 +1,6 @@
using ReactiveUI; using ReactiveUI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@ -9,22 +8,18 @@ using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Reflection; using System.Reflection;
using System.Security.Authentication; using System.Security.Authentication;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Documents;
using Syroot.Windows.IO;
using Wabbajack.Common; using Wabbajack.Common;
using Wabbajack.Lib.Downloaders; using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.LibCefHelpers; using Wabbajack.Lib.LibCefHelpers;
using WebSocketSharp; using WebSocketSharp;
using Xilium.CefGlue;
using Xilium.CefGlue.Common;
using Xilium.CefGlue.Common.Handlers;
using Xilium.CefGlue.WPF;
using static Wabbajack.Lib.NexusApi.NexusApiUtils; using static Wabbajack.Lib.NexusApi.NexusApiUtils;
using System.Threading; using System.Threading;
using CefSharp;
using CefSharp.Handler;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wabbajack.Lib.WebAutomation;
namespace Wabbajack.Lib.NexusApi namespace Wabbajack.Lib.NexusApi
{ {
@ -98,30 +93,13 @@ namespace Wabbajack.Lib.NexusApi
return result; return result;
} }
class RefererHandler : RequestHandler public static async Task<string> SetupNexusLogin(IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
{
private string _referer;
public RefererHandler(string referer)
{
_referer = referer;
}
protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect)
{
base.OnBeforeBrowse(browser, frame, request, userGesture, isRedirect);
if (request.ReferrerURL == null)
request.SetReferrer(_referer, CefReferrerPolicy.Default);
return false;
}
}
public static async Task<string> SetupNexusLogin(BaseCefBrowser browser, Action<string> updateStatus, CancellationToken cancel)
{ {
updateStatus("Please Log Into the Nexus"); updateStatus("Please Log Into the Nexus");
browser.Address = "https://users.nexusmods.com/auth/continue?client_id=nexus&redirect_uri=https://www.nexusmods.com/oauth/callback&response_type=code&referrer=//www.nexusmods.com"; await browser.NavigateTo(new Uri("https://users.nexusmods.com/auth/continue?client_id=nexus&redirect_uri=https://www.nexusmods.com/oauth/callback&response_type=code&referrer=//www.nexusmods.com"));
while (true) while (true)
{ {
var cookies = await Helpers.GetCookies("nexusmods.com"); var cookies = await browser.GetCookies("nexusmods.com");
if (cookies.Any(c => c.Name == "member_id")) if (cookies.Any(c => c.Name == "member_id"))
break; break;
cancel.ThrowIfCancellationRequested(); cancel.ThrowIfCancellationRequested();
@ -147,7 +125,7 @@ namespace Wabbajack.Lib.NexusApi
await Task.Delay(1000, cancel); await Task.Delay(1000, cancel);
// open a web browser to get user permission // open a web browser to get user permission
browser.Address = $"https://www.nexusmods.com/sso?id={guid}&application={Consts.AppName}"; await browser.NavigateTo(new Uri($"https://www.nexusmods.com/sso?id={guid}&application={Consts.AppName}"));
using (cancel.Register(() => using (cancel.Register(() =>
{ {
api_key.SetCanceled(); api_key.SetCanceled();

View File

@ -156,16 +156,14 @@
<Compile Include="ViewModel.cs" /> <Compile Include="ViewModel.cs" />
<Compile Include="VortexCompiler.cs" /> <Compile Include="VortexCompiler.cs" />
<Compile Include="VortexInstaller.cs" /> <Compile Include="VortexInstaller.cs" />
<Compile Include="WebAutomation\CefSharpWrapper.cs" />
<Compile Include="WebAutomation\IWebDriver.cs" />
<Compile Include="WebAutomation\WebAutomation.cs" /> <Compile Include="WebAutomation\WebAutomation.cs" />
<Compile Include="WebAutomation\WebAutomationWindow.xaml.cs">
<DependentUpon>WebAutomationWindow.xaml</DependentUpon>
</Compile>
<Compile Include="WebAutomation\WebAutomationWindowViewModel.cs" />
<Compile Include="zEditIntegration.cs" /> <Compile Include="zEditIntegration.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />
<EmbeddedResource Include="LibCefHelpers\cefglue.7z" /> <EmbeddedResource Include="LibCefHelpers\cefsharp.7z" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="$(SolutionDir)\Compression.BSA\Compression.BSA.csproj"> <ProjectReference Include="$(SolutionDir)\Compression.BSA\Compression.BSA.csproj">
@ -191,8 +189,8 @@
<PackageReference Include="AlphaFS"> <PackageReference Include="AlphaFS">
<Version>2.2.6</Version> <Version>2.2.6</Version>
</PackageReference> </PackageReference>
<PackageReference Include="CefGlue.Wpf"> <PackageReference Include="CefSharp.OffScreen">
<Version>75.1.28</Version> <Version>75.1.143</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Ceras"> <PackageReference Include="Ceras">
<Version>4.1.7</Version> <Version>4.1.7</Version>
@ -209,8 +207,8 @@
<PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView"> <PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView">
<Version>6.0.0</Version> <Version>6.0.0</Version>
</PackageReference> </PackageReference>
<PackageReference Include="MongoDB.Bson"> <PackageReference Include="ModuleInit.Fody">
<Version>2.10.0</Version> <Version>2.1.0</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version> <Version>12.0.3</Version>
@ -237,12 +235,6 @@
<Version>8.0.0</Version> <Version>8.0.0</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Page Include="WebAutomation\WebAutomationWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Channels;
using System.Text;
using System.Threading.Tasks;
using CefSharp;
using Wabbajack.Lib.LibCefHelpers;
namespace Wabbajack.Lib.WebAutomation
{
public class CefSharpWrapper : IWebDriver
{
private IWebBrowser _browser;
public CefSharpWrapper(IWebBrowser browser)
{
_browser = browser;
}
public Task NavigateTo(Uri uri)
{
var tcs = new TaskCompletionSource<bool>();
EventHandler<LoadingStateChangedEventArgs> handler = null;
handler = (sender, e) =>
{
if (!e.IsLoading)
{
_browser.LoadingStateChanged -= handler;
tcs.SetResult(true);
}
};
_browser.LoadingStateChanged += handler;
_browser.Load(uri.ToString());
return tcs.Task;
}
public async Task<string> EvaluateJavaScript(string text)
{
var result = await _browser.EvaluateScriptAsync(text);
if (!result.Success)
throw new Exception(result.Message);
return (string)result.Result;
}
public Task<Helpers.Cookie[]> GetCookies(string domainPrefix)
{
return Helpers.GetCookies(domainPrefix);
}
public async Task WaitForInitialized()
{
while (!_browser.IsBrowserInitialized)
await Task.Delay(100);
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wabbajack.Lib.LibCefHelpers;
namespace Wabbajack.Lib.WebAutomation
{
public interface IWebDriver
{
Task NavigateTo(Uri uri);
Task<string> EvaluateJavaScript(string text);
Task<Helpers.Cookie[]> GetCookies(string domainPrefix);
}
}

View File

@ -2,93 +2,54 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using CefSharp;
using CefSharp.OffScreen;
namespace Wabbajack.Lib.WebAutomation namespace Wabbajack.Lib.WebAutomation
{ {
public enum DisplayMode
{
Visible,
Hidden
}
public class Driver : IDisposable public class Driver : IDisposable
{ {
private WebAutomationWindow _window; private IWebBrowser _browser;
private WebAutomationWindowViewModel _ctx; private CefSharpWrapper _driver;
private Task<WebAutomationWindow> _windowTask;
private Driver(DisplayMode displayMode = DisplayMode.Hidden) public Driver()
{ {
var windowTask = new TaskCompletionSource<WebAutomationWindow>(); _browser = new ChromiumWebBrowser();
_driver = new CefSharpWrapper(_browser);
var t = new Thread(() =>
{
_window = new WebAutomationWindow();
_ctx = (WebAutomationWindowViewModel)_window.DataContext;
// Initiates the dispatcher thread shutdown when the window closes
_window.Closed += (s, e) => _window.Dispatcher.InvokeShutdown();
if (displayMode == DisplayMode.Hidden)
{
_window.WindowState = WindowState.Minimized;
_window.ShowInTaskbar = false;
}
_window.Show();
windowTask.SetResult(_window);
// Makes the thread support message pumping
System.Windows.Threading.Dispatcher.Run();
});
_windowTask = windowTask.Task;
t.SetApartmentState(ApartmentState.STA);
t.Start();
} }
public static async Task<Driver> Create() public static async Task<Driver> Create()
{ {
var driver = new Driver(); var driver = new Driver();
driver._window = await driver._windowTask; await driver._driver.WaitForInitialized();
driver._ctx = (WebAutomationWindowViewModel) driver._window.DataContext;
return driver; return driver;
} }
public Task<Uri> NavigateTo(Uri uri) public async Task<Uri> NavigateTo(Uri uri)
{ {
return _ctx.NavigateTo(uri); await _driver.NavigateTo(uri);
return await GetLocation();
} }
public Task<Uri> GetLocation() public async ValueTask<Uri> GetLocation()
{ {
var tcs = new TaskCompletionSource<Uri>(); try
_window.Dispatcher.Invoke(() => tcs.SetResult(_window.WebView.Source)); {
return tcs.Task; return new Uri(_browser.Address);
}
catch (UriFormatException)
{
return null;
}
} }
public Task<string> GetAttr(string selector, string attr) public Task<string> GetAttr(string selector, string attr)
{ {
var tcs = new TaskCompletionSource<string>(); return _driver.EvaluateJavaScript($"document.querySelector(\"{selector}\").{attr}");
_window.Dispatcher.Invoke(() =>
{
try
{
var script = $"document.querySelector(\"{selector}\").{attr}";
var result = _window.WebView.InvokeScript("eval", script);
tcs.SetResult(result);
}
catch (Exception ex)
{
tcs.SetException(ex);
}
});
return tcs.Task;
} }
public void Dispose() public void Dispose()
{ {
_window.Dispatcher.Invoke(_window.Close); _browser.Dispose();
} }
} }
} }

View File

@ -1,14 +0,0 @@
<Window x:Class="Wabbajack.WebAutomationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wabbajack"
xmlns:controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls.WebView"
mc:Ignorable="d"
Title="WebAutomationWindow" Height="450" Width="800">
<Grid>
<controls:WebView Name="WebView">
</controls:WebView>
</Grid>
</Window>

View File

@ -1,17 +0,0 @@
using System.Windows;
using Wabbajack.Lib.WebAutomation;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for WebAutomationWindow.xaml
/// </summary>
public partial class WebAutomationWindow : Window
{
public WebAutomationWindow()
{
InitializeComponent();
DataContext = new WebAutomationWindowViewModel(this);
}
}
}

View File

@ -1,36 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
using Microsoft.Toolkit.Wpf.UI.Controls;
namespace Wabbajack.Lib.WebAutomation
{
public class WebAutomationWindowViewModel : ViewModel
{
private WebAutomationWindow _window;
private WebView Browser => _window.WebView;
public WebAutomationWindowViewModel(WebAutomationWindow window)
{
_window = window;
}
public Task<Uri> NavigateTo(Uri uri)
{
var tcs = new TaskCompletionSource<Uri>();
EventHandler<WebViewControlNavigationCompletedEventArgs> handler = null;
handler = (s, e) =>
{
Browser.NavigationCompleted -= handler;
tcs.SetResult(uri);
};
Browser.NavigationCompleted += handler;
Browser.Source = uri;
return tcs.Task;
}
}
}

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common; using Wabbajack.Common;
using Wabbajack.Lib; using Wabbajack.Lib;
@ -15,7 +16,7 @@ namespace Wabbajack.Test
[TestInitialize] [TestInitialize]
public async Task TestInitialize() public async Task TestInitialize()
{ {
await Helpers.Initialize(); Helpers.Init();
Consts.TestMode = true; Consts.TestMode = true;
utils = new TestUtils(); utils = new TestUtils();

View File

@ -4,6 +4,8 @@ using System.Threading.Tasks;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Alphaleonis.Win32.Filesystem; using Alphaleonis.Win32.Filesystem;
using CefSharp;
using CefSharp.OffScreen;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Wabbajack.Common; using Wabbajack.Common;
using Wabbajack.Common.StatusFeed; using Wabbajack.Common.StatusFeed;
@ -12,6 +14,7 @@ using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.LibCefHelpers; using Wabbajack.Lib.LibCefHelpers;
using Wabbajack.Lib.NexusApi; using Wabbajack.Lib.NexusApi;
using Wabbajack.Lib.Validation; using Wabbajack.Lib.Validation;
using Wabbajack.Lib.WebAutomation;
using File = Alphaleonis.Win32.Filesystem.File; using File = Alphaleonis.Win32.Filesystem.File;
using Game = Wabbajack.Common.Game; using Game = Wabbajack.Common.Game;
@ -20,13 +23,17 @@ namespace Wabbajack.Test
[TestClass] [TestClass]
public class DownloaderTests public class DownloaderTests
{ {
static DownloaderTests()
{
Helpers.Init();
}
public TestContext TestContext { get; set; } public TestContext TestContext { get; set; }
[TestInitialize] [TestInitialize]
public async Task Setup() public async Task Setup()
{ {
await Helpers.Initialize(); Helpers.Init();
Utils.LogMessages.OfType<IInfo>().Subscribe(onNext: msg => TestContext.WriteLine(msg.ShortDescription)); Utils.LogMessages.OfType<IInfo>().Subscribe(onNext: msg => TestContext.WriteLine(msg.ShortDescription));
Utils.LogMessages.OfType<IUserIntervention>().Subscribe(msg => Utils.LogMessages.OfType<IUserIntervention>().Subscribe(msg =>
TestContext.WriteLine("ERROR: User intervetion required: " + msg.ShortDescription)); TestContext.WriteLine("ERROR: User intervetion required: " + msg.ShortDescription));
@ -182,6 +189,7 @@ namespace Wabbajack.Test
//Assert.AreEqual(File.ReadAllText(filename), "Cheese for Everyone!"); //Assert.AreEqual(File.ReadAllText(filename), "Cheese for Everyone!");
} }
/*
[TestMethod] [TestMethod]
public async Task MediaFireDownload() public async Task MediaFireDownload()
{ {
@ -210,7 +218,7 @@ namespace Wabbajack.Test
Assert.AreEqual(File.ReadAllText(filename), "Cheese for Everyone!"); Assert.AreEqual(File.ReadAllText(filename), "Cheese for Everyone!");
} }*/
[TestMethod] [TestMethod]
public async Task NexusDownload() public async Task NexusDownload()

View File

@ -32,8 +32,8 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<NoWarn>CS1998</NoWarn> <NoWarn>CS1998</NoWarn>
<WarningsAsErrors>CS4014</WarningsAsErrors> <WarningsAsErrors>CS4014</WarningsAsErrors>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -44,8 +44,8 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<NoWarn>CS1998</NoWarn> <NoWarn>CS1998</NoWarn>
<WarningsAsErrors>CS4014</WarningsAsErrors> <WarningsAsErrors>CS4014</WarningsAsErrors>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -55,8 +55,8 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath> <OutputPath>bin\x64\Release\</OutputPath>
@ -66,8 +66,8 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -78,8 +78,8 @@
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath> <OutputPath>bin\x86\Release\</OutputPath>
@ -90,10 +90,18 @@
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CefSharp.Core, Version=75.1.143.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Users\tbald\.nuget\packages\cefsharp.common\75.1.143\CefSharp\x64\CefSharp.Core.dll</HintPath>
</Reference>
<Reference Include="CefSharp.OffScreen, Version=75.1.143.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Users\tbald\.nuget\packages\cefsharp.offscreen\75.1.143\CefSharp\x64\CefSharp.OffScreen.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
@ -161,8 +169,11 @@
<PackageReference Include="AlphaFS"> <PackageReference Include="AlphaFS">
<Version>2.2.6</Version> <Version>2.2.6</Version>
</PackageReference> </PackageReference>
<PackageReference Include="CefGlue.Wpf"> <PackageReference Include="CefSharp.Common">
<Version>75.1.28</Version> <Version>75.1.143</Version>
</PackageReference>
<PackageReference Include="CefSharp.OffScreen">
<Version>75.1.143</Version>
</PackageReference> </PackageReference>
<PackageReference Include="MSTest.TestAdapter"> <PackageReference Include="MSTest.TestAdapter">
<Version>2.0.0</Version> <Version>2.0.0</Version>

View File

@ -11,6 +11,7 @@ namespace Wabbajack.Test
[TestClass] [TestClass]
public class WebAutomationTests public class WebAutomationTests
{ {
/*
[TestMethod] [TestMethod]
public async Task TestBasicNavigation() public async Task TestBasicNavigation()
{ {
@ -30,5 +31,6 @@ namespace Wabbajack.Test
Assert.IsTrue((await w.GetAttr("a.input", "href")).StartsWith("http://")); Assert.IsTrue((await w.GetAttr("a.input", "href")).StartsWith("http://"));
} }
} }
*/
} }
} }

View File

@ -49,8 +49,8 @@ Global
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -67,8 +67,8 @@ Global
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x64.Build.0 = Release|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x64.Build.0 = Release|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x86.ActiveCfg = Release|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x86.ActiveCfg = Release|Any CPU
{B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x86.Build.0 = Release|Any CPU {B3F3FB6E-B9EB-4F49-9875-D78578BC7AE5}.Release|x86.Build.0 = Release|Any CPU
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug (no commandargs)|Any CPU {33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug (no commandargs)|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|Any CPU.Build.0 = Debug (no commandargs)|Any CPU {33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|Any CPU.Build.0 = Debug (no commandargs)|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x64.ActiveCfg = Debug (no commandargs)|x64 {33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x64.ActiveCfg = Debug (no commandargs)|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x64.Build.0 = Debug (no commandargs)|x64 {33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x64.Build.0 = Debug (no commandargs)|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x86.ActiveCfg = Debug (no commandargs)|x86 {33602679-8484-40C7-A10C-774DFF5D8314}.Debug (no commandargs)|x86.ActiveCfg = Debug (no commandargs)|x86
@ -85,8 +85,8 @@ Global
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|x64.Build.0 = Release|x64 {33602679-8484-40C7-A10C-774DFF5D8314}.Release|x64.Build.0 = Release|x64
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|x86.ActiveCfg = Release|x86 {33602679-8484-40C7-A10C-774DFF5D8314}.Release|x86.ActiveCfg = Release|x86
{33602679-8484-40C7-A10C-774DFF5D8314}.Release|x86.Build.0 = Release|x86 {33602679-8484-40C7-A10C-774DFF5D8314}.Release|x86.Build.0 = Release|x86
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -103,8 +103,8 @@ Global
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x64.Build.0 = Release|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x64.Build.0 = Release|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x86.ActiveCfg = Release|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x86.ActiveCfg = Release|Any CPU
{FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x86.Build.0 = Release|Any CPU {FF5D892F-8FF4-44FC-8F7F-CD58F307AD1B}.Release|x86.Build.0 = Release|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64 {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x64.Build.0 = Debug|x64 {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x86.ActiveCfg = Debug|x86 {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Debug (no commandargs)|x86.ActiveCfg = Debug|x86
@ -121,8 +121,8 @@ Global
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x64.Build.0 = Release|Any CPU {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x64.Build.0 = Release|Any CPU
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x86.ActiveCfg = Release|x86 {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x86.ActiveCfg = Release|x86
{A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x86.Build.0 = Release|x86 {A47FFF32-782B-4D9F-8704-C98FB32FA8CC}.Release|x86.Build.0 = Release|x86
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|x64.ActiveCfg = Debug|x64
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|x64.Build.0 = Debug|x64 {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|x64.Build.0 = Debug|x64
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -139,8 +139,8 @@ Global
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x64.Build.0 = Release|Any CPU {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x64.Build.0 = Release|Any CPU
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x86.ActiveCfg = Release|Any CPU {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x86.ActiveCfg = Release|Any CPU
{0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x86.Build.0 = Release|Any CPU {0A820830-A298-497D-85E0-E9A89EFEF5FE}.Release|x86.Build.0 = Release|Any CPU
{9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -157,8 +157,8 @@ Global
{9C004392-571A-4D28-A9F6-0E25115E6727}.Release|x64.Build.0 = Release|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Release|x64.Build.0 = Release|Any CPU
{9C004392-571A-4D28-A9F6-0E25115E6727}.Release|x86.ActiveCfg = Release|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Release|x86.ActiveCfg = Release|Any CPU
{9C004392-571A-4D28-A9F6-0E25115E6727}.Release|x86.Build.0 = Release|Any CPU {9C004392-571A-4D28-A9F6-0E25115E6727}.Release|x86.Build.0 = Release|Any CPU
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -175,8 +175,8 @@ Global
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x64.Build.0 = Release|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x64.Build.0 = Release|Any CPU
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x86.ActiveCfg = Release|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x86.ActiveCfg = Release|Any CPU
{9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x86.Build.0 = Release|Any CPU {9E69BC98-1512-4977-B683-6E7E5292C0B8}.Release|x86.Build.0 = Release|Any CPU
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -193,8 +193,8 @@ Global
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x64.Build.0 = Release|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x64.Build.0 = Release|Any CPU
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x86.ActiveCfg = Release|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x86.ActiveCfg = Release|Any CPU
{5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x86.Build.0 = Release|Any CPU {5D6A2EAF-6604-4C51-8AE2-A746B4BC5E3E}.Release|x86.Build.0 = Release|Any CPU
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -211,8 +211,8 @@ Global
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Release|x64.Build.0 = Release|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Release|x64.Build.0 = Release|Any CPU
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Release|x86.ActiveCfg = Release|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Release|x86.ActiveCfg = Release|Any CPU
{51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Release|x86.Build.0 = Release|Any CPU {51CEB604-985A-45B9-AF0D-C5BA8CFA1BF0}.Release|x86.Build.0 = Release|Any CPU
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU
@ -229,8 +229,8 @@ Global
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Release|x64.Build.0 = Release|x64 {BDC9A094-D235-47CD-83CA-44199B60AB20}.Release|x64.Build.0 = Release|x64
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Release|x86.ActiveCfg = Release|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Release|x86.ActiveCfg = Release|Any CPU
{BDC9A094-D235-47CD-83CA-44199B60AB20}.Release|x86.Build.0 = Release|Any CPU {BDC9A094-D235-47CD-83CA-44199B60AB20}.Release|x86.Build.0 = Release|Any CPU
{37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|Any CPU {37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|Any CPU.ActiveCfg = Debug|x64
{37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|Any CPU.Build.0 = Debug|Any CPU {37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|Any CPU.Build.0 = Debug|x64
{37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU {37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|x64.ActiveCfg = Debug|Any CPU
{37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU {37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|x64.Build.0 = Debug|Any CPU
{37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU {37E4D421-8FD3-4D57-8F3A-7A511D6ED5C5}.Debug (no commandargs)|x86.ActiveCfg = Debug|Any CPU

View File

@ -10,6 +10,7 @@ using ReactiveUI;
using Wabbajack.Common; using Wabbajack.Common;
using Wabbajack.Lib.Downloaders; using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.NexusApi; using Wabbajack.Lib.NexusApi;
using Wabbajack.Lib.WebAutomation;
using Wabbajack.UserInterventions; using Wabbajack.UserInterventions;
namespace Wabbajack namespace Wabbajack
@ -60,14 +61,16 @@ namespace Wabbajack
case RequestNexusAuthorization c: case RequestNexusAuthorization c:
await WrapBrowserJob(msg, async (vm, cancel) => await WrapBrowserJob(msg, async (vm, cancel) =>
{ {
var key = await NexusApiClient.SetupNexusLogin(vm.Browser, m => vm.Instructions = m, cancel.Token); await vm.Driver.WaitForInitialized();
var key = await NexusApiClient.SetupNexusLogin(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
c.Resume(key); c.Resume(key);
}); });
break; break;
case RequestLoversLabLogin c: case RequestLoversLabLogin c:
await WrapBrowserJob(msg, async (vm, cancel) => await WrapBrowserJob(msg, async (vm, cancel) =>
{ {
var data = await LoversLabDownloader.GetAndCacheLoversLabCookies(vm.Browser, m => vm.Instructions = m, cancel.Token); await vm.Driver.WaitForInitialized();
var data = await LoversLabDownloader.GetAndCacheLoversLabCookies(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
c.Resume(data); c.Resume(data);
}); });
break; break;

View File

@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CefSharp;
using CefSharp.Wpf;
using ReactiveUI; using ReactiveUI;
using ReactiveUI.Fody.Helpers; using ReactiveUI.Fody.Helpers;
using Wabbajack.Lib; using Wabbajack.Lib;
using Wabbajack.Lib.LibCefHelpers; using Wabbajack.Lib.LibCefHelpers;
using Xilium.CefGlue.WPF; using Wabbajack.Lib.WebAutomation;
namespace Wabbajack namespace Wabbajack
{ {
@ -16,21 +18,20 @@ namespace Wabbajack
[Reactive] [Reactive]
public string Instructions { get; set; } public string Instructions { get; set; }
public WpfCefBrowser Browser { get; } = new WpfCefBrowser(); public IWebBrowser Browser { get; } = new ChromiumWebBrowser();
public CefSharpWrapper Driver => new CefSharpWrapper(Browser);
[Reactive] [Reactive]
public IReactiveCommand BackCommand { get; set; } public IReactiveCommand BackCommand { get; set; }
private WebBrowserVM(string url = "http://www.wabbajack.org") private WebBrowserVM(string url = "http://www.wabbajack.org")
{ {
Browser.Address = url;
Instructions = "Wabbajack Web Browser"; Instructions = "Wabbajack Web Browser";
} }
public static async Task<WebBrowserVM> GetNew(string url = "http://www.wabbajack.org") public static async Task<WebBrowserVM> GetNew(string url = "http://www.wabbajack.org")
{ {
// Make sure libraries are extracted first // Make sure libraries are extracted first
await Helpers.Initialize();
return new WebBrowserVM(url); return new WebBrowserVM(url);
} }
} }

View File

@ -20,6 +20,7 @@ namespace Wabbajack
public MainWindow() public MainWindow()
{ {
Helpers.Init();
// Wire any unhandled crashing exceptions to log before exiting // Wire any unhandled crashing exceptions to log before exiting
AppDomain.CurrentDomain.UnhandledException += (sender, e) => AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{ {
@ -32,7 +33,6 @@ namespace Wabbajack
// Run some init tasks in background // Run some init tasks in background
Task.Run(async () => Task.Run(async () =>
{ {
await Helpers.Initialize();
var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
try try
{ {

View File

@ -5,7 +5,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:wabbajack="clr-namespace:Wabbajack" xmlns:wabbajack="clr-namespace:Wabbajack"
xmlns:wpf="clr-namespace:Xilium.CefGlue.WPF;assembly=Xilium.CefGlue.WPF"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources> <UserControl.Resources>

View File

@ -476,8 +476,8 @@
<PackageReference Include="AlphaFS"> <PackageReference Include="AlphaFS">
<Version>2.2.6</Version> <Version>2.2.6</Version>
</PackageReference> </PackageReference>
<PackageReference Include="CefGlue.Wpf"> <PackageReference Include="CefSharp.Wpf">
<Version>75.1.28</Version> <Version>75.1.143</Version>
</PackageReference> </PackageReference>
<PackageReference Include="CommonMark.NET"> <PackageReference Include="CommonMark.NET">
<Version>0.15.1</Version> <Version>0.15.1</Version>