Untitled

 avatar
unknown
plain_text
2 years ago
978 B
4
Indexable
(function () {
  try {
    function waitForElement(selector, trigger, delayInterval, delayTimeout) {
      var interval = setInterval(function () {
        if (
          document &&
          document.querySelector(selector) &&
          document.querySelectorAll(selector).length > 0
        ) {
          clearInterval(interval);
          trigger();
        }
      }, delayInterval);
      setTimeout(function () {
        clearInterval(interval);
      }, delayTimeout);
    }
    function init() {
      /* start your code here */
      console.log('Test activated!');
      dataLayer.push({ 'event': 'optimize.activate' })
    }
    /* Initialise variation */
    if (window.location.href.indexOf('https://trustandwill.com/learn/') != -1) {
      waitForElement('#Test-Blog-Post li a[href^="/learn/trusts"], #Test-Blog-Post li a[href^="/learn/wills"]', init, 50, 15000);
    }
  } catch (e) {
    console.log(e, "error in Test");
  }
})();
Editor is loading...