
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
@eyeo/abp2dnr
Advanced tools
This is a script to convert Adblock Plus filter lists to chrome.declarativeNetRequest rulesets.
API docs are available at https://eyeo.gitlab.io/adblockplus/abc/abp2dnr/.
Before you begin, make sure to install:
After these prerequisites are met, you can add abp2dnr to your project with npm install
.
abp2dnr
is available as a NPM module:
@eyeo/abp2dnr
.
npm install --save @eyeo/abp2dnr
abp2dnr can be called on the command line. When you do, it will accept a filter list on stdin and print a DNR ruleset to stdout.
cat easylist.txt | npx @eyeo/abp2dnr > ruleset.json
abp2dnr can also be used in a script. This exposes the function convertFilter
,
which converts a single filter text into one or more DNR rule. Note that, unlike
the CLI script, these rules do not have IDs, so assigning IDs and assembling
into a ruleset is up to you.
import {convertFilter} from "@eyeo/abp2dnr";
let filters = [
"-popup-ad."
];
let nextId = 1;
let ruleset = [];
for (let filter of filters)
{
for (let rule of await convertFilter(filter))
{
rule.id = nextId++;
ruleset.push(rule);
}
}
console.log(JSON.stringify(ruleset));
You can also use it to just validate the Regular Expressions that can appear in filter texts, to ensure that they will work when used in DNR rules.
import {isRegexSupported} from "@eyeo/abp2dnr";
let validRegexSupportedResult = isRegexSupported({
regex: "[a-z0-9]+",
isCaseSensitive: false,
requireCapturing: false
});
console.log(validRegexSupportedResult);
// { isSupported: true }
let invalidRegexSupportedResult = isRegexSupported({
regex: "[a-z0-9]{1000,}",
isCaseSensitive: false,
requireCapturing: false
});
console.log(invalidRegexSupportedResult);
// { isSupported: false, reason: 'memoryLimitExceeded' }
Documentation on how to work with abp2dnr as a developer is in CONTRIBUTING.md.
Chromium has a Chromium's built-in filter list converter, however it appears that this has not been kept up to date with changes to the DNR rule syntax and defaults.
FAQs
Adblock Plus filter list to DeclarativeNetRequest conversion
We found that @eyeo/abp2dnr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.