Documentation

BlockableScanner extends AbstractPlugin
in package

Provide a scanner for our content blocker. That means, you can pass `ScannableBlockable` instances to your `HeadlessContentBlocker` instance and you can continually fetch the scanned blockables from this plugin instance.

Table of Contents

Constants

BLOCKED_RESULT_DATA_KEY_IGNORE_IN_SCANNER  = 'Plugin.BlockableScanner.ignore-in-scanner'

Properties

$active  : mixed
$excludeHosts  : mixed
A list of excluded hosts.
$headlessContentBlocker  : mixed
$results  : array<string|int, ScanEntry>
Scan results.
$sourceUrl  : string
The source URL of the current HTML.

Methods

__construct()  : mixed
C'tor.
afterSetup()  : mixed
The content blocker got setup completely.
beforeMatch()  : mixed
See `AbstractPlugin`.
beforeSetBlockedInResult()  : bool
Allows to add an additional check before a blockable and expression gets added to a `BlockedResult`.
blockableStringExpression()  : string
Allows to modify the passed string expression to a blockable.
blockedMatch()  : mixed
See `AbstractPlugin`.
checkResult()  : BlockedResult
Called after a match got found and the matcher decided, if it should be blocked or not.
excludeHostByUrl()  : mixed
Give any URL and the host is completely excluded from the scanner results. In most cases, you need to exclude your own host!
filterFalsePositives()  : mixed
See `FalsePositivesProcessor`.
flushResults()  : mixed
Reset the scanner and return the found results.
getHeadlessContentBlocker()  : mixed
Getter.
init()  : mixed
Initialize your plugin add e.g. new visual parent definitions.
inlineStyleBlockRule()  : bool
Decide if a URL in a CSS rule should be blocked.
inlineStyleModifyDocuments()  : bool
Allows to modify blocked CSS documents.
inlineStyleShouldBeExtracted()  : bool
Do not extract blocked rules of a CSS inline script to a second document.
isNotAnExcludedUrl()  : mixed
Check if a given URL is not excluded from our hosts.
isStyleAttributeFalsePositive()  : mixed
Example: `<div style="opacity:0"`. Here, the `opacity:0` could be considered as external URL.
iterateBlockablesInString()  : mixed
This method is run while iterating blockables and check if rules are found within a string.
keepAlwaysAttributes()  : array<string|int, string>
Keep attributes for a specific match.
modifyBlockables()  : array<string|int, AbstractBlockable>
Modify the blockables array before it gets registered.
modifyHtmlAfterProcessing()  : mixed
Allows to modify the HTML after the content blocker has done its job.
notBlockedMatch()  : mixed
See `AbstractPlugin`. Needed to obtain external URLs.
setActive()  : mixed
Setter.
setSourceUrl()  : mixed
Setter.
setup()  : mixed
Before the content blocker gets setup.
skipInlineScriptVariableAssignment()  : array<string|int, string>
See `AbstractPlugin`.
visualParent()  : bool|string|number
Set a visual parent for a specific match.
probablyMemorizeExternalUrl()  : mixed
Probably memorize an external URL when it got not blocked through template nor created content blocker.
probablyMemorizeIsBlocked()  : mixed
Probably memorize a blocked content.
processAdditionalResults()  : mixed
Process additional results.
processBlockedByScriptInlineMatch()  : mixed
Memorize when an inline script got blocked through a non-created template.
processBlockedBySelectorSyntax()  : mixed
Memorize when a custom element by CSS Selector got blocked through a non-created template.
processBlockedByTagAttributeMatch()  : mixed
Memorize when a content got blocked through a non-created template.

Constants

BLOCKED_RESULT_DATA_KEY_IGNORE_IN_SCANNER

public mixed BLOCKED_RESULT_DATA_KEY_IGNORE_IN_SCANNER = 'Plugin.BlockableScanner.ignore-in-scanner'

Properties

$excludeHosts

A list of excluded hosts.

private mixed $excludeHosts = []

$sourceUrl

The source URL of the current HTML.

private string $sourceUrl = null

Methods

afterSetup()

The content blocker got setup completely.

public afterSetup() : mixed
Tags
codeCoverageIgnore

blockableStringExpression()

Allows to modify the passed string expression to a blockable.

public blockableStringExpression(string $expression, AbstractBlockable $blockable) : string
Parameters
$expression : string
$blockable : AbstractBlockable
Tags
codeCoverageIgnore
Return values
string

excludeHostByUrl()

Give any URL and the host is completely excluded from the scanner results. In most cases, you need to exclude your own host!

public excludeHostByUrl(string $url) : mixed
Parameters
$url : string

filterFalsePositives()

See `FalsePositivesProcessor`.

public filterFalsePositives() : mixed

flushResults()

Reset the scanner and return the found results.

public flushResults() : mixed

getHeadlessContentBlocker()

Getter.

public final getHeadlessContentBlocker() : mixed

init()

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

public init() : mixed

inlineStyleModifyDocuments()

Allows to modify blocked CSS documents.

public inlineStyleModifyDocuments(Document $document, Document $extractedDocument, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
Parameters
$document : Document
$extractedDocument : Document
$matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
$match : StyleInlineMatch|StyleInlineAttributeMatch
Tags
codeCoverageIgnore
Return values
bool

isNotAnExcludedUrl()

Check if a given URL is not excluded from our hosts.

public isNotAnExcludedUrl(string $url) : mixed
Parameters
$url : string

isStyleAttributeFalsePositive()

Example: `<div style="opacity:0"`. Here, the `opacity:0` could be considered as external URL.

public isStyleAttributeFalsePositive(string $linkAttribute, string $link) : mixed
Parameters
$linkAttribute : string
$link : string
Tags
see
https://regex101.com/r/gPlyEq/1

iterateBlockablesInString()

This method is run while iterating blockables and check if rules are found within a string.

public iterateBlockablesInString(AbstractMatcher $matcher, BlockedResult $result, string $string, bool $useContainsRegularExpression, bool $multilineRegexp, array<string|int, string> $useRegularExpressionFromMap, array<string|int, AbstractBlockable$useBlockables, bool $allowMultiple) : mixed

It allows you to add additional blockables to the result even if isAllowMultipleBlockerResults is false.

Note: All required IDs from each matching Blockable will be merged together, but only the ID of the first Blockable found will be assigned as the consent-id of the element.

Parameters
$matcher : AbstractMatcher
$result : BlockedResult
$string : string
$useContainsRegularExpression : bool
$multilineRegexp : bool
$useRegularExpressionFromMap : array<string|int, string>
$useBlockables : array<string|int, AbstractBlockable>
$allowMultiple : bool
Tags
codeCoverageIgnore

keepAlwaysAttributes()

Keep attributes for a specific match.

public keepAlwaysAttributes(array<string|int, string> $keepAttributes, AbstractMatcher $matcher, AbstractMatch $match) : array<string|int, string>
Parameters
$keepAttributes : array<string|int, string>
$matcher : AbstractMatcher
$match : AbstractMatch
Tags
codeCoverageIgnore
Return values
array<string|int, string>

modifyHtmlAfterProcessing()

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

public modifyHtmlAfterProcessing(string $html) : mixed
Parameters
$html : string
Tags
codeCoverageIgnore

setActive()

Setter.

public setActive(bool $active) : mixed
Parameters
$active : bool

setSourceUrl()

Setter.

public setSourceUrl(string $url) : mixed
Parameters
$url : string

setup()

Before the content blocker gets setup.

public setup() : mixed
Tags
codeCoverageIgnore

skipInlineScriptVariableAssignment()

See `AbstractPlugin`.

public skipInlineScriptVariableAssignment(array<string|int, string> $names, ScriptInlineMatcher $matcher, ScriptInlineMatch $match) : array<string|int, string>
Parameters
$names : array<string|int, string>
$matcher : ScriptInlineMatcher
$match : ScriptInlineMatch
Return values
array<string|int, string>

visualParent()

Set a visual parent for a specific match.

public visualParent(bool|string|number $visualParent, AbstractMatcher $matcher, AbstractMatch $match) : bool|string|number
Parameters
$visualParent : bool|string|number
$matcher : AbstractMatcher
$match : AbstractMatch
Tags
codeCoverageIgnore
Return values
bool|string|number

probablyMemorizeExternalUrl()

Probably memorize an external URL when it got not blocked through template nor created content blocker.

protected probablyMemorizeExternalUrl(BlockedResult $isBlocked, string $url, string $tag, string $attribute, Markup|null $markup) : mixed
Parameters
$isBlocked : BlockedResult
$url : string
$tag : string
$attribute : string
$markup : Markup|null

probablyMemorizeIsBlocked()

Probably memorize a blocked content.

protected probablyMemorizeIsBlocked(BlockedResult $isBlocked, string|null $url, string $tag, string $attribute) : mixed
Parameters
$isBlocked : BlockedResult
$url : string|null
$tag : string
$attribute : string

processBlockedByScriptInlineMatch()

Memorize when an inline script got blocked through a non-created template.

protected processBlockedByScriptInlineMatch(BlockedResult $isBlocked) : mixed
Parameters
$isBlocked : BlockedResult

processBlockedBySelectorSyntax()

Memorize when a custom element by CSS Selector got blocked through a non-created template.

protected processBlockedBySelectorSyntax(BlockedResult $isBlocked, SelectorSyntaxMatch $match) : mixed
Parameters
$isBlocked : BlockedResult
$match : SelectorSyntaxMatch

processBlockedByTagAttributeMatch()

Memorize when a content got blocked through a non-created template.

protected processBlockedByTagAttributeMatch(BlockedResult $isBlocked, TagAttributeMatch $match) : mixed
Parameters
$isBlocked : BlockedResult
$match : TagAttributeMatch

        
On this page

Search results