initial commit

This commit is contained in:
askiiart 2025-03-08 10:59:21 -06:00
commit ea46d473de
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
4 changed files with 152 additions and 0 deletions

17
.drone.yml Normal file
View file

@ -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

27
README.md Normal file
View file

@ -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.

58
allow_dark.patch Normal file
View file

@ -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

50
compilation.sh Executable file
View file

@ -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"