raingart / Nova-YouTube-extension

Apache License 2.0
218 stars 11 forks source link

Problem with "Autopause if tab loses focus" #100

Closed zkisaboss closed 1 year ago

zkisaboss commented 1 year ago

1.43.4 | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36

Autopause only works when switching between fullscreen windows. YouTube video doesn't pause when switching between applications or tabs in the same window.

zkisaboss commented 1 year ago

Also, I wanted to thank you for building such a fantastic script/extension. I respect your programming skills 🤜

raingart commented 1 year ago

try replacing this line:

if (document.visibilityState == 'hidden' && 'PLAYING' == NOVA.getPlayerState()) {

on

if ('PLAYING' == NOVA.getPlayerState()) {

Probably the reason is that document.visibilityState update afterwindow.blur event

raingart commented 1 year ago

i replaced the line in this version https://openuserjs.org/scripts/raingart/Nova_YouTube

zkisaboss commented 1 year ago

I'm actually using the extension since it has better latency. I'll test the Userscript w/ that change and if it works I'll stick with that until the extension gets an update.

zkisaboss commented 1 year ago

The fix works, but minor bug when switching quickly between tabs with 'autoplay on focus' enabled. Likely timing issue with code execution.