(function () {
let commentURL = "https://comment.ifragasatt.se/comment?customerId=867994221&articleId=article103230&stickylogin=false&languageName=svenska&languageShortName=sv";
let allowSticky = commentURL.includes("stickylogin=true");
if (allowSticky) {
let cookie = document.cookie
.split('; ')
.find(row => row.startsWith('ifragasatt_cookie='));
if (cookie) {
let cookieValue = cookie.split('=')[1];
commentURL += "&cookie=" + cookieValue;
}
}
function getDomain(url) {
url = url.replace(/(https?:\/\/)?(www.)?/i, '');
if (url.indexOf('/') !== -1) {
url = url.split('/')[0];
}
return "." + url;
}
let ifrURL = "";
document.getElementById("ifragasatt-article103230").innerHTML = ifrURL;
window.addEventListener('message', receiveMessage, false);
function receiveMessage(evt) {
const commentDiv = document.getElementById("ifragasatt-article103230");
let domain = window.location.hostname.replace(/(https?:\/\/)?(www.)?/i, '');
if (domain.indexOf('/') !== -1) {
domain = domain.split('/')[0];
}
if (evt.data.id === "ifragasatt-article103230" && commentDiv && commentDiv.firstChild) {
document.getElementById("ifragasatt-article103230").firstChild.style.height = evt.data.height;
}
if (allowSticky && (evt.data.id === "ifr-set-cookie")) {
const token = evt.data.token;
if (token && token.length > 0) {
const maxAge = 30 * 24 * 60 * 60;
const cookie = "ifragasatt_cookie=" + token + "; max-age=" + maxAge + ";domain=." + domain + ";";
document.cookie = cookie;
}
}
if (evt.data.id === "ifr-remove-cookie") {
const cookie = "ifragasatt_cookie=;expires=Thu, 01 Jan 1970 00:00:01 GMT;max-age=-1;domain=." + domain + ";";
document.cookie = cookie;
commentURL = "https://comment.ifragasatt.se/comment?customerId=867994221&articleId=article103230&stickylogin=false&languageName=svenska&languageShortName=sv";
ifrURL = "";
document.getElementById("ifragasatt-article103230").innerHTML = ifrURL;
}
}
})();