Skip to content

Commit 0ca80c9

Browse files
authored
feat: add new ruleset grammar (iorate#490)
* implement new grammar * trivial change of grammar * rewrite match pattern * update grammar * minor refactoring of match pattern * rename MatchPatternBatch to MatchPatternSet * rename MatchPatternBatch to MatchPatternSet * implement ruleset * minor refactoring * allow dollar sign in identifier * add props * update third party notices * set scheme/host/path in InteractiveRuleset * $ can be used only at beginning of identifier * fix precedence of ! * refactor grammar * remove octal escape sequences * rename $engine to $site * read names from metadata of subscriptions * add kagi support * change regexp match operator: "=~" -> "~=" * change grammar of identifier * fix: add URL parts when creating patch * update grammar - change regexp operator from "~=" to "=~" - add case insensitive operator "i" * add documents for expressions * add documents for YAML frontmatter * <all_urls> is supported * <all_urls> is supported * expression including undefine properties return false * minor refactoring * remove description about name in subscription URL * move link to subscriptions page * fix typo * minor refactoring * remove compiledRules from subscriptions * ddg: add props to news card in web search
1 parent cc3dab3 commit 0ca80c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3200
-1582
lines changed

README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,23 @@ This extension is available in the below search engines.
4444
To publish a ruleset as a subscription, place a ruleset file encoded in UTF-8 on a suitable HTTP(S) server, and publish the URL. Here is an example hosted on GitHub:<br>
4545
https://raw.githubusercontent.com/iorate/ublacklist-example-subscription/master/uBlacklist.txt
4646

47-
In uBlacklist >=6.6.0 for _Chrome_, subscription links are available. To add a subscription with `name` and `url`, the following URL can be used as a shortcut to the options page:
47+
You can prepend YAML frontmatter to your ruleset. It is recommended that you set the `name` variable.
4848

4949
```
50-
https://iorate.github.io/ublacklist/subscribe?name={urlEncode(name)}&url={urlEncode(url)}
50+
---
51+
name: Your ruleset name
52+
---
53+
*://*.example.com/*
54+
```
55+
56+
In uBlacklist >=6.6.0 for _Chrome_, subscription links are available. To add a subscription with `url`, the following URL can be used as a shortcut to the options page:
57+
58+
```
59+
https://iorate.github.io/ublacklist/subscribe?url={urlEncode(url)}
5160
```
5261

5362
For the above example:<br>
54-
https://iorate.github.io/ublacklist/subscribe?name=Example&url=https%3A%2F%2Fraw.githubusercontent.com%2Fiorate%2Fublacklist-example-subscription%2Fmaster%2FuBlacklist.txt
63+
https://iorate.github.io/ublacklist/subscribe?url=https%3A%2F%2Fraw.githubusercontent.com%2Fiorate%2Fublacklist-example-subscription%2Fmaster%2FuBlacklist.txt
5564

5665
## For developers
5766

biome.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
33
"files": {
4-
"ignore": ["**/package.json"]
4+
"ignore": ["**/package.json", "**/parser.js"]
55
},
66
"vcs": {
77
"enabled": true,

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
"version": "0.0.0",
44
"dependencies": {
55
"@codemirror/commands": "^6.5.0",
6+
"@codemirror/lang-yaml": "^6.1.1",
67
"@codemirror/language": "^6.10.1",
8+
"@codemirror/lint": "^6.7.0",
79
"@codemirror/state": "^6.4.1",
810
"@codemirror/view": "^6.26.3",
11+
"@lezer/common": "^1.2.1",
912
"@lezer/highlight": "^1.2.0",
13+
"@lezer/lr": "^1.4.0",
1014
"@mdi/svg": "^7.4.47",
1115
"colord": "^2.9.3",
1216
"dayjs": "^1.11.11",
1317
"goober": "2.1.10",
1418
"is-mobile": "^4.0.0",
19+
"js-yaml": "^4.1.0",
1520
"punycode": "^2.3.1",
1621
"react": "^18.3.1",
1722
"react-colorful": "^5.6.1",
@@ -21,7 +26,9 @@
2126
},
2227
"devDependencies": {
2328
"@biomejs/biome": "^1.7.3",
29+
"@lezer/generator": "^1.7.0",
2430
"@types/fs-extra": "^11.0.4",
31+
"@types/js-yaml": "^4.0.9",
2532
"@types/license-checker": "^25.0.6",
2633
"@types/node": "^20.12.8",
2734
"@types/punycode": "^2.1.4",
@@ -56,8 +63,8 @@
5663
"fix": "pnpm run /^fix:/",
5764
"fix:biome": "biome check --apply .",
5865
"fix:prettier": "prettier --write .",
66+
"generate-ruleset-parser": "lezer-generator src/scripts/ruleset/ruleset.grammar -o src/scripts/ruleset/parser.js --noTerms",
5967
"generate-third-party-notices": "tsx scripts/generate-third-party-notices.ts",
60-
"postinstall": "pnpm generate-third-party-notices",
6168
"test": "tsx scripts/test.ts"
6269
},
6370
"type": "module",

pnpm-lock.yaml

+87
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async function createBuildScripts(
170170
bundle: true,
171171
define: defineProcessEnv(context),
172172
entryPoints: sources.map((file) => path.join(srcDir, file)),
173-
format: "esm",
173+
format: "iife",
174174
jsx: "automatic",
175175
jsxDev: debug,
176176
// https://github.com/evanw/esbuild/issues/3418

src/_locales/en/messages.json.ts

+8
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,20 @@ export default exportAsMessages({
344344
// The title of the add-subscription dialog.
345345
options_addSubscriptionDialog_title: "Add a subscription",
346346

347+
// UNUSED
347348
// The label for the name input on the add-subscription dialog.
348349
options_addSubscriptionDialog_nameLabel: "Name",
349350

350351
// The label for the URL input on the add-subscription dialog.
351352
options_addSubscriptionDialog_urlLabel: "URL",
352353

354+
// The label for the alternative name input on the add-subscription dialog.
355+
options_addSubscriptionDialog_altNameLabel: "Alternative name (optional)",
356+
357+
// The helper text for the alternative name input on the add-subscription dialog.
358+
options_addSubscriptionDialog_altNameDescription:
359+
"The alternative name used when a downloaded ruleset does not contain a name.",
360+
353361
// The text of the add button on the add-subscription dialog.
354362
options_addSubscriptionDialog_addButton: "Add",
355363

src/_locales/ja/messages.json.ts

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export default exportAsMessages({
126126
options_addSubscriptionDialog_title: "購読を追加する",
127127
options_addSubscriptionDialog_nameLabel: "名前",
128128
options_addSubscriptionDialog_urlLabel: "URL",
129+
options_addSubscriptionDialog_altNameLabel: "代替の名前 (オプション)",
130+
options_addSubscriptionDialog_altNameDescription:
131+
"ダウンロードしたルールセットに名前が含まれないときに、代わりに使用される名前です。",
129132
options_addSubscriptionDialog_addButton: "追加",
130133
options_showSubscriptionDialog_blacklistLabel: "ルールのリスト",
131134
options_updateInterval: "更新の間隔",

src/common/locales.ts

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export type MessageName =
108108
| "options_addSubscriptionDialog_title"
109109
| "options_addSubscriptionDialog_nameLabel"
110110
| "options_addSubscriptionDialog_urlLabel"
111+
| "options_addSubscriptionDialog_altNameLabel"
112+
| "options_addSubscriptionDialog_altNameDescription"
111113
| "options_addSubscriptionDialog_addButton"
112114
| "options_showSubscriptionDialog_blacklistLabel"
113115
| "options_updateInterval"

0 commit comments

Comments
 (0)