Skip to content

Commit

Permalink
Merge pull request AdguardTeam#55 from scripthunter7/hotfix-1
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
ameshkov authored Nov 11, 2022
2 parents de372c9 + 2ec4887 commit 2261166
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 0.0.28

- Fix `!##`-like comments: #54
- Add support for optional arguments in uBO scriptlets: #53
- Add support for `env_legacy` condition: #52
- Improve regex detection: #51
- Permissive domain names: #10

## 0.0.27

- Added support for adblock agents
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "adblock",
"displayName": "Adblock/AdGuard/uBlock filters grammar",
"description": "VS code extension that adds support for ad blocking rules syntax.",
"version": "0.0.27",
"version": "0.0.28",
"publisher": "adguard",
"icon": "images/icon.png",
"engines": {
Expand Down
69 changes: 63 additions & 6 deletions syntaxes/adblock.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
{
"include": "#basicRulesNoUrl"
},
{
"include": "#basicRulesRegex"
},
{
"include": "#basicRules"
}
Expand Down Expand Up @@ -97,7 +100,7 @@
"patterns": [
{
"name": "constant.language.platform.name",
"match": "(adguard_app_windows|adguard_app_mac|adguard_app_android|adguard_app_ios|adguard_ext_chromium|adguard_ext_firefox|adguard_ext_edge|adguard_ext_safari|adguard_ext_opera|adguard_ext_android_cb|adguard|ext_abp|ext_ublock|env_chromium|env_edge|env_firefox|env_mobile|env_safari|false|cap_html_filtering|cap_user_stylesheet)"
"match": "(adguard_app_windows|adguard_app_mac|adguard_app_android|adguard_app_ios|adguard_ext_chromium|adguard_ext_firefox|adguard_ext_edge|adguard_ext_safari|adguard_ext_opera|adguard_ext_android_cb|adguard|ext_abp|ext_ublock|env_chromium|env_edge|env_firefox|env_mobile|env_safari|false|cap_html_filtering|cap_user_stylesheet|env_legacy)"
},
{
"name": "keyword.control.characters",
Expand Down Expand Up @@ -179,8 +182,8 @@
}
},
{
"match": "^!#.+$",
"name": "invalid.preprocessor"
"match": "^!#(?!#).+$",
"name": "invalid.illegal.preprocessor"
}
]
},
Expand Down Expand Up @@ -446,6 +449,32 @@
}
]
},
"basicRulesRegex": {
"patterns": [
{
"match": "^(\\\/[^\\\/\\\\]*(?:\\\\.[^\\\/\\\\]*)*\\\/[dgimsuy]*)(?:(\\$)(.+))?$",
"captures": {
"1": {
"patterns": [
{
"include": "#regularExpression"
}
]
},
"2": {
"name": "keyword.control.adblock"
},
"3": {
"patterns": [
{
"include": "#basicRulesOptions"
}
]
}
}
}
]
},
"basicRules": {
"patterns": [
{
Expand All @@ -472,6 +501,34 @@
}
]
},
"regularExpression": {
"patterns": [
{
"begin": "(/)",
"beginCaptures": {
"1": {
"name": "keyword.other.regex.begin"
}
},
"end": "((?<!\\\\)/)([dgimsuy]*)?",
"endCaptures": {
"1": {
"name": "keyword.other.regex.end"
},
"2": {
"name": "keyword.other.regex"
}
},
"contentName": "string.regexp",
"patterns": [
{
"match": "(?<!\\\\)([/\\^\\$\\|])",
"name": "keyword.control.regex"
}
]
}
]
},
"urlPattern": {
"patterns": [
{
Expand Down Expand Up @@ -836,7 +893,7 @@
"scriptletFunctionUBO": {
"patterns": [
{
"match": "([^,]+)(,\\s*)?",
"match": "([^,]*)(,\\s*)?",
"captures": {
"1": {
"name": "string.quoted.adblock"
Expand Down Expand Up @@ -896,7 +953,7 @@
"domainListCommaSeparated": {
"patterns": [
{
"match": "(~?)([a-zA-Z0-9.*-]+)(,?)",
"match": "(~?)([^,]+)(,?)",
"captures": {
"1": {
"name": "keyword.other.adblock"
Expand All @@ -918,7 +975,7 @@
"domainListPipeSeparated": {
"patterns": [
{
"match": "(~?)([a-zA-Z0-9.*-]+)(\\|?)",
"match": "(~?)([^|]+)(\\|?)",
"captures": {
"1": {
"name": "keyword.other.adblock"
Expand Down
20 changes: 20 additions & 0 deletions test_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
!#safari_cb_affinity(general,privacy)
!#safari_cb_affinity
!#safari_cb_affinity(invalid)
! https://github.com/ameshkov/VscodeAdblockSyntax/issues/52
!#if env_legacy
!#invalidpreprocessor

!
! Ignore !##-like comments
! https://github.com/ameshkov/VscodeAdblockSyntax/issues/54
!
!#
!##
!#####


!
! Basic rules (valid)
Expand Down Expand Up @@ -219,6 +231,8 @@ example.com#%#//scriptlet("remove-class", 'branding', "div[class^=\"inner\"]")
example.org##+js(goyavelab-defuser.js)
ze.tt##+js(addEventListener-defuser.js, /^(?:DOMContentLoaded|load)$/, =!0)
lablue.*##+js(setTimeout-defuser.js, r(), 500)
! https://github.com/ameshkov/VscodeAdblockSyntax/issues/53
example.com##+js(scriptlet, , arg1)

!
! ABP snippets
Expand Down Expand Up @@ -317,3 +331,9 @@ $removeheader=location,domain=zannn.top|innal.top
||example.com/example.js^$script,$third-party,$domain=example.org
||example.com/example.js^$script,$~third-party,$domain=example.org
||example.com/example.js^$script,third-party,$domain=example.org|example.net

! https://github.com/ameshkov/VscodeAdblockSyntax/issues/51
/telsu\.fi\/(?![^>].*\.(jpg|png|svg|ico)$).+/$image,domain=www.telsu.fi

! https://github.com/ameshkov/VscodeAdblockSyntax/issues/10
한글코딩.org##div

0 comments on commit 2261166

Please sign in to comment.