/minimal-webbrowser-adblock

A Minimal Web Browser with Built-in Adblocker in Less Than 100 Lines of Code

Primary LanguageC++GNU General Public License v3.0GPL-3.0

A Minimal QtWebEngine Web Browser with Adblocker

How Does It Work

This is a minimal network filter implementation using QWebEngineUrlRequestInterceptor and QtWebEngine, with AdBlock Plus compatible filters provided by easylist. The parser is currently based on ad-block from Brave, but alternatives might be needed in the future.

Reference:

Dependencies

  • Qt 5.10+ with QtWebEngine module

    On Debian or Ubuntu, this can be done by:

      sudo apt install qtwebengine5-dev qml-module-qtwebengine \ 
      qml-module-qtquick-window2 qml-module-qtquick2 qml-module-qtquick-controls2
    
  • ABP-style parser from Brave's ad-block C++ library

    Checkout this repo:

      git clone https://github.com/penk/minimal-webbrowser-adblock
      cd minimal-webbrowser-adblock
      mkdir -p third_party
    

    Then checkout the following 3 repositories:

      git clone https://github.com/brave/ad-block.git third_party/ad-block 
      git clone https://github.com/brave/hashset-cpp.git third_party/hashset-cpp 
      git clone https://github.com/brave/bloom-filter-cpp.git third_party/bloom-filter-cpp 
    

    And copy all *.h and *.cc to third_party/ad-block:

      cp third_party/hashset-cpp/{*.cc,*.h} third_party/ad-block/
      cp third_party/bloom-filter-cpp/{*.cpp,*.h} third_party/ad-block/
    

Build Instructions

qmake DEFINES+=USE_ADBLOCK
make 

Copyright & License

Copyright © 2021 Penk Chen <penkia@gmail.com>