var prefix = "pinup-"; allCookieString = document.cookie; allCookie = allCookieString.split(";"); var cookieToQuery = "?"; for (var i in allCookie){ var query = ""; var cookieName = allCookie[i].split("=")[0].replace(' ',''); var cookeValue = allCookie[i].split("=")[1].replace(' ',''); switch (cookieName){ case prefix+"streamId": query = "st"; break; case prefix+"subId1": query = "s1"; break; case prefix+"subId2": query = "s2"; break; case prefix+"subId3": query = "s3"; break; case prefix+"subId4": query = "s4"; break; case prefix+"subId5": query = "s5"; break; case prefix+"promocode": if (!cookeValue.includes("form_key")){ query = "form_key"; }; break; case prefix+"email": if (!cookeValue.includes("form_email")){ query = "form_email"; }; break; case prefix+"phone": if (!cookeValue.includes("form_phone")){ query = "form_phone"; }; break; case prefix+"pc": break; default: break; } if (query!=""){ if (i==0){ cookieToQuery+=query+"="+cookeValue; continue; } cookieToQuery+="&"+query+"="+cookeValue; } }; var instaRedirect = { cookieName: "disableInstaRed", cookieExpiresTime: 1, userAgent: navigator.userAgent, isInstaBrowser: function() { return /instagram/i.test(this.userAgent); }, isAndroid: function() { return /android/i.test(this.userAgent); }, isIOS: function() { return /iphone|ipad|ipod/i.test(this.userAgent); }, isDisabledRedirect: function() { return $.cookie(instaRedirect.cookieName); }, isWindowFocused: function() { instaRedirect.isFocused = true; window.onfocus = function() { instaRedirect.isFocused = true; }; window.onblur = function() { instaRedirect.isFocused = false; }; }, createFrame: function() { var f = document.createElement("iframe"); f.src = "https://google.com/"; f.style.display = "none"; return document.body.appendChild(f); }, deleteFrame: function(f) { document.body.removeChild(f); }, setLocation: function(url) { if (!instaRedirect.isFocused) return Promise.resolve(); return new Promise(function(resolve, reject) { var frame = instaRedirect.createFrame(); frame.onload = function() { frame.contentWindow.parent.location = url; instaRedirect.deleteFrame(frame); setTimeout(function() { resolve(); }, 100); }; }); }, getLinkForAndroid: function(clearUrl, protocol, packageStr, targetLink) { return "intent://" + clearUrl + "#Intent" + ";scheme=" + protocol + ";package=" + packageStr + ";S.browser_fallback_url=" + encodeURIComponent(targetLink) + ";end"; }, openInBrowser: function(targetLink) { var url = new URL(targetLink), protocol = url.protocol.replace(":", ""), cookie = $.cookie("getParamsRef"), getParams = cookie ? cookie : "", getParams= cookieToQuery+getParams, hash = url.hash, clearUrl = url.hostname + url.pathname + getParams + hash; if (this.isAndroid()) { window.openInChrome = this.getLinkForAndroid(clearUrl, protocol, "com.android.chrome", clearUrl); window.openInNativeBrowser = this.getLinkForAndroid(clearUrl, protocol, "com.android.browser", clearUrl); instaRedirect.setLocation(openInChrome).then(function() { setTimeout(function() { instaRedirect.setLocation(openInNativeBrowser); }, 1e3); }); } else if (this.isIOS()) { return; } else { instaRedirect.setLocation(protocol + "://" + clearUrl); } var date = new Date; date.setTime(date.getTime() + instaRedirect.cookieExpiresTime * 60 * 1e3); $.cookie(instaRedirect.cookieName, "true", { expires: date }); } }; if (instaRedirect.isInstaBrowser() && !instaRedirect.isDisabledRedirect()) { instaRedirect.isWindowFocused(); instaRedirect.openInBrowser(location.href); } setInterval("signboardBulbs()", 1000);