AGENT SKILL

write-adguard-filters

Complete AdGuard filtering rules syntax reference. Use this skill when writing AdGuard custom filters. Covers basic rule syntax, all modifiers ($domain/$third-party/$important/$redirect/$replace/$removeparam/$cookie/$csp etc.), cosmetic rules (element hiding/CSS/Extended CSS selectors), HTML filtering, JavaScript/scriptlet rules, non-basic rule modifiers, preprocessor directives, and debugging. Trigger when user mentions AdGuard filtering rules, ad blocking rule syntax, filter list authoring, ABP syntax compatibility, element hiding rules, Extended CSS selectors (:has/:contains/:matches-css etc.). Use this skill even when the user is just writing or debugging any type of ad filtering rules.

License 许可
MIT
所属仓库
luestr/skills
最近更新
2026-11-14
Stars
★ 94
Forks
1

01 前言 Front Matter

name
write-adguard-filters
metadata
{ "language": "en-US" }
description
Complete AdGuard filtering rules syntax reference. Use this skill when writing AdGuard custom filters. Covers basic rule syntax, all modifiers ($domain/$third-party/$important/$redirect/$replace/$removeparam/$cookie/$csp etc.), cosmetic rules (element hiding/CSS/Extended CSS selectors), HTML filtering, JavaScript/scriptlet rules, non-basic rule modifiers, preprocessor directives, and debugging. Trigger when user mentions AdGuard filtering rules, ad blocking rule syntax, filter list authoring, ABP syntax compatibility, element hiding rules, Extended CSS selectors (:has/:contains/:matches-css etc.). Use this skill even when the user is just writing or debugging any type of ad filtering rules.

02 资源文件 12

03 SKILL.md 正文

AdGuard Filtering Rules Syntax Reference

Source: https://adguard.com/kb/general/ad-filtering/create-own-filters/

This skill is a complete reference index for AdGuard filtering rule syntax. Do not load all reference files at once — load only the relevant file based on the user's question to save tokens.

Quick Routing: Which File to Load

User Need Load File
Basic rule syntax, special chars (*, ||, ^, |), regex, TLD wildcards references/01-basic-rules-syntax.md
$domain, $third-party, $important, $match-case, $app, $denyallow, $header, $method, $popup, $strict-first-party, $strict-third-party, $to references/02-basic-modifiers.md
$document, $image, $script, $stylesheet, $font, $media, $subdocument, $websocket, $xmlhttprequest, $ping, $object, $other references/03-content-type-modifiers.md
Exception rule (@@) modifiers: $elemhide, $content, $urlblock, $jsinject, $stealth, $extension; Generic rules: $genericblock, $generichide, $specifichide references/04-exception-modifiers.md
$all, $badfilter, $cookie, $csp, $hls, $inline-script, $inline-font, $jsonprune, $xmlprune, $network, $permissions, $redirect, $redirect-rule, $referrerpolicy, $removeheader, $removeparam, $replace, $urltransform, $reason, noop, $empty(deprecated), $mp4(deprecated) references/05-advanced-modifiers.md
Rule priority calculation, priority conflict resolution references/06-rule-priorities.md
Cosmetic rules (element hiding ##, CSS rules #$#), Extended CSS selectors (:has(), :contains(), :matches-css(), :matches-attr(), :matches-property(), :xpath(), :nth-ancestor(), :upward(), :remove(), :is(), :not()) references/07-cosmetic-rules.md
HTML filtering rules ($$), special attributes (tag-content, wildcard, max-length, min-length), :contains() pseudo-class references/08-html-filtering.md
JavaScript rules (#%#), scriptlet rules (//scriptlet()), trusted scriptlets references/09-javascript-scriptlet.md
Non-basic rule modifiers: [$domain=...], [$app=...], [$path=...], [$url=...] syntax references/10-non-basic-modifiers.md
Preprocessor directives (!#include, !#if/!#else/!#endif, !#safari_cb_affinity), hints (NOT_OPTIMIZED, PLATFORM/NOT_PLATFORM, NOT_VALIDATE), debugging (filtering log, selector debugging, scriptlet debugging), compatibility legend references/11-preprocessor-debugging.md
Safari/iOS limitations, SafariConverterLib compatibility details, Content Blocker limitations, trusted filter definitions, removed/deprecated modifier list references/12-restrictions-safari.md

Rule Types Quick Reference

1. Basic Rules — Block/Allow URL Requests

rule = ["@@"] pattern ["$" modifiers]
  • ||example.com^ — Block all requests to example.com and subdomains
  • |https://example.com| — Exact URL match
  • @@||example.com^ — Allow example.com
  • ||example.com^$important — Force rule (overrides exceptions)

2. Cosmetic Rules — Hide/Modify Page Elements

  • example.com##.ad-banner — Hide element
  • example.com#$#body { background: #fff; } — Inject CSS
  • example.com#?#div:has(> .ad) — Extended CSS selector
  • example.com#@#.ad-banner — Exception (unhide)

3. HTML Filtering Rules — Modify HTML Before Page Load

  • example.com$$script[data-src="banner"] — Remove HTML element
  • example.com$@$script[data-src="banner"] — Exception

4. JavaScript Rules — Inject JS Code

  • example.com#%#window.__gaq = undefined; — Execute JS

5. Scriptlet Rules — Declarative JS Functions

  • example.com#%#//scriptlet('abort-on-property-read', 'alert') — Use scriptlet

Key Concepts

  • Comments: Lines starting with ! are comments
  • Exception rules: Rules starting with @@ allow requests
  • Modifiers: Parameters after $ that limit/change rule behavior
  • Domain restriction: $domain= or domain prefix in cosmetic rules
  • Third-party: $third-party ($3p) restricts to cross-site requests
  • Minimum rule length: 4 characters, otherwise treated as invalid
  • URL truncation: AdGuard truncates URLs to 4096 characters for faster matching
  • Trusted filters: $replace, $hls, JavaScript rules, scriptlet rules etc. can only be used in trusted filters

Compatibility Quick Reference

Abbreviation Meaning
CoreLibs apps AdGuard for Windows/Mac/Android/Linux
AdGuard for Chromium Chrome/Edge/Opera extension
AdGuard for Chrome MV3 Chrome MV3 extension
AdGuard for Firefox Firefox extension
AdGuard for iOS iOS Safari
AdGuard for Safari Desktop Safari
AdGuard Content Blocker Android Samsung/Yandex browsers
Symbol Meaning
✅ Fully supported
✅ * Supported with limitations
❌ Not supported
👎 Deprecated
🚫 Removed

04 同仓库更多 Skills

luestr
luestr/skills

write-ublock-origin-filters

完整的 uBlock Origin (uBO) 静态过滤语法参考。编写 uBlock Origin 自定义过滤规则时使用此技能,涵盖广告拦截、隐私保护或内容过滤。包含基础网络过滤模式(||、*、^、|)、所有网络过滤选项($domain、$third-party、$important、$redirect、$removeparam、$csp、$replace、$header、$method、$denyallow、$badfilter、$all 等)、内容类型选项($script、$image、$stylesheet、$font、$media、$xhr、$popup、$document、$frame 等)、元素隐藏规则(## 选择器、实体匹配、主机名正则)、过程式元素隐藏过滤器(:has、:has-text、:matches-css、:upward、:xpath、:matches-path、:watch-attr 等)、动作操作符(:remove、:style、:remove-attr、:remove-class)、HTML 过滤器(##^)、响应头过滤(##^responseheader)、脚本注入(##+js())以及预处理指令(!#include、!#if)。当用户提到 uBlock Origin 过滤规则、uBO 语法、广告拦截规则、元素隐藏规则、过程式选择器、脚本注入或希望编写/调试任何 uBO 兼容过滤列表时触发。即使用户只是在编写或调试 uBlock Origin 过滤规则、创建自定义过滤列表或从 AdBlock Plus/AdGuard 迁移过滤规则到 uBO,也应使用此技能。

★ 94
luestr
luestr/skills

write-ublock-origin-filters

Complete uBlock Origin (uBO) static filter reference. Use this skill when writing or debugging uBO custom filters or filter lists for ad blocking, privacy or content filtering, or when migrating filters from AdBlock Plus/AdGuard. Covers network patterns (||, *, ^, |) and options ($domain, $third-party, $important, $redirect, $removeparam, $csp, $replace, $header, $method, $badfilter, $all), content-type options ($script, $image, $stylesheet, $font, $media, $xhr, $popup, $document, $frame), cosmetic filters (##, CSS selectors, entity matching), procedural filters (:has, :has-text, :matches-css, :upward, :xpath, :matches-path, :watch-attr), action operators (:remove, :style, :remove-attr), HTML filters (##^), response-header filtering (##^responseheader), scriptlet injection (##+js()), and pre-parsing directives (!#include, !#if). Trigger whenever the user mentions uBO syntax, ad blocking rules, element hiding, procedural selectors, scriptlet injection, or a uBO-compatible filter list.

★ 94
luestr
luestr/skills

write-tampermonkey-scripts

引导 AI 代理规划、编写、调试、测试和维护 Tampermonkey 用户脚本。当用户请求用户脚本、浏览器页面自动化、DOM 增强、Tampermonkey 元数据、GM_* API、@match、@grant、@run-at、@connect、跨源请求、SPA 页面集成或脚本注入任务时使用此技能,即使用户没有明确提及 Tampermonkey。

★ 94
luestr
luestr/skills

write-tampermonkey-scripts

Guide an AI agent through planning, writing, debugging, testing, and maintaining Tampermonkey userscripts. Use this skill whenever a user asks for a userscript, browser-page automation, DOM enhancement, Tampermonkey metadata, GM_* API, @match, @grant, @run-at, @connect, cross-origin request, SPA page integration, or script injection task, even when Tampermonkey is not named explicitly.

★ 94
luestr
luestr/skills

write-adguard-filters

编写 AdGuard 自定义过滤规则时使用此技能。涵盖基本规则语法、所有修饰符($domain/$third-party/$important/$redirect/$replace/$removeparam/$cookie/$csp 等)、外观规则(元素隐藏/CSS/Extended CSS 选择器)、HTML 过滤、JavaScript/脚本片段规则、非基本规则修饰符、预处理器指令和调试技巧。当用户提及 AdGuard 过滤规则、广告拦截规则语法、过滤器列表编写、ABP 语法兼容、元素隐藏规则、Extended CSS 选择器(:has/:contains/:matches-css 等)时触发。即使用户只是在编写或调试任何类型的广告过滤规则,也应使用此技能。

★ 94
luestr
luestr/skills

write-adblock-plus-filters

编写、调试和解释 Adblock Plus (ABP) 过滤规则语法。当用户需要创建 ABP 过滤规则、了解过滤规则语法、构建过滤规则列表、调试规则为何不生效、在不同过滤规则类型之间转换,或学习 ABP 特有功能(如扩展 CSS 选择器、代码片段过滤器、站点密钥等)时使用此技能。当用户提到广告拦截规则、元素隐藏、过滤规则选项、EasyList 格式或任何 ABP 过滤规则相关问题时也应触发,即使他们没有明确说'Adblock Plus'。

★ 94