\DevOwl\HeadlessContentBlocker\pluginsLinkBlocker

Block `href` attribute for special links. Usually, the blocker does not block links cause they do not load external sources. But there are some special cases, e.g.

lightbox plugins which need a content blocker for a link.

Summary

Methods
Properties
Constants
__construct()
afterSetup()
init()
modifyHtmlAfterProcessing()
beforeMatch()
blockedMatch()
notBlockedMatch()
checkResult()
keepAlwaysAttributes()
skipInlineScriptVariableAssignment()
inlineStyleShouldBeExtracted()
inlineStyleModifyDocuments()
inlineStyleBlockRule()
visualParent()
blockableStringExpression()
getHeadlessContentBlocker()
addBlockIfClassCallback()
addBlockIfClass()
No public properties found
REPLACE_TAGS
REPLACE_ATTRIBUTES
No protected methods found
No protected properties found
N/A
No private methods found
$headlessContentBlocker
$blockIfClass
$blockIfClassCallback
N/A

Constants

REPLACE_TAGS

REPLACE_TAGS =array('a')

REPLACE_ATTRIBUTES

REPLACE_ATTRIBUTES =array('href')

Properties

$headlessContentBlocker

$headlessContentBlocker :

Type

$blockIfClass

$blockIfClass :

Type

$blockIfClassCallback

$blockIfClassCallback :

Type

Methods

afterSetup()

afterSetup()

The content blocker got setup completely.

init()

init()

Initialize your plugin add e.g. new visual parent definitions.

modifyHtmlAfterProcessing()

modifyHtmlAfterProcessing(string  $html)

Allows to modify the HTML after the content blocker has done its job.

Parameters

string $html

checkResult()

checkResult(\DevOwl\HeadlessContentBlocker\BlockedResult  $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher  $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch  $match): \DevOwl\HeadlessContentBlocker\BlockedResult

See `AbstractPlugin`.

Parameters

\DevOwl\HeadlessContentBlocker\BlockedResult $result
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher
\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match

Returns

\DevOwl\HeadlessContentBlocker\BlockedResult

inlineStyleShouldBeExtracted()

inlineStyleShouldBeExtracted(boolean  $extract,\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher|\DevOwl\HeadlessContentBlocker\matcher\StyleInlineAttributeMatcher  $matcher,\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch|\DevOwl\HeadlessContentBlocker\finder\match\StyleInlineAttributeMatch  $match): boolean

Do not extract blocked rules of a CSS inline script to a second document.

Parameters

boolean $extract
\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher|\DevOwl\HeadlessContentBlocker\matcher\StyleInlineAttributeMatcher $matcher
\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch|\DevOwl\HeadlessContentBlocker\finder\match\StyleInlineAttributeMatch $match

Returns

boolean

inlineStyleModifyDocuments()

inlineStyleModifyDocuments(\Sabberworm\CSS\CSSList\Document  $document,\Sabberworm\CSS\CSSList\Document  $extractedDocument,\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher|\DevOwl\HeadlessContentBlocker\matcher\StyleInlineAttributeMatcher  $matcher,\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch|\DevOwl\HeadlessContentBlocker\finder\match\StyleInlineAttributeMatch  $match): boolean

Allows to modify blocked CSS documents.

Parameters

\Sabberworm\CSS\CSSList\Document $document
\Sabberworm\CSS\CSSList\Document $extractedDocument
\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher|\DevOwl\HeadlessContentBlocker\matcher\StyleInlineAttributeMatcher $matcher
\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch|\DevOwl\HeadlessContentBlocker\finder\match\StyleInlineAttributeMatch $match

Returns

boolean

inlineStyleBlockRule()

inlineStyleBlockRule(\DevOwl\HeadlessContentBlocker\BlockedResult  $result,string  $url,\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher|\DevOwl\HeadlessContentBlocker\matcher\StyleInlineAttributeMatcher  $matcher,\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch|\DevOwl\HeadlessContentBlocker\finder\match\StyleInlineAttributeMatch  $match): boolean

Decide if a URL in a CSS rule should be blocked.

Parameters

\DevOwl\HeadlessContentBlocker\BlockedResult $result
string $url
\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher|\DevOwl\HeadlessContentBlocker\matcher\StyleInlineAttributeMatcher $matcher
\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch|\DevOwl\HeadlessContentBlocker\finder\match\StyleInlineAttributeMatch $match

Returns

boolean

visualParent()

visualParent(boolean|string|\DevOwl\HeadlessContentBlocker\number  $visualParent,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher  $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch  $match): boolean|string|\DevOwl\HeadlessContentBlocker\number

Set a visual parent for a specific match.

Parameters

boolean|string|\DevOwl\HeadlessContentBlocker\number $visualParent
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher
\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match

Returns

boolean|string|\DevOwl\HeadlessContentBlocker\number

blockableStringExpression()

blockableStringExpression(string  $expression,\DevOwl\HeadlessContentBlocker\AbstractBlockable  $blockable): string

Allows to modify the passed string expression to a blockable.

Parameters

string $expression
\DevOwl\HeadlessContentBlocker\AbstractBlockable $blockable

Returns

string

getHeadlessContentBlocker()

getHeadlessContentBlocker()

Getter.

addBlockIfClassCallback()

addBlockIfClassCallback(callable  $callback)

Change the class list for a given match.

Parameters: string[] $classList, AbstractMatcher $matcher, AbstractMatch $match. This function needs to return a string[]!

Parameters

callable $callback

addBlockIfClass()

addBlockIfClass(array<mixed,string>  $classNames)

Only block links with this class.

Parameters

array<mixed,string> $classNames