NikolayBezay

Loccitane GTM teg to uplay the coupon

Mar 1st, 2022 (edited)
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. <script>
  2. (function() {
  3. function upplyAdoricCoupon() {
  4. var discountCodeContainer = document.getElementById('discount-code');
  5. var couponCodeContainer = document.getElementById('coupon_code');
  6. var coupon = window.localStorage.getItem('adoricCoupon');
  7. window.localStorage.removeItem('adoricCoupon');
  8.  
  9. function appearInput() {
  10. var firstSubmitButton, firstBlockContent, firstBlockDiscount = document.querySelector('.checkout-discount-block');
  11. var secondSubmitButton, secondBlockContent, secondBlockDiscount = document.querySelector('#block-discount');
  12. if (firstBlockDiscount) {
  13. firstBlockContent = firstBlockDiscount.querySelector('.block-content');
  14. firstSubmitButton = firstBlockDiscount.querySelector('.action-apply');
  15. firstBlockDiscount.classList.add('_active');
  16. if (firstBlockContent) {
  17. firstBlockContent.style.display = 'block';
  18. }
  19. setTimeout(function() {
  20. if (firstSubmitButton) {
  21. firstSubmitButton.click();
  22. }
  23. }, 1000);
  24. }
  25. if (secondBlockDiscount) {
  26. secondBlockContent = secondBlockDiscount.querySelector('.content');
  27. secondSubmitButton = secondBlockDiscount.querySelector('.action.apply');
  28. secondBlockDiscount.classList.add('active');
  29. if (secondBlockContent) {
  30. secondBlockContent.style.display = 'block';
  31. }
  32. setTimeout(function() {
  33. if (secondSubmitButton) {
  34. secondSubmitButton.click();
  35. }
  36. }, 1000);
  37. }
  38. }
  39. if (coupon) {
  40. if (discountCodeContainer) {
  41. discountCodeContainer.value = coupon;
  42. }
  43. if (couponCodeContainer) {
  44. couponCodeContainer.value = coupon;
  45. }
  46. appearInput();
  47. }
  48. }
  49.  
  50. var MAXIMUM_WAITING_TIME = 10 * 1000;/*10 seconds*/
  51. var waitPageTriggerElement = setInterval(function() {
  52. var discountCodeContainer = document.getElementById('discount-code');
  53. var couponCodeContainer = document.getElementById('coupon_code');
  54.  
  55. if (discountCodeContainer || couponCodeContainer) {
  56. clearInterval(waitPageTriggerElement);
  57. upplyAdoricCoupon();
  58. }
  59. }, 500);
  60. setTimeout(function() {
  61. clearInterval(waitPageTriggerElement);
  62. }, MAXIMUM_WAITING_TIME);
  63. })();
  64. </script>
Add Comment
Please, Sign In to add comment