Advertisement
arie_cristianD

hide ads wrapper if unfilled

Apr 24th, 2025 (edited)
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.     function hideUnfilledAds() {
  3.       const $ads =  $(document).find('ins.adsbygoogle');
  4.  
  5.       $ads.each(function () {
  6.         const $ad = $(this);
  7.         const status = $ad.attr('data-ad-status');
  8.  
  9.         if (status !== 'filled') {
  10.           const $wrapper = $ad.closest('.ads-wrapper');
  11.           if ($wrapper.length) {
  12.             $wrapper.hide();
  13.           }
  14.         }
  15.       });
  16.     }
  17.  
  18.     $(function () {
  19.       setTimeout(() => hideUnfilledAds(), 3000);
  20.     });
  21.  
  22.     $(document).on('jnews-ajax-load', function (e, context) {
  23.       setTimeout(() => hideUnfilledAds(), 3000);
  24.     });
  25.   })(jQuery);
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement