raingart / Nova-YouTube-extension

Apache License 2.0
199 stars 9 forks source link

[Bug] Audio playing when on home page #135

Closed misspent closed 6 months ago

misspent commented 6 months ago

Issue: Audio plays in the background of the home page every now and then, almost like it's automatically playing an advertisement. I've got a theme that removes them, and I have an ad blocker; however, I can't find out exactly why it's happening. I disabled this script, and it stopped happening. This script is a necessity for me at this point, so I will try to find out what specifically is causing it, and I'll block it with the uBlock Origin filter if you can't do anything. I just thought I'd let you know, and I'm curious if it's just my issue.

Fix that may work: block or auto-pause anything that's playing on the home page?

I'm happy to help in any way possible and will sure give more feedback the more I look into it.


I've disabled and tested on multiple browsers

misspent commented 6 months ago

It seems to happen when I load YouTube in a new tab or window, which is very strange and isn't consistent either; sometimes it'll do it and sometimes it won't. I've disabled and enabled the ones you've specified (some of them I didn't have enabled in the first place), and I'm still having the issue. I'm going to attempt to find whatever is playing, Thank you for getting back to me fast.

raingart commented 6 months ago

Each plugin contains an indication of the pages in which they can be injected. https://github.com/raingart/Nova-YouTube-extension/blob/master/plugins/plugin_example.js#L16

That is, if you loaded the home page for the first time. Other plugins simply won't start Note, if you navigate from other pages using lazyload, then already running plugins may lag behind and work.

I will now create a list of all plugins that have access to the home page

misspent commented 6 months ago

I've disabled other TamperMonkey scripts I had enabled and disabled any extension I have installed that may affect YouTube, which was only 1 (uBlock Origin), and it still happens.

I love how you've optimized it, and it's scary how much something like that is needed for a YouTube script given how everything is loaded.

misspent commented 6 months ago

Strange as I've not got any of them enabled, I'll disable all of them and work through them, but first I'll disable the extension for a while and see if I can get it to do it again (I've already done this, but why not do it again). I'll keep you posted.

Features I have enabled (names):

Image of what I have enabled: What I have enabled

I've got no intentions of moving to a Chrome browser whatsoever, as v2 > v3 imo.

misspent commented 6 months ago

I've figured out what is causing it. It's the `Volume" feature. I have everything else enabled but that, and it stopped happening. I'm not sure why it stopped it, but I hope that helps.

raingart commented 6 months ago

I just can't understand why the bug appears. You can test the new version. Don't forget to turn off the main one

The plugin states that it should not be launched on the homepage run_on_pages: 'watch, embed, -mobile',

I created a stripped down version. All other plugins are cut https://gist.github.com/raingart/d0b67cc51da0aed9e05b6e59f37ae197

and added 3 new options. They disable the function blocks

Screenshot from 2023-12-26 21-45-14

misspent commented 6 months ago

Removing everything but volume seems to have fixed it (your test version worked). This is all so strange, and I'm completely clueless. I'll more than likely add a new function for volume to your script or just straight up use another script just for volume. This script works flawlessly with your script when I have the volume feature in your script off. I might attempt to merge this code with yours so I can have an AIO.

Thanks for all the effort, and stay dedicated to this script as it's the new and improved "Enhancer for YouTube" for us Firefox users hehe.

raingart commented 6 months ago

You can try to remove more such functions. Original ver this.saveInSession(newLevel);

NOVA.triggerHUD(Math.round(this.volume * 100) + '%');

and if all else fails then playerVolume.set(+user_settings.volume_default);

if none of them help, but I have no ideas

misspent commented 6 months ago

You're correct, and honestly, I don't mind using something else just for one little feature; everything else your script offers is perfect for me and required at this point, so no harm, no foul.

The volume-only one (https://gist.github.com/raingart/00be2f6ef48382718054f983d732fc19) works flawlessly.

I'll test the one you just posted very soon; I'm just going to go make a hot one, and I'll be back.

misspent commented 6 months ago

Removing the top two you mentioned worked for me; I'm no longer having the issue, and it still sets the audio to the value of my choosing in settings.

Ones that fixed it: this.saveInSession(newLevel); & NOVA.triggerHUD(Math.round(this.volume * 100) + '%');

Those will, for sure, be handy. I love having stuff like that on hand and enjoy looking into them, using them, or messing with them. Thank you for all the help (+ recommendations) and fixing the bizarre issue I was having. You're a champ.

raingart commented 6 months ago

I hope this is the final fix

https://gist.github.com/raingart/74392fbf16a3a69d5e9944ce0b54b91f

triggerHUD is only activated on the watch page saveInSession is updated only if 'Not keep muted state' is enabled. To reset the mute state

misspent commented 6 months ago

That final fix worked; everything is as smooth as butter now, thank you.

raingart commented 6 months ago

Thank you @misspent too for your patience and persistence