Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- if (window.Element && !Element.prototype.closest) {
- Element.prototype.closest =
- function(s) {
- var matches = (this.document || this.ownerDocument).querySelectorAll(s),
- i,
- el = this;
- do {
- i = matches.length;
- while (--i >= 0 && matches.item(i) !== el) {};
- } while ((i < 0) && (el = el.parentElement));
- return el;
- };
- }
- function checkProductCount() {
- var productCount = document.querySelector(".page-header .cartCnt.count");
- if (productCount && productCount.textContent.length > 0) {
- productCount = parseInt(productCount.textContent);
- } else {
- productCount = 0;
- }
- window.localStorage.setItem('cartProductCount', productCount);
- return productCount;
- }
- function showAdoricCampaign() {
- var waitPageTriggerElement = setInterval(function() {
- var pageTriggerElements = document.querySelector('.minicart-bottom > div');
- if (pageTriggerElements) {
- clearInterval(waitPageTriggerElement);
- adoric.lightboxes.forEach(function(item) {
- if (item.isShowing && item.options.campaignId === '60742caa3b07ca156bb8d0f2') {
- item.close(4);
- }
- });
- adoric.trigger('showProductCount1to8');
- }
- }, 500);
- setTimeout(function() {
- clearInterval(waitPageTriggerElement);
- }, 5000);
- }
- function checkCampaignCondition() {
- var currentProductCount = checkProductCount();
- if (currentProductCount > 0 && currentProductCount <= 8 && adoric) {
- showAdoricCampaign();
- }
- }
- setTimeout(checkCampaignCondition, 2000);
- document.querySelector('body').addEventListener('mouseup', function(event) {
- var removeFromCartButton = event.target.closest('.button-remove');
- if (removeFromCartButton) {
- setTimeout(checkCampaignCondition, 2500);
- setTimeout(checkCampaignCondition, 3500);
- }
- var addToCartButton = event.target.closest('.btn-cart');
- if (addToCartButton) {
- setTimeout(checkCampaignCondition, 2500);
- setTimeout(checkCampaignCondition, 3500);
- }
- });
- document.querySelector('body').addEventListener('touchend', function(event) {
- var removeFromCartButton = event.target.closest('.button-remove');
- if (removeFromCartButton) {
- setTimeout(checkCampaignCondition, 3500);
- setTimeout(checkCampaignCondition, 5500);
- }
- var addToCartButton = event.target.closest('.btn-cart');
- if (addToCartButton) {
- setTimeout(checkCampaignCondition, 3500);
- setTimeout(checkCampaignCondition, 5500);
- }
- });
- })();
- </script>
Add Comment
Please, Sign In to add comment