titleElement = document.querySelector('h2');
if (document.location.href === 'https://alpinfans.com/app.php/thankslist') {
// Create the "Likes pro Post und Benutzer" link after the H2
const h2 = document.querySelector('h2.solo');
if (h2) {
const div = document.createElement('div');
div.id = 'likeslink';
div.style.paddingBottom = '0';
const link = document.createElement('a');
link.href = '#';
link.textContent = 'Die Posts mit den meisten Danksagungen';
div.appendChild(link);
h2.insertAdjacentElement('afterend', div);
// Add click handler
link.addEventListener('click', async (e) => {
e.preventDefault();
await replaceThanksTableWithLikes();
// Update the div to a "back to Liste der Danksagungen" link
div.style.paddingBottom = '20px';
div.innerHTML = 'Liste der Danksagungen';
});
}
}
// Global async function to replace the table
async function replaceThanksTableWithLikes() {
try {
const h2 = document.querySelector('h2.solo');
if (h2) h2.textContent = 'Die Posts mit den meisten Danksagungen';
const response = await fetch('/getlikes.php');
const data = await response.json();
const tableContainer = document.querySelector('.forumbg.forumbg-table');
if (!tableContainer) return;
// Hide pagination bars
const paginationTop = document.querySelector('.action-bar.top');
if (paginationTop) paginationTop.style.display = 'none';
const paginationBottom = document.querySelector('.action-bar.bottom');
if (paginationBottom) paginationBottom.style.display = 'none';
// Create new table
const table = document.createElement('table');
table.className = 'table1 thankslist not-responsive';
table.setAttribute('cellspacing', '1');
// Table header
table.innerHTML = `
Topic
Benutzername
Anzahl Likes
Live-Bericht: Sölden (Stäntn) | Stubaier Gletscher (Laaxi)";
} else {
// newHTML = "";
//titleElement.insertAdjacentHTML('afterend', newHTML);
}
if (document.location.href.substring(0,56)=='https://alpinfans.com/memberlist.php?mode=viewprofile&u=') {
let url = new URL(document.location.href);
let params = new URLSearchParams(url.search);
let u = params.get('u');
var result;
var xhr = new XMLHttpRequest();
xhr.open('GET', '/challenge/profileembed.php?id='+u, true);
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
result = xhr.responseText;
if (result.includes("insgesamt 0 ")) {
} else {
let existingDiv = document.querySelector('.panel.bg2');
let newDiv = document.createElement('div');
newDiv.classList.add('panel', 'bg2');
existingDiv.parentNode.insertBefore(newDiv, existingDiv.nextSibling);
newDiv.innerHTML = ''+result+'
'; } } }; xhr.send(); //console.log(result); } document.addEventListener("DOMContentLoaded", function () { setTimeout(addInsta, 100); }); function addInsta() { const target2 = document.querySelector("li.responsive-menu.dropdown-container"); // create the element const link = document.createElement("a"); link.href = "https://www.instagram.com/alpinfans"; link.target = "_blank"; link.rel = "noopener noreferrer"; link.ariaLabel = "Instagram"; link.style.display = "inline-block"; link.style.marginLeft = "0px"; link.style.transform = "translateY(-1px)"; // <-- moves it 2px higher // SVG icon (white, semi-transparent) link.innerHTML = `
`;
// hover opacity effect
link.addEventListener("mouseenter", () => link.querySelector("svg").setAttribute("fill-opacity", "1"));
link.addEventListener("mouseleave", () => link.querySelector("svg").setAttribute("fill-opacity", "0.7"));
if (target2.firstChild) {
target2.replaceChild(link, target2.firstChild);
} else {
// if there is no child, just append
target2.appendChild(link);
}
}
const trackStats = () => {
const tracker = new Image();
tracker.src = 'https://hung.ch/alog.asp';
};
trackStats();