import { fullLists , PuppeteerBlocker , Request } from '@cliqz/adblocker-puppeteer' ; import fetch from 'node-fetch' ; import * as puppeteer from 'puppeteer' ; import { promises as fs } from 'fs' ; function getUrlToLoad ( ) { let url = 'https://www.mangareader.net/' ; if ( process . argv [ process . argv . length - 1 ] . endsWith ( '.ts' ) === false ) { url = process . argv [ process . argv . length - 1 ] ; } return url ; } ( async ( ) => { const blocker = await PuppeteerBlocker . fromLists ( fetch , fullLists , { enableCompression : true , } , { path : 'engine.bin' , read : fs . readFile , write : fs . writeFile , } ) ; const browser = await puppeteer . launch ( { defaultViewport : null , headless : false , } ) ; const page = await browser . newPage ( ) ; await blocker . enableBlockingInPage ( page ) ; blocker . on ( 'request-blocked' , ( request ) => { console . log ( 'blocked' , request . url ) ; } ) ; blocker . on ( 'request-redirected' , ( request ) => { console . log ( 'redirected' , request . url ) ; } ) ; blocker . on ( 'request-whitelisted' , ( request ) => { console . log ( 'whitelisted' , request . url ) ; } ) ; blocker . on ( 'csp-injected' , ( request ) => { console . log ( 'csp' , request . url ) ; } ) ; blocker . on ( 'script-injected' , ( script , url ) => { console . log ( 'script' , script . length , url ) ; } ) ; blocker . on ( 'style-injected' , ( style , url ) => { console . log ( 'style' , style . length , url ) ; } ) ; await page . goto ( getUrlToLoad ( ) ) ; } ) ( ) ;