Compare commits
6 Commits
sweb
...
spotify-se
| Author | SHA1 | Date | |
|---|---|---|---|
| 723c8af2ba | |||
| 2e567e638b | |||
| 9e2cc10160 | |||
| de82ebd56f | |||
| 876a537354 | |||
| 3dcec7d43f |
62
content.js
Normal file
62
content.js
Normal file
@@ -0,0 +1,62 @@
|
||||
const TARGET_URL = "http://localhost:8080/endpoint";
|
||||
let lastSentSignature = "";
|
||||
|
||||
function extractAndSendSong() {
|
||||
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";
|
||||
|
||||
// Získání obrázku alba
|
||||
const imgElement = trackInfo.querySelector('img');
|
||||
const albumCoverUrl = imgElement ? imgElement.src : null;
|
||||
|
||||
// Získání času
|
||||
const currentTimeEl = document.querySelector('[data-testid="playback-position"]');
|
||||
const durationEl = document.querySelector('[data-testid="playback-duration"]');
|
||||
|
||||
const currentTime = currentTimeEl ? currentTimeEl.innerText : "0:00";
|
||||
const duration = durationEl ? durationEl.innerText : "0:00";
|
||||
|
||||
const progressFull = `${currentTime}/${duration}`;
|
||||
|
||||
// Spolehlivější detekce reklamy:
|
||||
// Reklamy na Spotify trvají vždy přesně 30 vteřin (0:30) nebo nemají běžné odkazy na skladbu
|
||||
const isAd = (duration === "0:30") || (links.length < 2) || (songTitle === null);
|
||||
|
||||
const finalTitle = isAd ? "Reklama" : songTitle;
|
||||
const finalArtist = isAd ? "Spotify" : artistName;
|
||||
|
||||
if (finalTitle || isAd) {
|
||||
const currentSignature = `${finalArtist}-${finalTitle}-${currentTime}-${isAd}`;
|
||||
|
||||
if (currentSignature !== lastSentSignature) {
|
||||
lastSentSignature = currentSignature;
|
||||
|
||||
console.log("Odesílám data:", finalArtist, "-", finalTitle, `[${progressFull}]`, "Reklama:", isAd);
|
||||
|
||||
fetch(TARGET_URL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
artist: finalArtist,
|
||||
title: finalTitle,
|
||||
coverImg: albumCoverUrl,
|
||||
progressTime: progressFull,
|
||||
ad: isAd ? "true" : "false",
|
||||
timestamp: new Date().toISOString()
|
||||
})
|
||||
}).catch(err => {
|
||||
console.error("Chyba při odesílání:", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Kontrola každou vteřinu
|
||||
setInterval(extractAndSendSong, 1000);
|
||||
20
manifest.json
Normal file
20
manifest.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Spotify IP Sender",
|
||||
"version": "1.0",
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"storage"
|
||||
],
|
||||
"host_permissions": [
|
||||
"https://open.spotify.com/*",
|
||||
"http://*/*",
|
||||
"https://*/*"
|
||||
],
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://open.spotify.com/*"],
|
||||
"js": ["content.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
17
proces.txt
17
proces.txt
@@ -1,17 +0,0 @@
|
||||
T:
|
||||
19.9
|
||||
zacal jsem tim ze jsem vyjmul kartu z toho RP a zalohoval ji do .img souboru. flashnuljsem novy lehky konzolovy OS do toho RP.
|
||||
|
||||
snazim jse najit spusob jak ziskat nazev songy ktera prave hraje ve spotify ve prohlizeci na laptopu ktery bude na jarmarku a na nem se bude poustet hudba.
|
||||
a jeste jse snazim vymyslet jak to udelat aby ten laptop potom poslal ten nazev ty songy na hlavni server.
|
||||
|
||||
zjistovani songy ktera prave hraje asi udelame cez nejaky kod a ne cez chrome extention
|
||||
|
||||
|
||||
|
||||
O:
|
||||
|
||||
|
||||
|
||||
|
||||
M:
|
||||
BIN
spotify-sender.zip
Normal file
BIN
spotify-sender.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user