Code Monkey home page Code Monkey logo

adblock-decoder's Introduction

AdBlock Filter List Decoder

A set of tools for the decoding and conversion of AdBlock and filter lists. The decoder itself is part of the PyFunceble project.

Installation

$ pip install --user adblock-decoder

Update

$ pip install --user --upgrade adblock-decoder

Python API

If you want to use the decoder in your own Python modules or infrastructure, you may use the PyFunceble project to access the decoder.

from PyFunceble.converter.adblock_input_line2subject import AdblockInputLine2Subject

to_decode = ["||example.com^", "||example.net^"]

decoder = AdblockInputLine2Subject()
decoder.aggressive = False

decoded = set()

for line in to_decode:
    # One shot method.
    decoded.update(decoder.set_data_to_convert(line).get_converted())

    # Step by step method
    decoder.set_data_to_convert(line)
    decoded.update(decoder.get_converted())

print("Decoded:", decoded)

Tools

adblock2hosts

A tool to convert adblock or filter lists to hosts format.

Usage

usage: adblock2hosts [-h] [--aggressive] [--ip IP] [-o OUTPUT] input_file

An AdBlock2hosts converter.

positional arguments:
    input_file            The input file to work with.

optional arguments:
    -h, --help            show this help message and exit
    --aggressive          [USE AT YOUR OWN RISK AS IT IS EXPERIMENTAL] Activates the extraction of everything regardless of the interpretation of AdBlock/UBlock.
    --ip IP               Sets the IP to use while generating the hosts file.
    -o OUTPUT, --output OUTPUT
                            The file to write to.

Crafted with ♥ by Nissar Chababy (Funilrys)!

adblock2plain

A tool to convert adblock or filter lists to plain text format.

Usage

usage: adblock2plain [-h] [--aggressive] [-o OUTPUT] input_file

An AdBlock2plain (text) converter.

positional arguments:
    input_file            The input file to work with.

optional arguments:
    -h, --help            show this help message and exit
    --aggressive          [USE AT YOUR OWN RISK AS IT IS EXPERIMENTAL] Activates the extraction of everything regardless of the interpretation of AdBlock/UBlock.
    -o OUTPUT, --output OUTPUT
                            The file to write to.

Crafted with ♥ by Nissar Chababy (Funilrys)!

License

Copyright 2017, 2018, 2019, 2020, 2021, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

adblock-decoder's People

Contributors

funilrys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

adblock-decoder's Issues

[FEATURE] Sorting and duplicate deletion of output

@keczuppp said:

I know you have a reason to not do so in the embeded Adblock Decoder,
but shouldn't at least the standalone Adblock Decoder remove duplicates and then sort in a-z order?
If not internally, then at least in the output.
A parameter like --clean could be added.

Invalid output

Testing the below list

||com/*?adver=123.456
||aaa.*/ads1/
||aaa.*/ads2/
||bbb.com^*ads3
||ccc.com^*ads4
||ddd.com*.ads.com
||eee.com/*$image,domain=fff.com
||ggg.hhh-*
||ggg.hhh-*
||ggg.hhh*iii-jjj
|http://kkk.com/ads/*
|https://kkk.lll/*
|https://ads.mmm.nnn^
||ooo.com/*.ppp
||qqq.com/img1*.ads8
||qqq.com/img2/*.ads9
||qqq.com/img3/.*./ads0
||qqq.com/img4/*.*/
||qqq.com/img5/*..*/
||rrr.com/*.php?123
||sss.com^*/img/
||ttt.com/*/ban.js
||uuu.com/*$script

Output

?adver=123.456
aaa.
aaa.
bbb.com
ccc.com
.ads.com
ddd.com
eee.com
ggg.hhh-
ggg.hhh-
ggg.hhh
.ppp
ooo.com
.ads8
qqq.com
.ads9
qqq.com
.
qqq.com
.
qqq.com
..
qqq.com
.php
rrr.com
sss.com
ttt.com
uuu.com

The expected output should be

kkk.lll
ads.mmm.nnn

Potential dependency conflicts between adblock-decoder and urllib3

Hi, as shown in the following full dependency graph of adblock-decoder, pyfunceble-dev requires urllib3 (the latest version), while the installed version of requests(2.23.0) requires urllib3>=1.21.1,<1.26.

According to Pip's “first found wins” installation strategy, urllib3 1.25.8 is the actually installed version.

Although the first found package version urllib3 1.25.8 just satisfies the later dependency constraint (urllib3>=1.21.1,<1.26), it will lead to a build failure once developers release a newer version of urllib3.

Dependency tree--------

adblock-decoder - 1.0.2
| +- pyfunceble-dev(install version:3.1.7 version range:*)
| | +- colorama(install version:0.4.3 version range:*)
| | +- cryptography(install version:2.9 version range:*)
| | | +- cffi(install version:1.14.0 version range:>=1.8)
| | | +- six (install version:1.14.0 version range:>=1.4.1)
| | +- dnspython(install version:1.16.0 version range:*)
| | +- domain2idna(install version:1.9.1 version range:>=1.6.1)
| | | +- colorama(install version:0.4.3 version range:>=0.4.1)
| | | +- setuptools(install version:46.1.3 version range:>=40.8.0)
| | +- pymysql(install version:0.9.3 version range:*)
| | +- python-box(install version:4.2.2 version range:*)
| | | +- ruamel.yaml(install version:0.16.10 version range:*)
| | | +- toml(install version:0.10.0 version range:*)
| | +- python-dotenv(install version:0.12.0 version range:*)
| | | +- typing(install version:3.7.4.1 version range:*)
| | +- pyyaml(install version:5.3.1 version range:*)
| | +- requests(install version:2.23.0 version range:*)
| | | +- certifi(install version:2020.4.5.1 version range:>=2017.4.17)
| | | +- chardet(install version:3.0.4 version range:>=3.0.2,<4)
| | | +- idna(install version:2.9 version range:>=2.5,<3)
| | | +- urllib3(install version:1.25.8 version range:>=1.21.1,<1.26)
| | +- setuptools(install version:46.1.3 version range:*)
| | +- urllib3(install version:1.25.8 version range:*)

Thanks for your attention.
Best,
Neolith

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.