Untitled

 avatar
unknown
plain_text
a year ago
1.3 kB
7
Indexable
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    /* all Pure helper functions */

    var waitForElement = function (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 bestSeller = '' +
      '<div class="eg-best-seller">' +
      '<span class="eg-bestSeller-text">Best Seller</span>' +
      '</div>';


    /* Variation Init */
    var init = function () {
      var image = document.querySelector('html body a[href="/products/classic-whip-spf-30"]:last-child');
      if (image && !document.querySelector('.eg-best-seller')) {
        image.insertAdjacentHTML("afterend", bestSeller);
      }
    }

    /* Initialize variation */
    waitForElement('html body a[href="/products/classic-whip-spf-30"]:last-child', init, 1000, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();





Editor is loading...
Leave a Comment