Skip to content

Commit ff96351

Browse files
authored
feat: added mobile ui subscription nag removal (#7164)
* feat: added mobile ui nag removal * chore: remove my ansible comment
1 parent 1b63219 commit ff96351

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tools/pve/post-pve-install.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,42 @@ post_routines_common() {
514514
yes)
515515
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox --title "Support Subscriptions" "Supporting the software's development team is essential. Check their official website's Support Subscriptions for pricing. Without their dedicated work, we wouldn't have this exceptional software." 10 58
516516
msg_info "Disabling subscription nag"
517-
echo "DPkg::Post-Invoke { \"if [ -s /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js ] && ! grep -q -F 'NoMoreNagging' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; then echo 'Removing subscription nag from UI...'; sed -i '/data\.status/{s/\\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; fi\" };" >/etc/apt/apt.conf.d/no-nag-script
517+
# Create external script, this is needed because DPkg::Post-Invoke is fidly with quote interpretation
518+
cat >/usr/local/bin/pve-remove-nag.sh <<'EOF'
519+
#!/bin/sh
520+
WEB_JS=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
521+
if [ -s "$WEB_JS" ] && ! grep -q NoMoreNagging "$WEB_JS"; then
522+
echo "Patching Web UI nag..."
523+
sed -i -e "/data\.status/ s/!//" -e "/data\.status/ s/active/NoMoreNagging/" "$WEB_JS"
524+
fi
525+
526+
MOBILE_TPL=/usr/share/pve-yew-mobile-gui/index.html.tpl
527+
MARKER="<!-- MANAGED BLOCK FOR MOBILE NAG -->"
528+
if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then
529+
echo "Patching Mobile UI nag..."
530+
printf "%s\n" \
531+
"$MARKER" \
532+
"<script>" \
533+
" function watchAndRemoveDialog() {" \
534+
" const observer = new MutationObserver(() => {" \
535+
" const dialog = document.querySelector('dialog[aria-label=\"No valid subscription\"]');" \
536+
" if (dialog) { dialog.remove(); console.log('Removed dialog: No valid subscription'); observer.disconnect(); }" \
537+
" });" \
538+
" observer.observe(document.body, { childList: true, subtree: true });" \
539+
" }" \
540+
" setTimeout(watchAndRemoveDialog, 100);" \
541+
"</script>" \
542+
"" >> "$MOBILE_TPL"
543+
fi
544+
EOF
545+
546+
chmod 755 /usr/local/bin/pve-remove-nag.sh
547+
548+
cat >/etc/apt/apt.conf.d/no-nag-script <<'EOF'
549+
DPkg::Post-Invoke { "/usr/local/bin/pve-remove-nag.sh"; };
550+
EOF
551+
chmod 644 /etc/apt/apt.conf.d/no-nag-script
552+
518553
msg_ok "Disabled subscription nag (Delete browser cache)"
519554
;;
520555
no)

0 commit comments

Comments
 (0)