Advertisement
Dzhubal

Untitled

Jul 9th, 2021
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     function addWhatsApp() {
  3.         var innerHtml = document.createElement("a");
  4.             innerHtml.href = ''; //сюда нужно вставить ссылку на whatsapp
  5.             innerHtml.target = "_blank";
  6.             innerHtml.setAttribute('class', 'carrotquest-social-messenger-button carrotquest-social-messenger-button-whatsapp');
  7.         var innerDiv = document.createElement('div');
  8.             innerDiv.textContent = 'Написать нам в WhatsApp';
  9.             innerDiv.setAttribute('class', 'carrotquest-social-messenger-button-title');
  10.         innerHtml.appendChild(innerDiv);
  11.         document.querySelector('#carrotquest-social-messenger-buttons').appendChild(innerHtml);
  12.     };
  13.  
  14.     var css = '.carrotquest-social-messenger-button.carrotquest-social-messenger-button-whatsapp{background-color: #25D366!important; background-image: url(https://files.carrotquest.io/message-images/100/100-1574239739864-kyjphllb.png)!important; background-size: 60px auto !important;}',
  15.         head = document.head || document.getElementsByTagName('head')[0],
  16.         style = document.createElement('style');
  17.     style.type = 'text/css';
  18.     if (style.styleSheet){
  19.         style.styleSheet.cssText = css;
  20.     } else {
  21.         style.appendChild(document.createTextNode(css));
  22.     };
  23.     head.appendChild(style);
  24.  
  25.     var checkSocButtons = setInterval(function() {
  26.         if (document.querySelector('#carrotquest-social-messenger-buttons')!=null) {
  27.             clearInterval(checkSocButtons);
  28.             addWhatsApp();
  29.         };
  30.     }, 500);
  31.  
  32.     carrotquest.addCallback('messenger_closed', function() {
  33.         var checkSocButtons = setInterval(function() {
  34.             if (document.querySelector('#carrotquest-social-messenger-buttons')!=null) {
  35.                 clearInterval(checkSocButtons);
  36.                 addWhatsApp();
  37.             };
  38.         }, 100);
  39.     });
  40. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement