Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.4 kB
1
Indexable
Never
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    /* all Pure helper functions */

    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);
    }

    var cardInformation = `<div class="eg-card-info">Card information</div>`


    /* Variation Init */
    function init() {
      var paymentMethodTitle = document.querySelector('html body #checkout-payment-method-load .payment-method-braintree .payment-method-title .label');
      if (paymentMethodTitle && !document.querySelector('.eg-card-info')) {
        paymentMethodTitle.innerText = "Credit Card";
        paymentMethodTitle.insertAdjacentHTML("afterend", cardInformation);
      }
    }

    /* Initialize variation */
    waitForElement('html body #checkout-payment-method-load .payment-method', init, 1500, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();





Leave a Comment