import { fullLists , PlaywrightBlocker , Request } from '@cliqz/adblocker-playwright' ; import fetch from 'node-fetch' ; import * as pw from 'playwright' ; ( async ( ) => { const blocker = await PlaywrightBlocker . fromLists ( fetch , fullLists , { enableCompression : true , } ) ; const browser = await pw . chromium . launch ( { headless : false } ) ; const context = await browser . newContext ( ) ; const page = await context . 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 ( 'https://www.mangareader.net/' ) ; await page . screenshot ( { path : 'output.png' } ) ; await blocker . disableBlockingInPage ( page ) ; await browser . close ( ) ; } ) ( ) ;