TAG_ATTRIBUTE_MAP_LINKABLE
TAG_ATTRIBUTE_MAP_LINKABLE ='linkable'
The tag-attribute map for the usual links like `script[src],link[href],iframe[href]`.
Initialize a new headless content blocker.
$finder :array<mixed,\DevOwl\FastHtmlTag\finder\AbstractFinder>
See `AbstractFinder`.
$blockables :array<mixed,\DevOwl\HeadlessContentBlocker\AbstractBlockable>
List of blocked elements.
addFinder(\DevOwl\FastHtmlTag\finder\AbstractFinder $finder)
Add a finder scheme. See `finder/` for available ones.
\DevOwl\FastHtmlTag\finder\AbstractFinder | $finder |
addSelectorSyntaxFunction(string $functionName,callable $callback)
Add a callable for a Selector Syntax function.
The callback gets the following parameters and expects boolean
as result:
SelectorSyntaxAttributeFunction $function, SelectorSyntaxMatch $match, mixed $value
string | $functionName | |
callable | $callback |
addTagAttributeMap(array<mixed,string> $tags,array<mixed,string> $attributes = array(),string $mapName = self::TAG_ATTRIBUTE_MAP_LINKABLE)
Respect additional tags and attributes for a given map. For example, there is the `self::TAG_ATTRIBUTE_MAP_LINKABLE` map which respects known linkable tags like `script[src],link[href],iframe[href]`.
array<mixed,string> | $tags | Additional tags to consider for the passed map |
array<mixed,string> | $attributes | Additional tags to consider for the passed map |
string | $mapName | Default is |
addSelectorSyntaxMap(array<mixed,string> $selectorSyntax)
Respect additional selector-syntax as blockable candiates. Keep in mind that this selector-syntax does not automatically block the defined attribute. Instead, you need to create a custom plugin / callback for `checkResult`.
array<mixed,string> | $selectorSyntax |
addBlockables(array<mixed,\DevOwl\HeadlessContentBlocker\AbstractBlockable> $blockables)
Add a blockable item. In general, this are the URLs and elements you want to block.
array<mixed,\DevOwl\HeadlessContentBlocker\AbstractBlockable> | $blockables |
setBlockables(array<mixed,\DevOwl\HeadlessContentBlocker\AbstractBlockable> $blockables)
Set blockable items. In general, this are the URLs and elements you want to block.
array<mixed,\DevOwl\HeadlessContentBlocker\AbstractBlockable> | $blockables |
addCheckResultCallback(callable $callback)
Add a callable after a match got found and the matcher decided if it should be blocked or not.
Parameters: BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match
.
This function needs to return a BlockedResult
instance.
callable | $callback |
addKeepAlwaysAttributes(array<mixed,string> $attributes)
In some cases we need to keep the attributes as original instead of prefix it with `consent-original-`.
Keep in mind, that no external data should be loaded if the attribute is set!
array<mixed,string> | $attributes |
addKeepAlwaysAttributesCallback(callable $callback)
Add a callable after a match got found and the matcher decided if it should be blocked or not.
Parameters: string[] $keepAttributes, AbstractMatcher $matcher, AbstractMatch $match
.
This function needs to return a string[]
array!
callable | $callback |
addSkipInlineScriptVariableAssignmentsCallback(callable $callback)
Add a callable after a match got found and skip a script by custom variable name.
Parameters: string[] $variableNames, ScriptInlineMatcher $matcher, ScriptInlineMatch $match
.
This function needs to return a string[]
array!
callable | $callback |
setInlineStyleDummyUrlPath(string $urlPath)
When blocking CSS inline styles, we replace URLs with dummy URLs and we cannot rely on data-uri's as we need to pass parameters, too.
Default: https://assets.devowl.io/packages/devowl-wp/headless-content-blocker/
In the folder there need to exist the following two files: dummy.css
, dummy.png
.
string | $urlPath |
addVisualParentCallback(callable $callback)
Decide a visual parent for an individual match.
Parameters: boolean|string|number $useVisualParent, AbstractMatcher $matcher, AbstractMatch $match
.
This function needs to return a boolean|string|number
array!
callable | $callback |
addInlineStyleShouldBeExtractedCallback(callable $callback)
Add a callable after a blocked inline style got found and skip creation of a second document with blocked URLs.
Parameters: boolean $extract, StyleInlineMatcher $matcher, StyleInlineMatch $match
.
This function needs to return a boolean
array!
callable | $callback |
addInlineStyleModifyDocumentsCallback(callable $callback)
Add a callable after a blocked inline style got found, parsed and you can modify the `Document` instance.
Parameters: boolean $extract, StyleInlineMatcher $matcher, StyleInlineMatch $match
.
callable | $callback |
addInlineStyleBlockRuleCallback(callable $callback)
Add a callable after a blocked inline CSS rule got found, and we need to decide to block it or not.
Parameters: BlockedResult $extract, string $url, StyleInlineMatcher $matcher, StyleInlineMatch $match
.
callable | $callback |
runCheckResultCallback(\DevOwl\HeadlessContentBlocker\BlockedResult $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match): \DevOwl\HeadlessContentBlocker\BlockedResult
Run registered check-result callbacks.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runKeepAlwaysAttributesCallback(array<mixed,string> $keepAttributes,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match): array<mixed,string>
Run registered keep-always-attributes callbacks.
array<mixed,string> | $keepAttributes | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runSkipInlineScriptVariableAssignmentsCallback(array<mixed,string> $names,\DevOwl\HeadlessContentBlocker\matcher\ScriptInlineMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\ScriptInlineMatch $match): array<mixed,string>
Run registered skip-inline-names callbacks.
array<mixed,string> | $names | |
\DevOwl\HeadlessContentBlocker\matcher\ScriptInlineMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\ScriptInlineMatch | $match |
runInlineStyleShouldBeExtractedByCallback(boolean $extract,\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch $match): boolean
Run registered callbacks to not extract blocked CSS rules to a second document.
boolean | $extract | |
\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch | $match |
runInlineStyleModifyDocumentsCallback(\Sabberworm\CSS\CSSList\Document $document,\Sabberworm\CSS\CSSList\Document $extractedDocument,\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch $match)
Run registered callbacks to not extract blocked CSS rules to a second document.
\Sabberworm\CSS\CSSList\Document | $document | |
\Sabberworm\CSS\CSSList\Document | $extractedDocument | |
\DevOwl\HeadlessContentBlocker\matcher\StyleInlineMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\StyleInlineMatch | $match |
runInlineStyleBlockRuleCallback(\DevOwl\HeadlessContentBlocker\BlockedResult $result,string $url,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match): \DevOwl\HeadlessContentBlocker\BlockedResult
Run registered check-result callbacks.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
string | $url | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runVisualParentCallback(boolean|string|\DevOwl\HeadlessContentBlocker\number $visualParent,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Run registered check-result callbacks.
boolean|string|\DevOwl\HeadlessContentBlocker\number | $visualParent | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runBlockableStringExpressionCallback(string $expression,\DevOwl\HeadlessContentBlocker\AbstractBlockable $blockable)
Run registered blockable string expression callbacks.
string | $expression | |
\DevOwl\HeadlessContentBlocker\AbstractBlockable | $blockable |
processMatch(\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
A match got found from one of our finders. Run plugins and hooks.
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runBeforeMatchCallback(\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Run registered before-match callbacks.
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runBlockedMatchCallback(\DevOwl\HeadlessContentBlocker\BlockedResult $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Run registered blocked-match callbacks.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
runNotBlockedMatchCallback(\DevOwl\HeadlessContentBlocker\BlockedResult $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Run registered not-blocked-match callbacks.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |