feat: client-seitige erkennung fuer elementor-videos und JS-iframes

- frontend.js erkennt JS-nachgeladene iframes (Slider etc.) per initialem Scan
  + MutationObserver und ersetzt sie durch den Platzhalter.
- Elementor-Video-Widgets: data-settings (youtube_url/vimeo_url) wird gelesen,
  zu Embed-URL konvertiert, Widget neutralisiert und durch Platzhalter ersetzt.
- Service-Daten + i18n werden dafuer ans Frontend lokalisiert (cbConfig).
- readme: Erkennung + Grenzen (Elementor-Vorschaubild) dokumentiert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
s4luorth
2026-06-07 15:11:48 +02:00
parent 3c37bf63cc
commit a738841d60
3 changed files with 234 additions and 2 deletions

View File

@@ -45,6 +45,42 @@ class CB_Renderer {
CB_VERSION,
true
);
// Service data + i18n for client-side detection (JS-injected iframes such
// as Elementor video widgets, sliders, …).
wp_localize_script( 'cb-frontend', 'cbConfig', [
'services' => self::services_for_js(),
'i18n' => [
'recipient' => __( 'Empfänger:', 'gdpr-content-blocker' ),
'purpose' => __( 'Zweck:', 'gdpr-content-blocker' ),
'thirdCountry' => __( '⚠ Datenübermittlung in ein Drittland außerhalb der EU/des EWR', 'gdpr-content-blocker' ),
'privacy' => __( 'Datenschutzerklärung des Anbieters', 'gdpr-content-blocker' ),
'load' => __( '%s jetzt laden', 'gdpr-content-blocker' ),
'remember' => __( 'Diesen Dienst künftig immer laden', 'gdpr-content-blocker' ),
'defaultText' => __( 'Um diesen Inhalt von %s zu laden, ist Ihre Einwilligung erforderlich. Dabei werden personenbezogene Daten (z. B. Ihre IP-Adresse) an den Anbieter übertragen.', 'gdpr-content-blocker' ),
],
] );
}
/** Minimal, public service data for client-side detection. */
private static function services_for_js(): array {
$out = [];
foreach ( CB_Settings::get_services() as $svc ) {
if ( empty( $svc['match_pattern'] ) || ! ( $svc['enabled'] ?? true ) ) {
continue;
}
$out[] = [
'id' => $svc['id'],
'name' => $svc['name'],
'match' => $svc['match_pattern'],
'recipient' => $svc['recipient'],
'third_country' => ! empty( $svc['third_country'] ),
'purpose' => $svc['purpose'],
'privacy_url' => $svc['privacy_url'] ?? '',
'placeholder' => $svc['placeholder_text'] ?? '',
];
}
return $out;
}
/**