-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspo.js
More file actions
43 lines (36 loc) · 1.51 KB
/
spo.js
File metadata and controls
43 lines (36 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function getCurrentTrackInfo() {
const titleElement = document.querySelector('[data-testid="context-item-info-title"] a')
const artistElement = document.querySelector('[data-testid="context-item-info-subtitles"] a');
if (titleElement && artistElement) {
const title = titleElement.textContent;
const artist = artistElement.textContent;
chrome.runtime.sendMessage({
type: 'TRACK_INFO',
title: title,
artist: artist
});
return true;
} else {
console.log('[SyncManager]: 제목 또는 아티스트 요소를 찾을 수 없습니다.');
return false;
}
}
function getCurrentPlaybackTime() {
const timeElement = document.querySelector("#main > div > div.ZQftYELq0aOsg6tPbVbV > div.JG5J9NWJkaUO9fiKECMA > footer > div > div.sVv2OQORCQ4kf6iKfUTF > div > div.pn5V0OzovI9p6b8nWq8p.gglUjikTBtMzCZFgSmpS > div.encore-text.encore-text-marginal.encore-internal-color-text-subdued.IPbBrI6yF4zhaizFmrg6");
if (timeElement) {
const currentTime = timeElement.innerText.split(" / ")[0].trim();
// console.log(`Current time: ${currentTime}`);
chrome.runtime.sendMessage({
type: 'PLAYBACK_TIME',
currentTime: currentTime
});
} else {
console.log('[SyncManager]: 재생 시각 요소를 찾을 수 없습니다.');
}
}
setInterval(() => {
getCurrentTrackInfo();
}, 500);
setInterval(() => {
getCurrentPlaybackTime();
}, 100); // 1초 간격으로 업데이트