The read-only isActive property of the UserActivation interface indicates whether the current window has transient user activation.
A boolean.
Use the isActive property to check whether the user is currently interacting with the page.
if (navigator.userActivation.isActive) {
// proceed to request playing media, for example
}