diff --git a/packages/api/src/utils/axios-handler.ts b/packages/api/src/utils/axios-handler.ts index 868181c85..00f6ff86a 100644 --- a/packages/api/src/utils/axios-handler.ts +++ b/packages/api/src/utils/axios-handler.ts @@ -11,9 +11,11 @@ export class AxiosHandler { prehandle = (url: URL, dom: Document): Promise => { 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 } })