remove metadata and cover image from content

This commit is contained in:
Hongbo Wu 2024-07-18 11:18:51 +08:00
parent 02280b576b
commit f2b3a66b72
2 changed files with 16 additions and 5 deletions

View file

@ -27,16 +27,25 @@ export class WeixinQqHandler extends ContentHandler {
metaNode.setAttribute('content', publishTimeISO)
dom.querySelector('head')?.appendChild(metaNode)
}
// This replace the class name of the article info to preserve the block
dom
.querySelector('.rich_media_meta_list')
?.setAttribute('class', '_omnivore_rich_media_meta_list')
// This removes the title
const author = (
dom.querySelector('#js_author_name') || dom.querySelector('#js_name')
)?.textContent?.trim()
if (author) {
const authorNode = dom.createElement('meta')
authorNode.setAttribute('name', 'author')
authorNode.setAttribute('content', author)
dom.querySelector('head')?.appendChild(authorNode)
}
// This removes the title, metadata and cover image
dom.querySelector('.rich_media_title')?.remove()
dom.querySelector('.rich_media_meta_list')?.remove()
dom.querySelector('#js_row_immersive_cover_img')?.remove()
// This removes the profile info
dom.querySelector('.profile_container')?.remove()
dom.querySelector('.profile_card_container')?.remove()
// This removes the footer
dom.querySelector('#content_bottom_area')?.remove()

View file

@ -2004,6 +2004,8 @@ Readability.prototype = {
metadata.byline = jsonld.byline ||
values["dc:creator"] ||
values["dcterm:creator"] ||
values["og:article:author"] ||
values["twitter:creator"] ||
values["author"];
// get description