` on a site and then leaving a YouTube embed in the
* page is not a partial job, it is a broken one: the iframe sets its cookies
* the moment the document parses, before the banner has painted, and it does
* it without running a line of the site's own JavaScript. The same is true of
* a tracking pixel, which is an `` and therefore also invisible to
* everything the script layers do.
*
* Two element types, handled differently because what they cost is different.
* An iframe is content the visitor came for, so blocking it has to leave
* something in its place and a way to get it back. A pixel is not content at
* all: it is removed and nothing is said, because there is nothing to say.
*
* The list below is an allowlist and that is the whole safety argument. A
* consent plugin that guesses at iframes will eventually blank a payment form
* or a captcha, and a checkout that does not load is a worse failure than an
* ungated embed. Nothing matches unless it is named here.
*/
class Embeds {
/**
* Embeds worth blocking, and what to call them when they are.
*
* `label` is shown to the visitor in the placeholder, so it is the name
* they would recognise rather than the domain it happens to load from.
*/
public static function default_rules() {
return [
[
'id' => 'youtube',
'label' => 'YouTube',
'category' => 'marketing',
// `youtube-nocookie` is included deliberately. It withholds
// cookies until playback, not for ever, so it still needs
// consent — the name is a description of the first second.
'src' => '(youtube\.com|youtube-nocookie\.com)/embed/',
'enabled' => true,
],
[
'id' => 'vimeo',
'label' => 'Vimeo',
'category' => 'marketing',
'src' => 'player\.vimeo\.com/video/',
'enabled' => true,
],
[
'id' => 'google-maps',
'label' => 'Google Maps',
'category' => 'functional',
'src' => '(google\.[a-z.]+/maps/embed|maps\.google\.[a-z.]+/maps)',
'enabled' => true,
],
[
'id' => 'soundcloud',
'label' => 'SoundCloud',
'category' => 'marketing',
'src' => 'w\.soundcloud\.com/player',
'enabled' => true,
],
[
'id' => 'spotify',
'label' => 'Spotify',
'category' => 'marketing',
'src' => 'open\.spotify\.com/embed',
'enabled' => true,
],
[
'id' => 'x-twitter',
'label' => 'X (Twitter)',
'category' => 'marketing',
'src' => '(platform\.twitter\.com|syndication\.twitter\.com)',
'enabled' => true,
],
[
'id' => 'facebook-embed',
'label' => 'Facebook',
'category' => 'marketing',
'src' => 'facebook\.com/plugins/',
'enabled' => true,
],
[
'id' => 'instagram-embed',
'label' => 'Instagram',
'category' => 'marketing',
'src' => 'instagram\.com/(p|reel|tv)/[^/]+/embed',
'enabled' => true,
],
[
'id' => 'tiktok-embed',
'label' => 'TikTok',
'category' => 'marketing',
'src' => 'tiktok\.com/(embed|player)',
'enabled' => true,
],
[
// The `