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'
- IGNORE_LINK_REL = ['profile', 'author', 'shortlink', 'canonical']
Properties
- $active : mixed
- $excludeHosts : mixed
- A list of excluded hosts.
- $headlessContentBlocker : mixed
- $results : array<string|int, ScanEntry>
- Scan results.
Methods
- __construct() : mixed
- C'tor.
- afterSetup() : mixed
- The content blocker got setup completely.
- beforeMatch() : mixed
- See `AbstractPlugin`.
- 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.
- keepAlwaysAttributes() : array<string|int, string>
- Keep attributes for a specific match.
- 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.
- setup() : mixed
- Before the content blocker gets setup.
- skipInlineScriptVariableAssignment() : array<string|int, string>
- Skip inline script by variable name.
- 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.
- 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'
IGNORE_LINK_REL
public
mixed
IGNORE_LINK_REL
= ['profile', 'author', 'shortlink', 'canonical']
Properties
$active
private
mixed
$active
= true
$excludeHosts
A list of excluded hosts.
private
mixed
$excludeHosts
= []
$headlessContentBlocker
private
mixed
$headlessContentBlocker
$results
Scan results.
private
array<string|int, ScanEntry>
$results
= []
Methods
__construct()
C'tor.
public
final __construct(HeadlessContentBlocker $headlessContentBlocker) : mixed
Parameters
- $headlessContentBlocker : HeadlessContentBlocker
Tags
afterSetup()
The content blocker got setup completely.
public
afterSetup() : mixed
beforeMatch()
See `AbstractPlugin`.
public
beforeMatch(AbstractMatcher $matcher, AbstractMatch $match) : mixed
Parameters
- $matcher : AbstractMatcher
- $match : AbstractMatch
blockableStringExpression()
Allows to modify the passed string expression to a blockable.
public
blockableStringExpression(string $expression, AbstractBlockable $blockable) : string
Parameters
- $expression : string
- $blockable : AbstractBlockable
Return values
stringblockedMatch()
See `AbstractPlugin`.
public
blockedMatch(BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match) : mixed
Parameters
- $result : BlockedResult
- $matcher : AbstractMatcher
- $match : AbstractMatch
checkResult()
Called after a match got found and the matcher decided, if it should be blocked or not.
public
checkResult(BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match) : BlockedResult
Parameters
- $result : BlockedResult
- $matcher : AbstractMatcher
- $match : AbstractMatch
Return values
BlockedResultexcludeHostByUrl()
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
Tags
init()
Initialize your plugin add e.g. new visual parent definitions.
public
init() : mixed
inlineStyleBlockRule()
Decide if a URL in a CSS rule should be blocked.
public
inlineStyleBlockRule(BlockedResult $result, string $url, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
Parameters
- $result : BlockedResult
- $url : string
- $matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
- $match : StyleInlineMatch|StyleInlineAttributeMatch
Return values
boolinlineStyleModifyDocuments()
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
Return values
boolinlineStyleShouldBeExtracted()
Do not extract blocked rules of a CSS inline script to a second document.
public
inlineStyleShouldBeExtracted(bool $extract, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
Parameters
- $extract : bool
- $matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
- $match : StyleInlineMatch|StyleInlineAttributeMatch
Return values
boolisNotAnExcludedUrl()
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
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
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
notBlockedMatch()
See `AbstractPlugin`. Needed to obtain external URLs.
public
notBlockedMatch(BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match) : mixed
Parameters
- $result : BlockedResult
- $matcher : AbstractMatcher
- $match : AbstractMatch
setActive()
Setter.
public
setActive(bool $active) : mixed
Parameters
- $active : bool
Tags
setup()
Before the content blocker gets setup.
public
setup() : mixed
skipInlineScriptVariableAssignment()
Skip inline script by variable name.
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
Return values
bool|string|numberprobablyMemorizeExternalUrl()
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 $m) : mixed
Parameters
- $isBlocked : BlockedResult
- $m : SelectorSyntaxMatch
processBlockedByTagAttributeMatch()
Memorize when a content got blocked through a non-created template.
protected
processBlockedByTagAttributeMatch(BlockedResult $isBlocked, string $linkAttribute, string $link) : mixed
Parameters
- $isBlocked : BlockedResult
- $linkAttribute : string
- $link : string