mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #935 from omnivore-app/newsletter-convertkit
support newsletters hosted on convertkit.com
This commit is contained in:
commit
48c9062aee
1 changed files with 25 additions and 0 deletions
|
|
@ -451,6 +451,14 @@ export const isProbablyNewsletter = async (html: string): Promise<boolean> => {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if this is a convertkit.com newsletter
|
||||
if (dom.querySelectorAll('img[src*="convertkit-mail.com"]').length > 0) {
|
||||
const convertkitUrl = convertkitNewsletterHref(dom)
|
||||
if (convertkitUrl) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +473,17 @@ const beehiivNewsletterHref = (dom: Document): string | undefined => {
|
|||
return res
|
||||
}
|
||||
|
||||
const convertkitNewsletterHref = (dom: Document): string | undefined => {
|
||||
const readOnline = dom.querySelectorAll('table tr td div a')
|
||||
let res: string | undefined = undefined
|
||||
readOnline.forEach((e) => {
|
||||
if (e.textContent === 'View this email in your browser') {
|
||||
res = e.getAttribute('href') || undefined
|
||||
}
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
const revueNewsletterHref = (dom: Document): string | undefined => {
|
||||
const viewOnline = dom.querySelectorAll('table tr td div a[target="_blank"]')
|
||||
let res: string | undefined = undefined
|
||||
|
|
@ -495,6 +514,12 @@ const findNewsletterHeaderHref = (dom: Document): string | undefined => {
|
|||
return revue
|
||||
}
|
||||
|
||||
// Check if this is a convertkit.com newsletter
|
||||
const convertkitUrl = convertkitNewsletterHref(dom)
|
||||
if (convertkitUrl) {
|
||||
return convertkitUrl
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue