HTML_ATTRIBUTE_TO_FETCH_URL_FROM
HTML_ATTRIBUTE_TO_FETCH_URL_FROM ='hcb-fetch-image-from'
Detects, if there could be created an image preview for a given URL, downloads it and appends it as a custom attribute to the blocked HTML tag so the visual content blocker could create something cool.
setCache
to the plugin instance, otherwise the mechanism does not track any URLs. The
purpose of the headless content blocker is to block external URLs, and we do not want to use an external URL as image preview!AbstractBlockable
needs to implement ImagePreviewBlockable
interface to determine if thumbnails
should be loaded for the blocked content!$htmlHeadThumbnailParser :\DevOwl\HeadlessContentBlocker\plugins\imagePreview\HtmlHeadThumbnailParser
HtmlHeadThumbnailParser.
$cache :\DevOwl\HeadlessContentBlocker\plugins\imagePreview\ImagePreviewCache
ImagePreviewCache.
__construct(\DevOwl\HeadlessContentBlocker\HeadlessContentBlocker $headlessContentBlocker)
C'tor.
\DevOwl\HeadlessContentBlocker\HeadlessContentBlocker | $headlessContentBlocker |
beforeMatch(\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Called before a match got found.
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
blockedMatch(\DevOwl\HeadlessContentBlocker\BlockedResult $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
See `AbstractPlugin`.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
notBlockedMatch(\DevOwl\HeadlessContentBlocker\BlockedResult $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Called after a match got not blocked. Opposite of `blockedMatch`.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
checkResult(\DevOwl\HeadlessContentBlocker\BlockedResult $result,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match): \DevOwl\HeadlessContentBlocker\BlockedResult
Special case: Read attribute of the original embed URL if it got passed via a custom attribute.
\DevOwl\HeadlessContentBlocker\BlockedResult | $result | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
keepAlwaysAttributes(array<mixed,string> $keepAttributes,\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match): array<mixed,string>
Keep attributes for a specific match.
array<mixed,string> | $keepAttributes | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
skipInlineScriptVariableAssignment(array<mixed,string> $names,\DevOwl\HeadlessContentBlocker\matcher\ScriptInlineMatcher $matcher,\DevOwl\FastHtmlTag\finder\match\ScriptInlineMatch $match): array<mixed,string>
Skip inline script by variable name.
array<mixed,string> | $names | |
\DevOwl\HeadlessContentBlocker\matcher\ScriptInlineMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\ScriptInlineMatch | $match |
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.
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.
\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 |
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.
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.
boolean|string|\DevOwl\HeadlessContentBlocker\number | $visualParent | |
\DevOwl\HeadlessContentBlocker\matcher\AbstractMatcher | $matcher | |
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |
blockableStringExpression(string $expression,\DevOwl\HeadlessContentBlocker\AbstractBlockable $blockable): string
Allows to modify the passed string expression to a blockable.
string | $expression | |
\DevOwl\HeadlessContentBlocker\AbstractBlockable | $blockable |
getWriteJson(\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail $thumbnail)
Create the result for the HTML attribute which our unblocker can consume.
\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail | $thumbnail |
fetchMetadata(array<mixed,\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail> $thumbnails)
Use multiple mechanism to extract a thumbnail from any URL. It returns an map of URL => thumbnail, and if a thumbnail got not found it is no longer part of the returned map.
Mechanism:
array<mixed,\DevOwl\HeadlessContentBlocker\plugins\imagePreview\Thumbnail> | $thumbnails | Key needs to be the embed URL |
setCache(\DevOwl\HeadlessContentBlocker\plugins\imagePreview\ImagePreviewCache $cache)
Setter.
\DevOwl\HeadlessContentBlocker\plugins\imagePreview\ImagePreviewCache | $cache |
findUrlForSpecialMatch(\DevOwl\FastHtmlTag\finder\match\AbstractMatch $match)
Find an embed URL for a special match.
\DevOwl\FastHtmlTag\finder\match\AbstractMatch | $match |