Merge branch 'master' of https://github.com/OdyseeTeam/odysee-frontend
This commit is contained in:
commit
bb9afff2d4
1 changed files with 16 additions and 12 deletions
|
@ -49,6 +49,20 @@ function removeIfExists(querySelector) {
|
|||
if (element) element.remove();
|
||||
}
|
||||
|
||||
function clearAdElements() {
|
||||
// clear aniview state to allow ad reload
|
||||
delete window.aniplayerPos;
|
||||
delete window.storageAni;
|
||||
delete window.__VIDCRUNCH_CONFIG_618bb4d28aac298191eec411__;
|
||||
delete window.__player_618bb4d28aac298191eec411__;
|
||||
|
||||
// clean DOM elements from ad related elements
|
||||
removeIfExists('[src^="https://cdn.vidcrunch.com/618bb4d28aac298191eec411.js"]');
|
||||
removeIfExists('[src^="https://player.aniview.com/script/6.1/aniview.js"]');
|
||||
removeIfExists('[id^="AVLoaderaniplayer_vidcrunch"]');
|
||||
removeIfExists('#av_css_id');
|
||||
}
|
||||
|
||||
function Ads(props: Props) {
|
||||
const {
|
||||
location: { pathname },
|
||||
|
@ -71,6 +85,7 @@ function Ads(props: Props) {
|
|||
if (shouldShowAds) {
|
||||
let script;
|
||||
try {
|
||||
clearAdElements();
|
||||
script = document.createElement('script');
|
||||
script.src = adConfig.url;
|
||||
// $FlowFixMe
|
||||
|
@ -79,18 +94,7 @@ function Ads(props: Props) {
|
|||
return () => {
|
||||
// $FlowFixMe
|
||||
document.head.removeChild(script);
|
||||
|
||||
// clear aniview state to allow ad reload
|
||||
delete window.aniplayerPos;
|
||||
delete window.storageAni;
|
||||
delete window.__VIDCRUNCH_CONFIG_618bb4d28aac298191eec411__;
|
||||
delete window.__player_618bb4d28aac298191eec411__;
|
||||
|
||||
// clean DOM elements from ad related elements
|
||||
removeIfExists('[src^="https://cdn.vidcrunch.com/618bb4d28aac298191eec411.js"]');
|
||||
removeIfExists('[src^="https://player.aniview.com/script/6.1/aniview.js"]');
|
||||
removeIfExists('[id^="AVLoaderaniplayer_vidcrunch"]');
|
||||
removeIfExists('#av_css_id');
|
||||
clearAdElements();
|
||||
};
|
||||
} catch (e) {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue