mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Remove the table with text content less than 20 because these are ads
This commit is contained in:
parent
99dad48dd1
commit
0239103fc4
1 changed files with 6 additions and 2 deletions
|
|
@ -11,9 +11,11 @@ export class AxiosHandler {
|
|||
prehandle = (url: URL, dom: Document): Promise<Document> => {
|
||||
const body = dom.querySelector('table')
|
||||
|
||||
let isFooter = false
|
||||
// this removes ads and replaces table with a div
|
||||
body?.querySelectorAll('table').forEach((el, k) => {
|
||||
if (k > 0) {
|
||||
body?.querySelectorAll('table').forEach((el) => {
|
||||
// remove the footer and the ads
|
||||
if (!el.textContent || el.textContent.length < 20 || isFooter) {
|
||||
el.remove()
|
||||
} else {
|
||||
// removes the first few rows of the table (the header)
|
||||
|
|
@ -28,6 +30,8 @@ export class AxiosHandler {
|
|||
const div = dom.createElement('div')
|
||||
div.innerHTML = el.innerHTML
|
||||
el.parentNode?.replaceChild(div, el)
|
||||
// set the isFooter flag to true because the next table is the footer
|
||||
isFooter = true
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue