--- 2019-6-17转载 ---

链接点我

Adblock Plus filters explained

  • Simple blocking rules

    • Example 1: Blocking by address parts
    • Example 2: Blocking by domain name
    • Example 3: Blocking exact address
  • Options in blocking rules
  • Exception rules
    • Example 1: Exception for particular requests
    • Example 2: Exception for an entire site
  • Comments
  • Filter options
  • Element hiding
    • Domain selection
    • Element selection
    • Extended CSS selectors (Adblock Plus specific)

Unfinished, not for translating

Simple blocking rules

Blocking rules determine addresses that Adblock Plus should block.

Example 1: Blocking by address parts

Verbatim text

This text must be present in the address to be blocked.

Wildcard character

This stands for any number of characters.

Separator

The address must either end here or a separator character like ? or / has to follow.

/banner/*/img^

This rule blocks:

  • http://example.com/banner/foo/img
  • http://example.com/banner/foo/bar/img?param
  • http://example.com/banner//img/foo

This rule doesn't block:

  • http://example.com/banner/img
  • http://example.com/banner/foo/imgraph
  • http://example.com/banner/foo/img.gif

Example 2: Blocking by domain name

Domain name anchor

The following text must be the domain name of the address.

Verbatim text

This text must be present in the address to be blocked.

Separator

A separator character has to follow that will indicate the end of the domain name, e.g. / or :.

||ads.example.com^

This rule blocks:

  • http://ads.example.com/foo.gif
  • http://server1.ads.example.com/foo.gif
  • https://ads.example.com:8000/

This rule doesn't block:

  • http://ads.example.com.ua/foo.gif
  • http://example.com/redirect/http://ads.example.com/

Example 3: Blocking exact address

Start anchor

The following text must be the beginning of the address.

Verbatim text

This text must be present in the address to be blocked.

End anchor

The preceding text must be the end of the address.

|http://example.com/|

This rule blocks:

  • http://example.com/

This rule doesn't block:

  • http://example.com/foo.gif
  • http://example.info/redirect/http://example.com/

Options in blocking rules

Blocking rules can have a number of options to fine-tune their behavior.

Address to be blocked

This part of the rule defines which addresses it is applied to.

Option separator

This character indicates that the following text defines filter option.

Type option

Type options define request types to be blocked. Common type options arescript or image indicating that only scripts/images should be blocked. The inverse type option ~script means that the filter should not be applied to scripts.

Domain option

Domain option restricts the filter to a set of domains (here example.com). It also allows to disable the rule on some domains (here on foo.example.com).

||ads.example.com^$script,image,domain=example.com|~foo.example.info

This rule blocks http://ads.example.com/foo.gif only if the following conditions are met:

  • This address is being loaded as a script or an image.
  • The page loading it comes from example.com domain (for example example.com itself or subdomain.example.com) but not from foo.example.com or its subdomains.

Exception rules

Exception rules are built the same as blocking rules, they define which addresses should be allowed even if matching blocking rules exists.

Example 1: Exception for particular requests

Exception rule

Rules starting like this are exceptions, they will override blocking rules.

Address to be allowed

This part of the rule defines which addresses it is applied to, it is structured the same as for blocking rules.

Type option

This type option prevents the exception from being applied to scripts.

@@||ads.example.com/notbanner^$~script

Example 2: Exception for an entire site

Exception rule

Rules starting like this are exceptions, they will override blocking rules.

Address to be allowed

This part of the rule defines which addresses it is applied to, it is structured the same as for blocking rules.

Type option

This special type option indicates that Adblock Plus should be completely disabled on pages that this rule applies to.

@@||example.com^$document

Comments

Comment

An exclamation mark at the beginning of the rule indicates a comment.

Comment text

This text will not be used for blocking, you can write anything you want.

!This is a comment

Filter options

Option Purpose
Types
script
~script
Include or exclude JavaScript files
image
~image
Include or exclude image files
stylesheet
~stylesheet
Include or exclude stylesheets (CSS files)
object
~object
Include or exclude content handled by browser plug-ins like Flash or Java
subdocument
~subdocument
Include or exclude pages loaded within pages (frames)
xmlhttprequest
~xmlhttprequest
Include or exclude requests started using the XMLHttpRequest object or fetch API
websocket
~websocket
Include or exclude requests initiated via WebSocket object
webrtc
~webrtc
Include or exclude connections opened via RTCPeerConnection instances to ICE servers
popup Include pages opened in a new tab or window
generichide Used to prevent applying global element rules on a page (e.g. @@||example.com^$generichide)
genericblock Used to prevent applying global blocking rules on a page (e.g. @@||example.com^$genericblock)
Exceptions
document Used to whitelist the page itself (e.g. @@||example.com^$document)
elemhide Used to prevent element rules from applying on a page (e.g. @@||example.com^$elemhide)
Domains
domain= Specify a list of domains, separated by bar lines (|), on which a filter should be active. A filter may be prevented from being activated on a domain by preceding the domain name with a tilde (~).
third-party
~third-party
Specify whether a filter should be active on third-party or first domains
Misc

Less frequently used options, including pingother and match-case are explained in the Writing Adblock Plus Filters documentation.

Element hiding

Domain selection

##selector is used as a placeholder for element selectors.

Example rules Domain selection
##selector

Active on:

  • All domains, including:
  • http://example.com/
  • https://example.net/
  • ftp://example.edu/

Not active on:

  • Not applicable
example.com##selector

Active on, for example:

  • http://example.com/
  • ftp://subdomain.example.com/

Not active on:

  • All other domains, including
  • http://example.edu/
  • ftp://example.net/
~example.com##selector

Active on:

  • All other domains, including
  • http://example.edu/
  • ftp://example.net/

Not active on, for example:

  • http://example.com/
  • ftp://subdomain.example.com/
example.com,example.edu##selector

Active on, for example:

  • http://example.com/
  • https://subdomain.example.com/
  • ftp://example.edu/

Not active on:

  • All other domains, including:
  • http://example.net/
example.com,~mail.example.com##selector

Active on:

  • http://example.com/
  • https://adverts.example.com/

Not active on:

  • http://mail.example.com/
  • All other domains

Element selection

Selector Purpose
###advert Matches the element with the unique id "advert"
##.advert Matches elements with the class "advert"
##table[height="100"][width="100"] Matches a table with a height of 100 and a width of 100
##a[href="http://example.com/"] Matches links to http://example.com/
##div[style="width:300px;height:250px;"] Matches div elements that have exactly the style specified
###advert > .link Matches elements with the class "link" that are enclosed within elements with the id "advert"
###advert + .link Matches elements with the class "link" that are immediately preceded by elements with the id "advert"
##a[href^="http://example.com/"] Matches links to any pages hosted on http://example.com/
##div[style^="width:300px;height:250px;"] Matches div elements that start with the style specified
##div[style$="width:300px;height:250px;"] Matches div elements that end the style specified
##div[style*="width:300px;height:250px;"] Matches div elements that containing the style specified

The above filters are examples of valid element hiding rules. Any CSS selector supported by your browser can be used for element hiding.

Extended CSS selectors (Adblock Plus specific)

In some situations standard CSS selectors are not sufficient, for those cases you can also use the following Adblock Plus specific pseudo-selectors:

Pseudo-class Purpose
:-abp-properties() Select an element if its CSS style properties match what's specified. You can pass a regular expression by surrounding it with "/".
:-abp-has() Select an element if its content subtree match the selector specified
:-abp-contains() Select an element if its text content contains the specified string

When writing element hiding filters that make use those you must use the #?# syntax (replace ## with #?#) and take care to specify one or more domains. Some examples:

Selector Purpose
example.com#?#div:-abp-properties(width:300px;height:250px;) Matches div elements whose style contain the specified properties
example.com#?#div:-abp-has(> div > img.advert) Matches div elements that contain as a direct descendant a div element whose direct descendant is an img with the class "advert"
example.com#?#div:-abp-has(> div > img:-abp-properties(width:300px;height:250px;)) Matches div elements that contain as a direct descendant a div element whose direct descendant is an img element whose style properties contain the specified properties, a width of 300 pixels and an height of 250 pixels
example.com#?#div:-abp-has(> div > img:-abp-properties(WidTh:300px;hEigHt:250px;)) Since the CSS properties are matched case-insensitively, this filter matches the same thing as above
example.com#?#div:-abp-has(> span:-abp-contains(Advertisment)) Matches div elements that have a direct descendent span element containing the text "Advertisment"
example.com#?#div > img:-abp-properties(width:*px;height:250px;) By using a wildcard *, this filter matches an img whose CSS style properties have a widthspecified in pixels and a height of 250 pixels
example.com#?#div > img:-abp-properties(/width: 3[2-8]px;/) By using a regular expression, this filter matches an img whose CSS style properties have a width between 32 and 38 pixels

Adblock语法说明相关推荐

  1. abp过滤规则android,撰写 Adblock Plus 过滤规则

    当前的 Adblock Plus 版本允许您通过许多不同的方法来优化过滤规则.本文档就是告诉您如何做. 声明:这里给出的过滤规则只是示例,不一定能直接使用. AdBlock Plus 过滤规则介绍 本 ...

  2. adblock过滤规则编写

    本指南旨在帮助您编写和维护自己的Adblock Plus过滤器.通过创建自己的过滤器,您可以更好地控制要访问的网站上不希望看到的东西,包括广告,图像,请求和脚本. 重要提示:本指南中的所有过滤器示例仅 ...

  3. adblock plus过滤规则介绍

    (整理自adblock 官网) 基本过滤规则 最简单的过滤规则当然就是您想阻挡的横幅广告地址,但是这些地址常常会在您每次打开页面时改变.例如: http://example.com/ads/banne ...

  4. 使用adblock的高级自定义过滤器, 来过滤包含特定文字的html元素

    需求:  想用adblock 过滤一个div窗体,   该窗体的特征是其子元素包含指定的文字. 解决方法: 使用adblock的 Snippet  过滤器语法. snippet 命令 hide-if- ...

  5. Adblock plus 过滤规则

    整理自官方规则 AdBlock Plus 过滤规则介绍 基本过滤规则 最简单的过滤规则当然就是您想阻挡的横幅广告地址,但是这些地址常常会在您每次打开页面时改变.例如: http://example.c ...

  6. 【JavaScript总结】JavaScript语法基础:BOM

    DOM是文档对象模型,操作对象是文档 window.document,和浏览器没有直接关系 DOM常用事件: onload,onbeforeunload, onunload onclick,ondbl ...

  7. 【JavaScript总结】JavaScript语法基础:JS编码

    运算符 数学:+. -. *. / 逻辑:>. < .>= .<=. == . !=.&&.|| . === .!==(完全等于) 对象相关 new delet ...

  8. 【JavaScript总结】JavaScript语法基础:数据类型

    ------>数据类型有哪些? ->基本类型:数字类型,布尔类型,字符串类型 ->引用类型:对象类型,函数类型 ->空类型:null 和 undefined ->运算符: ...

  9. 第二天:Vue基础语法

    1.计算属性的setter和getter 每个计算属性都有setter和getter 一般来说用到setter较少,都不希望数据被改动,所以只用getter时也有缩写 <!DOCTYPE htm ...

最新文章

  1. python 列表(list)操作及函数
  2. 文件不混淆_Android Studio配置反混淆
  3. HBase伪分布式集群配置
  4. linux判断字符串命令行,bash – 将命令行参数与字符串进行比较
  5. uml边界类例子_UML中边界类、控制类和实体类
  6. python-excel 批量新建excel工作表
  7. 浅谈Linux操作系统基础知识
  8. 啦啦外卖独立版41.4+全插件+可运营版本+开源(亲测100%可用)
  9. Winform微信扫码支付
  10. Contest3115 - 2021级新生个人训练赛第23场_10247 Problem C 爱好数学的国王
  11. spring-boot文件上传限制
  12. select函数是怎么用的
  13. _pickle.UnpicklingError: unpickling stack underflow
  14. 观后感 - stormzhang 跨年直播
  15. 浪潮存储中标中国天眼;华为发布离网去油综合供能全系列解决方案;罗克韦尔自动化推出新品牌 | 全球TMT...
  16. Microsoft Windows 环境中NLS_LANG的正确设置 (文档 ID 1577370.1)
  17. DevExpress皮肤样式
  18. 读bitcoin白皮书后
  19. NCCloud OpenAPI扩展开发
  20. java属性注解_【java自定义注解1】java自定义注解-属性

热门文章

  1. android应用示例代码_Android指南针代码示例
  2. 企业微信审批功能有哪些?
  3. unity简易的摄像机小地图制作
  4. 高职高专专业目录与本科专业目录
  5. mysql add trandata_OGG add trandata 到底做了什么
  6. C# NanoFramework使用ESP32开发超声波距离传感器(HC-SR04)
  7. Tomb.finance突破4亿TVL大关
  8. java 文本词频统计_java实现文本词频统计
  9. BUUCTF Reverse xor WriteUp
  10. 常用Linux系统安装分区方案