Commit 4b1afce2 authored by João Ventura's avatar João Ventura Committed by João Ventura
Browse files

Issue #3268059 by jcnventura: Remove jQuery from js/unblock.js

parent 28a86153
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@ adsense.unblock:
    js/unblock.js: {}
  dependencies:
    - core/drupal
    - core/jquery

adsense.adsbygoogle:
  version: 1.x
+10 −9
Original line number Diff line number Diff line
(function ($, Drupal, drupalSettings) {
(function (Drupal, drupalSettings) {
  Drupal.behaviors.adSenseUnblock = {
    attach: function (context, settings) {
      setTimeout(function() {
        $('.adsense').each(function() {
          var $ins = $(this).find('ins');
          if (($ins.length) && ($ins.contents().length === 0)) {
            $(this).html(Drupal.t("Please, enable ads on this site. By using ad-blocking software, you're depriving this site of revenue that is needed to keep it free and current. Thank you."));
            $(this).css({'overflow': 'hidden', 'font-size': 'smaller'});
    attach: () => {
      setTimeout(() => {
        document.querySelectorAll('.adsense').forEach((el) => {
          let insEl = el.querySelector('ins');
          if (insEl.innerHTML.length === 0) {
            el.innerHTML = Drupal.t("Please, enable ads on this site. By using ad-blocking software, you're depriving this site of revenue that is needed to keep it free and current. Thank you.");
            el.style.overflow = 'hidden';
            el.style.fontSize = 'smaller';
          }
        });
        // Wait 3 seconds for adsense async to execute.
      }, 3000);
    }
  };
})(jQuery, Drupal, drupalSettings);
})(Drupal, drupalSettings);