This Development Guide contains development notes that help to ease up getting familiar with the codebase, its tools and the process of how the Defiant Browser Extension can be debugged, and developed on.
- Install node.js latest (minimum version
12). - Install Ungoogled Chromium latest (minimum version
70). - Install Firefox latest (minimum version
90).
The Browser Extension requires esbuild in order to generate the Content Scripts
that clean up the DOM via MutationObserver. As the Content Scripts currently
are the only part that's not EcmaScript Module (ESM) syntax compatible, they need
to be bundled as standalone ES5 files without any import statement in them.
cd /path/to/defiant;
# Install all dependencies
npm install;# Build the Extension
node ./defiant/make.mjs;
# Spawn a pre-patched-Preferences Chromium Sandbox in Developer Mode
# (will spawn Chromium two times due to lack of --developer-mode CLI flags)
node ./defiant/make.mjs test;Notes: The test Step will do the following, as there's a lack of CLI flags to ease
up Chromium usage. It requires a graphical environment (Xorg or Wayland) to work:
- Re-Build the Content Scripts.
- Create a temporary Profile Folder in
/tmp/defiant-chromium-profile-*(viamktemp()). - Spawn Chromium with
--user-data-dirset to/tmp/defiant-chromium-profile-*. - Kill Chromium.
- Patch the
/tmp/defiant-chromium-profile-*/Default/Preferencesfile to setextensions.ui.developer_modetotrue. - Spawn Chromium again with
--user-data-dirset to/tmp/defiant-chromium-profile-*and--load-extensionset to the/defiant/manifest.jsoncontaining folder in order to load Defiant as anUnpacked Extension. - The User can now use the Browser Extension in an isolated manner.
Debugging Hints:
-
The
background.htmlPage runs the globalDEFIANTinstance, which contains the Interceptor that filters Network Requests. -
The
BooleanDEFIANT.settings.debugproperty can be changed to show debug messages. -
The
background.htmlPage exposes a globalconsolevariable that can be used from anywhere else using theAPI['extension'].getBackgroundPage().consolereference. -
(Chromium) Syntax Errors are available in the
chrome.runtime.lastErrorreference or in thechrome://extensionsPage via a click on theErrorsbutton.
This Browser Extension can be built for both Chromium (Chrome) based Browsers
and Firefox based Browsers, and is only verified to be working on an up-to-date
ArchLinux host build system.
-
The
SIGNING_KEYenvironment variable can be used to use a custom/path/to/certificate.pemthat is used to sign the generated Chromium Extension (.crxfile). -
The
STEALTHenvironment variable can be used to update/import shared implementations and Settings (such as theblockers.json,filters.jsonandidentities.json) from the Vendor Profile folder from Tholian Stealth.
cd /path/to/defiant;
# Build and Pack the Extension
node ./defiant/make.mjs pack /tmp/sandbox;
# Chromium Extension
ls /tmp/sandbox/defiant-*.crx;
# Firefox Extension
ls /tmp/sandbox/defiant-*.xpi;TODO: Release Instructions (to push Release to GitHub and Website)