Add support for identifying newsletters hosted on beehiiv.com

This commit is contained in:
Jackson Harper 2022-03-07 15:23:56 -08:00
parent bba094fbcd
commit 2cb5cc065a

View file

@ -432,9 +432,28 @@ export const isProbablyNewsletter = (html: string): boolean => {
return true
}
const beehiivUrl = beehiivNewsletterHref(dom.window)
if (beehiivUrl) {
return true
}
return false
}
const beehiivNewsletterHref = (dom: DOMWindow): string | undefined => {
const readOnline = dom.document.querySelectorAll(
'table tr td div a[class*="link"]'
)
let res: string | undefined = undefined
readOnline.forEach((e) => {
console.log('text content', e.textContent)
if (e.textContent === 'Read Online') {
res = e.getAttribute('href') || undefined
}
})
return res
}
const findNewsletterHeaderHref = (dom: DOMWindow): string | undefined => {
const postLink = dom.document.querySelector('h1 a ')
if (postLink) {