const thynkconsent = { vars: { dismissed: false, lifetime: 2592000, localStorageName: 'thynkconsent-dismissed', dataprotectionurl: 'https://www.hebamme-simone-röttgers.de/datenschutz.html', language: 'de-DE' }, selectors: { modalTable: 'thynk-consent-table', hint: 'thynk-consent-hint' }, functions: { init: function() { let dismissed = localStorage.getItem(thynkconsent.vars.localStorageName); if (dismissed !== null) { let now = thynkconsent.functions.getTime(); let difference = parseInt(now) - parseInt(dismissed); if (difference > thynkconsent.vars.lifetime) { localStorage.removeItem(thynkconsent.vars.localStorageName); } else { thynkconsent.vars.dismissed = true; } } let oldButton = document.querySelector('a[href="#CCM.openControlPanel"]'); if (oldButton) { oldButton.setAttribute('href', '#'); oldButton.setAttribute('onclick', 'thynkconsent.functions.showTMCModal(); return false;'); } console.log('-- IFrame Blocker Development --'); console.log('-- Collecting all iframes --'); let iframes = document.querySelectorAll('iframe'); console.log('-- Load given consents --'); thynkconsent.functions.consents.loadConsents(); console.log('-- Loop through iframes --'); iframes.forEach(thynkconsent.functions.iframes.replaceOriginalSource); console.log('-- Adding Message Eventlistener to top window --'); window.addEventListener("message", thynkconsent.functions.listenToIframeConsentMessage); }, consents: { loadConsents: function () { let consents = sessionStorage.getItem('iframe-consents'); if (consents === null) { consents = []; } else { consents = JSON.parse(consents); } thynkconsent.vars.givenConsents = consents; }, addConsent: function (host) { thynkconsent.vars.givenConsents.push(host); sessionStorage.setItem('iframe-consents', JSON.stringify(thynkconsent.vars.givenConsents)); }, }, dismiss: function() { localStorage.setItem(thynkconsent.vars.localStorageName, thynkconsent.functions.getTime()); document.querySelector('#' + thynkconsent.selectors.hint).style.display = 'none'; }, translate: function (key) { return thynkconsent.language['app'][key] ?? key; }, getTime: function() { return Math.floor(Date.now() / 1000); }, showTMCModal: function() { let modal = document.querySelector('#' + thynkconsent.selectors.modalTable); modal.style.display = 'flex'; }, hideTMCModal: function() { let modal = document.querySelector('#' + thynkconsent.selectors.modalTable); modal.style.display = 'none'; }, listenToIframeConsentMessage: function (event) { let host = event.data; let run = false; try { let t = JSON.parse(host); } catch (e) { run = true; } if (!run) { return; } console.log('-- Collecting all iframes with host ' + host); let iframes = document.querySelectorAll('iframe[data-host="' + host + '"]'); console.log('-- Add consent to session list --'); thynkconsent.functions.consents.addConsent(host); console.log('-- Loop through iframes --'); iframes.forEach(thynkconsent.functions.iframes.restoreOriginalSource); }, iframes: { replaceOriginalSource: function (iframe, index) { console.log('-- Process iframe no. ' + (index + 1) + ' --'); let src = iframe.getAttribute('src'); let url = new URL(src); let host = url.host; if (thynkconsent.vars.givenConsents.includes(host)) { console.log('-- Consent for ' + host + ' already given, no need to block. --'); return; } console.log('-- Source: ' + src + ' --'); console.log('-- Host: ' + host + ' --'); iframe.setAttribute('src', "https://keks.thynk.media/content-blocked/" + thynkconsent.vars.language + "?src=" + encodeURIComponent(src)); iframe.setAttribute('data-src', src); iframe.setAttribute('data-host', host); }, restoreOriginalSource: function (iframe) { console.log('-- Restore original source --'); let originalSrc = iframe.getAttribute('data-src'); console.log(originalSrc) iframe.setAttribute('src', originalSrc); }, } }, language: JSON.parse('{"app":{"general_cookie_text":"Diese Webseite nutzt ausschlie\u00dflich technische Cookies. Weitere Informationen finden Sie in der","general_cookie_dataprotection":"Datenschutzerkl\u00e4rung","general_cookie_show_table":"Liste aller Cookies anzeigen","general_cookie_heading_table":"Liste der Cookies","general_cookie_ok":"Verstanden","general_cookie_embedding_company":"Herausgeber","general_cookie_embedding_description":"Beschreibung","general_cookie_embedding_dataprotection":"Link zur Datenschutzerkl\u00e4rung","general_cookie_embedding_datacollection":"Welche Daten werden erhoben?","general_cookie_embedding_cookies":"Cookies","general_cookie_embedding_datacollectionpurpose":"Zweck der Datenerhebung","general_cookie_embedding_legalbase":"Rechtliche Grundlage","general_cookie_embedding_placeofagreement":"Ort der Verarbeitung","general_cookie_cookie_name":"Name","general_cookie_cookie_lifetime":"Lebensdauer","general_cookie_cookie_desc":"Beschreibung"},"cookies":{"session":{"integrationname":"Session-Cookie","company":"Simone R\u00f6ttgers","description":"Dieser Cookie ist f\u00fcr eine fehlerfreie Funktionalit\u00e4t unserer Webseite erforderlich und kann nicht deaktiviert werden.","datacollection":"Loginstatus, Sprache und Formulardaten werden zur Laufzeit im Browser gespeichert. Mit Schlie\u00dfen des Browserfensters verfallen diese Daten.","datacollectionpurpose":"Verwaltung von Loginstatus, Sprache und Formulardaten.","legalbase":"Berechtigtes Interesse, Art. 6 Abs.1 lit. f i.V.m. Art. 7 Abs.1 DSGVO","placeprivacyagreement":"Simone R\u00f6ttgers, Klosterstr. 4, 49832 Thuine","dataprotectionlink":"https:\/\/www.hebamme-simone-r\u00f6ttgers.de\/datenschutz.html","cookies":[{"name":"Sitzungscookie","lifetime":"Session","desc":"Erm\u00f6glicht die Grundfunktion der Webseite."}]}}}'), cookies: JSON.parse('[{"key":"session"}]'), templates: { css: function() { return ` `; }, hint: function() { return `

${thynkconsent.functions.translate('general_cookie_text')} ${thynkconsent.functions.translate('general_cookie_dataprotection')}

`; }, modal: function() { return `

${thynkconsent.functions.translate('general_cookie_heading_table')}

`; } } }; document.addEventListener('DOMContentLoaded', function() { thynkconsent.functions.init(); let elm = document.createElement('div'); elm.innerHTML = ` ${thynkconsent.templates.hint()} ${thynkconsent.templates.modal()} ${thynkconsent.templates.css()} `; document.body.appendChild(elm); });