mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
17 lines
535 B
TypeScript
17 lines
535 B
TypeScript
import { DOMWindow } from 'jsdom'
|
|
|
|
export class WikipediaHandler {
|
|
name = 'wikipedia'
|
|
|
|
shouldPrehandle = (url: URL, _dom: DOMWindow): boolean => {
|
|
return url.hostname.endsWith('wikipedia.org')
|
|
}
|
|
|
|
prehandle = (url: URL, dom: DOMWindow): Promise<DOMWindow> => {
|
|
// This removes the [edit] anchors from wikipedia pages
|
|
dom.document.querySelectorAll('.mw-editsection').forEach((e) => e.remove())
|
|
// this removes the sidebar
|
|
dom.document.querySelector('.infobox')?.remove()
|
|
return Promise.resolve(dom)
|
|
}
|
|
}
|