The code below will only work from verified domains. Please Baemail Me to Whitelist your Domain.
Include this at the head of any page you wish to send Baemails from.
<script src="https://unpkg.com/open-baemail"></script>
Please adapt the code below to suit the needs of your application.
// The Button Above Does This
const setData = () => {
Baemail.service = {}
const name = document.querySelector('.merch-name').innerText
const domain = document.querySelector('.merch-domain').innerText
const valid = name.length > 0 && !!domain.match(/(https:\/\/)[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}/)
if (valid) {
Baemail.service.name = name
Baemail.service.domain = domain
getMerchantSetupButton()
document.querySelector('.setbut').style.display = 'none'
document.querySelector('#merchant').style.display = 'block'
document.querySelector('.merch-return').innerText = ''
} else {
if (name.length < 1) {
document.querySelector('.merch-return').innerText = 'Merchant Name must be at least 1 character long'
} else {
document.querySelector('.merch-return').innerText = 'Domain must be https, and be in this format: https://baemail.me'
}
}
}