Linting fixes
This commit is contained in:
@ -10,34 +10,39 @@ export class TheAtlanticHandler extends ContentHandler {
|
||||
|
||||
shouldPreHandle(url: string): boolean {
|
||||
const u = new URL(url)
|
||||
return u.hostname.endsWith('theatlantic.com');
|
||||
return u.hostname.endsWith('theatlantic.com')
|
||||
}
|
||||
|
||||
|
||||
unfurlContent(content: Document): Document {
|
||||
const articleContentSection = content.querySelector('[data-event-module="article body"]');
|
||||
unfurlContent(content: Document): Document {
|
||||
const articleContentSection = content.querySelector(
|
||||
'[data-event-module="article body"]'
|
||||
)
|
||||
|
||||
if (!articleContentSection) {
|
||||
return content;
|
||||
return content
|
||||
}
|
||||
|
||||
const divOverArticle = content.createElement("div");
|
||||
const divOverArticle = content.createElement('div')
|
||||
divOverArticle.setAttribute('id', 'prehandled')
|
||||
divOverArticle.innerHTML += articleContentSection.innerHTML
|
||||
content.insertBefore(divOverArticle, articleContentSection);
|
||||
content.insertBefore(divOverArticle, articleContentSection)
|
||||
|
||||
articleContentSection.remove();
|
||||
articleContentSection.remove()
|
||||
|
||||
return content;
|
||||
return content
|
||||
}
|
||||
|
||||
async preHandle(url: string): Promise<PreHandleResult> {
|
||||
// We simply retrieve the article without Javascript enabled using a GET command.
|
||||
// We simply retrieve the article without Javascript enabled using a GET command.
|
||||
const response = await axios.get(url)
|
||||
const data = response.data as string
|
||||
const dom = parseHTML(data).document
|
||||
const editedDom = this.unfurlContent(dom);
|
||||
const editedDom = this.unfurlContent(dom)
|
||||
|
||||
return { content: editedDom.body.outerHTML, title: dom.title, dom: editedDom };
|
||||
return {
|
||||
content: editedDom.body.outerHTML,
|
||||
title: dom.title,
|
||||
dom: editedDom,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user