-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitch.html
More file actions
210 lines (185 loc) · 5.17 KB
/
Copy pathtwitch.html
File metadata and controls
210 lines (185 loc) · 5.17 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: transparent !important;
overflow: hidden;
width: 1920px;
height: 1080px;
}
.widget {
position: fixed;
bottom: 40px;
left: 40px;
display: flex;
align-items: center;
gap: 18px;
background: rgba(8, 8, 8, 0.85);
border: 0.5px solid rgba(255,255,255,0.09);
border-radius: 14px;
padding: 16px 22px;
min-width: 360px;
max-width: 500px;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
opacity: 0;
transform: translateY(8px);
transition: opacity 0.6s ease, transform 0.6s ease;
overflow: hidden;
}
.widget.visible {
opacity: 1;
transform: translateY(0);
}
.widget::before {
content: '';
position: absolute;
left: 0; top: 0; bottom: 0;
width: 2px;
background: #dce8ff;
opacity: 0.45;
border-radius: 2px 0 0 2px;
}
#albumArt {
width: 64px;
height: 64px;
border-radius: 8px;
background: #111;
flex-shrink: 0;
overflow: hidden;
border: 0.5px solid rgba(255,255,255,0.08);
}
#albumArt img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.info {
flex: 1;
min-width: 0;
}
.status {
font-family: 'Poppins', sans-serif;
font-size: 10px;
color: rgba(255,255,255,0.28);
letter-spacing: 0.14em;
text-transform: uppercase;
margin-bottom: 6px;
display: flex;
align-items: center;
gap: 6px;
}
.dot {
width: 5px;
height: 5px;
border-radius: 50%;
background: #368b5d;
flex-shrink: 0;
animation: pulse 2s ease-in-out infinite;
}
.dot.idle {
animation: none;
opacity: 0.2;
}
.idleText {
color: rgba(255,255,255,0.55) !important;
}
@keyframes pulse {
0%, 100% { opacity: 0.75; }
50% { opacity: 0.15; }
}
#trackName {
font-family: 'Poppins', sans-serif;
font-size: 18px;
font-weight: 500;
color: rgba(255,255,255,0.93);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.25;
}
#trackArtist {
font-family: 'Poppins', sans-serif;
font-size: 13px;
font-weight: 300;
color: rgba(255,255,255,0.38);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 3px;
}
.divider {
width: 0.5px;
height: 36px;
background: rgba(255,255,255,0.1);
flex-shrink: 0;
}
.spotify-logo {
flex-shrink: 0;
opacity: 0.45;
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>
<body>
<div class="widget" id="widget">
<div id="albumArt"></div>
<div class="info">
<div class="status">
<div class="dot" id="dot"></div>
<span id="statusTxt">now playing</span>
</div>
<div id="trackName">—</div>
<div id="trackArtist">—</div>
</div>
<div class="spotify-logo">
<svg width="22" height="22" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="#ffffff" d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.516 17.32a.748.748 0 0 1-1.029.25c-2.817-1.722-6.362-2.112-10.54-1.157a.749.749 0 0 1-.333-1.461c4.571-1.044 8.492-.594 11.653 1.339a.748.748 0 0 1 .249 1.029zm1.472-3.27a.936.936 0 0 1-1.287.308c-3.225-1.982-8.141-2.557-11.956-1.399a.936.936 0 1 1-.543-1.79c4.358-1.322 9.776-.682 13.478 1.594a.937.937 0 0 1 .308 1.287zm.127-3.404C15.37 8.453 9.386 8.25 5.852 9.337a1.123 1.123 0 1 1-.652-2.148c4.099-1.245 10.913-1.004 15.213 1.57a1.124 1.124 0 0 1-1.298 1.838v-.001z"/>
</svg>
</div>
</div>
<script>
async function poll() {
try {
const res = await fetch('twitch-data.php');
const data = await res.json();
const playing = data.playing === true;
const trackNameEl = document.getElementById('trackName');
const trackArtistEl = document.getElementById('trackArtist');
const statusTxtEl = document.getElementById('statusTxt');
const dotEl = document.getElementById('dot');
const albumArtEl = document.getElementById('albumArt');
if (!playing) {
trackNameEl.textContent = 'not playing';
trackArtistEl.textContent = '';
statusTxtEl.textContent = 'not playing';
dotEl.className = 'dot idle';
trackNameEl.classList.add('idleText');
trackArtistEl.classList.add('idleText');
albumArtEl.innerHTML = '';
document.getElementById('widget').classList.add('visible');
return;
}
trackNameEl.classList.remove('idleText');
trackArtistEl.classList.remove('idleText');
trackNameEl.textContent = data.trackName || '—';
trackArtistEl.textContent = data.artist || '—';
statusTxtEl.textContent = data.status || 'now playing';
dotEl.className = 'dot';
const img = data.image || '';
albumArtEl.innerHTML = img ? '<img src="' + img + '" />' : '';
document.getElementById('widget').classList.add('visible');
} catch (e) {}
}
poll();
setInterval(poll, 5000);
</script>
</body>
</html>