rehypejs + Easylist and company
// deno world
import rehypeAdVacuum from 'https://denopkg.com/ericdmoore/rehype-ad-vacuum@main/mod.ts'
// Yarn | NPM world
// npm i rehype-ad-vacuum
// yarn add rehype-ad-vacuum
// no CJS/ require support
import rehypeAdVacuum from 'rehype-ad-vacuum'
// deno world
import { unified } from 'https://denopkg.com/ericdmoore/unified@main/mod.ts';
import rehypeParse from 'https://denopkg.com/ericdmoore/unified@main/mod.ts';
import {vacuum, starterLists} from 'https://denopkg.com/ericdmoore/rehype-ad-vacuum@main/mod.ts'
const someCoolUrl:string = await getRandUrlFromDB()
const html = await (await fetch(someCoolUrl)).text()
unified()
.use(rehypeParse)
.use(rehypeAdVacuum, {lists: starterLists})
.process(html)
interface IVacuumParams{
lists?: string[] // default - [ easylist ] url of txt file holding parsable filter rules
strict?: boolean // default - false
}
interface IElement{
allow: boolean;
selectorType: 'css' | 'xpath';
selector: string;
}
interface ABPRuleInit {
allow: boolean;
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
pathname?: string;
search?: string;
hash?: string;
baseURL?: string;
element?: IElement
} // type is basically {URLPattern & {allow:boolean, element?: IElement}}