Jestem Rudy

Jestem Rudy's profile picture

Last active:

Mood:

View my: Blog | Forum Topics

SpaceHey URL:

https://spacehey.com/profile?id=4021386

Jestem Rudy's Interests

General

ja jestem tylko RUDY
📝 Ostatni wpis na blogu
ładowanie ostatniego wpisu…

Jeśli widzisz ten tekst dłużej niż kilka sekund, skrypt włączy tryb awaryjny i pokaże tytuł + link.

Pokaż cały wpis Otwórz w nowej karcie
(function(){ /* ---------------- OVERLAY: znika po 10s i usuwa się z DOM ---------------- */ function hideIntro() { var overlay = document.getElementById('intro-overlay'); if (!overlay) return; overlay.classList.add('hidden'); overlay.addEventListener('transitionend', function(){ if (overlay && overlay.parentNode) overlay.parentNode.removeChild(overlay); }, {once:true}); } // bezpieczeństwo: start po pełnym DOM if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function(){ setTimeout(hideIntro, 10000); }); } else { setTimeout(hideIntro, 10000); } /* ---------------- OSTATNI WPIS: konfiguracja ---------------- */ // (Opcjonalnie) ręcznie podaj URL konkretnego wpisu, żeby wymusić pobranie tego posta: // np. const BLOG_URL_OVERRIDE = "https://spacehey.com/blog?id=123456&post=7890"; const BLOG_URL_OVERRIDE = ""; const sel = { panel: document.getElementById('last-post'), meta: document.getElementById('lp-meta'), content: document.getElementById('lp-content'), toggle: document.getElementById('lp-toggle'), open: document.getElementById('lp-open') }; /* ---------------- Pomocnicze: sanitizacja HTML fragmentu ---------------- */ function sanitizeFragment(rootEl) { // usuń niebezpieczne elementy rootEl.querySelectorAll('script, style, link, iframe, object, embed, noscript').forEach(function(el){ el.remove(); }); // usuń potencjalne atrybuty 'on*' i niechciany inline CSS rootEl.querySelectorAll('*').forEach(function(el){ // atrybuty on* [].slice.call(el.attributes).forEach(function(attr){ if (/^on/i.test(attr.name)) el.removeAttribute(attr.name); // zostawiamy style, ale możesz wymusić czystość: // if (attr.name === 'style') el.removeAttribute('style'); }); // obrazki/zasoby – ogranicz maksymalny rozmiar via CSS, nie usuwamy }); return rootEl; } /* ---------------- Ekstrakcja tytułu/treści z pobranej strony ---------------- */ function extractFromDoc(doc) { // tytuł — różne możliwe selektory var titleEl = doc.querySelector('.blog-entry h1, article h1, .heading h1, h1'); var title = titleEl ? titleEl.textContent.trim() : 'Ostatni wpis'; // treść — spróbuj kilku selektorów i wybierz najbogatszy var candidates = [ '.blog-entry .content', '.blog-entry .body', 'article .content', 'article .post-body', '.post .content', '.post-body', '.blog-entry', '#content' ]; var best = null, bestLen = 0; candidates.forEach(function(sel){ var el = doc.querySelector(sel); if (el) { var len = (el.textContent || '').trim().length; if (len > bestLen) { best = el; bestLen = len; } } }); // awaryjnie: bierz główne <main> jeżeli jest if (!best) { best = doc.querySelector('main') || doc.body; } // zrób czysty fragment var frag = document.createElement('div'); frag.innerHTML = best.innerHTML || ''; sanitizeFragment(frag); return { title: title, html: frag.innerHTML }; } /* ---------------- Znajdź najnowszy link z modułu bloga na profilu ---------------- */ function findLatestBlogURLFromProfile() { // Szukamy linków do pojedynczych postów w sekcji blog — zwykle /blog/ lub ?p= w href var blogModule = document.querySelector('.profile .blog, .blog'); if (!blogModule) return null; // bierzemy pierwszy link, który wygląda na link do konkretnego posta (nie do listy) var selectors = [ 'a[href*="/blog/"]', 'a[href*="blog?id="]', 'a[href*="&post="]' ]; for (var i=0; i<selectors.length; i++) { var link = blogModule.querySelector(selectors[i]); if (link && link.href) { return link.href; } } return null; } /* ---------------- Wstaw tytuł, treść i link do panelu ---------------- */ function renderPost({title, html, url}) { if (sel.meta) sel.meta.textContent = title; if (sel.content) sel.content.innerHTML = html || '<p>(Brak treści)'; if (sel.open && url) sel.open.href = url; // Obrazy responsywne w treści sel.content.querySelectorAll('img').forEach(function(img){ img.style.maxWidth = '100%'; img.style.height = 'auto'; img.loading = 'lazy'; }); // Linki w treści – nowa karta sel.content.querySelectorAll('a').forEach(function(a){ a.setAttribute('target','_blank'); a.setAttribute('rel','noopener'); }); } /* ---------------- Pobierz i pokaż ostatni wpis ---------------- */ async function loadLatestPost() { // 1) priorytet: ręcznie podany URL (jeśli ustawisz BLOG_URL_OVERRIDE) var url = BLOG_URL_OVERRIDE && BLOG_URL_OVERRIDE.trim() ? BLOG_URL_OVERRIDE.trim() : null; // 2) fallback: spróbuj znaleźć automatycznie pierwszy link z modułu bloga if (!url) url = findLatestBlogURLFromProfile(); // 3) jeśli nic nie znaleziono – tryb awaryjny if (!url) { if (sel.meta) sel.meta.textContent = 'Nie udało się odnaleźć ostatniego wpisu (brak linku na profilu).'; if (sel.content) sel.content.innerHTML = '<p>Upewnij się, że sekcja bloga na profilu pokazuje listę wpisów lub ustaw <code>BLOG_URL_OVERRIDE w kodzie.'; if (sel.open) sel.open.removeAttribute('href'); return; } // wpisz link do przycisku „Otwórz” if (sel.open) sel.open.href = url; try { var res = await fetch(url, { credentials: 'include' }); if (!res.ok) throw new Error('HTTP ' + res.status); var text = await res.text(); var parser = new DOMParser(); var doc = parser.parseFromString(text, 'text/html'); var data = extractFromDoc(doc); renderPost({ title: data.title, html: data.html, url: url }); // zaktualizuj meta (tytuł + skrót) if (sel.meta) sel.meta.textContent = data.title; } catch (e) { // Tryb awaryjny: pokaż tylko link if (sel.meta) sel.meta.textContent = 'Nie udało się pobrać treści wpisu (CORS/HTTP).'; if (sel.content) sel.content.innerHTML = '<p>Zobacz ostatni wpis tutaj: <a href="'+ url +'" target="_blank" >'+ url +''; } } // uruchom po załadowaniu DOM (bez czekania na obrazy) if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', loadLatestPost); } else { loadLatestPost(); } /* ---------------- Przycisk "Pokaż cały wpis" ---------------- */ function setupToggle() { if (!sel.toggle || !sel.panel) return; sel.toggle.addEventListener('click', function(){ sel.panel.classList.toggle('expanded'); sel.toggle.textContent = sel.panel.classList.contains('expanded') ? 'Zwiń' : 'Pokaż cały wpis'; }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', setupToggle); } else { setupToggle(); } })();

Music

Movies

Television

Books

Heroes

Jestem Rudy's Latest Blog Entries [View Blog]

The next night in the Tower (view more)

Jestem Rudy's Blurbs

About me:

Who I'd like to meet:

Jestem Rudy's Friends Comments

Displaying 2 of 2 comments ( View all | Add Comment )

dedfr

dedfr's profile picture

rudy sie nie dostał

Report Comment

jestem piwo

jestem piwo's profile picture

giga ziom

Report Comment