Closed 1nikolas closed 4 years ago
So about a month ago the uBO team added these filters to the uBlock Filters
list (which is active by default):
!#if env_firefox
youtube.com##+js(json-prune, [].playerResponse.adPlacements [].playerResponse.playerAds playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)
!#endif
!#if !env_firefox
youtube.com##+js(json-prune, playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)
!#endif
It removes important metadata (inside a script tag, not loaded separately) and effectively disables ads entirely for the duration of the page's lifecycle, so even if &disableadblock is added later, no ads will play. Which defeats the purpose of the extension.
I've been testing a variety of different fixes over the past week like intercepting the metadata and re-adding it later, delaying the execution of YouTube scripts (intercepting the script in question and eval'ing it so that uBlock can't modify it), intercepting pushStates/replaceStates, etc. Nothing was quite working so as a temporary workaround I decided to add &disableadblock to the first page load, regardless of whether the content should be whitelisted or not. Force skipping ads that shouldn't be playing.
Despite the fact that this behavior is intentional I am still marking it as a bug and will push some improvements hopefully tomorrow. I still need to find a real fix that doesn't involve asking users to disable uBlock Filters
. I've am working on adding some built-in adblocking to get rid of ads that should not be displaying.
A solution I just thought of is to add disableadblock=1 to all the links on youtube (recommended videos, videos on yt homepage, subscription feed, etc) so when you click a link, it will already have the disableadblock=1 and adblock will be disabled before page is loaded. But then, when you load a link from outside youtube, it won't work..
and effectively disables ads entirely for the duration of the page's lifecycle
Wait, does that mean that clicking a link inside Youtube (which doesn't reload the page) count as the same page (and has the same lifecycle)?
Wait, does that mean that clicking a link inside Youtube (which doesn't reload the page) count as the same page (and has the same lifecycle)?
Yup. So if ads were disabled from the start they will never show/play even on whitelisted channels.
The solution right now is to reload the page if it didn't include an &disableadblock, and then changing it back if it's not meant to be whitelisted, + some built in adblocking to remove ads that came through. It might end up being a permanent solution if I can't find a more elegant solution.
What about adding an "exception rule" to "My filters":
!#if env_firefox
@@youtube.com##+js(json-prune, [].playerResponse.adPlacements [].playerResponse.playerAds playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)
!#endif
!#if !env_firefox
@@youtube.com##+js(json-prune, playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)
!#endif
Would this work?
Probably. My only concern with that is that it requires a bit more work on the user-side so it might be considered a flaw that we can't deal with this within the extension itself.
I've added some built-in adblocking with https://github.com/x0a/uBO-YouTube/commit/5bc03345810488cb2d21ed25180551c7017a6b4d and https://github.com/x0a/uBO-YouTube/commit/b81432c0b1df5437690b4c49dc8037ea332b21f7 and also added some changes to remove disableadblock=1
shortly after page load if the page does not require it.
I am keeping this bug open, feel free to report back any new bugs/unexpected behavior as a result of this change
Don't you already have to add a custom filter when you install the extension?
@ajayyy That's a good point.
I've added your filter suggestions to the README in https://github.com/x0a/uBO-YouTube/commit/604cb1986f11284b151cb632bafb22a294ddb8af and am working on getting them added to the Chrome WebStore/FF Addons store
Same issue is happening on Chrome 84.0.4147.125.
Thanks!
Hey everyone,
I've decided that as a fix to the json-prune snippet (which works by intercepting calls to JSON.parse), I'd just restore the original JSON.parse using an iframe. This works well enough that we don't need to needlessly add &disableadblock=1 to every page. These changes should be available pretty soon in v0.11.4.
Keep in mind that this is probably not a long-term fix as it's part of an advertiser/adblocker arms race.
I will be re-implementing the json-prune snippet in this extension since it's kind of genius, but will make it dependent on whether or not the channel is whitelisted or whether the advertiser is blacklisted, etc.
For some reason the extention adds
disableadblock=1
to the YouTube homepage so adblock is being disabled there. Here is what the url looks likehttps://www.youtube.com/?igno=re&disableadblock=1
. I don't know if theigno=re
argument is added by an addon or by YouTube itself but YouTube homepage should be excluded from thedisableadblock=1
.EDIT: I don't want to open another issue so here is another problem: loading a video to a new tab causes the extension to add
disableadblock=1
for a split second and then remove it, thus YouTube loads the ads (while adblock is disabled) on non-whitelisted channelsNOTE: I use Firefox Beta (80.0b3), don't know if that matters