Untitled

 avatar
unknown
plain_text
2 years ago
5.1 kB
5
Indexable
/*changing anchor text in des*/
html body .eg-new-text {
    width: 102px !important;
    position: relative;
    color: transparent !important;
    display: block;
}

html body .eg-new-text::before {
    content: "Contactanos";
    position: absolute;
    width: 100%;
    color: white !important;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}



(function () {
  if (!document.body.classList.contains("eg-hsbc")) {
    try {
      /* main variables */
      var debug = 0;
      var variation_name = "";

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

      let tabData = {
        "tab1": {
          "link": "https://www.business.hsbc.com.ar/es-ar/contactanos-argentina",
          "para": "¿Necesitas ayuda? Ponete en contacto con nosotros para obtener más información sobre nuestras soluciones bancarias y cómo podemos ayudarte a impulsar tu negocio.",
          "title": "Consultas",
          "img": "/-/jssmedia/media/illustrations/hsbc_future-skills_illustration_personal-skills.jpg?h=1080&iar=0&w=1920&hash=6C0F91971D05C7BA64162FAF531B24A9"
        }
      }
      // INSTERTING NEW TAB BTN AND CHANGING RIGHT DIV DATA
      function changeDataInPanel(tabNum) {
        waitForElement('html body div[id*="useful-links-content"] > div[class*="useful-links__content-info"] > a', function () {
          // console.log(tabNum);
          let tabSelector = 'tab' + tabNum;
          // changing image
        //  document.querySelector('html body div[id*="useful-links-content"] > div[class*="useful-links__content-image"] img').src = tabData[tabSelector].img;
          // changing headline
          document.querySelector('html body div[id*="useful-links-content"] > div[class*="useful-links__content-info"] > h3').innerText = tabData[tabSelector].title;
          // changing subheading
          document.querySelector('html body div[id*="useful-links-content"] > div[class*="useful-links__content-info"] > span').innerText = tabData[tabSelector].para;
          // changing link
         // document.querySelector('html body div[id*="useful-links-content"] > div[class*="useful-links__content-info"] > a').href = tabData[tabSelector].link;
          // changing link inner html 
          document.querySelector('html body div[id*="useful-links-content"] > div[class*="useful-links__content-info"] > a > span > span').classList.add("eg-new-text")

        }, 50, 15000);
      }

      function mob() {
        if (window.innerWidth < 768) {
          if (document.querySelector('html body div[class*="useful-links__head"] > div[class*="dropdown-list"] > button')) {
            document.querySelector('html body div[class*="useful-links__head"] > div[class*="dropdown-list"] > button').addEventListener("click", function () {
              waitForElement('html body div[class*="useful-links__head"] > div[class*="dropdown-list"] > button + ul', function () {
                document.querySelectorAll('html body div[class*="useful-links__head"] > div[class*="dropdown-list"] > button + ul>li').forEach((itm, i) => {
                  itm.addEventListener("click", function () {
                    if (i == 0) {
                      changeDataInPanel(i + 1);
                    } else {
                      document.querySelector(".eg-new-text") && document.querySelector(".eg-new-text").classList.remove();
                    }
                  });
                })
              }, 100, 15000);
            });
          }
        }
      }

      function des() {
        if (window.innerWidth > 767) {
          setTimeout(() => {
            document.querySelectorAll("html body .useful-links_tab-container > button").forEach((cta, i) => {
              cta.addEventListener("click", function () {
                if (i == 0) {
                  changeDataInPanel(i + 1);
                } else {
                  document.querySelector(".eg-new-text") && document.querySelector(".eg-new-text").classList.remove("eg-new-text");
                }
              });
            })
          }, 500);
        }
      }

      waitForElement("html body", function () {
        if (!document.body.classList.contains("eg-hsbc")) {
          document.body.classList.add("eg-hsbc");
          waitForElement('html body div[id*="useful-links-content"] > div[class*="useful-links__content-info"] > a', des, 50, 15000);
          waitForElement('html body div[class*="useful-links__head"] > div[class*="dropdown-list"] > button', mob, 50, 15000);
          changeDataInPanel(1);
        }
      }, 50, 15000);

    } catch (e) {
      if (debug) console.log(e, "error in Test" + variation_name);
    }
  }
})();
Editor is loading...