adblock

package
Version: v0.0.0-...-b6ae310 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2015 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package adblock is in charge of parsing adblock filter fists and deciding whether or not to block URIs.

Index

Constants

View Source
const (
	Script uint64 = 1 << iota
	Image
	StyleSheet
	Object
	XMLHTTPRequest
	ObjectSubrequest
	Subdocument
	Document
	Elemhide
	Other
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockRule

type BlockRule struct {
	*regexp.Regexp
	RuleType
	IsSimple     bool
	ThirdParty   *bool
	EnableFlags  uint64
	DisableFlags uint64

	Domains       []string
	DomainsExcept []string
	// contains filtered or unexported fields
}

A BlockRule is a single filter in the filterlist.

func NewBlockRule

func NewBlockRule(rule []byte) (*BlockRule, error)

NewBlockRule creates a new rule from the corresponding line in the filterlist.

func (*BlockRule) String

func (r *BlockRule) String() string

String returns the original rule text.

type Blocker

type Blocker struct {
	// contains filtered or unexported fields
}

A Blocker is an instance of adblock.

func NewBlocker

func NewBlocker(dir string) *Blocker

NewBlocker creates a new ad blocker.

func (*Blocker) Blocks

func (b *Blocker) Blocks(uri, firstPartyURI string, flags uint64) bool

Blocks checks if a specific uri is blocked or not.

func (*Blocker) DomainElemHideCSS

func (b *Blocker) DomainElemHideCSS(domain string) string

DomainElemHideCSS returns the css string to hide the elements on a given domain.

type ElemHideRule

type ElemHideRule struct {
	RuleType
	// contains filtered or unexported fields
}

A ElemHideRule filters a single element on a single domain.

If domain is empty, all domains are filtered.

func NewElemHideRules

func NewElemHideRules(rule []byte) ([]*ElemHideRule, error)

NewElemHideRules creates new rules for hiding elements from a given line.

type Rule

type Rule interface {
	// contains filtered or unexported methods
}

A Rule is either a BlockRule or a HideRule.

type RuleType

type RuleType uint

The RuleType of a Rule is what the rule does when it matches.

const (
	// RuleTypeBlock indicates that matching this rule blocks the URI.
	RuleTypeBlock RuleType = iota
	// RuleTypeException indicates that matching this rule exempts the URI
	// from blocking.
	RuleTypeException
)

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL