pixeltris / TwitchAdSolutions

7.75k stars 446 forks source link

[Doc] Eventually update the documentation to reflect the state of a userscript #197

Closed Harest closed 7 months ago

Harest commented 11 months ago

Hello,

Just a little message regarding the documentation (full-list.md) stating userscripts being not up-to-date and probably not working anymore:

Web browser scripts (uBlock Origin / userscript) These haven't been updated in a while and probably don't work.

My script has been working since the beginning, even during the long period where i didn't updated it (as i didn't have ads for a while so my script didn't trigger, except in new private tabs i used to check if it was still working). Since it's not a script blocking completely the ads (just muting, and hiding if wanted), it wasn't targeted and they didn't change the way i have been hooking my ads detection.

On a side note, i updated it recently as i started to have ads again and saw they added more often the smaller video player top right, so i decided to add a little function to activate the sound of it during an ad. I wanted to add a function to manage PiP to stop one if the user wants to hide the ads but sadly Firefox doesn't support it yet, it'll in December, so i'll see at that time to add this improvement.

pixeltris commented 11 months ago

Sorry about that. Its been a while since I looked through the solutions / checked the state of things. I'll update that when I get the chance.

pixeltris commented 7 months ago

I couldn't get the script working for me when I tried it today but I've removed that note in https://github.com/pixeltris/TwitchAdSolutions/commit/7a8fa9923ca0fac8ed293d396898eea5124c616a

Harest commented 7 months ago

It's still working on my side and nobody reported me any issue (but we all know most don't bother doing so).
If you've time, feel free to tell me what you eventually had in your console log as error, or what behavior it had to make it not working (and the browser used, i'm only testing under Firefox, and tested a bit with Edge for the PiP part).

Anyway, thanks for the update.

pixeltris commented 7 months ago

Ah it did actually work. I didn't realize it polls at 500ms. I must have seen the ad / heard the audio and instantly closed the tab.

There was a PR here a while ago which used a MutationObserver instead of polling which might be an idea for quickly muting/hiding the ads without having to poll faster #16

Harest commented 7 months ago

Ah ok ok. I'm indeed aware of the existence of MutationObserver, but i didn't test it a lot yet. I might give it a try and adapt the script accordingly, depending on how it goes.

Edit: Working with a MutationObserver for ads detection requires a complete rework of the script, as polling is used everywhere in the whole logic. I think if i do it at some point, it'll still require a bit of polling (eg. if the current page doesn't have the ad div, during the loading for instance, or clicking on the avatar, redrawing some DOM elements, including the "Ads Options" button the script adds), combined with popState event, and then the mutation observer.

syndenbock commented 7 months ago

I highly recommend using MutationObservers, they are much more performant as they don't rely on polling and you can "listen" to very specific changes inside the DOM tree,