简体   繁体   English

Geckofx C#阻止特定域

[英]Geckofx C# Blocking Specific domains

I am using Geckofx v18 for a C# application. 我正在将Geckofx v18用于C#应用程序。

Is it possible to configure it to block certain domains? 是否可以将其配置为阻止某些域? If so, how. 如果是这样,怎么做。

Update: I want to do this to block certain external images from loading on a website as they are consuming excess bandwidth. 更新:我想这样做是为了阻止某些外部图像消耗过多的带宽,从而阻止它们加载到网站上。 Also, I use ip:port proxies, so it should work with that set too. 另外,我使用ip:port代理,因此它也应与该设置一起使用。

You can block images from loading from domain using firefox. 您可以使用firefox阻止从域加载图像。 how to block images from domains using firefox 如何使用Firefox阻止来自域的图像

Firefox writes this into a permissions.sqlite file. Firefox将此内容写入Permissions.sqlite文件。

Add the domains you wish to block to firefox then if you copy this file over to the geckofx profile directory and replace the permissions.sqlite file there it will cause geckofx to block the required images. 将您要阻止的域添加到firefox中,然后,如果将此文件复制到geckofx配置文件目录中,并在其中替换Permissions.sqlite文件,它将导致geckofx阻止所需的图像。

Your Geckofx profile will likely be in a folder like: 您的Geckofx个人资料可能位于以下文件夹中:

C:\Users\%USER%\AppData\Local\Geckofx\DefaultProfile

Your Firefox profile will likely be in a folder something like: 您的Firefox个人资料可能位于以下文件夹中:

C:\Users\%USER%\AppData\Roaming\Mozilla\Firefox\Profiles\2boeeqja.default

To set permissions from C# (rather than in Firefox and copying the permissions.sqlite file) you can prolly use the nsIPermissionManager interface. 要从C#设置权限(而不是在Firefox中复制权限。sqlite文件),可以使用nsIPermissionManager接口。 you can create an instance of one like so: 您可以这样创建一个实例:

var instance = Xpcom.CreateInstance<nsIPermissionManager>("@mozilla.org/permissionmanager;1");

More information about nsIPermissionManager can be found here 有关nsIPermissionManager的更多信息,请参见此处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM