Skip to content

๐Ÿฒ A dead simple Go module that counts Adblock filter rules. Adaptation of my original npm/TypeScript package.๐Ÿฆ˜

License

Notifications You must be signed in to change notification settings

igorskyflyer/go-adblock-filter-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

56 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ go := "Adblock filter counter"

๐Ÿฒ A dead simple Go module that counts Adblock filter rules.๐Ÿฆ˜

Note: it only operates on a string-level, it doesn't check the validity of the provided filter rules.



Documentation: https://godocs.io/github.com/igorskyflyer/go-adblock-filter-counter

See the releases page for a changelog.


This library requires Go 1.20 or newer; add it to your go.mod with:

go get github.com/igorskyflyer/go-adblock-filter-counter@latest

and import it like

...

import (
	abcounter "github.com/igorskyflyer/go-adblock-filter-counter"
)

...

๐Ÿคน๐Ÿผ Examples

CountRules(source string) int

source string = `
	[Adblock Plus 2.0]
	||hello.world^
	||hello.world^
	||hello.world^
	! Comment
	||another.test^
	`

abcounter.CountRules(source) // returns 4

CountFileRules(filename string) (int, error)

filePath string = "./data/AdVoid.Core.txt"

abcounter.CountFileRules(filePath) // returns (2495, nil)