duckduckgo/abp-filter-parser

Name: abp-filter-parser

Owner: DuckDuckGo

Description: JavaScript Adblock Plus filter parser for lists like EasyList

Forked from: bbondy/abp-filter-parser

Created: 2017-07-13 13:15:42.0

Updated: 2018-03-27 22:31:22.0

Pushed: 2018-04-19 14:59:40.0

Homepage: null

Size: 593

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

abp-filter-parser

For a faster more precise version of this library, see its C++ gyp rewrite.

JavaScript Adblock Plus filter parser for lists like EasyList

Build Status

Parses filter rules as per:

Usage

Babel / ES6:

rt * as ABPFilterParser from 'abp-filter-parser.js';

Node:

ABPFilterParser = require('abp-filter-parser');
Primary API:
ABPFilterParser = require('abp-filter-parser');
fs = require('fs');

easyListTxt = fs.readFileSync('./test/data/easylist.txt', 'utf-8');
parsedFilterData = {};
urlToCheck = 'http://static.tumblr.com/dhqhfum/WgAn39721/cfh_header_banner_v2.jpg';

his is the site who's URLs are being checked, not the domain of the URL being checked.
currentPageDomain = 'slashdot.org';

ilterParser.parse(easyListTxt, parsedFilterData);
BPFilterParser.parse(someOtherListOfFilters, parsedFilterData);

ABPFilterParser.matches(parsedFilterData, urlToCheck, {
  domain: currentPageDomain,
  elementTypeMaskMap: ABPFilterParser.elementTypes.SCRIPT,
})) {
nsole.log('You should block this URL!');
se {
nsole.log('You should NOT block this URL!');

Secondary APIs

You probably won't need these directly, they are used by the primary API above.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.