Advertisement
arie_cristianD

hide ads wrapper if unfilled

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