Comment by gear54rus
2 years ago
That's because it's not actually what's happening. I'm all for bashing bigcorps and especially ad empires but reddit folks confused correlation with causation here.
The code in question is part of a function that injects a video ad (that plays before the start) and the code itself is just a fallback in case it fails to load over 5 seconds so that video page doesn't break completely.
Why was this affected by user agent change? My best guess is that on some combinations they somehow decide not to show any ads at all (for now) and therefore this function is not called and some other code path is taken. This is consistent with my own experience with the recent anti-adblock bullshit they implemented. The banner was not being shown after user agent change implying it's one of the considered variables.
You can verify all this if you click 'format code' in browser debugger.
That makes sense and explains why it seemed so odd.
I don't use YouTube so the comment was more of a way to bring up the other behavior in business reviews. It seemed relevant.
Edit: reviews are also broken(for me) on Firefox desktop with no extensions enabled and with ublock enabled.
The code also returns 0 if the advert loads and 1 if it doesn't load. In other words, it detects adblockers.