Fix accumulation of ad <style> tags

This commit is contained in:
infinite-persistence 2022-05-23 20:06:25 +08:00
parent 8303856a06
commit c66f597f09
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -99,6 +99,16 @@ function Ads(props: Props) {
delete window.__VIDCRUNCH_CONFIG_618bb4d28aac298191eec411__;
delete window.__player_618bb4d28aac298191eec411__;
const styles = document.querySelectorAll('body > style');
styles.forEach((s) => {
// We are asking Adnimation to supply us with a specific ID or
// pattern so that our query wouldn't break when they change their
// script. For now, this is the "best effort".
if (s.innerText && s.innerText.startsWith('#outbrain')) {
s.remove();
}
});
// clean DOM elements from ad related elements
removeIfExists('[src^="https://player.avplayer.com"]');
removeIfExists('[src^="https://gum.criteo.com"]');