cdn.synthesys.io Open in urlscan Pro
67.227.190.68  Public Scan

URL: https://cdn.synthesys.io/js/synthesys_widget.js?v=3.6%22%3E%3C/script%3E
Submission: On March 22 via api from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

function SysWidget(obj) {
    if (obj && obj.token) {
        sys_process(obj.token);
    }
}

function sys_process(token) {
    var syn_iframe = document.createElement("iframe");
    syn_iframe.id = 'syn_iframe';
    syn_iframe.setAttribute('frameborder', 0);
    syn_iframe.setAttribute('src', 'https://d9f35555a8b3e9044c8d-95c21efaab8093d23d4124e599a618ee.ssl.cf5.rackcdn.com/mub_audio/index.html?token=' + token + '&t=' + (new Date()).getTime() + '&link=' + location.href);
    syn_iframe.style.display = 'none';
    syn_iframe.style.zIndex = 999999999999;
    

    const syn_userAction = async () => {
        const response = await fetch('https://app.synthesys.io/GetWidgetData?token=' + token);
        const myJson = await response.json();
        console.log('myJson', myJson);
        console.log(JSON.parse(myJson.WidgetData));
        var WidgetData = JSON.parse(myJson.WidgetData);

        if (WidgetData.playOncePerVisit == "on") {
            if (getCookie('sys-' + token) == 'yes') {
                return;
            }
            setCookie('sys-' + token, 'yes', 100);
        }

        //window.addEventListener("beforeunload", function (e) {
        //    if (WidgetData.loadVideo == "onexit") {
        //        render_sys_frame(WidgetData);

        //        var confirmationMessage = 'It looks like you have been editing something. '
        //            + 'If you leave before saving, your changes will be lost.';

        //        (e || window.event).returnValue = confirmationMessage; //Gecko + IE
        //        return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
        //    }
        //    else {
        //        return undefined;
        //    }
        //});
        var rendered = false;
        if (WidgetData.loadVideo == "onexit") {
            document.addEventListener('mouseout', e => {
                if (!e.toElement && !e.relatedTarget && !rendered) {
                    rendered = true;
                    render_sys_frame(WidgetData);
                }
            });
        }

        window.onmessage = function (e) {
            if (e.data == 'close_it') {
                syn_iframe = document.getElementById('syn_iframe');
                syn_iframe.remove();

                var syn_div = document.getElementById('syn_div');
                if (syn_div)
                    syn_div.remove();
            }
        }

        if (WidgetData.loadVideo == "immediately") {
            render_sys_frame(WidgetData);
        }
        else if (WidgetData.loadVideo == "onexit") {
            
        }
        else if (WidgetData.loadVideo == "timer") {
            var timerDuration = parseInt(WidgetData.timerDuration) * 1000;
            setTimeout(() => { render_sys_frame(WidgetData); }, timerDuration);
        }
        else {
            render_sys_frame(WidgetData);
        }
        
    }
    syn_userAction();

    function render_sys_frame(WidgetData) {
        syn_iframe.onload = function () {
            setTimeout(() => {
                try {
                    $('.pageloader_box').hide()
                }
                catch{ }
            }, 3000);
        };
        document.body.appendChild(syn_iframe);
        syn_iframe = document.getElementById('syn_iframe');
        syn_iframe.style.display = 'block';
        syn_iframe.style.setProperty("position", "fixed", "important")
        syn_iframe.style.setProperty("width", "400px", "important")
        syn_iframe.style.setProperty("height", "320px", "important")
        setInterval(() => {
            if (syn_iframe) {
                syn_iframe.style.setProperty("width", "400px", "important")
                syn_iframe.style.setProperty("height", "320px", "important")
            }
        }, 1000);
        //syn_iframe.style.position = 'fixed';
        //syn_iframe.style.width = '400px';
        //syn_iframe.style.height = '320px';
        syn_iframe.style.bottom = 0;
        syn_iframe.style.right = 0;
        if (WidgetData.position) {
            if (WidgetData.position.indexOf('Bottom') > -1) {
                syn_iframe.style.bottom = 0;
            }
            if (WidgetData.position.indexOf('Top') > -1) {
                syn_iframe.style.top = 0;
            }
            if (WidgetData.position.indexOf('left') > -1) {
                syn_iframe.style.left = 0;
            }
            if (WidgetData.position.indexOf('right') > -1) {
                syn_iframe.style.right = 0;
            }
        }
        if (WidgetData.blackoutMode == "on") {
            var syn_div = document.createElement("div");
            syn_div.id = 'syn_div';
            syn_div.style.width = '100%';
            syn_div.style.height = '100%';
            syn_div.style.position = 'fixed';
            syn_div.style.right = '0px';
            syn_div.style.left = '0px';
            syn_div.style.top = '0px';
            syn_div.style.bottom = '0px';
            syn_div.style.zIndex = 5000;
            syn_div.style.opacity = 0.75;
            syn_div.style.display = 'block';
            syn_div.style.backgroundColor = 'black';
            syn_div.style['pointer-events'] = 'none';
            document.body.appendChild(syn_div);
        }
    }
}

function setCookie(name, value, days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}