From a661bf2d0f00603edcbda71205ef9ccbcdec22e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hosa?= Date: Sat, 19 Sep 2026 22:01:21 +0000 Subject: [PATCH] Odstranit content.js --- content.js | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 content.js diff --git a/content.js b/content.js deleted file mode 100644 index 5475b3f..0000000 --- a/content.js +++ /dev/null @@ -1,45 +0,0 @@ -const TARGET_URL = "http://localhost:8080/endpoint"; -let lastSentSong = ""; - -function extractAndSendSong() { - // Najdeme widget "Now Playing" v levém dolním rohu Spotify - const trackInfo = document.querySelector('[data-testid="now-playing-widget"]'); - - if (trackInfo) { - const links = trackInfo.querySelectorAll('a'); - const songTitle = links[0] ? links[0].innerText : null; - const artistName = links[1] ? links[1].innerText : "Unknown Artist"; - - if (songTitle) { - const currentTrackString = `${artistName} - ${songTitle}`; - - // Odesíláme pouze pokud se písnička změnila, abychom zbytečně nezatěžovali server - if (currentTrackString !== lastSentSong) { - lastSentSong = currentTrackString; - - console.log("Odesílám skladbu:", currentTrackString); - - fetch(TARGET_URL, { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - artist: artistName, - title: songTitle, - timestamp: new Date().toISOString() - }) - }).catch(err => { - console.error("Chyba při odesílání:", err); - }); - } - } - } -} - -// Sledujeme změny na stránce, protože Spotify funguje jako Single Page Application -const observer = new MutationObserver(() => { - extractAndSendSong(); -}); - -observer.observe(document.body, { childList: true, subtree: true }); \ No newline at end of file