Improve subscription element removal in post-install script (#7814)

This commit is contained in:
CanbiZ 2025-09-23 10:44:14 +02:00 committed by GitHub
parent e208bc110b
commit b15d7be4c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -532,20 +532,28 @@ if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then
"$MARKER" \
"<script>" \
" function removeSubscriptionElements() {" \
" // --- Remove subscription dialogs ---" \
" const dialogs = document.querySelectorAll('dialog.pwt-outer-dialog');" \
" dialogs.forEach(dialog => {" \
" const closeButton = dialog.querySelector('.fa-close');" \
" const exclamationIcon = dialog.querySelector('.fa-exclamation-triangle');" \
" const continueButton = dialog.querySelector('button');" \
" if (closeButton && exclamationIcon && continueButton) { dialog.remove(); console.log('Removed subscription dialog'); }" \
" const text = (dialog.textContent || '').toLowerCase();" \
" if (text.includes('subscription')) {" \
" dialog.remove();" \
" console.log('Removed subscription dialog');" \
" }" \
" });" \
"" \
" // --- Remove subscription cards, but keep Reboot/Shutdown/Console ---" \
" const cards = document.querySelectorAll('.pwt-card.pwt-p-2.pwt-d-flex.pwt-interactive.pwt-justify-content-center');" \
" cards.forEach(card => {" \
" const hasInteractiveElements = card.querySelector('button, input, a');" \
" const hasComplexStructure = card.querySelector('.pwt-grid, .pwt-flex, .pwt-button');" \
" if (!hasInteractiveElements && !hasComplexStructure) { card.remove(); console.log('Removed subscription card'); }" \
" const text = (card.textContent || '').toLowerCase();" \
" const hasButton = card.querySelector('button');" \
" if (!hasButton && text.includes('subscription')) {" \
" card.remove();" \
" console.log('Removed subscription card');" \
" }" \
" });" \
" }" \
"" \
" const observer = new MutationObserver(removeSubscriptionElements);" \
" observer.observe(document.body, { childList: true, subtree: true });" \
" removeSubscriptionElements();" \
@ -555,9 +563,8 @@ if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then
"" >> "$MOBILE_TPL"
fi
EOF
chmod 755 /usr/local/bin/pve-remove-nag.sh
cat >/etc/apt/apt.conf.d/no-nag-script <<'EOF'
DPkg::Post-Invoke { "/usr/local/bin/pve-remove-nag.sh"; };
EOF