tifroz / Adios-Engine

ABP rules => Safari content blocker rules

Home Page:https://www.npmjs.com/package/adios-engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preamble

Forked from this project, for the purpose of fixing bugs.

One Bug fix at the moment: when easylist domain options start with a ~ (exclude domain), all domains are lumped indiscrimminately into an Apple Content Filter unless-domain condition, potentially resulting in very large portions of website resources getting blocked. The imperfect but simple fix applied will ignore unless-domain conditions if at least one if-domain condition is present

Adios Engine

A small library to transform standard AdBlock Plus rules like EasyList into rules working in Safari.

Demo

You can visit this website to try the engine.

Working example

If you want to see how to use Adios Engine, check this project.

Installation

npm install adios-engine --save

Usage

var parser = require('adios-engine');
var rule = 'savevideo.me,sddt.com,~search.yahoo.com,yahoo.com,youthedesigner.com,yuku.com##.ads';
var rules = ['@@|http://example.com', 'http://example.com/banner/foo/bar/img?param'];
var wrongRule = '|http://*.com^*|*$script,third-party,domain=lύ.com';

for (var rule of parser.parseRule(rule)) {
	console.log(rule); // The original rule created two parsed rules, parseRule() always returns an array even if the output is only one parsed rule.
}

for (var rule of parser.parseRules(rules)) {
	console.log(rule); // Will print all the parsed rules from the original rules array, can be used to parse an entire list like EasyList.
}

for (var rule of parser.parseRule(wrongRule)) {
	console.log(rule); // Nothing will be printed because the array returned is empty, the original rule contains characters that are not ASCII compliant.
}

Documentation

Only two functions:

parseRule(rule): takes a String as an argument and returns an array containing the parsed rules. If the rule given cannot be parsed the method returns an empty array.

parseRules(rules): takes a String array as an argument and returns the same thing as parseRule().

Tests

npm test

About

ABP rules => Safari content blocker rules

https://www.npmjs.com/package/adios-engine


Languages

Language:JavaScript 100.0%