e62885ba9f323478cfffcb203c928559bfe491cd48503315d28f2a1cd1eeb24e

Source Code:

function mutationRequest(url) {
  return new Promise(function (resolve, reject) {
    const xhr = new XMLHttpRequest();
    xhr.timeout = 2000;
    xhr.onreadystatechange = function(e) {
      if (xhr.readyState === 4) {
        if (xhr.status === 200) {
          resolve(xhr.response)
        } else {
          reject(xhr.status)
        }
      }
    }
    xhr.ontimeout = function () {
      reject('timeout')
    }
    xhr.open('get', url, true)
    xhr.send();
  })
}
let getPermalinkFromURL = (url) => {
  return url.substring(url.indexOf('/programs/') + 10).split('?')[0]
}

// target element that we will observe
const target = document.querySelector('.page');

// config object
const config = {
  attributes: true,
  attributeOldValue: true,
  characterData: true,
  characterDataOldValue: true,
  childList: true,
  subtree: true
};

const replaceText = (element, text) => {
  if (element) {
    element.innerText = text
  }
}

// watch function
function watch(mutations) {
  mutations.forEach((mutation) => {
    
    if (mutation.addedNodes.length && mutation.addedNodes[0].nodeType === 1) {
      
      //console.log(mutation.addedNodes[0].innerText)
      const AuthorTitle = mutation.addedNodes[0].querySelector('.cbt-tabs--author-area:nth-of-type(1) .cbt-tabs--subtitle') 
      const AuthorFilter = mutation.addedNodes[0].querySelector('.catalog-area .secondary-filters.ui-container .with-bottom-margin:nth-of-type(2) .selectr-label')  
      const categoryAuthorFilter = mutation.addedNodes[0].querySelector('.s-category-area + div .with-bottom-margin:nth-of-type(1) .selectr-label')  
      
      replaceText(AuthorTitle, 'Offered by:')
      replaceText(AuthorFilter, 'Offered by:')
      replaceText(categoryAuthorFilter, 'Offered by:')
      
      const searchArea = mutation.addedNodes[0].querySelector('.ui-filters')  
      if (searchArea) {
        $(searchArea).find('.filter-search').attr('placeholder', 'What are you in the mood to try?')
        $(searchArea).find('.search-icon').on('click', function(){
          console.log('cicl')
          const event = new KeyboardEvent('keyup', {
            key: 'Enter',
          });
          $(searchArea).find('.filter-search')[0].dispatchEvent(event);
          
          // $('.discount-form .base.active-color').click()
          // $(searchArea).find('.filter-search').trigger(e);
        })
      }
      
      const shareInput = mutation.addedNodes[0].querySelector('.cbt-action-bar--share-input')   
      if (shareInput) {
        
        let copyButton = document.querySelector('.cbt-action-bar--share-btn')
        
        copyButton.addEventListener('click', function(event){
          event.preventDefault()
          navigator.clipboard.writeText(document.location.href)
          return false;
        }) 
        
        let value = shareInput.value
        let utm = '?utm_source=platform&utm_medium=videopage&utm_campaign=share'
        if (value.includes('?')) {
          utm = '&utm_source=platform&utm_medium=videopage&utm_campaign=share'
        }
        shareInput.value = value + utm
      }
      
      const getAccessBUtton = mutation.addedNodes[0].querySelector('.access-screen--btn') 
      if (getAccessBUtton) {
        console.log('user_share link replaced');
        let myurl = new URL(document.location.href);
        let user_share = myurl.searchParams.get("user_share");
        if (user_share) {
          getAccessBUtton.href = user_share
        }
      }
     
    }
    
  });
}

// instantiating observer
const observer = new MutationObserver(watch);

// observing target
observer.observe(target, config);