function autoLockPlaylist() { const playlistLength = document.querySelector('#pllength'); const config = { characterData: true, childList: true, subtree: true, }; const observer = new MutationObserver(([mutation], obs) => { const newText = mutation.target.textContent || mutation.target.nodeValue; let totalSeconds = 0; if (typeof newText === 'string') { const trim = newText.trim(); // テキストが 00:00 または 00:00:00 の形式であることを確認 if (/^\d{2}:\d{2}$/.test(trim)) { const [minutes, seconds] = trim.split(':').map(Number); totalSeconds = minutes * 60 + seconds; } else if (/^\d{2}:\d{2}:\d{2}$/.test(trim)) { const [hours, minutes, seconds] = trim.split(':').map(Number); totalSeconds = hours * 3600 + minutes * 60 + seconds; } // 90分以上かをチェック (5400秒) if (totalSeconds >= 5400) { const lockBtnElm = document.querySelector('#qlockbtn'); const unlockIconElm = lockBtnElm?.querySelector('.glyphicon-ok'); if (lockBtnElm && unlockIconElm) { lockBtnElm?.click(); } } } }); if (playlistLength) { observer.observe(playlistLength, config); } } autoLockPlaylist();