NikolayBezay

Hist trigger thank you message campaign by event.

May 17th, 2021 (edited)
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.11 KB | None | 0 0
  1. <script>
  2. (function() {
  3.     var TIME_GAP_TO_SHOW_CAMPAIGN = 4000;/* 1000 = 1 second */
  4.     function checkThankYouElement() {
  5.         var thankYouMessegeElement = document.querySelector('.main-thanks-container .main-title-container h1.custom-header-text');
  6.         if (thankYouMessegeElement && thankYouMessegeElement.textContent.indexOf('תודה') != -1) {
  7.            observer.disconnect();
  8.             setTimeout(function() {
  9.                 adoric.trigger('showAdoricThankYouMessageCampaign');
  10.             }, TIME_GAP_TO_SHOW_CAMPAIGN);
  11.            
  12.         }
  13.     }
  14.  
  15.     if (adoric) {
  16.         var targetNode = document.querySelector('body');
  17.         var config = { attributes: true, childList: true, subtree: true };
  18.         var callback = function(mutationsList, observer) {
  19.             for(var i = 0; i < mutationsList.length; i++) {
  20.                if (mutationsList[i].type === 'childList') {
  21.                    checkThankYouElement();
  22.                }
  23.            }
  24.        };
  25.        var observer = new MutationObserver(callback);
  26.        observer.observe(targetNode, config);
  27.    }
  28. })();
  29. </script>
Advertisement
Add Comment
Please, Sign In to add comment