I am trying to create a userscript to unpause the video when I change the tab to listen to music etc because, whenever I change the tab the video pauses itself on m.youtube.com (mobile version of youtube)
I have tried to look around the web to find any possible solutions like turning off browser flags but none of it seems to work.
document.addEventListener("visibilitychange", event => {
if (document.visibilityState == "visible") {
console.log("tab is active")
} else {
var ytplayer = document.getElementById("movie_player"); // get youtube player
ytplayer.playVideo(); // play it when tab inactive
}
})
Userscript extension: Tampermonkey
Browser: Brave
Site: https://m.youtube.com (Click here to access mobile YouTube on desktop)