Handle case where ad-cleanup fails (redo)
The solution didn't work 100%, only reduces the chances of happening significantly. So far, still can happen on hot-reload during development.
- Reverted 15bd26399f
.
- Fix by just hiding the unoccupied aniBox
This commit is contained in:
parent
2dd0fc283d
commit
ea8af5aa89
2 changed files with 16 additions and 16 deletions
|
@ -66,6 +66,10 @@
|
||||||
transition: unset !important;
|
transition: unset !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#aniBox[style*='height: 1px'] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#aniBox,
|
#aniBox,
|
||||||
#av-container {
|
#av-container {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
|
|
|
@ -50,20 +50,6 @@ function removeIfExists(querySelector) {
|
||||||
if (element) element.remove();
|
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) {
|
function Ads(props: Props) {
|
||||||
const { type = 'video', tileLayout, small, userHasPremiumPlus, className } = props;
|
const { type = 'video', tileLayout, small, userHasPremiumPlus, className } = props;
|
||||||
|
|
||||||
|
@ -79,7 +65,6 @@ function Ads(props: Props) {
|
||||||
if (shouldShowAds) {
|
if (shouldShowAds) {
|
||||||
let script;
|
let script;
|
||||||
try {
|
try {
|
||||||
clearAdElements();
|
|
||||||
script = document.createElement('script');
|
script = document.createElement('script');
|
||||||
script.src = adConfig.url;
|
script.src = adConfig.url;
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -88,7 +73,18 @@ function Ads(props: Props) {
|
||||||
return () => {
|
return () => {
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
document.head.removeChild(script);
|
document.head.removeChild(script);
|
||||||
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');
|
||||||
};
|
};
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue