mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #315 from wabbajack-tools/remove-webview
Remove Webview, swap to CefSharp
This commit is contained in:
commit
96ad1d6130
@ -5,5 +5,6 @@
|
||||
<Workers>0</Workers>
|
||||
<Scope>MethodLevel</Scope>
|
||||
</Parallelize>
|
||||
<DisableAppDomain>True</DisableAppDomain>
|
||||
</MSTest>
|
||||
</RunSettings>
|
@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Genbox.AlphaFS" Version="2.2.2.1" />
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -59,6 +59,32 @@
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</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>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -2,6 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Reactive" Version="4.3.2" />
|
||||
|
@ -2,6 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="7z.dll.gz" />
|
||||
|
@ -3,18 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using Wabbajack.Lib.Validation;
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
|
@ -15,7 +15,7 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Lib.LibCefHelpers;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Xilium.CefGlue.Common;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
|
||||
namespace Wabbajack.Lib.Downloaders
|
||||
@ -64,16 +64,15 @@ namespace Wabbajack.Lib.Downloaders
|
||||
_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");
|
||||
browser.Address = "https://www.loverslab.com/login";
|
||||
|
||||
await browser.NavigateTo(new Uri("https://www.loverslab.com/login"));
|
||||
async Task<bool> CleanAds()
|
||||
{
|
||||
try
|
||||
{
|
||||
await browser.EvaluateJavaScript<string>(
|
||||
await browser.EvaluateJavaScript(
|
||||
"document.querySelectorAll(\".ll_adblock\").forEach(function (itm) { itm.innerHTML = \"\";});");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -87,7 +86,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
cancel.ThrowIfCancellationRequested();
|
||||
await CleanAds();
|
||||
cookies = (await Helpers.GetCookies("loverslab.com"));
|
||||
cookies = (await browser.GetCookies("loverslab.com"));
|
||||
if (cookies.FirstOrDefault(c => c.Name == "ips4_member_id") != null)
|
||||
break;
|
||||
await Task.Delay(500, cancel);
|
||||
|
@ -1,3 +1,4 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ReactiveUI />
|
||||
<ModuleInit />
|
||||
</Weavers>
|
@ -5,6 +5,7 @@
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<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:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
|
@ -8,42 +8,38 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using CefSharp;
|
||||
using CefSharp.OffScreen;
|
||||
using Wabbajack.Common;
|
||||
using Xilium.CefGlue;
|
||||
|
||||
namespace Wabbajack.Lib.LibCefHelpers
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
private static readonly Task _initTask;
|
||||
|
||||
/// <summary>
|
||||
/// We bundle the cef libs inside the .exe, we need to extract them before loading any wpf code that requires them
|
||||
/// </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 rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wabbajack.Lib.LibCefHelpers.cefglue.7z"))
|
||||
using (var fs = File.OpenWrite("cefsharp.7z"))
|
||||
using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wabbajack.Lib.LibCefHelpers.cefsharp.7z"))
|
||||
{
|
||||
rs.CopyTo(fs);
|
||||
Utils.Log("Extracting libCef files");
|
||||
}
|
||||
using (var wq = new WorkQueue(1))
|
||||
{
|
||||
await FileExtractor.ExtractAll(wq, "cefglue.7z", ".");
|
||||
FileExtractor.ExtractAll(wq, "cefsharp.7z", ".").Wait();
|
||||
}
|
||||
}
|
||||
|
||||
static Helpers()
|
||||
{
|
||||
_initTask = Task.Run(ExtractLibs);
|
||||
}
|
||||
|
||||
public static Task Initialize()
|
||||
{
|
||||
return _initTask;
|
||||
ExtractLibs();
|
||||
//if (!Cef.IsInitialized)
|
||||
// Cef.Initialize(new CefSettings { MultiThreadedMessageLoop = true });
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var manager = CefCookieManager.GetGlobal(null);
|
||||
var manager = Cef.GetGlobalCookieManager();
|
||||
var visitor = new CookieVisitor();
|
||||
if (!manager.VisitAllCookies(visitor))
|
||||
return new Cookie[0];
|
||||
@ -78,13 +74,18 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
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>>();
|
||||
public Task<List<Cookie>> Task => _source.Task;
|
||||
|
||||
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
|
||||
{
|
||||
@ -95,15 +96,9 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
});
|
||||
if (count == total)
|
||||
_source.SetResult(Cookies);
|
||||
delete = false;
|
||||
deleteCookie = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
_source.SetResult(Cookies);
|
||||
}
|
||||
}
|
||||
|
||||
public class Cookie
|
||||
@ -113,5 +108,18 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
public string Domain { 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -1,7 +1,6 @@
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -9,22 +8,18 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Security.Authentication;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
using Syroot.Windows.IO;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.LibCefHelpers;
|
||||
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 System.Threading;
|
||||
using CefSharp;
|
||||
using CefSharp.Handler;
|
||||
using Newtonsoft.Json;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
|
||||
namespace Wabbajack.Lib.NexusApi
|
||||
{
|
||||
@ -98,30 +93,13 @@ namespace Wabbajack.Lib.NexusApi
|
||||
return result;
|
||||
}
|
||||
|
||||
class RefererHandler : RequestHandler
|
||||
{
|
||||
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)
|
||||
public static async Task<string> SetupNexusLogin(IWebDriver browser, Action<string> updateStatus, CancellationToken cancel)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var cookies = await Helpers.GetCookies("nexusmods.com");
|
||||
var cookies = await browser.GetCookies("nexusmods.com");
|
||||
if (cookies.Any(c => c.Name == "member_id"))
|
||||
break;
|
||||
cancel.ThrowIfCancellationRequested();
|
||||
@ -147,7 +125,7 @@ namespace Wabbajack.Lib.NexusApi
|
||||
await Task.Delay(1000, cancel);
|
||||
|
||||
// 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(() =>
|
||||
{
|
||||
api_key.SetCanceled();
|
||||
|
@ -156,16 +156,14 @@
|
||||
<Compile Include="ViewModel.cs" />
|
||||
<Compile Include="VortexCompiler.cs" />
|
||||
<Compile Include="VortexInstaller.cs" />
|
||||
<Compile Include="WebAutomation\CefSharpWrapper.cs" />
|
||||
<Compile Include="WebAutomation\IWebDriver.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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<EmbeddedResource Include="LibCefHelpers\cefglue.7z" />
|
||||
<EmbeddedResource Include="LibCefHelpers\cefsharp.7z" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\Compression.BSA\Compression.BSA.csproj">
|
||||
@ -191,8 +189,8 @@
|
||||
<PackageReference Include="AlphaFS">
|
||||
<Version>2.2.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CefGlue.Wpf">
|
||||
<Version>75.1.28</Version>
|
||||
<PackageReference Include="CefSharp.OffScreen">
|
||||
<Version>75.1.143</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Ceras">
|
||||
<Version>4.1.7</Version>
|
||||
@ -209,8 +207,8 @@
|
||||
<PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView">
|
||||
<Version>6.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MongoDB.Bson">
|
||||
<Version>2.10.0</Version>
|
||||
<PackageReference Include="ModuleInit.Fody">
|
||||
<Version>2.1.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>12.0.3</Version>
|
||||
@ -237,12 +235,6 @@
|
||||
<Version>8.0.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="WebAutomation\WebAutomationWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
60
Wabbajack.Lib/WebAutomation/CefSharpWrapper.cs
Normal file
60
Wabbajack.Lib/WebAutomation/CefSharpWrapper.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
16
Wabbajack.Lib/WebAutomation/IWebDriver.cs
Normal file
16
Wabbajack.Lib/WebAutomation/IWebDriver.cs
Normal 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);
|
||||
}
|
||||
}
|
@ -2,93 +2,54 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using CefSharp;
|
||||
using CefSharp.OffScreen;
|
||||
|
||||
namespace Wabbajack.Lib.WebAutomation
|
||||
{
|
||||
public enum DisplayMode
|
||||
{
|
||||
Visible,
|
||||
Hidden
|
||||
}
|
||||
|
||||
public class Driver : IDisposable
|
||||
{
|
||||
private WebAutomationWindow _window;
|
||||
private WebAutomationWindowViewModel _ctx;
|
||||
private Task<WebAutomationWindow> _windowTask;
|
||||
private IWebBrowser _browser;
|
||||
private CefSharpWrapper _driver;
|
||||
|
||||
private Driver(DisplayMode displayMode = DisplayMode.Hidden)
|
||||
public Driver()
|
||||
{
|
||||
var windowTask = new TaskCompletionSource<WebAutomationWindow>();
|
||||
|
||||
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;
|
||||
_browser = new ChromiumWebBrowser();
|
||||
_driver = new CefSharpWrapper(_browser);
|
||||
}
|
||||
|
||||
_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()
|
||||
{
|
||||
var driver = new Driver();
|
||||
driver._window = await driver._windowTask;
|
||||
driver._ctx = (WebAutomationWindowViewModel) driver._window.DataContext;
|
||||
await driver._driver.WaitForInitialized();
|
||||
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>();
|
||||
_window.Dispatcher.Invoke(() => tcs.SetResult(_window.WebView.Source));
|
||||
return tcs.Task;
|
||||
try
|
||||
{
|
||||
return new Uri(_browser.Address);
|
||||
}
|
||||
catch (UriFormatException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<string> GetAttr(string selector, string attr)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
_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;
|
||||
return _driver.EvaluateJavaScript($"document.querySelector(\"{selector}\").{attr}");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_window.Dispatcher.Invoke(_window.Close);
|
||||
_browser.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
@ -15,7 +16,7 @@ namespace Wabbajack.Test
|
||||
[TestInitialize]
|
||||
public async Task TestInitialize()
|
||||
{
|
||||
await Helpers.Initialize();
|
||||
Helpers.Init();
|
||||
Consts.TestMode = true;
|
||||
|
||||
utils = new TestUtils();
|
||||
|
@ -4,6 +4,8 @@ using System.Threading.Tasks;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using CefSharp;
|
||||
using CefSharp.OffScreen;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.StatusFeed;
|
||||
@ -12,6 +14,7 @@ using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.LibCefHelpers;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
|
||||
@ -20,13 +23,17 @@ namespace Wabbajack.Test
|
||||
[TestClass]
|
||||
public class DownloaderTests
|
||||
{
|
||||
static DownloaderTests()
|
||||
{
|
||||
Helpers.Init();
|
||||
}
|
||||
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
[TestInitialize]
|
||||
public async Task Setup()
|
||||
{
|
||||
await Helpers.Initialize();
|
||||
Helpers.Init();
|
||||
Utils.LogMessages.OfType<IInfo>().Subscribe(onNext: msg => TestContext.WriteLine(msg.ShortDescription));
|
||||
Utils.LogMessages.OfType<IUserIntervention>().Subscribe(msg =>
|
||||
TestContext.WriteLine("ERROR: User intervetion required: " + msg.ShortDescription));
|
||||
@ -182,6 +189,7 @@ namespace Wabbajack.Test
|
||||
//Assert.AreEqual(File.ReadAllText(filename), "Cheese for Everyone!");
|
||||
}
|
||||
|
||||
/*
|
||||
[TestMethod]
|
||||
public async Task MediaFireDownload()
|
||||
{
|
||||
@ -210,7 +218,7 @@ namespace Wabbajack.Test
|
||||
|
||||
Assert.AreEqual(File.ReadAllText(filename), "Cheese for Everyone!");
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
[TestMethod]
|
||||
public async Task NexusDownload()
|
||||
|
@ -94,6 +94,14 @@
|
||||
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
|
||||
</PropertyGroup>
|
||||
<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="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
@ -161,8 +169,11 @@
|
||||
<PackageReference Include="AlphaFS">
|
||||
<Version>2.2.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CefGlue.Wpf">
|
||||
<Version>75.1.28</Version>
|
||||
<PackageReference Include="CefSharp.Common">
|
||||
<Version>75.1.143</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CefSharp.OffScreen">
|
||||
<Version>75.1.143</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MSTest.TestAdapter">
|
||||
<Version>2.0.0</Version>
|
||||
|
@ -11,6 +11,7 @@ namespace Wabbajack.Test
|
||||
[TestClass]
|
||||
public class WebAutomationTests
|
||||
{
|
||||
/*
|
||||
[TestMethod]
|
||||
public async Task TestBasicNavigation()
|
||||
{
|
||||
@ -30,5 +31,6 @@ namespace Wabbajack.Test
|
||||
Assert.IsTrue((await w.GetAttr("a.input", "href")).StartsWith("http://"));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ Global
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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)|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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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|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)|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|x86.ActiveCfg = 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.Build.0 = 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|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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|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|x86.ActiveCfg = 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.Build.0 = 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|x64
|
||||
{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)|x86.ActiveCfg = Debug|Any CPU
|
||||
|
@ -10,6 +10,7 @@ using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
using Wabbajack.UserInterventions;
|
||||
|
||||
namespace Wabbajack
|
||||
@ -60,14 +61,16 @@ namespace Wabbajack
|
||||
case RequestNexusAuthorization c:
|
||||
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);
|
||||
});
|
||||
break;
|
||||
case RequestLoversLabLogin c:
|
||||
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);
|
||||
});
|
||||
break;
|
||||
|
@ -3,11 +3,13 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CefSharp;
|
||||
using CefSharp.Wpf;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.LibCefHelpers;
|
||||
using Xilium.CefGlue.WPF;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -16,21 +18,20 @@ namespace Wabbajack
|
||||
[Reactive]
|
||||
public string Instructions { get; set; }
|
||||
|
||||
public WpfCefBrowser Browser { get; } = new WpfCefBrowser();
|
||||
public IWebBrowser Browser { get; } = new ChromiumWebBrowser();
|
||||
public CefSharpWrapper Driver => new CefSharpWrapper(Browser);
|
||||
|
||||
[Reactive]
|
||||
public IReactiveCommand BackCommand { get; set; }
|
||||
|
||||
private WebBrowserVM(string url = "http://www.wabbajack.org")
|
||||
{
|
||||
Browser.Address = url;
|
||||
Instructions = "Wabbajack Web Browser";
|
||||
}
|
||||
|
||||
public static async Task<WebBrowserVM> GetNew(string url = "http://www.wabbajack.org")
|
||||
{
|
||||
// Make sure libraries are extracted first
|
||||
await Helpers.Initialize();
|
||||
return new WebBrowserVM(url);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ namespace Wabbajack
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
Helpers.Init();
|
||||
// Wire any unhandled crashing exceptions to log before exiting
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
||||
{
|
||||
@ -32,7 +33,6 @@ namespace Wabbajack
|
||||
// Run some init tasks in background
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Helpers.Initialize();
|
||||
var appPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
try
|
||||
{
|
||||
|
@ -5,7 +5,6 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
|
||||
xmlns:wabbajack="clr-namespace:Wabbajack"
|
||||
xmlns:wpf="clr-namespace:Xilium.CefGlue.WPF;assembly=Xilium.CefGlue.WPF"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
|
@ -476,8 +476,8 @@
|
||||
<PackageReference Include="AlphaFS">
|
||||
<Version>2.2.6</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CefGlue.Wpf">
|
||||
<Version>75.1.28</Version>
|
||||
<PackageReference Include="CefSharp.Wpf">
|
||||
<Version>75.1.143</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="CommonMark.NET">
|
||||
<Version>0.15.1</Version>
|
||||
|
Loading…
Reference in New Issue
Block a user