From ea46d473de2f0753fbb31c5b46ac5338fe5a01e2 Mon Sep 17 00:00:00 2001 From: askiiart <dev@askiiart.net> Date: Sat, 8 Mar 2025 10:59:21 -0600 Subject: [PATCH] initial commit --- .drone.yml | 17 ++++++++++++++ README.md | 27 ++++++++++++++++++++++ allow_dark.patch | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ compilation.sh | 50 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 .drone.yml create mode 100644 README.md create mode 100644 allow_dark.patch create mode 100755 compilation.sh diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..aeaf20c --- /dev/null +++ b/.drone.yml @@ -0,0 +1,17 @@ +kind: pipeline +type: docker +name: default + +steps: + - name: Build librewolf-allow-dark + image: debian + commands: + - '/drone/src/compilation.sh' + volumes: + - name: program-archives + path: /compiled + +volumes: + - name: program-archives + host: + path: /mnt/user/files/repos/archives \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..cb6d6e0 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Librewolf-allow-dark build + +Librewolf with the privacy.override_rfp_for_color_scheme about:config option added, which (if enabled) let's you change the color scheme even if rfp is turned on + +- Builds librewolf-allow-dark and places it in `$COMPILED_DIR/librewolf-allow-dark/librewolf.tar.zst` +- Version file at `$COMPILED_DIR/librewolf-allow-dark/version` + +## Archive details + +TODO: **FIX THIS SECTION** + +``` +. +├── polycat +└── polycat.ttf +``` + +Recommended: + +| File | Location | Permissions | +| --------------- | -------------------------------------- | ----------- | +| `./polycat` | `/usr/bin/polycat` | 755 | +| `./polycat.ttf` | `/usr/share/fonts/polycat/polycat.ttf` | 644 | + +--- + +Based on the [librewolf-allow-dark](https://aur.archlinux.org/packages/librewolf-allow-dark) AUR package, directly copying `allow_dark.patch` from it. diff --git a/allow_dark.patch b/allow_dark.patch new file mode 100644 index 0000000..b56ca53 --- /dev/null +++ b/allow_dark.patch @@ -0,0 +1,58 @@ +diff -ru a/browser/components/preferences/main.js b/browser/components/preferences/main.js +--- a/browser/components/preferences/main.js ++++ b/browser/components/preferences/main.js +@@ -4287,6 +4287,7 @@ + FORCED_COLORS_QUERY.addEventListener("change", this); + Services.prefs.addObserver(PREF_USE_SYSTEM_COLORS, this); + Services.prefs.addObserver("privacy.resistFingerprinting", this); ++ Services.prefs.addObserver("privacy.override_rfp_for_color_scheme", this); + Services.obs.addObserver(this, "look-and-feel-changed"); + this._update(); + }, +@@ -4324,6 +4325,7 @@ + destroy() { + Services.prefs.removeObserver(PREF_USE_SYSTEM_COLORS, this); + Services.prefs.removeObserver("privacy.resistFingerprinting", this); ++ Services.prefs.removeObserver("privacy.override_rfp_for_color_scheme", this); + Services.obs.removeObserver(this, "look-and-feel-changed"); + FORCED_COLORS_QUERY.removeEventListener("change", this); + }, +@@ -4365,7 +4367,8 @@ + this.warning.hidden = !forcingColorsAndNoColorSchemeSupport; + + document.getElementById("web-appearance-rfp-warning")?.remove(); +- if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) { ++ if (Services.prefs.getBoolPref("privacy.resistFingerprinting") && ++ !Services.prefs.getBoolPref("privacy.override_rfp_for_color_scheme")) { + document.getElementById("web-appearance-chooser").style.opacity = 0.3; + document.getElementById("web-appearance-chooser").style.pointerEvents = "none"; + const infoBox = document.createElement("div"); +diff -ru a/dom/base/Document.cpp b/dom/base/Document.cpp +--- a/dom/base/Document.cpp ++++ b/dom/base/Document.cpp +@@ -19620,7 +19620,8 @@ + + ColorScheme Document::PreferredColorScheme(IgnoreRFP aIgnoreRFP) const { + if (ShouldResistFingerprinting(RFPTarget::CSSPrefersColorScheme) && +- aIgnoreRFP == IgnoreRFP::No) { ++ aIgnoreRFP == IgnoreRFP::No && ++ !StaticPrefs::privacy_override_rfp_for_color_scheme()) { + return ColorScheme::Light; + } + +diff -ru a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml +--- a/modules/libpref/init/StaticPrefList.yaml ++++ b/modules/libpref/init/StaticPrefList.yaml +@@ -15246,6 +15246,12 @@ + value: false + mirror: always + ++# Allows overriding RFP for only the dark/light pref ++- name: privacy.override_rfp_for_color_scheme ++ type: bool ++ value: false ++ mirror: always ++ + # Enforce tracking protection in all modes. + - name: privacy.trackingprotection.enabled + type: bool \ No newline at end of file diff --git a/compilation.sh b/compilation.sh new file mode 100755 index 0000000..8f25ee2 --- /dev/null +++ b/compilation.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -euo pipefail + +program_name="librewolf-allow-dark" +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) + +# prep +workdir=$(mktemp -d) +built_dir=${COMPILED_DIR:-/compiled}/$program_name +mkdir -p $built_dir +apt update && apt install curl jq -y + +# check whether it's up-to-date +version_file=$built_dir/version +touch $version_file +version=$(curl 'https://gitlab.com/api/v4/projects/32320088/packages?sort=desc' | jq '.[0].version' -r) +if grep -q $version $version_file; then + echo "already up to date, exiting" + exit +fi + +# get source and build +cd $workdir +curl "https://gitlab.com/api/v4/projects/32320088/packages/generic/librewolf-source/$version/librewolf-$version.source.tar.gz" -LO +tar -xzf librewolf-136.0-2.source.tar.gz +cd ./librewolf-$version/ +# get build deps +apt install python3 python3-pip wget patch -y +# apply allow dark patch +patch -p1 -i $SCRIPT_DIR/allow_dark.patch +export MOZ_BUILD_DATE="$(date -u${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH} +%Y%m%d%H%M%S)" +# not entirely sure what this does, but it's what librewolf-allow-dark does +export MOZ_NOSPAM=1 +# build +./mach --no-interactive bootstrap --application-choice=browser +./lw/setup-wasi-linux.sh +./mach build +./mach package + + +# build .tar.zst archive +cd $workdir +tar -xvf ./librewolf-$version/obj-x86_64-pc-linux-gnu/dist/librewolf-$version.en-US.linux-x86_64.tar.xz +cd ./librewolf/ +apt install zstd -y +mkdir -p $built_dir +tar --zstd -cf $built_dir/$program_name.tar.zst . +echo $version >$version_file + +echo "$program_name updated to $version"