feat: LeechBlock default config, Chrome repo, nsswitch fixes, extended checker

- Add leechblock_defaults.js with pre-configured blocking rules matching
  hosts/install.sh (YouTube, food delivery, fast food — 3 block sets)
- install_leechblock.sh: switch to LeechBlockNG-chrome repo, download
  jQuery UI, inject defaults.js into extension, patch background.js to
  seed storage on first run, replace browser binary in-place
- remove_guest_mode.sh: fix associative array key spacing
- enforce-nsswitch.sh: handle 'resolve' without 'dns' in emergency fix
- setup_hosts_guard.sh: ensure 'files' in nsswitch hosts line before
  snapshotting, remove erroneous 'local' outside function
- check_and_enable_services.sh: extend from 5 to 12 services, add
  nsswitch.conf validation and auto-fix
This commit is contained in:
Krzysztof Rudnicki 2026-02-20 20:24:13 +01:00
parent 4c4e966e5f
commit 09e85cd914
6 changed files with 1390 additions and 717 deletions

View File

@ -69,9 +69,15 @@ if ! validate_hosts_line "$current_hosts_line"; then
log "ERROR: Canonical source not found at $CANONICAL_SOURCE" log "ERROR: Canonical source not found at $CANONICAL_SOURCE"
# Emergency fix: add "files" back to hosts line # Emergency fix: add "files" back to hosts line
chattr -i "$TARGET" 2>/dev/null || true chattr -i "$TARGET" 2>/dev/null || true
if grep -q '^hosts:.*dns' "$TARGET"; then
sed -i 's/^hosts:\(.*\)dns/hosts:\1files dns/' "$TARGET" sed -i 's/^hosts:\(.*\)dns/hosts:\1files dns/' "$TARGET"
elif grep -q '^hosts:.*resolve' "$TARGET"; then
sed -i 's/^hosts:\(.*\)resolve/hosts: files\1resolve/' "$TARGET"
else
sed -i 's/^hosts:/hosts: files/' "$TARGET"
fi
chattr +i "$TARGET" 2>/dev/null || true chattr +i "$TARGET" 2>/dev/null || true
log "Emergency fix applied: added 'files' before 'dns'" log "Emergency fix applied: added 'files' to hosts line"
fi fi
exit 0 exit 0
fi fi

View File

@ -394,6 +394,22 @@ if [[ $ENABLE_NSSWITCH -eq 1 ]]; then
msg "Installing nsswitch enforcement script -> $INSTALL_ENFORCE_NSSWITCH" msg "Installing nsswitch enforcement script -> $INSTALL_ENFORCE_NSSWITCH"
run install -m 755 "$TEMPLATE_ENFORCE_NSSWITCH" "$INSTALL_ENFORCE_NSSWITCH" run install -m 755 "$TEMPLATE_ENFORCE_NSSWITCH" "$INSTALL_ENFORCE_NSSWITCH"
# Ensure 'files' is present in the hosts line before snapshotting
if [[ -f "$NSSWITCH" ]]; then
hosts_line=$(grep '^hosts:' "$NSSWITCH" 2>/dev/null || echo "")
if [[ -n "$hosts_line" ]] && ! echo "$hosts_line" | grep -qw 'files'; then
msg "Adding 'files' to nsswitch.conf hosts line (was: $hosts_line)"
if echo "$hosts_line" | grep -qw 'resolve'; then
run sed -i 's/^hosts:\(.*\)resolve/hosts: files\1resolve/' "$NSSWITCH"
elif echo "$hosts_line" | grep -qw 'dns'; then
run sed -i 's/^hosts:\(.*\)dns/hosts:\1files dns/' "$NSSWITCH"
else
run sed -i 's/^hosts:/hosts: files/' "$NSSWITCH"
fi
msg "nsswitch.conf hosts line fixed: $(grep '^hosts:' "$NSSWITCH")"
fi
fi
# Create nsswitch canonical snapshot if needed # Create nsswitch canonical snapshot if needed
if [[ -f "$NSSWITCH" ]]; then if [[ -f "$NSSWITCH" ]]; then
if [[ ! -f "$CANON_NSSWITCH" ]]; then if [[ ! -f "$CANON_NSSWITCH" ]]; then

View File

@ -37,6 +37,13 @@ PERIODIC_SYSTEM_SCRIPT="$CONFIG_DIR/scripts/setup_periodic_system.sh"
HOSTS_INSTALL_SCRIPT="$CONFIG_DIR/hosts/install.sh" HOSTS_INSTALL_SCRIPT="$CONFIG_DIR/hosts/install.sh"
HOSTS_GUARD_SCRIPT="$CONFIG_DIR/hosts/guard/setup_hosts_guard.sh" HOSTS_GUARD_SCRIPT="$CONFIG_DIR/hosts/guard/setup_hosts_guard.sh"
HOSTS_PACMAN_HOOKS_SCRIPT="$CONFIG_DIR/hosts/guard/install_pacman_hooks.sh" HOSTS_PACMAN_HOOKS_SCRIPT="$CONFIG_DIR/hosts/guard/install_pacman_hooks.sh"
THESIS_TRACKER_SCRIPT="$CONFIG_DIR/scripts/digital_wellbeing/setup_thesis_work_tracker.sh"
FOCUS_MODE_SCRIPT="$CONFIG_DIR/scripts/digital_wellbeing/install_focus_mode_daemon.sh"
COMPULSIVE_BLOCK_SCRIPT="$CONFIG_DIR/scripts/digital_wellbeing/block_compulsive_opening.sh"
THORIUM_STARTUP_SCRIPT="$CONFIG_DIR/scripts/setup_thorium_startup.sh"
LEECHBLOCK_SCRIPT="$CONFIG_DIR/scripts/digital_wellbeing/install_leechblock.sh"
REMOVE_GUEST_MODE_SCRIPT="$CONFIG_DIR/scripts/digital_wellbeing/remove_guest_mode.sh"
VBOX_HOSTS_SCRIPT="$CONFIG_DIR/scripts/digital_wellbeing/virtualbox/enforce_vbox_hosts.sh"
###################################################################### ######################################################################
# Helpers # Helpers
@ -65,7 +72,7 @@ require_root() {
} }
usage() { usage() {
cat << 'EOF' cat <<'EOF'
Check and Enable Digital Wellbeing Services Check and Enable Digital Wellbeing Services
============================================ ============================================
@ -82,6 +89,13 @@ Services checked:
3. Startup monitor - PC startup time monitoring service 3. Startup monitor - PC startup time monitoring service
4. Periodic systems - Hourly maintenance timer and hosts monitor 4. Periodic systems - Hourly maintenance timer and hosts monitor
5. Hosts and guards - /etc/hosts blocking and protection layers 5. Hosts and guards - /etc/hosts blocking and protection layers
6. Thesis work tracker - Work quota enforcement with distraction blocking
7. Focus mode daemon - Steam/Browser mutual exclusion (user service)
8. Compulsive blocker - Limits messaging apps to one launch per hour
9. Thorium startup - Auto-launch Thorium with Fitatu on boot
10. LeechBlock - Browser extension for site blocking
11. Guest mode removal - Disable Chromium guest mode via policy
12. VirtualBox hosts - Enforce /etc/hosts inside VMs
EOF EOF
} }
@ -150,7 +164,7 @@ report_and_fix() {
run bash "$setup_script" "${script_args[@]}" run bash "$setup_script" "${script_args[@]}"
((FIXES_APPLIED++)) || true ((FIXES_APPLIED++)) || true
# Re-verify after fix # Re-verify after fix
if [[ $DRY_RUN -eq 0 && -n $verify_service ]] && systemctl is-enabled "$verify_service" &> /dev/null; then if [[ $DRY_RUN -eq 0 && -n $verify_service ]] && systemctl is-enabled "$verify_service" &>/dev/null; then
_status="ok" _status="ok"
fi fi
else else
@ -244,14 +258,14 @@ check_midnight_shutdown() {
local issues=() local issues=()
# Check timer # Check timer
if systemctl is-enabled day-specific-shutdown.timer &> /dev/null; then if systemctl is-enabled day-specific-shutdown.timer &>/dev/null; then
msg "day-specific-shutdown.timer is enabled" msg "day-specific-shutdown.timer is enabled"
else else
issues+=("day-specific-shutdown.timer is not enabled") issues+=("day-specific-shutdown.timer is not enabled")
status="error" status="error"
fi fi
if systemctl is-active day-specific-shutdown.timer &> /dev/null; then if systemctl is-active day-specific-shutdown.timer &>/dev/null; then
msg "day-specific-shutdown.timer is active" msg "day-specific-shutdown.timer is active"
else else
issues+=("day-specific-shutdown.timer is not active") issues+=("day-specific-shutdown.timer is not active")
@ -288,14 +302,14 @@ check_startup_monitor() {
local issues=() local issues=()
# Check timer (the timer triggers the service, so we check the timer) # Check timer (the timer triggers the service, so we check the timer)
if systemctl is-enabled pc-startup-monitor.timer &> /dev/null; then if systemctl is-enabled pc-startup-monitor.timer &>/dev/null; then
msg "pc-startup-monitor.timer is enabled" msg "pc-startup-monitor.timer is enabled"
else else
issues+=("pc-startup-monitor.timer is not enabled") issues+=("pc-startup-monitor.timer is not enabled")
status="error" status="error"
fi fi
if systemctl is-active pc-startup-monitor.timer &> /dev/null; then if systemctl is-active pc-startup-monitor.timer &>/dev/null; then
msg "pc-startup-monitor.timer is active" msg "pc-startup-monitor.timer is active"
else else
issues+=("pc-startup-monitor.timer is not active") issues+=("pc-startup-monitor.timer is not active")
@ -331,14 +345,14 @@ check_periodic_systems() {
local issues=() local issues=()
# Check timer # Check timer
if systemctl is-enabled periodic-system-maintenance.timer &> /dev/null; then if systemctl is-enabled periodic-system-maintenance.timer &>/dev/null; then
msg "periodic-system-maintenance.timer is enabled" msg "periodic-system-maintenance.timer is enabled"
else else
issues+=("periodic-system-maintenance.timer is not enabled") issues+=("periodic-system-maintenance.timer is not enabled")
status="error" status="error"
fi fi
if systemctl is-active periodic-system-maintenance.timer &> /dev/null; then if systemctl is-active periodic-system-maintenance.timer &>/dev/null; then
msg "periodic-system-maintenance.timer is active" msg "periodic-system-maintenance.timer is active"
else else
issues+=("periodic-system-maintenance.timer is not active") issues+=("periodic-system-maintenance.timer is not active")
@ -346,7 +360,7 @@ check_periodic_systems() {
fi fi
# Check startup service # Check startup service
if systemctl is-enabled periodic-system-startup.service &> /dev/null; then if systemctl is-enabled periodic-system-startup.service &>/dev/null; then
msg "periodic-system-startup.service is enabled" msg "periodic-system-startup.service is enabled"
else else
issues+=("periodic-system-startup.service is not enabled") issues+=("periodic-system-startup.service is not enabled")
@ -354,14 +368,14 @@ check_periodic_systems() {
fi fi
# Check hosts file monitor # Check hosts file monitor
if systemctl is-enabled hosts-file-monitor.service &> /dev/null; then if systemctl is-enabled hosts-file-monitor.service &>/dev/null; then
msg "hosts-file-monitor.service is enabled" msg "hosts-file-monitor.service is enabled"
else else
issues+=("hosts-file-monitor.service is not enabled") issues+=("hosts-file-monitor.service is not enabled")
status="error" status="error"
fi fi
if systemctl is-active hosts-file-monitor.service &> /dev/null; then if systemctl is-active hosts-file-monitor.service &>/dev/null; then
msg "hosts-file-monitor.service is active" msg "hosts-file-monitor.service is active"
else else
issues+=("hosts-file-monitor.service is not active") issues+=("hosts-file-monitor.service is not active")
@ -391,7 +405,7 @@ check_hosts() {
# Check /etc/hosts exists and has content # Check /etc/hosts exists and has content
if [[ -f /etc/hosts ]]; then if [[ -f /etc/hosts ]]; then
local line_count local line_count
line_count=$(wc -l < /etc/hosts) line_count=$(wc -l </etc/hosts)
if [[ $line_count -gt 100 ]]; then if [[ $line_count -gt 100 ]]; then
msg "/etc/hosts exists with $line_count lines (StevenBlack list likely installed)" msg "/etc/hosts exists with $line_count lines (StevenBlack list likely installed)"
else else
@ -405,7 +419,7 @@ check_hosts() {
# Check if hosts file is immutable # Check if hosts file is immutable
local attrs local attrs
attrs=$(lsattr /etc/hosts 2> /dev/null | cut -d' ' -f1 || echo "") attrs=$(lsattr /etc/hosts 2>/dev/null | cut -d' ' -f1 || echo "")
if [[ $attrs == *"i"* ]]; then if [[ $attrs == *"i"* ]]; then
msg "/etc/hosts has immutable attribute set" msg "/etc/hosts has immutable attribute set"
else else
@ -422,14 +436,14 @@ check_hosts() {
fi fi
# Check hosts guard path watcher # Check hosts guard path watcher
if systemctl is-enabled hosts-guard.path &> /dev/null; then if systemctl is-enabled hosts-guard.path &>/dev/null; then
msg "hosts-guard.path is enabled" msg "hosts-guard.path is enabled"
else else
issues+=("hosts-guard.path is not enabled") issues+=("hosts-guard.path is not enabled")
status="error" status="error"
fi fi
if systemctl is-active hosts-guard.path &> /dev/null; then if systemctl is-active hosts-guard.path &>/dev/null; then
msg "hosts-guard.path is active" msg "hosts-guard.path is active"
else else
issues+=("hosts-guard.path is not active") issues+=("hosts-guard.path is not active")
@ -437,7 +451,7 @@ check_hosts() {
fi fi
# Check hosts bind mount service # Check hosts bind mount service
if systemctl is-enabled hosts-bind-mount.service &> /dev/null; then if systemctl is-enabled hosts-bind-mount.service &>/dev/null; then
msg "hosts-bind-mount.service is enabled" msg "hosts-bind-mount.service is enabled"
else else
issues+=("hosts-bind-mount.service is not enabled") issues+=("hosts-bind-mount.service is not enabled")
@ -476,6 +490,29 @@ check_hosts() {
status="warning" status="warning"
fi fi
# Check nsswitch.conf has 'files' in hosts line
if [[ -f /etc/nsswitch.conf ]]; then
local nsswitch_hosts
nsswitch_hosts=$(grep '^hosts:' /etc/nsswitch.conf 2>/dev/null || echo "")
if echo "$nsswitch_hosts" | grep -qw 'files'; then
msg "nsswitch.conf hosts line includes 'files'"
else
issues+=("nsswitch.conf hosts line missing 'files' — /etc/hosts is bypassed!")
status="error"
fi
else
issues+=("/etc/nsswitch.conf does not exist")
status="error"
fi
# Check nsswitch guard
if systemctl is-enabled nsswitch-guard.path &>/dev/null; then
msg "nsswitch-guard.path is enabled"
else
issues+=("nsswitch-guard.path is not enabled")
status="warning"
fi
# Report issues # Report issues
if [[ $status != "ok" ]]; then if [[ $status != "ok" ]]; then
for issue in "${issues[@]}"; do for issue in "${issues[@]}"; do
@ -488,8 +525,26 @@ check_hosts() {
((ISSUES_FOUND++)) || true ((ISSUES_FOUND++)) || true
if [[ $STATUS_ONLY -eq 0 ]]; then if [[ $STATUS_ONLY -eq 0 ]]; then
# Fix nsswitch.conf if 'files' is missing (critical — hosts bypass)
if [[ -f /etc/nsswitch.conf ]]; then
local nsswitch_hosts_fix
nsswitch_hosts_fix=$(grep '^hosts:' /etc/nsswitch.conf 2>/dev/null || echo "")
if [[ -n $nsswitch_hosts_fix ]] && ! echo "$nsswitch_hosts_fix" | grep -qw 'files'; then
note "Fixing nsswitch.conf — adding 'files' to hosts line..."
if echo "$nsswitch_hosts_fix" | grep -qw 'resolve'; then
run sed -i 's/^hosts:\(.*\)resolve/hosts: files\1resolve/' /etc/nsswitch.conf
elif echo "$nsswitch_hosts_fix" | grep -qw 'dns'; then
run sed -i 's/^hosts:\(.*\)dns/hosts:\1files dns/' /etc/nsswitch.conf
else
run sed -i 's/^hosts:/hosts: files/' /etc/nsswitch.conf
fi
((FIXES_APPLIED++)) || true
msg "nsswitch.conf fixed: $(grep '^hosts:' /etc/nsswitch.conf)"
fi
fi
# Run hosts install first # Run hosts install first
if [[ ! -f /etc/hosts ]] || [[ $(wc -l < /etc/hosts) -lt 100 ]]; then if [[ ! -f /etc/hosts ]] || [[ $(wc -l </etc/hosts) -lt 100 ]]; then
note "Installing hosts file..." note "Installing hosts file..."
if [[ -f $HOSTS_INSTALL_SCRIPT ]]; then if [[ -f $HOSTS_INSTALL_SCRIPT ]]; then
run bash "$HOSTS_INSTALL_SCRIPT" run bash "$HOSTS_INSTALL_SCRIPT"
@ -500,7 +555,7 @@ check_hosts() {
fi fi
# Run hosts guard setup # Run hosts guard setup
if ! systemctl is-enabled hosts-guard.path &> /dev/null || [[ ! -f /usr/local/sbin/enforce-hosts.sh ]]; then if ! systemctl is-enabled hosts-guard.path &>/dev/null || [[ ! -f /usr/local/sbin/enforce-hosts.sh ]]; then
note "Setting up hosts guard..." note "Setting up hosts guard..."
if [[ -f $HOSTS_GUARD_SCRIPT ]]; then if [[ -f $HOSTS_GUARD_SCRIPT ]]; then
run bash "$HOSTS_GUARD_SCRIPT" run bash "$HOSTS_GUARD_SCRIPT"
@ -523,7 +578,7 @@ check_hosts() {
# Re-verify after fixes # Re-verify after fixes
if [[ $DRY_RUN -eq 0 ]]; then if [[ $DRY_RUN -eq 0 ]]; then
if systemctl is-enabled hosts-guard.path &> /dev/null && if systemctl is-enabled hosts-guard.path &>/dev/null &&
[[ -f /usr/local/sbin/enforce-hosts.sh ]] && [[ -f /usr/local/sbin/enforce-hosts.sh ]] &&
[[ -f /usr/local/share/locked-hosts ]] && [[ -f /usr/local/share/locked-hosts ]] &&
[[ -f /etc/pacman.d/hooks/10-unlock-etc-hosts.hook ]]; then [[ -f /etc/pacman.d/hooks/10-unlock-etc-hosts.hook ]]; then
@ -537,6 +592,356 @@ check_hosts() {
SERVICE_STATUS["hosts"]=$status SERVICE_STATUS["hosts"]=$status
} }
check_thesis_tracker() {
header "Thesis Work Tracker"
local status="ok"
local issues=()
local user="${SUDO_USER:-$USER}"
# Check service
if systemctl is-enabled "thesis-work-tracker@${user}.service" &>/dev/null; then
msg "thesis-work-tracker@${user}.service is enabled"
else
issues+=("thesis-work-tracker@${user}.service is not enabled")
status="error"
fi
if systemctl is-active "thesis-work-tracker@${user}.service" &>/dev/null; then
msg "thesis-work-tracker@${user}.service is active"
else
issues+=("thesis-work-tracker@${user}.service is not active")
if [[ $status != "error" ]]; then status="warning"; fi
fi
# Check tracker script
if [[ -f /usr/local/bin/thesis_work_tracker.sh ]]; then
msg "Tracker script exists at /usr/local/bin/thesis_work_tracker.sh"
else
issues+=("thesis_work_tracker.sh not found in /usr/local/bin")
status="error"
fi
# Check status script
if [[ -f /usr/local/bin/thesis_work_status.sh ]]; then
msg "Status script exists at /usr/local/bin/thesis_work_status.sh"
else
issues+=("thesis_work_status.sh not found in /usr/local/bin")
if [[ $status != "error" ]]; then status="warning"; fi
fi
# Check state directory
if [[ -d /var/lib/thesis-work-tracker ]]; then
msg "State directory exists"
else
issues+=("State directory /var/lib/thesis-work-tracker missing")
status="error"
fi
report_and_fix issues status "thesis_tracker" \
"Setting up thesis work tracker..." \
"$THESIS_TRACKER_SCRIPT" \
"thesis-work-tracker@${user}.service"
}
check_focus_mode() {
header "Focus Mode Daemon (Steam/Browser Mutual Exclusion)"
local status="ok"
local issues=()
# This is a user service, so check as the actual user
local user="${SUDO_USER:-$USER}"
# Check if daemon script is installed
if [[ -f /usr/local/bin/focus-mode-daemon ]]; then
msg "Focus mode daemon installed at /usr/local/bin/focus-mode-daemon"
else
issues+=("focus-mode-daemon not found in /usr/local/bin")
status="error"
fi
# Check user service (must run as actual user)
if sudo -u "$user" systemctl --user is-enabled focus-mode.service &>/dev/null 2>&1; then
msg "focus-mode.service is enabled (user service)"
else
issues+=("focus-mode.service is not enabled (user service)")
status="error"
fi
if sudo -u "$user" systemctl --user is-active focus-mode.service &>/dev/null 2>&1; then
msg "focus-mode.service is active"
else
issues+=("focus-mode.service is not active")
if [[ $status != "error" ]]; then status="warning"; fi
fi
# Report and fix - focus mode install needs to run as user
if [[ $status != "ok" ]]; then
for issue in "${issues[@]}"; do
if [[ $status == "error" ]]; then
err "$issue"
else
warn "$issue"
fi
done
((ISSUES_FOUND++)) || true
if [[ $STATUS_ONLY -eq 0 && $status == "error" ]]; then
note "Installing focus mode daemon..."
if [[ -f $FOCUS_MODE_SCRIPT ]]; then
run sudo -u "$user" bash "$FOCUS_MODE_SCRIPT" install
((FIXES_APPLIED++)) || true
else
err "Install script not found: $FOCUS_MODE_SCRIPT"
fi
fi
fi
SERVICE_STATUS["focus_mode"]=$status
}
check_compulsive_blocker() {
header "Compulsive Opening Blocker"
local status="ok"
local issues=()
# Check if main script is installed
if [[ -f /usr/local/bin/block-compulsive-opening.sh ]]; then
msg "Blocker script installed at /usr/local/bin/block-compulsive-opening.sh"
else
issues+=("block-compulsive-opening.sh not found in /usr/local/bin")
status="error"
fi
# Check if wrappers are installed for known apps
local checked_any=false
for app in beeper signal-desktop discord; do
local wrapper_path="/usr/bin/$app"
if [[ -f "${wrapper_path}.orig" ]] || [[ -L "$wrapper_path" ]]; then
if [[ -f "${wrapper_path}.orig" ]]; then
msg "$app wrapper installed (original backed up)"
checked_any=true
fi
elif command -v "$app" &>/dev/null; then
issues+=("$app is installed but wrapper not applied")
if [[ $status != "error" ]]; then status="warning"; fi
checked_any=true
fi
done
if [[ $checked_any == false && $status == "ok" ]]; then
note "No target apps (beeper, signal-desktop, discord) found on system"
fi
if [[ $status != "ok" ]]; then
for issue in "${issues[@]}"; do
if [[ $status == "error" ]]; then
err "$issue"
else
warn "$issue"
fi
done
((ISSUES_FOUND++)) || true
if [[ $STATUS_ONLY -eq 0 && $status == "error" ]]; then
note "Installing compulsive opening blocker..."
if [[ -f $COMPULSIVE_BLOCK_SCRIPT ]]; then
run bash "$COMPULSIVE_BLOCK_SCRIPT" install
((FIXES_APPLIED++)) || true
else
err "Install script not found: $COMPULSIVE_BLOCK_SCRIPT"
fi
fi
fi
SERVICE_STATUS["compulsive_blocker"]=$status
}
check_thorium_startup() {
header "Thorium Browser Auto-Startup (Fitatu)"
local status="ok"
local issues=()
# Check system service
if systemctl is-enabled thorium-fitatu-startup.service &>/dev/null; then
msg "thorium-fitatu-startup.service is enabled (system)"
else
# Check user service as fallback
local user="${SUDO_USER:-$USER}"
if sudo -u "$user" systemctl --user is-enabled thorium-fitatu-startup.service &>/dev/null 2>&1; then
msg "thorium-fitatu-startup.service is enabled (user service)"
else
issues+=("thorium-fitatu-startup.service is not enabled")
status="error"
fi
fi
# Check if thorium is available
if command -v thorium-browser &>/dev/null || [[ -x /opt/thorium/thorium ]] || [[ -x /opt/thorium-browser/thorium-browser ]]; then
msg "Thorium browser is installed"
else
issues+=("Thorium browser not found")
if [[ $status != "error" ]]; then status="warning"; fi
fi
report_and_fix issues status "thorium_startup" \
"Setting up Thorium startup..." \
"$THORIUM_STARTUP_SCRIPT" \
"thorium-fitatu-startup.service"
}
check_leechblock() {
header "LeechBlock Browser Extension"
local status="ok"
local issues=()
local user="${SUDO_USER:-$USER}"
local user_home
user_home="/home/$user"
# Check if LeechBlock is installed for any browser
local leechblock_dir="$user_home/.local/share/leechblockng"
if [[ -d $leechblock_dir ]]; then
msg "LeechBlock directory exists at $leechblock_dir"
else
issues+=("LeechBlock not found at $leechblock_dir")
status="error"
fi
# Check for browser wrappers with LeechBlock
local found_wrapper=false
for desktop_file in "$user_home/.local/share/applications/"*leechblock* "$user_home/.local/share/applications/"*LeechBlock*; do
if [[ -f $desktop_file ]]; then
msg "LeechBlock desktop entry found: $(basename "$desktop_file")"
found_wrapper=true
fi
done
if [[ $found_wrapper == false && -d $leechblock_dir ]]; then
issues+=("No LeechBlock desktop entries found")
if [[ $status != "error" ]]; then status="warning"; fi
fi
if [[ $status != "ok" ]]; then
for issue in "${issues[@]}"; do
if [[ $status == "error" ]]; then
err "$issue"
else
warn "$issue"
fi
done
((ISSUES_FOUND++)) || true
if [[ $STATUS_ONLY -eq 0 && $status == "error" ]]; then
note "Installing LeechBlock..."
if [[ -f $LEECHBLOCK_SCRIPT ]]; then
run sudo -u "$user" bash "$LEECHBLOCK_SCRIPT"
((FIXES_APPLIED++)) || true
else
err "Install script not found: $LEECHBLOCK_SCRIPT"
fi
fi
fi
SERVICE_STATUS["leechblock"]=$status
}
check_guest_mode_removal() {
header "Chromium Guest Mode Removal"
local status="ok"
local issues=()
# Check if managed policy files exist for any browser
local policy_found=false
for policy_dir in \
/etc/chromium/policies/managed \
/etc/opt/chrome/policies/managed \
/etc/thorium/policies/managed \
/etc/brave/policies/managed; do
if [[ -d $policy_dir ]] && ls "$policy_dir"/*.json &>/dev/null 2>&1; then
# Check for guest mode policy
if grep -rl 'BrowserGuestModeEnabled' "$policy_dir" &>/dev/null 2>&1; then
msg "Guest mode policy found in $policy_dir"
policy_found=true
fi
fi
done
if [[ $policy_found == false ]]; then
# Only flag as issue if a Chromium browser is actually installed
if command -v thorium-browser &>/dev/null || command -v chromium &>/dev/null || command -v google-chrome &>/dev/null || command -v brave-browser &>/dev/null; then
issues+=("No guest mode removal policies found for installed browsers")
status="error"
else
note "No Chromium-based browsers detected, skipping"
fi
fi
if [[ $status != "ok" ]]; then
for issue in "${issues[@]}"; do
err "$issue"
done
((ISSUES_FOUND++)) || true
if [[ $STATUS_ONLY -eq 0 ]]; then
note "Removing guest mode..."
if [[ -f $REMOVE_GUEST_MODE_SCRIPT ]]; then
run bash "$REMOVE_GUEST_MODE_SCRIPT"
((FIXES_APPLIED++)) || true
else
err "Script not found: $REMOVE_GUEST_MODE_SCRIPT"
fi
fi
fi
SERVICE_STATUS["guest_mode_removal"]=$status
}
check_vbox_hosts() {
header "VirtualBox Hosts Enforcement"
local status="ok"
local issues=()
# Only check if VirtualBox is installed
if ! command -v VBoxManage &>/dev/null; then
note "VirtualBox not installed, skipping"
SERVICE_STATUS["vbox_hosts"]="skipped"
return
fi
# Check if enforcement marker exists
if [[ -f /var/lib/vbox-hosts-enforced ]]; then
msg "VirtualBox hosts enforcement marker exists"
else
issues+=("VirtualBox hosts enforcement not applied")
status="error"
fi
if [[ $status != "ok" ]]; then
for issue in "${issues[@]}"; do
err "$issue"
done
((ISSUES_FOUND++)) || true
if [[ $STATUS_ONLY -eq 0 ]]; then
note "Enforcing hosts in VirtualBox VMs..."
if [[ -f $VBOX_HOSTS_SCRIPT ]]; then
run bash "$VBOX_HOSTS_SCRIPT"
((FIXES_APPLIED++)) || true
else
err "Script not found: $VBOX_HOSTS_SCRIPT"
fi
fi
fi
SERVICE_STATUS["vbox_hosts"]=$status
}
###################################################################### ######################################################################
# Summary # Summary
###################################################################### ######################################################################
@ -547,13 +952,14 @@ print_summary() {
printf "%-25s %s\n" "Service" "Status" printf "%-25s %s\n" "Service" "Status"
printf "%-25s %s\n" "-------" "------" printf "%-25s %s\n" "-------" "------"
for service in pacman_wrapper midnight_shutdown startup_monitor periodic_systems hosts; do for service in pacman_wrapper midnight_shutdown startup_monitor periodic_systems hosts thesis_tracker focus_mode compulsive_blocker thorium_startup leechblock guest_mode_removal vbox_hosts; do
local status="${SERVICE_STATUS[$service]:-unknown}" local status="${SERVICE_STATUS[$service]:-unknown}"
local color local color
case "$status" in case "$status" in
ok) color=$GREEN ;; ok) color=$GREEN ;;
warning) color=$YELLOW ;; warning) color=$YELLOW ;;
error) color=$RED ;; error) color=$RED ;;
skipped) color=$BLUE ;;
*) color=$NC ;; *) color=$NC ;;
esac esac
printf "%-25s ${color}%s${NC}\n" "$service" "$status" printf "%-25s ${color}%s${NC}\n" "$service" "$status"
@ -602,6 +1008,13 @@ main() {
check_startup_monitor check_startup_monitor
check_periodic_systems check_periodic_systems
check_hosts check_hosts
check_thesis_tracker
check_focus_mode
check_compulsive_blocker
check_thorium_startup
check_leechblock
check_guest_mode_removal
check_vbox_hosts
print_summary print_summary
} }

View File

@ -15,14 +15,14 @@ warn() { printf "\033[1;33m[WARN]\033[0m %s\n" "$*"; }
err() { printf "\033[1;31m[ERR ]\033[0m %s\n" "$*"; } err() { printf "\033[1;31m[ERR ]\033[0m %s\n" "$*"; }
require_cmd() { require_cmd() {
if ! command -v "$1" > /dev/null 2>&1; then if ! command -v "$1" >/dev/null 2>&1; then
err "Missing dependency: $1" err "Missing dependency: $1"
MISSING=1 MISSING=1
fi fi
} }
usage() { usage() {
cat << EOF cat <<EOF
${SCRIPT_NAME} — Download and wire up LeechBlockNG from GitHub ${SCRIPT_NAME} — Download and wire up LeechBlockNG from GitHub
Usage: ${SCRIPT_NAME} [--version vX.Y[.Z]] [--force] [--install-firefox] Usage: ${SCRIPT_NAME} [--version vX.Y[.Z]] [--force] [--install-firefox]
@ -76,7 +76,7 @@ require_cmd tar
require_cmd find require_cmd find
require_cmd sed require_cmd sed
require_cmd awk require_cmd awk
if ! command -v jq > /dev/null 2>&1; then if ! command -v jq >/dev/null 2>&1; then
warn "jq not found — will fall back to a simpler tag detection method." warn "jq not found — will fall back to a simpler tag detection method."
fi fi
[[ $MISSING -eq 1 ]] && { [[ $MISSING -eq 1 ]] && {
@ -85,19 +85,30 @@ fi
} }
REPO_OWNER="proginosko" REPO_OWNER="proginosko"
REPO_NAME="LeechBlockNG" REPO_NAME_CHROME="LeechBlockNG-chrome"
# Firefox repo (for reference): LeechBlockNG
# Use Chrome repo for Chromium-based browsers (the default target)
REPO_NAME="$REPO_NAME_CHROME"
get_latest_tag() { get_latest_tag() {
local repo="$1"
local tag local tag
if command -v jq > /dev/null 2>&1; then if command -v jq >/dev/null 2>&1; then
tag=$(curl -fsSL "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" | jq -r '.tag_name // empty' || true) tag=$(curl -fsSL "https://api.github.com/repos/${REPO_OWNER}/${repo}/releases/latest" | jq -r '.tag_name // empty' || true)
if [[ -n $tag && $tag != "null" ]]; then
echo "$tag"
return 0
fi
# Fallback: try tags endpoint
tag=$(curl -fsSL "https://api.github.com/repos/${REPO_OWNER}/${repo}/tags?per_page=1" | jq -r '.[0].name // empty' || true)
if [[ -n $tag && $tag != "null" ]]; then if [[ -n $tag && $tag != "null" ]]; then
echo "$tag" echo "$tag"
return 0 return 0
fi fi
fi fi
# Fallback: follow redirect for /releases/latest to extract tag # Fallback: follow redirect for /releases/latest to extract tag
tag=$(curl -fsSLI "https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/latest" | awk -F'/tag/' '/^location:/I {print $2}' | tr -d '\r\n' || true) tag=$(curl -fsSLI "https://github.com/${REPO_OWNER}/${repo}/releases/latest" | awk -F'/tag/' '/^location:/I {print $2}' | tr -d '\r\n' || true)
if [[ -n $tag ]]; then if [[ -n $tag ]]; then
echo "$tag" echo "$tag"
return 0 return 0
@ -107,7 +118,7 @@ get_latest_tag() {
if [[ -z $VERSION ]]; then if [[ -z $VERSION ]]; then
info "Resolving latest release tag from GitHub…" info "Resolving latest release tag from GitHub…"
if ! VERSION=$(get_latest_tag); then if ! VERSION=$(get_latest_tag "$REPO_NAME"); then
err "Failed to determine latest version tag" err "Failed to determine latest version tag"
exit 1 exit 1
fi fi
@ -157,13 +168,84 @@ else
info "Installing to $VERSION_DIR…" info "Installing to $VERSION_DIR…"
mkdir -p "$VERSION_DIR" mkdir -p "$VERSION_DIR"
# Copy the extension directory as-is (avoid bringing tests or build scripts) # Copy the extension directory as-is (avoid bringing tests or build scripts)
rsync -a --delete "$ext_dir/" "$VERSION_DIR/" 2> /dev/null || cp -a "$ext_dir/." "$VERSION_DIR/" rsync -a --delete "$ext_dir/" "$VERSION_DIR/" 2>/dev/null || cp -a "$ext_dir/." "$VERSION_DIR/"
# Download jQuery UI (not included in repo — listed in .gitignore)
# The extension's options.html expects:
# jquery-ui/jquery-ui.min.css
# jquery-ui/external/jquery/jquery.js
# jquery-ui/jquery-ui.min.js
info "Downloading jQuery UI…"
jqui_version="1.14.1"
jqui_url="https://jqueryui.com/resources/download/jquery-ui-${jqui_version}.zip"
jqui_zip="$tmpdir/jquery-ui.zip"
curl -fL --retry 3 -o "$jqui_zip" "$jqui_url"
mkdir -p "$tmpdir/jqui-extract"
unzip -q "$jqui_zip" -d "$tmpdir/jqui-extract"
jqui_src=$(find "$tmpdir/jqui-extract" -maxdepth 1 -type d -name "jquery-ui-*" | head -n1 || true)
if [[ -n $jqui_src ]]; then
mkdir -p "$VERSION_DIR/jquery-ui/external/jquery"
cp "$jqui_src/jquery-ui.min.css" "$VERSION_DIR/jquery-ui/" 2>/dev/null || true
cp "$jqui_src/jquery-ui.min.js" "$VERSION_DIR/jquery-ui/" 2>/dev/null || true
cp "$jqui_src/external/jquery/jquery.js" "$VERSION_DIR/jquery-ui/external/jquery/" 2>/dev/null || true
info "✓ jQuery UI ${jqui_version} installed into extension"
else
warn "Could not extract jQuery UI — options page may not work correctly"
fi
ln -sfn "$VERSION_DIR" "$CURRENT_LINK" ln -sfn "$VERSION_DIR" "$CURRENT_LINK"
fi fi
EXT_PATH="$CURRENT_LINK" # stable path used by wrappers EXT_PATH="$CURRENT_LINK" # stable path used by wrappers
# ── Inject default blocking configuration ─────────────────────────────
# Copy leechblock_defaults.js alongside the extension and patch
# background.js to import it and seed storage on first run.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEFAULTS_SRC="$SCRIPT_DIR/leechblock_defaults.js"
if [[ -f $DEFAULTS_SRC ]]; then
cp "$DEFAULTS_SRC" "$VERSION_DIR/defaults.js"
info "Copied default blocking configuration into extension"
BG_JS="$VERSION_DIR/background.js"
if [[ -f $BG_JS ]]; then
# 1) Add importScripts("defaults.js") right after importScripts("common.js")
if ! grep -q 'importScripts("defaults.js")' "$BG_JS"; then
sed -i 's|importScripts("common.js");|importScripts("common.js");\nimportScripts("defaults.js");|' "$BG_JS"
info "Patched background.js to import defaults.js"
fi
# 2) Inject first-run seeding logic after cleanTimeData(gOptions)
if ! grep -q 'LEECHBLOCK_DEFAULTS' "$BG_JS"; then
sed -i '/cleanTimeData(gOptions);/a\
\
\t\t// ── Seed default blocking rules on first run ──\
\t\tif (typeof LEECHBLOCK_DEFAULTS !== "undefined") {\
\t\t\tlet hasAnySites = false;\
\t\t\tfor (let s = 1; s <= +gOptions["numSets"]; s++) {\
\t\t\t\tif (gOptions["sites" + s]) { hasAnySites = true; break; }\
\t\t\t}\
\t\t\tif (!hasAnySites) {\
\t\t\t\tfor (let key in LEECHBLOCK_DEFAULTS) {\
\t\t\t\t\tgOptions[key] = LEECHBLOCK_DEFAULTS[key];\
\t\t\t\t}\
\t\t\t\tcleanOptions(gOptions);\
\t\t\t\tcleanTimeData(gOptions);\
\t\t\t\tgNumSets = +gOptions["numSets"];\
\t\t\t\tgStorage.set(gOptions).catch(\
\t\t\t\t\tfunction (e) { warn("Cannot seed defaults: " + e); }\
\t\t\t\t);\
\t\t\t\tlog("Seeded default blocking configuration");\
\t\t\t}\
\t\t}' "$BG_JS"
info "Patched background.js with first-run seeding logic"
fi
fi
else
warn "leechblock_defaults.js not found at $DEFAULTS_SRC — skipping default config"
fi
# Detect browsers # Detect browsers
declare -A BROWSERS declare -A BROWSERS
BROWSERS=( BROWSERS=(
@ -185,69 +267,74 @@ FIREFOXES=(
) )
found_any=0 found_any=0
wrap_bin_dir="$HOME/.local/bin"
mkdir -p "$wrap_bin_dir"
# Create a user desktop entry # Create a user desktop entry
user_apps_dir="${XDG_DATA_HOME:-$HOME/.local/share}/applications" user_apps_dir="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
mkdir -p "$user_apps_dir" mkdir -p "$user_apps_dir"
create_wrapper_and_desktop() { # Replace the system browser launcher in-place so every launch includes LeechBlock.
# The original script/binary is backed up as <path>.orig.
# Requires sudo for system paths (/usr/bin).
replace_browser_in_place() {
local bin="$1" local bin="$1"
shift shift
local pretty="$1" local pretty="$1"
shift shift
local wrapper="$wrap_bin_dir/${bin}-with-leechblock"
local real_bin local real_bin
real_bin=$(command -v "$bin" || true) real_bin=$(command -v "$bin" || true)
[[ -z $real_bin ]] && return [[ -z $real_bin ]] && return
cat > "$wrapper" << WRAP # Resolve to absolute path (handles symlinks etc.)
#!/usr/bin/env bash real_bin=$(readlink -f "$real_bin")
exec "$real_bin" --load-extension="$EXT_PATH" "$@"
WRAP
chmod +x "$wrapper"
# Try to reuse icon from an existing desktop file if available local orig_backup="${real_bin}.orig"
local sys_desktop existing_icon existing_name categories
sys_desktop=$(grep -RIl "^Exec=.*${bin}" /usr/share/applications 2> /dev/null | head -n1 || true) # If already wrapped, skip (idempotent)
if [[ -n $sys_desktop ]]; then if grep -q '__LEECHBLOCK_WRAPPER__' "$real_bin" 2>/dev/null; then
existing_icon=$(awk -F= '/^Icon=/{print $2; exit}' "$sys_desktop" || true) info "$pretty ($bin) already wrapped — skipping"
existing_name=$(awk -F= '/^Name=/{print $2; exit}' "$sys_desktop" || true) found_any=1
categories=$(awk -F= '/^Categories=/{print $2; exit}' "$sys_desktop" || true) return
fi fi
[[ -z $existing_icon ]] && existing_icon="$bin"
[[ -z $existing_name ]] && existing_name="$pretty"
[[ -z $categories ]] && categories="Network;WebBrowser;"
local desktop_file="$user_apps_dir/${bin}-with-leechblock.desktop" # Kill running instances so the new wrapper takes effect
cat > "$desktop_file" << DESK info "Killing running $pretty instances…"
[Desktop Entry] pkill -f "$real_bin" 2>/dev/null || true
Name=${existing_name} (LeechBlock) pkill -f "$(basename "$real_bin")" 2>/dev/null || true
Exec=${wrapper} %U sleep 1
Terminal=false
Type=Application
Icon=${existing_icon}
Categories=${categories}
StartupNotify=true
DESK
info "Created wrapper: $wrapper" # Back up original
info "Created launcher: $desktop_file" if [[ ! -f $orig_backup ]]; then
info "Backing up $real_bin → $orig_backup"
sudo cp -a "$real_bin" "$orig_backup"
else
info "Backup already exists: $orig_backup"
fi
# Write replacement wrapper
info "Replacing $real_bin with LeechBlock wrapper…"
sudo tee "$real_bin" >/dev/null <<WRAP
#!/usr/bin/env bash
# __LEECHBLOCK_WRAPPER__ — auto-generated by install_leechblock.sh
# Original backed up at: $orig_backup
exec "$orig_backup" --load-extension="$EXT_PATH" "\$@"
WRAP
sudo chmod +x "$real_bin"
info "✓ $pretty now always launches with LeechBlock"
found_any=1 found_any=1
} }
info "Detecting installed browsers…" info "Detecting installed browsers…"
for bin in "${!BROWSERS[@]}"; do for bin in "${!BROWSERS[@]}"; do
if command -v "$bin" > /dev/null 2>&1; then if command -v "$bin" >/dev/null 2>&1; then
create_wrapper_and_desktop "$bin" "${BROWSERS[$bin]}" replace_browser_in_place "$bin" "${BROWSERS[$bin]}"
fi fi
done done
ff_found=0 ff_found=0
for bin in "${!FIREFOXES[@]}"; do for bin in "${!FIREFOXES[@]}"; do
if command -v "$bin" > /dev/null 2>&1; then if command -v "$bin" >/dev/null 2>&1; then
ff_found=1 ff_found=1
fi fi
done done
@ -261,7 +348,7 @@ fi
if [[ $ff_found -eq 1 ]]; then if [[ $ff_found -eq 1 ]]; then
echo echo
warn "Detected Firefox-based browser(s). Permanent install from GitHub source isn't possible on stable builds due to required signing." warn "Detected Firefox-based browser(s). Permanent install from GitHub source isn't possible on stable builds due to required signing."
cat << FF cat <<FF
Options: Options:
1) Install from Mozilla Add-ons (recommended): 1) Install from Mozilla Add-ons (recommended):
https://addons.mozilla.org/firefox/addon/leechblock-ng/ https://addons.mozilla.org/firefox/addon/leechblock-ng/
@ -294,13 +381,13 @@ if [[ $AUTO_FIREFOX -eq 1 && $ff_found -eq 1 ]]; then
# Determine policy directories for detected Firefox-like browsers # Determine policy directories for detected Firefox-like browsers
declare -a POLICY_DIRS declare -a POLICY_DIRS
POLICY_DIRS=() POLICY_DIRS=()
if command -v firefox > /dev/null 2>&1; then if command -v firefox >/dev/null 2>&1; then
POLICY_DIRS+=("/etc/firefox/policies" "/usr/lib/firefox/distribution") POLICY_DIRS+=("/etc/firefox/policies" "/usr/lib/firefox/distribution")
fi fi
if command -v firefox-developer-edition > /dev/null 2>&1; then if command -v firefox-developer-edition >/dev/null 2>&1; then
POLICY_DIRS+=("/etc/firefox-developer-edition/policies" "/usr/lib/firefox-developer-edition/distribution") POLICY_DIRS+=("/etc/firefox-developer-edition/policies" "/usr/lib/firefox-developer-edition/distribution")
fi fi
if command -v librewolf > /dev/null 2>&1; then if command -v librewolf >/dev/null 2>&1; then
POLICY_DIRS+=("/etc/librewolf/policies" "/usr/lib/librewolf/distribution") POLICY_DIRS+=("/etc/librewolf/policies" "/usr/lib/librewolf/distribution")
fi fi
# Generic mozilla path as fallback # Generic mozilla path as fallback
@ -313,7 +400,7 @@ if [[ $AUTO_FIREFOX -eq 1 && $ff_found -eq 1 ]]; then
if sudo test -f "$existing"; then if sudo test -f "$existing"; then
info "Merging into existing policies.json at $existing" info "Merging into existing policies.json at $existing"
sudo cp "$existing" "$tmp_pol" sudo cp "$existing" "$tmp_pol"
if command -v jq > /dev/null 2>&1; then if command -v jq >/dev/null 2>&1; then
merged=$(jq --arg id "$ADDON_ID" --arg url "$ADDON_AMO_URL" ' merged=$(jq --arg id "$ADDON_ID" --arg url "$ADDON_AMO_URL" '
.policies |= (. // {}) | .policies |= (. // {}) |
.policies.ExtensionSettings |= (. // {}) | .policies.ExtensionSettings |= (. // {}) |
@ -323,7 +410,7 @@ if [[ $AUTO_FIREFOX -eq 1 && $ff_found -eq 1 ]]; then
.policies.ExtensionSettings[$id].install_url = $url .policies.ExtensionSettings[$id].install_url = $url
' "$tmp_pol") || merged="" ' "$tmp_pol") || merged=""
if [[ -n $merged ]]; then if [[ -n $merged ]]; then
printf '%s\n' "$merged" > "$tmp_pol" printf '%s\n' "$merged" >"$tmp_pol"
else else
warn "jq merge failed; skipping $pol_target" warn "jq merge failed; skipping $pol_target"
rm -f "$tmp_pol" rm -f "$tmp_pol"
@ -332,7 +419,7 @@ if [[ $AUTO_FIREFOX -eq 1 && $ff_found -eq 1 ]]; then
else else
warn "jq not available; creating minimal policies.json (existing file will be backed up)." warn "jq not available; creating minimal policies.json (existing file will be backed up)."
sudo cp "$existing" "${existing}.bak.$(date +%s)" sudo cp "$existing" "${existing}.bak.$(date +%s)"
cat > "$tmp_pol" << JSON cat >"$tmp_pol" <<JSON
{ {
"policies": { "policies": {
"ExtensionSettings": { "ExtensionSettings": {
@ -348,7 +435,7 @@ JSON
fi fi
else else
info "Creating new policies.json at $pol_target" info "Creating new policies.json at $pol_target"
cat > "$tmp_pol" << JSON cat >"$tmp_pol" <<JSON
{ {
"policies": { "policies": {
"ExtensionSettings": { "ExtensionSettings": {

View File

@ -0,0 +1,151 @@
/* LeechBlock NG default blocking configuration.
*
* Loaded by background.js via importScripts().
* On first run (no sites configured), these defaults are seeded into
* chrome.storage.local so the extension starts pre-configured.
*
* Mirrors the domains blocked in linux_configuration/hosts/install.sh.
* With matchSubdomains=true, listing "youtube.com" automatically covers
* www.youtube.com, m.youtube.com, etc.
*
* Maintained by install_leechblock.sh — edit THIS file then re-run the
* installer to push changes into the extension.
*/
// eslint-disable-next-line no-unused-vars
const LEECHBLOCK_DEFAULTS = {
// ── General options ────────────────────────────────────────────────
numSets: "6",
matchSubdomains: true,
// ── Set 1 — YouTube & alternative front-ends ───────────────────────
setName1: "YouTube",
sites1: [
// Core YouTube
"youtube.com",
"youtu.be",
"youtube-nocookie.com",
"youtubei.googleapis.com",
"youtube.googleapis.com",
"yt3.ggpht.com",
"ytimg.com",
"googlevideo.com",
// Invidious instances
"invidious.io",
"invidio.us",
"vid.puffyan.us",
"yewtu.be",
"invidious.kavin.rocks",
"inv.riverside.rocks",
"invidious.namazso.eu",
"invidious.nerdvpn.de",
"invidious.projectsegfau.lt",
"invidious.slipfox.xyz",
"invidious.privacydev.net",
"invidious.perennialte.ch",
"invidious.protokoll-11.de",
"invidious.einfachzocken.eu",
"invidious.fdn.fr",
"inv.in.projectsegfau.lt",
"invidious.tiekoetter.com",
"invidious.lunar.icu",
"iv.ggtyler.dev",
"iv.melmac.space",
"invidious.incogniweb.net",
"invidious.drgns.space",
"invidious.io.lol",
"inv.n8pjl.ca",
"inv.zzls.xyz",
"inv.tux.pizza",
// Piped instances
"piped.video",
"piped.kavin.rocks",
"piped.mha.fi",
"piped.mint.lgbt",
"piped.projectsegfau.lt",
"piped.privacydev.net",
"piped.smnz.de",
"piped.adminforge.de",
"watch.whatever.social",
"piped.lunar.icu",
// Other alternative clients / front-ends
"viewtube.io",
"freetube.io",
"tubo.media",
"materialious.nadeko.net",
"clipious.org",
"newpipe.net",
"newpipe.schabi.org",
"grayjay.app",
"libretube.dev",
"hyperion.deishelon.com",
].join(" "),
times1: "0000-2400",
days1: [true, true, true, true, true, true, true],
// ── Set 2 — Food delivery services ─────────────────────────────────
setName2: "Food Delivery",
sites2: [
// Polish services
"pyszne.pl",
"glovo.com",
"glovoapp.com",
"bolt.eu",
"woltwojta.pl",
"wolt.com",
"jush.pl",
"delio.pl",
"delio.com",
"delio.com.pl",
"lisek.app",
"stava.app",
"biedronka.pl",
"barbora.pl",
"frisco.pl",
"swiatkwiatow.pl",
"szama.pl",
"auchandirect.pl",
// International services
"ubereats.com",
"uber.com",
"deliveroo.com",
"deliveroo.co.uk",
"foodpanda.com",
"grubhub.com",
"doordash.com",
"justeat.com",
"justeat.co.uk",
"postmates.com",
"seamless.com",
"menulog.com.au",
"delivery.com",
"getir.com",
"flink.com",
"gorillas.io",
"gopuff.com",
"instacart.com",
"takeaway.com",
].join(" "),
times2: "0000-2400",
days2: [true, true, true, true, true, true, true],
// ── Set 3 — Fast food chain websites ───────────────────────────────
setName3: "Fast Food",
sites3: [
"mcdonalds.com",
"mcdonalds.pl",
"kfc.com",
"kfc.pl",
"burgerking.com",
"burgerking.pl",
"pizzahut.com",
"pizzahut.pl",
"dominos.com",
"dominos.pl",
"subway.com",
"subway.pl",
].join(" "),
times3: "0000-2400",
days3: [true, true, true, true, true, true, true],
};

View File

@ -15,7 +15,7 @@ for arg in "$@"; do
case "$arg" in case "$arg" in
--undo) UNDO=true ;; --undo) UNDO=true ;;
-h | --help) -h | --help)
cat << EOF cat <<EOF
Usage: $SCRIPT_NAME [--undo] Usage: $SCRIPT_NAME [--undo]
Actions: Actions:
@ -75,7 +75,7 @@ POLICY_JSON='{
# Discover installed browsers # Discover installed browsers
declare -A INSTALLED_KEYS=() declare -A INSTALLED_KEYS=()
for bin in "${!BIN_TO_KEY[@]}"; do for bin in "${!BIN_TO_KEY[@]}"; do
if command -v "$bin" > /dev/null 2>&1; then if command -v "$bin" >/dev/null 2>&1; then
key=${BIN_TO_KEY[$bin]} key=${BIN_TO_KEY[$bin]}
INSTALLED_KEYS[$key]=1 INSTALLED_KEYS[$key]=1
fi fi
@ -90,7 +90,7 @@ choose_target_dir() {
local key="$1" local key="$1"
local IFS=":" local IFS=":"
local dirs local dirs
read -r -a dirs <<< "${CANDIDATE_DIRS[$key]:-}" read -r -a dirs <<<"${CANDIDATE_DIRS[$key]:-}"
# Prefer an existing directory; else pick the first candidate # Prefer an existing directory; else pick the first candidate
for d in "${dirs[@]}"; do for d in "${dirs[@]}"; do
if [[ -d $d ]]; then if [[ -d $d ]]; then
@ -113,7 +113,7 @@ apply_policy() {
local tmp local tmp
tmp=$(mktemp) tmp=$(mktemp)
printf '%s printf '%s
' "$POLICY_JSON" > "$tmp" ' "$POLICY_JSON" >"$tmp"
install -m 0644 "$tmp" "$file" install -m 0644 "$tmp" "$file"
rm -f "$tmp" rm -f "$tmp"
} }