Duncan Tourolle 4d2f7df217
Some checks failed
Build Plugin / build (push) Successful in 49s
Release Plugin / build-and-release (push) Failing after 39s
new build system
inject controls in homepage
2026-06-13 23:35:46 +02:00

50 lines
1.5 KiB
JavaScript

(function () {
function getAuthToken() {
try {
var creds = JSON.parse(localStorage.getItem('jellyfin_credentials'));
var server = creds && creds.Servers && creds.Servers[0];
return (server && server.AccessToken) || null;
} catch (e) {
return null;
}
}
function addButton() {
if (document.getElementById('jellylms-remote-btn')) {
return;
}
var btn = document.createElement('a');
btn.id = 'jellylms-remote-btn';
btn.href = '/JellyLms/RemoteControl';
btn.title = 'Multi-room Remote';
btn.textContent = '🔊';
btn.style.cssText = 'position:fixed;bottom:20px;right:20px;width:48px;height:48px;' +
'border-radius:50%;background:#00a4dc;color:#fff;display:flex;' +
'align-items:center;justify-content:center;font-size:22px;' +
'text-decoration:none;z-index:99999;box-shadow:0 2px 8px rgba(0,0,0,0.5);';
document.body.appendChild(btn);
}
function init() {
var token = getAuthToken();
if (!token) {
return;
}
fetch('/JellyLms/RemoteControl/Access', { headers: { 'X-Emby-Token': token } })
.then(function (resp) {
if (resp.ok) {
addButton();
}
})
.catch(function () {});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();