2022-05-16 22:14:52 +00:00
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Wabbajack.DTOs.DownloadStates;
|
|
|
|
using Wabbajack.DTOs.Interventions;
|
|
|
|
|
|
|
|
namespace Wabbajack.UserIntervention;
|
|
|
|
|
2022-05-20 03:23:16 +00:00
|
|
|
public class ManualDownloadHandler : BrowserWindowViewModel
|
2022-05-16 22:14:52 +00:00
|
|
|
{
|
|
|
|
public ManualDownload Intervention { get; set; }
|
2022-05-19 03:21:38 +00:00
|
|
|
|
2022-05-16 22:14:52 +00:00
|
|
|
protected override async Task Run(CancellationToken token)
|
|
|
|
{
|
2022-05-20 04:12:16 +00:00
|
|
|
//await WaitForReady();
|
2022-05-16 22:14:52 +00:00
|
|
|
var archive = Intervention.Archive;
|
|
|
|
var md = Intervention.Archive.State as Manual;
|
2023-10-12 18:33:06 +00:00
|
|
|
|
2022-05-19 03:21:38 +00:00
|
|
|
HeaderText = $"Manual download ({md.Url.Host})";
|
2022-05-16 22:14:52 +00:00
|
|
|
|
2023-10-12 18:33:06 +00:00
|
|
|
Instructions = string.IsNullOrWhiteSpace(md.Prompt) ? $"Please download {archive.Name}" : md.Prompt;
|
2022-08-18 23:02:19 +00:00
|
|
|
|
2023-10-12 18:33:06 +00:00
|
|
|
var task = WaitForDownloadUri(token, async () =>
|
2022-08-18 23:02:19 +00:00
|
|
|
{
|
2023-11-15 03:19:53 +00:00
|
|
|
await RunJavaScript("Array.from(document.getElementsByTagName(\"iframe\")).forEach(f => {if (f.title != \"SP Consent Message\" && !f.src.includes(\"challenges.cloudflare.com\")) f.remove()})");
|
2022-08-18 23:02:19 +00:00
|
|
|
});
|
2023-10-12 18:33:06 +00:00
|
|
|
await NavigateTo(md.Url);
|
|
|
|
var uri = await task;
|
|
|
|
|
2022-05-16 22:14:52 +00:00
|
|
|
Intervention.Finish(uri);
|
2023-11-19 21:07:46 +00:00
|
|
|
await Task.Delay(5000, CancellationToken.None);
|
2022-05-16 22:14:52 +00:00
|
|
|
}
|
|
|
|
}
|