var newPreviewUrl = "https:\/\/app.abtasty.com\/ready\/preview\/index.php?clientID=&variationID=×tamp="; var token = getHashVars()["t"]; if(token){ newPreviewUrl += "&t=" + token; } var th = document.getElementsByTagName('head')[0]; var s = document.createElement('script'); s.setAttribute('type', 'text/javascript'); s.setAttribute('src', newPreviewUrl); th.appendChild(s); function getHashVars() { const vars = {}; const pos = window.location.href.indexOf('#'); const string = window.location.href.substring(pos); string.replace(/[#&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { (vars[key] = value) }); return vars; }