This project aims to provide a utility to convert urlfilters (in Easylist syntaxt) to the DNR (declarative net request) format, in a browser. It uses 3rd party libraries for the conversions.
The tool is publicaly available on a github page.
- AdGuard - @adguard/tsurlfilter licenses under GPLv3
- AdBlockPlus - @eyeo/abp2dnr licenses under GPLv3
Install nodejs with a tool like asdf, rtx or mise, eg.:
rtx installInstall node modules
npm ciBuild static page:
npm run build:pageStart development server:
npm run serveRunning tests:
npm run test.unit
npm run test.e2eNOTE: to run e2e tests playwright needs to install instumented browser. To do that run:
npx playwright install --with-depsThe conversion tool can be used in any page or web-extension when embeded in an iframe.
Example:
<iframe id="urlfilter2dnr" src="https://ghostery.github.io/urlfilter2dnr/" height="0" width="0"></iframe>window.addEventListener("message", (event) => {
console.log('DNR rules', event.data.rules);
});
document.getElementById("urlfilter2dnr").contentWindow.postMessage({
action: 'convert',
converter: 'adguard',
filters: ['||test.com'],
}, "*");