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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
For a faster more precise version of this library, see its C++ gyp rewrite.
JavaScript Adblock Plus filter parser for lists like EasyList
Parses filter rules as per:
Babel / ES6:
rt * as ABPFilterParser from 'abp-filter-parser.js';
Node:
ABPFilterParser = require('abp-filter-parser');
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!');
You probably won't need these directly, they are used by the primary API above.