Add uBlock extension support for Firefox driver

Upgrades Selenium.WebDriver to 4.38.0 and adds logic to automatically install the uBlock extension for FirefoxDriver instances. The uBlock extension file is now included in the project and set to copy to output. Warnings are logged if the extension fails to load.
This commit is contained in:
qwsdcvghyu89
2025-11-16 00:26:56 +11:00
parent f52aa6123b
commit a20d48ef02
3 changed files with 15 additions and 1 deletions
+6 -1
View File
@@ -7,9 +7,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.9" />
<PackageReference Include="Selenium.WebDriver" Version="4.34.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Beam.Downloaders\Beam.Downloaders.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="uBlock0_1.67.0.firefox.signed.xpi">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+9
View File
@@ -102,6 +102,15 @@ namespace Beam.Stealth {
driver = new RemoteWebDriver(new Uri(remoteAddress), def.Options);
else
driver = def.Factory(def.Options);
try {
if (driver is FirefoxDriver fd)
fd.InstallAddOnFromFile("uBlock0_1.67.0.firefox.signed.xpi");
}
catch {
logger?.LogWarning("Unable to load utility extensions");
}
break;
}
catch (Exception e) {
Binary file not shown.