'How to show aonce and then hide my socialproof popup on mobile?

I have two social proof pop-ups (one page visit, the other bought products). Everything works fine because the popup appears and disappears, but I would like the popup to appear only once on the mobile and then hide it.

(function($) {
  //VARS
  let productsBuy = parseInt("{% socialproof %} debc5b96-be0e-495d-938f-5a1fb5af9101 {% endsocialproof %}");
  let count = 'sztuk';
  let num = parseInt("{% socialproof %} 012a023f-e69a-4e61-9690-adcdf19e082b {% endsocialproof %}");

  //IFS

  //productsBUY
  if (productsBuy < 1) {
    productsBuy = 4;
  } else if (productsBuy > 2 & productsBuy < 3) {
    productsBuy = 7 * 2;
  } else {
    productsBuy = productsBuy * 4;
  }
  //sztuki
  if (productsBuy < 5) {
    count = 'sztuki';
  } else {
    count;
  }
  //productsWatch
  if (num < 1) {
    num = 11;
  } else {
    num = num * 9;
  }

  function langVariations(num) {
    const smallList = [2, 3, 4];
    const bigList = [0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21];
    let persons = "osoba ogląda";
    const lenght = Math.ceil(Math.log(num + 1) / Math.LN10);
    let value = num.toString().slice(lenght - 2);
    if (num < 1) {
      return `Jeszcze nikt nie kupił tego produktu, bądź pierwszy`;
    } else if (value == 1) {
      return `${num} ${persons} osoba ogląda`;
    } else if (value > 21) {
      const last = value.toString().slice(-1);
      if (smallList.includes(Number(last))) {
        persons = "osoby oglądają "
      } else {
        persons = "osób ogląda"
      }
    } else {
      if (bigList.includes(Number(value))) {
        persons = "osób ogląda"
      } else if (smallList.includes(Number(value))) {
        persons = "osoby oglądają"
      }
    }
    return `<b>${num}</b> ${persons} ten produkt`;
  };


  //FUNCTIONS
  (() => {
    const outOfStockBadge = document.querySelector('.out-of-stock-badge');
    outOfStockBadge ? null : init();

    function init() {
      insertBanner();
    }
  })();

  // functions
  function insertBanner() {
    const insertPlace = document.querySelector('.woocommerce-product-gallery');
    const html = `
    <section class="custom-social-proof">
        <div class="custom-notification">
          <div class="custom-notification-container">
            <div class="custom-notification-image-wrapper">
              <img src="https://upload.snrcdn.net/c9e42d48d6ab1291cdc55887be67321230d7b317/default/origin/f69e440322ed478b94696c1714a3e3b6.png">
            </div>
            <div class="custom-notification-content-wrapper">
              <p class="custom-notification-content">
                W ciągu 24h zakupiono <b>${productsBuy}</b> ${count}                
              </p>
            </div>
          </div>
        </div>
      </section>
      <section class="custom-social-proof2">
        <div class="custom-notification2">
          <div class="custom-notification-container">
            <div class="custom-notification-image-wrapper">
              <img src="https://upload.snrcdn.net/c9e42d48d6ab1291cdc55887be67321230d7b317/default/origin/18038cddd9de41748182ea0e1c1fab42.png">
            </div>
            <div class="custom-notification-content-wrapper">
              <p class="custom-notification-content">
                 ${langVariations(num)}
              </p>
            </div>
          </div>
        </div>
      </section>`;

    insertPlace.insertAdjacentHTML('beforebegin', html);
  }

  // (function($){
  //     setInterval(function() {
  //         $('.custom-social-proof').toggleClass('active');
  //     }, 4000);
  // })(jQuery);
  // (function($){
  //     setInterval(function() {
  //         $('.custom-social-proof2').toggleClass('active');
  //     }, 5000);
  // })(jQuery);

  (function($) {
    function customNotificationToggleClass() {
      $('.custom-social-proof').toggleClass('active');
    }

    customNotificationToggleClass();

    if (window.innerWidth > 768) {
      setInterval(function() {
        customNotificationToggleClass();
      }, 5000);
    }
  })(jQuery);

  (function($) {
    function customNotificationToggleClass() {
      $('.custom-social-proof2').toggleClass('active');
    }

    customNotificationToggleClass();

    if (window.innerWidth > 768) {
      setInterval(function() {
        customNotificationToggleClass();
      }, 6000);
    }
  })(jQuery);
})(jQuery);
.custom-social-proof {
  position: relative;
  bottom: -460px;
  left: 60px;
  font-family: 'Open Sans', sans-serif;
  -webkit-transform: translateY(20%);
  -ms-transform: translateY(20%);
  transform: translateY(20%);
  -webkit-transition: opacity 1s ease, -webkit-transform 1s ease;
  transition: opacity 1s ease, -webkit-transform 1s ease;
  -o-transition: transform 1s ease, opacity 1s ease;
  transition: transform 1s ease, opacity 1s ease;
  transition: transform 1s ease, opacity 1s ease, -webkit-transform 1s ease;
  opacity: 0;
  z-index: 3;
}

.custom-social-proof.active {
  -webkit-transform: translateY(0);
  -ms-transform: translateY(0);
  transform: translateY(0);
  opacity: 1;
}

.custom-social-proof2 {
  position: relative;
  bottom: -420px;
  left: 60px;
  font-family: 'Open Sans', sans-serif;
  -webkit-transform: translateY(20%);
  -ms-transform: translateY(20%);
  transform: translateY(20%);
  -webkit-transition: opacity 1s ease, -webkit-transform 1s ease;
  transition: opacity 1s ease, -webkit-transform 1s ease;
  -o-transition: transform 1s ease, opacity 1s ease;
  transition: transform 1s ease, opacity 1s ease;
  transition: transform 1s ease, opacity 1s ease, -webkit-transform 1s ease;
  opacity: 0;
  z-index: 3;
}

.custom-social-proof2.active {
  -webkit-transform: translateY(0);
  -ms-transform: translateY(0);
  transform: translateY(0);
  opacity: 1;
}

.custom-notification {
  width: 240px;
  border: 0;
  text-align: left;
  z-index: 3;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  font-weight: 400;
  border-radius: 6px;
  -webkit-box-shadow: 2px 2px 10px 2px hsla(0, 4%, 4%, 0.2);
  box-shadow: 2px 2px 10px 2px hsla(0, 4%, 4%, 0.2);
  background-color: #fff;
  cursor: pointer;
  position: absolute;
}

.custom-notification2 {
  width: 240px;
  border: 0;
  text-align: left;
  z-index: 3;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  font-weight: 400;
  border-radius: 6px;
  -webkit-box-shadow: 2px 2px 10px 2px hsla(0, 4%, 4%, 0.2);
  box-shadow: 2px 2px 10px 2px hsla(0, 4%, 4%, 0.2);
  background-color: #fff;
  cursor: pointer;
  position: absolute;
}

.custom-notification-container {
  display: -webkit-box !important;
  display: -ms-flexbox !important;
  display: flex !important;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  height: 30px;
}

.custom-notification-image-wrapper img {
  max-height: 12.5px;
  width: 12.5px;
  overflow: hidden;
  border-radius: 6px 0 0 6px;
  -o-object-fit: cover;
  object-fit: cover;
  margin-left: 10px;
}

.custom-notification-content-wrapper {
  margin: 0;
  height: 100%;
  color: #000000;
  padding-left: 8px;
  padding-right: 20px;
  border-radius: 0 6px 6px 0;
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  display: -webkit-box !important;
  display: -ms-flexbox !important;
  display: flex !important;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.custom-notification-content {
  font-family: inherit !important;
  /* margin: 0 !important; */
  padding: 0 !important;
  font-size: 12px;
  top: 50%;
  -webkit-transform: translateY(20%);
  -ms-transform: translateY(20%);
  transform: translateY(20%);
}

img {
  vertical-align: baseline;
}

@media screen and (max-width: 700px) {
  .custom-social-proof {
    bottom: -300px;
    left: 30px;
  }
  .custom-social-proof2 {
    bottom: -260px;
    left: 30px;
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source