Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
978 B
2
Indexable
Never
(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");
  }
})();