Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions OpenBullet2.Native/ViewModels/RLSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ public string SeleniumChromeBinaryLocation
}
}

public string SeleniumEdgeBinaryLocation
{
get => Selenium.EdgeBinaryLocation;
set
{
Selenium.EdgeBinaryLocation = value;
OnPropertyChanged();
}
}

public string SeleniumFirefoxBinaryLocation
{
get => Selenium.FirefoxBinaryLocation;
Expand Down
5 changes: 5 additions & 0 deletions OpenBullet2.Native/Views/Pages/RLSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@
<TextBox Text="{Binding SeleniumChromeBinaryLocation}"
Width="500"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 10 0 0">
<Label>Path of the edge.exe binary on disk</Label>
<TextBox Text="{Binding SeleniumEdgeBinaryLocation}"
Width="500"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 10 0 0">
<Label>Path of the firefox.exe binary on disk</Label>
<TextBox Text="{Binding SeleniumFirefoxBinaryLocation}"
Expand Down
53 changes: 53 additions & 0 deletions RuriLib/Blocks/Selenium/Browser/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RuriLib.Models.Settings;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Edge;
using System;
using OpenQA.Selenium;
using System.Linq;
Expand Down Expand Up @@ -88,6 +89,58 @@ public static void SeleniumOpenBrowser(BotData data, string extraCmdLineArgs = "
data.SetObject("selenium", new ChromeDriver(chromeservice, chromeop));
break;

case SeleniumBrowserType.Edge:
var edgeop = new EdgeOptions();
var edgeservice = EdgeDriverService.CreateDefaultService();
edgeservice.SuppressInitialDiagnosticInformation = true;
edgeservice.HideCommandPromptWindow = true;
edgeservice.EnableVerboseLogging = false;
edgeop.AddArgument("--log-level=3");
edgeop.BinaryLocation = provider.EdgeBinaryLocation;

if (Utils.IsDocker())
{
if (RootChecker.IsRoot())
{
edgeop.AddArgument("--no-sandbox");
}

edgeop.AddArgument("--whitelisted-ips=''");
edgeop.AddArgument("--disable-dev-shm-usage");
}

if (data.ConfigSettings.BrowserSettings.Headless)
{
edgeop.AddArgument("--headless");
}

if (data.ConfigSettings.BrowserSettings.DismissDialogs)
{
edgeop.AddArgument("--disable-notifications");
}

args = data.ConfigSettings.BrowserSettings.CommandLineArgs;

if (!string.IsNullOrWhiteSpace(args))
{
// Extra command line args (to have dynamic args via variables)
if (!string.IsNullOrWhiteSpace(extraCmdLineArgs))
{
args += ' ' + extraCmdLineArgs;
}

edgeop.AddArgument(args);
}

if (data.UseProxy)
{
// TODO: Add support for auth proxies using yove
edgeop.AddArgument($"--proxy-server={data.Proxy.Type.ToString().ToLower()}://{data.Proxy.Host}:{data.Proxy.Port}");
}

data.SetObject("selenium", new EdgeDriver(edgeservice, edgeop));
break;

case SeleniumBrowserType.Firefox:
var fireop = new FirefoxOptions();
var fireservice = FirefoxDriverService.CreateDefaultService();
Expand Down
43 changes: 43 additions & 0 deletions RuriLib/Legacy/Blocks/SBlockBrowserAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Interactions;
using RuriLib.Legacy.LS;
using RuriLib.Legacy.Models;
Expand Down Expand Up @@ -396,6 +397,48 @@ public static void OpenBrowser(BotData data)
data.SetObject("selenium", new ChromeDriver(chromeservice, chromeop));
break;

case SeleniumBrowserType.Edge:
var edgeop = new EdgeOptions();
var edgeservice = EdgeDriverService.CreateDefaultService();
edgeservice.SuppressInitialDiagnosticInformation = true;
edgeservice.HideCommandPromptWindow = true;
edgeservice.EnableVerboseLogging = false;
edgeop.AddArgument("--log-level=3");
edgeop.BinaryLocation = provider.EdgeBinaryLocation;

if (Helpers.Utils.IsDocker())
{
edgeop.AddArgument("--no-sandbox");
edgeop.AddArgument("--whitelisted-ips=''");
edgeop.AddArgument("--disable-dev-shm-usage");
}

if (data.ConfigSettings.BrowserSettings.Headless)
{
edgeop.AddArgument("--headless");
}

// TODO: Readd support for chrome extensions

if (data.ConfigSettings.BrowserSettings.DismissDialogs)
{
edgeop.AddArgument("--disable-notifications");
}

if (!string.IsNullOrWhiteSpace(data.ConfigSettings.BrowserSettings.CommandLineArgs))
{
edgeop.AddArgument(data.ConfigSettings.BrowserSettings.CommandLineArgs);
}

if (data.UseProxy)
{
// TODO: Add support for auth proxies using yove
edgeop.AddArgument($"--proxy-server={data.Proxy.Type.ToString().ToLower()}://{data.Proxy.Host}:{data.Proxy.Port}");
}

data.SetObject("selenium", new EdgeDriver(edgeservice, edgeop));
break;

case SeleniumBrowserType.Firefox:
var fireop = new FirefoxOptions();
var fireservice = FirefoxDriverService.CreateDefaultService();
Expand Down
2 changes: 2 additions & 0 deletions RuriLib/Models/Settings/SeleniumSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ public class SeleniumSettings
{
public SeleniumBrowserType BrowserType { get; set; } = SeleniumBrowserType.Chrome;
public string ChromeBinaryLocation { get; set; } = @"C:\Program Files\Google\Chrome\Application\chrome.exe";
public string EdgeBinaryLocation { get; set; } = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
public string FirefoxBinaryLocation { get; set; } = @"C:\Program Files\Mozilla Firefox\firefox.exe";
// public bool DrawMouseMovement { get; set; } = true;
}

public enum SeleniumBrowserType
{
Chrome,
Edge,
Firefox
}
}
2 changes: 2 additions & 0 deletions RuriLib/Providers/Selenium/DefaultSeleniumBrowserProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ namespace RuriLib.Providers.Selenium
public class DefaultSeleniumBrowserProvider : ISeleniumBrowserProvider
{
public string ChromeBinaryLocation { get; }
public string EdgeBinaryLocation { get; }
public string FirefoxBinaryLocation { get; }
public SeleniumBrowserType BrowserType { get; }

public DefaultSeleniumBrowserProvider(RuriLibSettingsService settings)
{
ChromeBinaryLocation = settings.RuriLibSettings.SeleniumSettings.ChromeBinaryLocation;
EdgeBinaryLocation = settings.RuriLibSettings.SeleniumSettings.EdgeBinaryLocation;
FirefoxBinaryLocation = settings.RuriLibSettings.SeleniumSettings.FirefoxBinaryLocation;
BrowserType = settings.RuriLibSettings.SeleniumSettings.BrowserType;
}
Expand Down
1 change: 1 addition & 0 deletions RuriLib/Providers/Selenium/ISeleniumBrowserProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace RuriLib.Providers.Selenium
public interface ISeleniumBrowserProvider
{
string ChromeBinaryLocation { get; }
string EdgeBinaryLocation { get; }
string FirefoxBinaryLocation { get; }
SeleniumBrowserType BrowserType { get; }
}
Expand Down
Loading