Skip to content

Commit

Permalink
Change how wildcard works
Browse files Browse the repository at this point in the history
  • Loading branch information
hanubeki committed Aug 22, 2024
1 parent f241da4 commit 4ffecc9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 0 additions & 3 deletions generate/cosmetic/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ func ParseLine(line string) (f Rule, ok bool) {
// General rules for all domains need the empty domain to work with the script
domains = append(domains, "")
}
if split[0] == "*" {
domains = []string{""}
}

joinedDomains := strings.Join(domains, ",")

Expand Down
2 changes: 1 addition & 1 deletion generate/cosmetic/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestParseLine(t *testing.T) {
{"###cookie_alert", Rule{Domains: []string{""}, JoinedDomains: "", CSSSelector: "#cookie_alert"}, true},
{"##.cookie_alert", Rule{Domains: []string{""}, JoinedDomains: "", CSSSelector: ".cookie_alert"}, true},
// Wildcard "*" is also supported
{"*###cookie_alert", Rule{Domains: []string{""}, JoinedDomains: "", CSSSelector: "#cookie_alert"}, true},
{"*###cookie_alert", Rule{Domains: []string{"*"}, JoinedDomains: "*", CSSSelector: "#cookie_alert"}, true},

// Normal rules that block certain CSS selectors
{"example.com##.ad", Rule{Domains: []string{"example.com"}, JoinedDomains: "example.com", CSSSelector: ".ad"}, true},
Expand Down
5 changes: 5 additions & 0 deletions generate/cosmetic/script-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
let output = [];

for (i in rules) {
if (i === "*") {
output.push(i);
continue;
}

let ruleSplit = i.split(",");

let allTilded = true;
Expand Down

0 comments on commit 4ffecc9

Please sign in to comment.