How to use adblock-rs - 5 common examples

To help you get started, we’ve selected a few adblock-rs 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 brave / brave-core-crx-packager / scripts / generateAdBlockRustDataFiles.js View on Github external
const generateDataFilesForAllRegions = () => {
  console.log('Processing per region list updates...')
  let p = Promise.resolve()
  new lists('regions').forEach((region) => { // eslint-disable-line
    p = p.then(generateDataFileFromURL.bind(null, region.url,
      region.langs, region.uuid, `rs-${region.uuid}.dat`))
  })
  return p
}
github brave / brave-core-crx-packager / scripts / generateAdBlockRustDataFiles.js View on Github external
let promises = []
  lists.forEach((l) => {
    console.log(`${l.url}...`)
    const filterFn = getListFilterFunction(l.uuid)
    promises.push(getListBufferFromURL(l.url, filterFn))
  })
  let p = Promise.all(promises)
  p = p.then((listBuffers) => {
    generateDataFileFromString(listBuffers, filename, 'default')
  })
  p = p.then(generateResourcesFile)
  return p
}

const generateDataFilesForDefaultAdblock =
  generateDataFilesForList.bind(null, new lists('default'), 'rs-ABPFilterParserData.dat')  // eslint-disable-line

// For adblock-rust-ffi, included just as a char array via hexdump
const generateTestDataFile1 =
  generateDataFileFromString.bind(null, 'ad-banner', 'ad-banner.dat', 'test-data')
// For adblock-rust-ffi, included just as a char array via hexdump
const generateTestDataFile2 =
  generateDataFileFromString.bind(null, 'ad-banner$tag=abc', 'ad-banner-tag-abc.dat', 'test-data')
// For brave-core ./data/adblock-data/adblock-default/rs-ABPFilterParserData.dat
// For brave-core ./data/adblock-data/adblock-v3/rs-ABPFilterParserData.dat
const generateTestDataFile3 =
  generateDataFileFromString.bind(null, 'adbanner\nad_banner', 'rs-default.dat', 'test-data')
// For brave-core ./data/adblock-data/adblock-v4/rs-ABPFilterParserData.dat
const generateTestDataFile4 =
  generateDataFileFromString.bind(null, 'v4_specific_banner.png', 'rs-v4.dat', 'test-data')
// For brave-core ./brave/test/data/adblock-data/adblock-regional/
// 9852EFC4-99E4-4F2D-A915-9C3196C7A1DE/rs-9852EFC4-99E4-4F2D-A915-9C3196C7A1DE.dat
github cliqz-oss / adblocker / packages / adblocker-benchmarks / blockers / brave.js View on Github external
static parse(rawLists) {
    return new Brave(new Engine(rawLists.split(/[\n\r]+/g)));
  }
github brave / brave-core-crx-packager / scripts / generateAdBlockRustDataFiles.js View on Github external
const generateDataFileFromString = (filterRuleData, outputDATFilename, outSubdir) => {
  let rules
  if (filterRuleData.constructor === Array) {
    rules = filterRuleData.join('\n')
  } else {
    rules = filterRuleData
  }
  const client = new Engine(rules.split('\n'))
  const arrayBuffer = client.serialize()
  const outPath = getOutPath(outputDATFilename, outSubdir)
  fs.writeFileSync(outPath, Buffer.from(arrayBuffer))
}
github brave / brave-core-crx-packager / scripts / generateAdBlockRustDataFiles.js View on Github external
return new Promise((resolve, reject) => {
    const jsonData = JSON.stringify(uBlockResources(
      uBlockWebAccessibleResources,
      uBlockRedirectEngine,
      uBlockScriptlets
    ))
    fs.writeFileSync(getOutPath('resources.json', 'default'), jsonData, 'utf8')
  })
}

adblock-rs

Very fast, Rust-based, native implementation of ad-blocker engine for Node

MPL-2.0
Latest version published 1 month ago

Package Health Score

79 / 100
Full package analysis