[Android] Ads on YT #10241
Labels
bug
OS/Android
Fixes related to Android browser functionality
QA Pass - Android ARM
QA Pass - Android Tab
QA/Yes
release-notes/include
Milestone
Description
There are ads on YT sometimes, we need to inject that script to prevent them
(function() { const prunePaths = ['playerResponse.adPlacements', 'playerResponse.playerAds', 'adPlacements', 'playerAds']; const findOwner = function(root, path) { let owner = root; let chain = path; for (;;) { if ( owner instanceof Object === false ) { return; } const pos = chain.indexOf('.'); if ( pos === -1 ) { return owner.hasOwnProperty(chain)? [ owner, chain ]: undefined; } const prop = chain.slice(0, pos); if ( owner.hasOwnProperty(prop) === false ) { return; } owner = owner[prop]; chain = chain.slice(pos + 1); } }; JSON.parse = new Proxy(JSON.parse, { apply: function() { const r = Reflect.apply(...arguments); for ( const path of prunePaths ) { const details = findOwner(r, path); if ( details !== undefined ) { delete details[0][details[1]]; } } return r; }, }); })();
We need to do it in that place
https://github.com/brave/brave-core/blob/master/browser/android/preferences/background_video_playback_tab_helper.cc
Steps to reproduce
Unfortunately I haven't found any video with ads before the fix. Maybe @antonok-edm has ideas on how to verify it properly.
Background video playback functionality should be also checked as there were modifications in that place.
Actual result
Users complain about ads on YouTube
Expected result
No ads on YouTube
Issue reproduces how often
No steps to reproduce
Issue happens on
Device details
Brave version
Website problems only
Additional information
The text was updated successfully, but these errors were encountered: