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 ${data.map((row, index) => ` ${row.post_subject} ${row.username} ${row.likes} `).join('')} `; // Replace old table tableContainer.innerHTML = ''; const innerDiv = document.createElement('div'); innerDiv.className = 'inner'; innerDiv.appendChild(table); tableContainer.appendChild(innerDiv); } catch (err) { console.error('Error loading likes table:', err); } } if (document.location.href=='https://alpinfans.com/search.php') { const form = document.querySelector("form"); if (form) { // --- Create and insert the new panel with
layout --- const newPanel = document.createElement("div"); newPanel.className = "panel"; newPanel.innerHTML = `

Suche in der Challenge

(nächste Skigebiete)
`; // Insert as 2nd child if (form.children.length > 1) { form.insertBefore(newPanel, form.children[1]); } else { form.appendChild(newPanel); } console.log("✅ Added 'Suche in der Challenge' panel with phpBB style layout."); // --- Add CSS for dropdown --- const style = document.createElement('style'); style.textContent = ` #resortResults { position: absolute; background: #fff; border: 1px solid #ccc; display: none; max-height: 250px; overflow-y: auto; box-shadow: 0 4px 8px rgba(0,0,0,0.1); z-index: 11; } #resortResults .result-item { padding: 6px 10px; cursor: pointer; } #resortResults .result-item:hover { background-color: #f0f0f0; } #resortResults a { text-decoration: none; color: #333; display: block; width: 100%; } #keywords2 { position: relative; } `; document.head.appendChild(style); // --- AJAX search function --- const keywordsInput = document.getElementById('keywords2'); const resortResults = document.getElementById('resortResults'); keywordsInput.addEventListener('input', function() { const query = this.value.trim(); if (query.length < 1) { resortResults.innerHTML = ''; resortResults.style.display = 'none'; return; } fetch(`https://alpinfans.com/challenge/ajax/ajax_searchresort_search.php?search=${encodeURIComponent(query)}`) .then(r => r.text()) .then(data => { const lines = data.split('\n').filter(l => l.trim() !== ''); let html = ''; lines.forEach(line => { const match = line.match(/\[(.*?)\]/); if (!match) return; const urlPart = match[1]; const link = 'https://alpinfans.com/skigebiete/' + urlPart; const displayText = line.replace(/\s*\[.*?\]\s*/, ''); html += `
${displayText}
`; }); resortResults.innerHTML = html || '
Keine Ergebnisse
'; resortResults.style.display = 'block'; }) .catch(err => { console.error(err); resortResults.innerHTML = '
Fehler beim Laden
'; }); }); // --- Hide dropdown when clicking outside --- document.addEventListener('click', function(event) { if (!keywordsInput.contains(event.target) && !resortResults.contains(event.target)) { resortResults.style.display = 'none'; } }); // --- GPS-based search --- window.searchGPS = function() { if (!navigator.geolocation) { alert('Geolocation wird von Ihrem Browser nicht unterstützt.'); return; } navigator.geolocation.getCurrentPosition(function(position) { const lat = position.coords.latitude; const lon = position.coords.longitude; fetch(`https://alpinfans.com/challenge/ajax/ajax_searchresort_closest.php?lat=${lat}&lon=${lon}`) .then(r => r.text()) .then(data => { const lines = data.split('\n').filter(l => l.trim() !== ''); let html = ''; lines.forEach(line => { const match = line.match(/\[(.*?)\]/); if (!match) return; const urlPart = match[1]; const displayText = line.replace(/\s*\[.*?\]\s*/, ''); html += `
${displayText}
`; }); resortResults.innerHTML = html || '
Keine Ergebnisse
'; resortResults.style.display = 'block'; }) .catch(err => { console.error(err); resortResults.innerHTML = '
Fehler beim Laden
'; }); }, function(err) { alert('Fehler beim Abrufen der Position: ' + err.message); }); }; // --- Attach click listener to GPS link --- const gpsLink = document.getElementById('gpsLink'); if (gpsLink) { gpsLink.addEventListener('click', function(e) { e.preventDefault(); searchGPS(); }); } } } if (document.location.href=='https://alpinfans.com/' || document.location.href.substring(0,31)=='https://alpinfans.com/index.php') { //newHTML = "
"; newHTML = ""; document.querySelector('#nav-breadcrumbs').innerHTML += newHTML + "
Ski-Challenge 2025/26: 1. Wenzel, 2. ski-chrigel, 3. Fabian_Skiing, 4. Vero69, 5. Sabine, 6. hitparade, 7. Laaxi, 8. Stäntn, 9. Snowboard-Tobi, 10. LOL - Karte mit aktuellen Berichten
365-Challenge | NEU: Ski-Weltcup-Tippspiel

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 = '

Alpinfans-Challenge

'+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();