How to use the @cliqz/adblocker-puppeteer.PuppeteerBlocker.deserialize function in @cliqz/adblocker-puppeteer

To help you get started, we’ve selected a few @cliqz/adblocker-puppeteer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microlinkhq / browserless / packages / goto / src / index.js View on Github external
'use strict'

const { PuppeteerBlocker } = require('@cliqz/adblocker-puppeteer')
const debug = require('debug-logfmt')('browserless:goto')
const createDevices = require('@browserless/devices')
const { getDomain } = require('tldts')
const pReflect = require('p-reflect')
const pTimeout = require('p-timeout')
const path = require('path')
const fs = require('fs')

const engine = PuppeteerBlocker.deserialize(
  new Uint8Array(fs.readFileSync(path.resolve(__dirname, './engine.bin')))
)

engine.on('request-blocked', ({ url }) => debug('adblock:block', url))
engine.on('request-redirected', ({ url }) => debug('adblock:redirect', url))

const isEmpty = val => val == null || !(Object.keys(val) || val).length

const parseCookies = (url, str) => {
  const domain = `.${getDomain(url)}`
  return str.split(';').reduce((acc, str) => {
    const [name, value] = str.split('=')
    const cookie = {
      name: name.trim(),
      value,
      domain,
github berstend / puppeteer-extra / packages / puppeteer-extra-plugin-adblocker / src / index.ts View on Github external
private async loadFromCache(): Promise {
    if (!this.opts.useCache) {
      throw new Error('caching disabled')
    }
    this.debug('load from cache', this.engineCacheFile)
    return PuppeteerBlocker.deserialize(
      new Uint8Array(await fs.readFile(this.engineCacheFile))
    )
  }

@cliqz/adblocker-puppeteer

Ghostery adblocker Puppeteer wrapper

MPL-2.0
Latest version published 2 months ago

Package Health Score

56 / 100
Full package analysis

Similar packages