c# - 如何在 GeckoFX Windows Forms 网络浏览器中获取广告拦截?
问题描述
我正在使用 GeckoFX45 在 Windows 窗体中运行浏览器。我希望能够添加一个广告拦截器(uBlock 或 AdBlock Plus)。
大多数广告拦截器都是针对 IE 的,并且 GeckoPreferences.Default("extensions.blocklist.enabled") = False;
给了我一个错误。
有没有办法在 GeckoFX 浏览器中实现 Adblock?
解决方案
尝试将 Firefox 扩展添加到 GeckoFX
首先,添加使用部署扩展的位置
Xpcom.ComponentRegistrar.AutoRegister():
void RegisterExtensionDir(string dir)
{
Console.WriteLine("Registering binary extension directory: " + dir);
var chromeDir = (nsIFile)Xpcom.NewNativeLocalFile(dir);
var chromeFile = chromeDir.Clone();
chromeFile.Append(new nsAString("chrome.manifest"));
Xpcom.ComponentRegistrar.AutoRegister(chromeFile);
}
其次,不要在扩展的 chrome.manifest 中使用 ABI 标志。所以而不是
binary-component components/GeckoScraper.dll ABI=WINNT_x86-msvc
利用
binary-component components/GeckoScraper.dll
推荐阅读
- unity3d - 轮廓着色器统一类似于 Gizmo 编辑器
- php - ReflectionException:类 PermissionsTableSeeder 不存在
- unity3d - 私有接口下的属性总是返回零
- c# - Asp.Net Core 从 appsettings.json 获取 json 数组
- java - reduce() 方法如何与 Java 8 中的并行流一起工作?
- javascript - 赛普拉斯等待 xhr 日志记录
- r - 是否有以日期范围为条件镜像 EXCEL COUNTIFS 的 R 函数?
- ansible - 在 Ansible 中使用 ipaddr 过滤对象列表
- c# - 设置图像源导致内存泄漏(wpf,c#)
- jquery - 在循环外检索每个循环中设置的变量值