Compare commits

...
5 Commits
Author SHA1 Message Date
Alexandru Macocian 1d774ab8de Disable script injection when dynamic build loading is disabled.
Fixed a bug where earth prayers was not a recognized attribute.
2021-04-23 11:11:19 +02:00
Alexandru Macocian bc66ca9948 Feature flag to disable dynamic build loading in experimental settings. 2021-04-22 17:53:04 +02:00
amacocianandGitHub 524cd21fd4 Update README.md 2021-04-22 17:39:51 +02:00
amacocianandGitHub 132cb0e1f4 Update README.md 2021-04-22 17:32:35 +02:00
amacocianandGitHub 09c99e7731 Update README.md 2021-04-22 17:29:49 +02:00
10 changed files with 69 additions and 13 deletions
@@ -8,5 +8,7 @@ namespace Daybreak.Configuration
public bool MultiLaunchSupport { get; set; }
[JsonProperty("ToolboxAutoLaunchDelay")]
public int ToolboxAutoLaunchDelay { get; set; } = 5000;
[JsonProperty("DynamicBuildLoading")]
public bool DynamicBuildLoading { get; set; } = true;
}
}
@@ -138,6 +138,7 @@ namespace Daybreak.Controls
{
await this.WebBrowser.EnsureCoreWebView2Async(this.coreWebView2Environment);
this.AddressBarReadonly = this.configurationManager.GetConfiguration().AddressBarReadonly;
this.CanDownloadBuild = this.configurationManager.GetConfiguration().ExperimentalFeatures.DynamicBuildLoading;
this.WebBrowser.CoreWebView2.NewWindowRequested += (browser, args) => args.Handled = true;
this.WebBrowser.NavigationStarting += (browser, args) =>
{
@@ -154,7 +155,10 @@ namespace Daybreak.Controls
this.WebBrowser.WebMessageReceived += this.CoreWebView2_WebMessageReceived;
this.WebBrowser.CoreWebView2.Settings.AreDevToolsEnabled = false;
this.WebBrowser.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
await this.WebBrowser.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(Scripts.AlterContextMenu);
if (this.CanDownloadBuild)
{
await this.WebBrowser.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(Scripts.SendSelectionOnContextMenu);
}
}
}
@@ -210,12 +214,17 @@ namespace Daybreak.Controls
if (payload?.Key == BrowserPayload.PayloadKeys.ContextMenu)
{
var contextMenuPayload = args.WebMessageAsJson.Deserialize<BrowserPayload<OnContextMenuPayload>>();
if (this.CanDownloadBuild is false)
var maybeTemplate = contextMenuPayload.Value.Selection;
if (string.IsNullOrWhiteSpace(maybeTemplate))
{
return;
}
if (this.buildTemplateManager.IsTemplate(maybeTemplate) is false)
{
return;
}
var maybeTemplate = contextMenuPayload.Value.Selection;
Task.Run(() =>
{
try
+4 -4
View File
@@ -9,17 +9,17 @@
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<Version>0.7.0</Version>
<Version>0.7.2</Version>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.32" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.774.44" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.818.41" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Slim" Version="1.2.1" />
<PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" />
<PackageReference Include="SystemExtensions.NetStandard" Version="1.1.3" />
<PackageReference Include="SystemExtensions.NetStandard" Version="1.1.4" />
<PackageReference Include="WCL" Version="1.0.2" />
<PackageReference Include="WpfExtended" Version="0.2.0" />
</ItemGroup>
+1
View File
@@ -89,6 +89,7 @@ namespace Daybreak.Models.Builds
Motivation,
Leadership,
ScytheMastery,
EarthPrayers,
WindPrayers,
EarthMagic,
Mysticism
@@ -24,6 +24,21 @@ namespace Daybreak.Services.BuildTemplates
this.logger = logger.ThrowIfNull(nameof(logger));
}
public bool IsTemplate(string template)
{
if (template.IsNullOrWhiteSpace())
{
return false;
}
if (template.Where(c => DecodingLookupTable.Contains(c) is false).Any())
{
return false;
}
return true;
}
public BuildEntry CreateBuild()
{
var emptyBuild = new Build();
@@ -5,6 +5,7 @@ namespace Daybreak.Services.BuildTemplates
{
public interface IBuildTemplateManager
{
bool IsTemplate(string template);
BuildEntry CreateBuild();
BuildEntry CreateBuild(string name);
void SaveBuild(BuildEntry buildEntry);
+10 -6
View File
@@ -2,17 +2,21 @@
{
public static class Scripts
{
public const string AlterContextMenu = @"
public const string SendSelectionOnContextMenu = @"
document.addEventListener('contextmenu', function (event)
{
var text = '';
if (window.getSelection)
var activeEl = document.activeElement;
var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null;
if ((activeElTagName == 'textarea') || (activeElTagName == 'input' &&
/^(?:text|search|password|tel|url)$/i.test(activeEl.type)) &&
(typeof activeEl.selectionStart == 'number'))
{
text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd);
}
else if (window.getSelection)
{
text = window.getSelection().toString();
}
else if (document.selection && document.selection.type != 'Control')
{
text = document.selection.createRange().text;
}
let jsonObject =
@@ -90,6 +90,7 @@
<StackPanel>
<TextBlock Text="Multi-launch support" Foreground="White" FontSize="22" VerticalAlignment="Center" Margin="0, 0, 15, 0" Height="30"></TextBlock>
<TextBlock Text="GWToolbox startup delay (in ms)" Foreground="White" FontSize="22" VerticalAlignment="Center" Margin="0, 0, 15, 0" Height="30"></TextBlock>
<TextBlock Text="Detect build templates (in browser)" Foreground="White" FontSize="22" VerticalAlignment="Center" Margin="0, 0, 15, 0" Height="30"></TextBlock>
</StackPanel>
<StackPanel Grid.Column="1">
<ToggleButton IsChecked="{Binding ElementName=_this, Path=MultiLaunch, Mode=TwoWay}" Style="{StaticResource AnimatedSwitch}"
@@ -97,6 +98,8 @@
<TextBox Background="Transparent" Foreground="White" FontSize="16" Height="30"
PreviewTextInput="TextBox_AllowNumbersOnly" Text="{Binding ElementName=_this, Path=GWToolboxLaunchDelay, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
CommandManager.PreviewCanExecute="TextBox_DisallowPaste"></TextBox>
<ToggleButton IsChecked="{Binding ElementName=_this, Path=DynamicBuildLoading, Mode=TwoWay}" Style="{StaticResource AnimatedSwitch}"
Height="30" Width="60"></ToggleButton>
</StackPanel>
</Grid>
</Grid>
@@ -19,6 +19,8 @@ namespace Daybreak.Views
DependencyPropertyExtensions.Register<ExperimentalSettingsView, bool>(nameof(MultiLaunch));
public static readonly DependencyProperty GWToolboxLaunchDelayProperty =
DependencyPropertyExtensions.Register<ExperimentalSettingsView, string>(nameof(GWToolboxLaunchDelay));
public static readonly DependencyProperty DynamicBuildLoadingProperty =
DependencyPropertyExtensions.Register<ExperimentalSettingsView, bool>(nameof(DynamicBuildLoading));
private readonly IViewManager viewManager;
private readonly IConfigurationManager configurationManager;
@@ -33,6 +35,11 @@ namespace Daybreak.Views
get => this.GetTypedValue<string>(GWToolboxLaunchDelayProperty);
set => this.SetValue(GWToolboxLaunchDelayProperty, value);
}
public bool DynamicBuildLoading
{
get => this.GetTypedValue<bool>(DynamicBuildLoadingProperty);
set => this.SetValue(DynamicBuildLoadingProperty, value);
}
public ExperimentalSettingsView(
IViewManager viewManager,
@@ -49,12 +56,14 @@ namespace Daybreak.Views
var config = this.configurationManager.GetConfiguration();
this.MultiLaunch = config.ExperimentalFeatures.MultiLaunchSupport;
this.GWToolboxLaunchDelay = config.ExperimentalFeatures.ToolboxAutoLaunchDelay.ToString();
this.DynamicBuildLoading = config.ExperimentalFeatures.DynamicBuildLoading;
}
private void SaveExperimentalSettings()
{
var config = this.configurationManager.GetConfiguration();
config.ExperimentalFeatures.MultiLaunchSupport = this.MultiLaunch;
config.ExperimentalFeatures.DynamicBuildLoading = this.DynamicBuildLoading;
if (int.TryParse(this.GWToolboxLaunchDelay, out var gwToolboxLaunchDelay))
{
config.ExperimentalFeatures.ToolboxAutoLaunchDelay = gwToolboxLaunchDelay;
+12
View File
@@ -5,6 +5,8 @@ Requires webview2 runtime https://go.microsoft.com/fwlink/p/?LinkId=2124703.
![Showcase 1](https://media1.giphy.com/media/Z32o0OZ5pZHDOIodzD/giphy.gif)
![Showcase 2](https://media0.giphy.com/media/aQ8Wl7lsuhT0AblCPI/giphy.gif)
![Showcase 3](https://media2.giphy.com/media/s06PtxgeAAZtoJhTx6/giphy.gif)
![Build Management Showcase](https://media2.giphy.com/media/C399pwfypdZvkmoJpi/giphy.gif)
![Dynamic build loading](https://media2.giphy.com/media/UKtJaoBk6NeuOmE8al/giphy.gif)
# Features
Automatically detect if guildwars is running or not. Includes the ability to launch guildwars from the client.
@@ -43,3 +45,13 @@ To adjust executables, go into Guildwars settings. Clicking on the star next to
To enable multiboxing (multi-launch), go into Experimental settings. Then, switch between executables/accounts and launch them.
![Multibox toggle](https://i.imgur.com/vEFF2pb.png)
To manage builds, go into Settings, Builds. Here you can select/remove builds.
![Builds list view](https://i.imgur.com/OFxnFcZ.png)
Doubleclick on one of the builds to enter the template management view. Here you can click on skills to open the wiki page of the skill. You can adjust professions, attributes and add/remove skills.
![Builds management view](https://i.imgur.com/exKWJb8.png)
To dynamically load a build, while browsing in the browsers from the main page, select and rightclick any text on the page that might be a template. If it is a template, the client will open a context menu with a button called "Load build template". Click on that button to load the build and switch to build template view.
![Dynamically load build](https://i.imgur.com/V5vvgsg.png)