// Aktiviert den bestehenden Tab mit Ziel-URL (ohne Reload). Falls nicht offen, wird er geƶffnet. function activateOrCreate(url) { chrome.tabs.query({}, tabs => { const t = tabs.find(tt => tt.url && tt.url.startsWith(url)); if (t) { chrome.tabs.update(t.id, {active: true}); } else { chrome.tabs.create({url}); } }); } chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => { if (msg && msg.cmd === 'toggle') { if (msg.from === 'volumio') activateOrCreate('http://localhost:8088/'); else activateOrCreate('http://localhost:3000/'); sendResponse({ok:true}); } });