<script>
(function(){
const ForumIDs = new Set([
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 89, 52, 65, 101, 85, 71,
53, 68, 109, 78, 91, 35, 34, 112, 80, 54, 92, 111, 58, 102, 3, 83, 75, 87, 36,
11, 23, 16, 12, 17, 76, 32, 89, 82
]);
function fnct1(el, href) {
let loader = document.createElement("img");
loader.src = "/img/loading.gif";
loader.classList.add("loader");
el.parentNode.appendChild(loader);
fetch(href)
.then((resp) => resp.text())
.then((html) => {
let raspars = new DOMParser();
let thread = raspars.parseFromString(html, "text/html");
let postImg = thread.querySelector("#pun-viewtopic .topicpost .postimg");
if (postImg) {
let img = document.createElement("img");
img.classList.add("postimg");
img.src = postImg.src;
img.addEventListener("click", function () {
if (el.parentNode.contains(img)) {
el.parentNode.removeChild(img);
fnct1(el, href);
}
});
let span = document.createElement("span");
span.classList.add("prew");
span.appendChild(img);
el.parentNode.appendChild(span);
localStorage.setItem(href, postImg.src);
} else {
return;
}
})
.finally(() => {
el.parentNode.removeChild(loader);
});
}
function fnct2(el, href) {
let icon = document.createElement("img");
icon.src = "/files/0007/af/57/17303.png";
icon.classList.add("mobile-icon");
icon.title = "Показать изображение";
icon.style.cursor = "pointer";
el.parentNode.appendChild(icon);
icon.addEventListener("click", function () {
fnct1(el, href);
el.parentNode.removeChild(icon);
});
}
if (
Array.from(ForumIDs).some((id) =>
window.location.href.includes(`/viewforum.php?id=${id}`)
)
) {
document
.querySelectorAll("#pun-viewforum .forum .tclcon > a")
.forEach(function (el) {
let href = el.getAttribute("href");
let imgSrc = localStorage.getItem(href);
if (imgSrc) {
let span = document.createElement("span");
span.classList.add("prew");
let img = document.createElement("img");
img.src = imgSrc;
span.appendChild(img);
img.addEventListener("click", function () {
fnct1(el, href);
el.parentNode.removeChild(span);
});
el.parentNode.appendChild(span);
} else {
if (
"ontouchstart" in window ||
navigator.maxTouchPoints > 0 ||
window.innerWidth <= 480
) {
fnct2(el, href);
} else {
el.addEventListener("mouseover", function () {
if (!el.classList.contains("hovered")) {
el.classList.add("hovered");
fnct1(el, href);
}
});
}
}
});
}
})()
</script>