(function () { var script = document.currentScript; var id = script.dataset.id; var style_id = 'easydmarc-embed-style'; if (!document.getElementById(style_id)){ var style = document.createElement('style'); style.id = style_id; style.innerHTML = ` .easydmarc-spin-loader { border: 4px solid #f3f3f3; /* Light grey */ border-top: 4px solid #c0c0c0; /* Blue */ border-radius: 50%; width: 30px; height: 30px; margin: 0 auto; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`; document.head.appendChild(style); } if(!script.dataset.token){ var settings = {...script.dataset, ...JSON.parse(script.dataset.settings)}; delete settings.settings; } else { var settings = {...script.dataset}; } var iframe = EasyDmarcUpdateEmbedWidget(settings); script.parentNode.insertBefore(iframe, script.nextSibling); if (settings?.internal_app && settings?.internal_app !== 'false') { script.parentNode.insertBefore(iframe.loader, script.nextSibling); } window.addEventListener('message', (e) => { if (e.data.key === `from-easydmarc-widget-${id}`) { iframe.style.opacity = '1'; iframe.style.height = `${e.data.height}px`; if (settings?.internal_app && settings?.internal_app !== 'false') { iframe.loader.style.display = 'none'; } } }, false); }()); function EasyDmarcUpdateEmbedWidget(settings){ let decodedOptions; let embedType = settings.type; if(settings.token){ decodedOptions = JSON.parse(window.atob(getBase64FromJWT(settings.token))); var params = { token: settings.token, is_embed: 'true', embed_id: settings.id, }; embedType = decodedOptions.type; }else{ var params = { is_embed: 'true', embed_settings: JSON.stringify(settings), embed_id: settings.id, }; embedType = settings.type; } var autoInit = settings.autoinit !== 'false'; var q = new URLSearchParams(params).toString(); var origin = "https://easydmarc.com/tools"; var embedPath = embedType; if (settings.token && decodedOptions?.embed_version) { embedPath = `${embedType}/embed/${decodedOptions.embed_version}`; } else if (embedType === 'domain-scanner') { embedPath = 'domain-scanner/embed/0.1.0'; } var url = `${origin}/${embedPath}?${q}`; var iframe = document.getElementById(settings.id) || document.createElement('iframe'); if (autoInit) { iframe.src = url; } iframe.style.opacity = 0; iframe.style.padding = '0px'; iframe.style.margin = '0px'; iframe.style.height = (settings.height === 'auto' || !settings.height) ? '0px' : settings.height; iframe.style.width = (settings.width === 'auto' || !settings.width) ? '100%' : settings.width; iframe.style.boxShadow = '0 0 10px #00000026'; iframe.style.overflow = 'hidden'; iframe.style.borderStyle = 'none'; iframe.style.borderRadius = !settings.border_radius ? '0' : settings.border_radius; iframe.scrolling = 'no'; iframe.loader = iframe.loader || document.createElement('div'); iframe.loader.classList.add('easydmarc-spin-loader'); iframe.loader.style.display = autoInit ? 'block' : 'none'; iframe.id = settings.id; return iframe } function getBase64FromJWT(jwt) { const parts = jwt.split('.'); if (parts.length === 3) { return parts[1]; } return null; } function inIframe () { try { return window.self !== window.top; } catch (e) { return true; } } function EasyDmarcUpdateEmbedWidget(settings){ let decodedOptions = {}; if(settings.token){ decodedOptions = JSON.parse(window.atob(getBase64FromJWT(settings.token))); } var autoInit = decodedOptions.autoinit !== false; var params = { token: settings.token, is_embed: 'true', embed_id: settings.id, bimi_activation: decodedOptions?.options?.bimi_activation, referrer: inIframe() ? document.referrer : window.location.href, }; if(settings?.domain){ params.domain = settings?.domain; } var origin; if (settings?.internal_app && settings?.internal_app !== 'false') { params.internal_app = settings?.internal_app !== 'false'; origin = "https://app.easydmarc.com"; } else { origin = "https://easydmarc.com/tools"; } var q = new URLSearchParams(params).toString(); var url = `${origin}/${decodedOptions.type}/embed/${decodedOptions?.embed_version}?${q}`; var iframe = document.getElementById(settings.id) || document.createElement('iframe'); if (autoInit && iframe.src !== url) { iframe.src = url; } if(decodedOptions?.options?.styles?.theme && JSON.parse(decodedOptions?.options?.styles?.theme?.shadowCheck)){ iframe.style.boxShadow = '0 9px 18px 0 ' + (decodedOptions?.options?.styles?.theme.shadowColor || '#CFD5EB'); }else{ iframe.style.boxShadow = 'unset'; } iframe.style.opacity = 0; iframe.style.padding = '0px'; iframe.style.margin = '0px'; iframe.style.height = (decodedOptions.height === 'auto' || !decodedOptions.height) ? '0px' : decodedOptions.height; iframe.style.width = (decodedOptions.width === 'auto' || !decodedOptions.width) ? '100%' : decodedOptions.width; iframe.style.overflow = 'hidden'; iframe.style.borderStyle = 'none'; iframe.style.minHeight = '265px'; iframe.style.borderRadius = !decodedOptions.border_radius ? '0' : decodedOptions.border_radius; iframe.scrolling = 'no'; if (settings?.internal_app && settings?.internal_app !== 'false') { iframe.loader = iframe.loader || document.createElement('div'); iframe.loader.classList.add('easydmarc-spin-loader'); iframe.loader.style.display = autoInit ? 'block' : 'none'; } iframe.id = settings.id; return iframe } function getBase64FromJWT(jwt) { const parts = jwt.split('.'); if (parts.length === 3) { return parts[1]; } return null; }