Rule Specification
Gooreplacer uses a plain-text rule format that is readable, version-control friendly, and editable with any text editor.
Specification
[filter],[filter_type],[action]
[condition]+
[action_options]+
Empty lines or lines starting with # act as rule delimiters.
Fields
| Field | Description |
|---|---|
| filter | URL pattern to match against |
| filter_type | wildcard or regex |
| action | block, redirect, or modifyHeaders |
Conditions
Format: condition:key=value. Repeat this line for multiple conditions.
| Condition | Meaning |
|---|---|
| initiatorDomains | Only match requests originating from these comma-separated domains |
| excludedInitiatorDomains | Exclude requests from these domains (takes precedence over initiatorDomains) |
| requestDomains | Only match when the request domain is in this list |
| isUrlFilterCaseSensitive | Case-sensitive filter matching (default: false) |
| resourceTypes | Match specific resource types |
| excludedResourceTypes | Exclude specific resource types |
| requestMethods | Match specific HTTP methods |
Action Options
block
No additional options required.
redirect
Supports url:[url] for static redirects, regexSubstitution:[url] with capture groups (\1 to \9), and transform:k1=v1,k2=v2 for parts like host, path, query, and scheme (see
URLTransform).
modifyHeaders
Format: [type]:[operation]:key=value where type is requestHeaders or responseHeaders, and operation is set, append (response only), or remove.
Filter Types
Wildcard
Supported constructs for wildcard patterns:
| Construct | Meaning |
|---|---|
| * | Wildcard matching any number of characters |
| | | Left or right anchor matching the beginning or end of the URL |
| || | Domain anchor matching the start of a domain or subdomain |
| ^ | Separator matching anything except letters, digits, _ - . % |
| urlFilter | Matches | Does not match |
|---|---|---|
| abc | https://abcd.com, https://example.com/abcd |
https://ab.com |
| abc*d | https://abcd.com, https://example.com/abcxyzd |
https://abc.com |
| ||a.example.com | https://a.example.com/, https://b.a.example.com/xyz |
https://example.com/ |
| |https* | https://example.com |
http://example.com/ |
urlFilter must be composed of ASCII characters only. Internationalized domains are matched in punycode format, and non-ASCII characters are URL-encoded in UTF-8.
See Chrome URL filter syntax docs for full details.
Regex
Regular expression matching uses
RE2 syntax.
Use regexSubstitution with capture groups (\1 to \9, and \0 for the full match).
^https://www\.(abc|def)\.xyz\.com/,regex,redirect
regexSubstitution:https://\1.xyz.com/
This redirects https://www.abc.xyz.com/path to https://abc.xyz.com/path.
Writing Good URL Conditions
Always anchor patterns so you match an entire domain. Common mistakes:
| Pattern | Problem |
|---|---|
| google.com | Matches https://example.com/?param=google.com |
| ||google.com | Matches https://google.company |
| https://www.google.com | Matches https://example.com/?param=https://www.google.com |
Better alternatives:
||google.com/matches all paths and subdomains|https://www.google.com/matches all paths without subdomains^https:\/\/www\.google\.com\/uses regex for exact domain matching
Header Modification
According to
Chrome docs,
the append operation is only supported for these headers:
Complete Example
# Block example.com main frame for specific initiators
example.com,wildcard,block
condition:resourceTypes=main_frame
condition:isUrlFilterCaseSensitive=true
condition:initiatorDomains=google.com,x.com
condition:requestMethods=get,post
# Modify headers on liujiacai.net
liujiacai.net,wildcard,modifyHeaders
responseHeaders:append:x-forwarded-for=129.9.9.1
requestHeaders:set:user-agent=gooreplacer