visibilitychange
let hidden,visibilitychange; if(typeof document.hidden !== "undefined"){ hidden = "hidden"; visibilitychange = "visibilitychange" }else if(typeof document.webkitHidden !== "undefined"){ hidden = "webkitHidden"; visibilitychange = "webkitvisibilitychange" }else if(typeof document.msHidden !== "undefined"){ hidden = "msHidden"; visibilitychange = "msvisiblitychange" } document.addEventListener(visibilitychange, ()=> { if(document['hidden']){ game.stop() } }) const originalData = [...answerData] originalData.forEach((item)=>{ if(item.type === 'markdown'){ item.content = item.content[0] } })