let url = window.location.href; let parsedUrl = new URL(url); let domain = parsedUrl.hostname; if (window.location.href.includes("editor") || window.location.href.includes("oseid")) { fetch('https://productreview.myappgurus.com/api/checkAppEmbed', { method: "POST", headers: { 'Accept': 'application/json', 'Content-type': 'application/json', 'Authorization': `Bearer ${window.sessionToken}` }, body: JSON.stringify({ shopName: domain }), }) .then(res => res.json()) .then(response => { if (response.disabled == undefined || response.disabled == true) { let html = `

Action required - mag is not set up

To add mag to your store, follow the instructions below:

  1. Click the button below
  2. Make sure "MyAppGurus Product Review" is on
  3. Click on "Save"
Dismiss
Enable app now
`; const wrapper = document.createElement('div'); wrapper.innerHTML = html; document.body.appendChild(wrapper.firstChild); closePopup(); enableappembed(); } console.log(response.disabled); }) var closePopup = () => { let closebtn = document.querySelector('.gurus-mag-btn.gurus-mag-btn-secondary'); if (closebtn) { closebtn.addEventListener('click', () => { document.querySelector('.main-gurusalert-wrapper').style.display = 'none'; }); } } var enableappembed = () => { console.log(domain); let appembed = document.querySelector('.gurus-mag-btn.gurus-mag-btn-primary'); if (appembed) { appembed.addEventListener('click', () => { window.open(`https://${domain}/admin/themes/current/editor?context=apps&activateAppId=c69d5134-3c50-47ae-8dee-1c30837be37a/app-embed`); }); } } }