MediaWiki:Strona główna.js: Różnice pomiędzy wersjami

Z Mammonopedia
Przejdź do nawigacji Przejdź do wyszukiwania
m UWAGA! Zastąpienie treści hasła bardzo krótkim tekstem: „console.log("Halo");”
Znacznik: Zastąpiono
mNie podano opisu zmian
Linia 1: Linia 1:
console.log("Halo");
fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCRiibFs5HGRW5EbAFwf5irA")
  .then(response => response.text())
  .then(xmlText => {
    const parser = new DOMParser();
    const xmlDoc = parser.parseFromString(xmlText, "application/xml");
 
    const entry = xmlDoc.querySelector("entry");
    if (!entry) {
      console.warn("Nie znaleziono wpisu w feedzie.");
      return;
    }
 
    const videoIdElem = entry.getElementsByTagName("yt:videoId")[0];
    if (!videoIdElem) {
      console.warn("Nie znaleziono videoId.");
      return;
    }
 
    const videoId = videoIdElem.textContent;
    const iframe = document.createElement("iframe");
    iframe.width = "560";
    iframe.height = "315";
    iframe.src = `https://www.youtube.com/embed/${videoId}`;
    iframe.frameBorder = "0";
    iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
    iframe.allowFullscreen = true;
 
    const container = document.getElementById("yt-latest-video");
    if (container) {
      container.innerHTML = ""; // czyść, jeśli już coś tam było
      container.appendChild(iframe);
    } else {
      console.warn("Nie znaleziono elementu #yt-latest-video na stronie.");
    }
  })
  .catch(error => {
    console.error("Błąd podczas ładowania feedu YouTube:", error);
  });

Wersja z 20:26, 29 lip 2025

fetch("https://www.youtube.com/feeds/videos.xml?channel_id=UCRiibFs5HGRW5EbAFwf5irA")
  .then(response => response.text())
  .then(xmlText => {
    const parser = new DOMParser();
    const xmlDoc = parser.parseFromString(xmlText, "application/xml");

    const entry = xmlDoc.querySelector("entry");
    if (!entry) {
      console.warn("Nie znaleziono wpisu w feedzie.");
      return;
    }

    const videoIdElem = entry.getElementsByTagName("yt:videoId")[0];
    if (!videoIdElem) {
      console.warn("Nie znaleziono videoId.");
      return;
    }

    const videoId = videoIdElem.textContent;
    const iframe = document.createElement("iframe");
    iframe.width = "560";
    iframe.height = "315";
    iframe.src = `https://www.youtube.com/embed/${videoId}`;
    iframe.frameBorder = "0";
    iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
    iframe.allowFullscreen = true;

    const container = document.getElementById("yt-latest-video");
    if (container) {
      container.innerHTML = ""; // czyść, jeśli już coś tam było
      container.appendChild(iframe);
    } else {
      console.warn("Nie znaleziono elementu #yt-latest-video na stronie.");
    }
  })
  .catch(error => {
    console.error("Błąd podczas ładowania feedu YouTube:", error);
  });