Merge pull request #2208 from omnivore-app/wechat-handler
Add content handler for weixin.qq.com
This commit is contained in:
@ -33,6 +33,7 @@ import { ScrapingBeeHandler } from './websites/scrapingBee-handler'
|
||||
import { StackOverflowHandler } from './websites/stack-overflow-handler'
|
||||
import { TDotCoHandler } from './websites/t-dot-co-handler'
|
||||
import { TwitterHandler } from './websites/twitter-handler'
|
||||
import { WeixinQqHandler } from './websites/weixin-qq-handler'
|
||||
import { WikipediaHandler } from './websites/wikipedia-handler'
|
||||
import { YoutubeHandler } from './websites/youtube-handler'
|
||||
|
||||
@ -75,6 +76,7 @@ const contentHandlers: ContentHandler[] = [
|
||||
new StackOverflowHandler(),
|
||||
new EnergyWorldHandler(),
|
||||
new PipedVideoHandler(),
|
||||
new WeixinQqHandler(),
|
||||
]
|
||||
|
||||
const newsletterHandlers: ContentHandler[] = [
|
||||
|
||||
32
packages/content-handler/src/websites/weixin-qq-handler.ts
Normal file
32
packages/content-handler/src/websites/weixin-qq-handler.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { ContentHandler } from '../content-handler'
|
||||
|
||||
export class WeixinQqHandler extends ContentHandler {
|
||||
constructor() {
|
||||
super()
|
||||
this.name = 'Weixin QQ'
|
||||
}
|
||||
|
||||
shouldPreParse(url: string, dom: Document): boolean {
|
||||
return new URL(url).hostname.endsWith('weixin.qq.com')
|
||||
}
|
||||
|
||||
async preParse(url: string, dom: Document): Promise<Document> {
|
||||
// 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
|
||||
dom.querySelector('.rich_media_title')?.remove()
|
||||
|
||||
// This removes the profile info
|
||||
dom.querySelector('.profile_container')?.remove()
|
||||
|
||||
// This removes the footer
|
||||
dom.querySelector('#content_bottom_area')?.remove()
|
||||
dom.querySelector('.rich_media_area_extra')?.remove()
|
||||
dom.querySelector('#js_pc_qr_code')?.remove()
|
||||
|
||||
return Promise.resolve(dom)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user