xiaowei-system/tmp/fix_footer.py

35 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

with open('/www/wwwroot/gaokao/index.html', 'r') as f:
c = f.read()
old_footer_right = ' <div class="footer-right">\n <p class="footer-contact-title">遇到问题?</p>\n <p style="color:#555;font-size:0.8rem">联系邮箱shangdiyefeng@vip.qq.com</p>\n </div>'
new_footer_right = ' <div class="footer-right">\n <div class="footer-contact-col">\n <p class="footer-contact-title">遇到问题?</p>\n <p style="color:#555;font-size:0.8rem">联系邮箱shangdiyefeng@vip.qq.com</p>\n </div>\n <div class="footer-contact-col" style="text-align:right">\n <p class="footer-contact-title">赞赏支持</p>\n <a href="/support.html" class="footer-donate-btn">☕ 支持运营</a>\n </div>\n </div>'
if old_footer_right in c:
c = c.replace(old_footer_right, new_footer_right)
# Update grid columns
c = c.replace('.footer-inner { display: grid; grid-template-columns: 1fr auto; gap: 40px;',
'.footer-inner { display: grid; grid-template-columns: 1fr auto auto; gap: 40px;')
# Add donate button CSS
donate_css = '.footer-donate-btn{display:inline-block;margin-top:6px;color:#667eea;text-decoration:none;font-size:0.85rem;padding:5px 14px;border-radius:20px;border:1px solid rgba(102,126,234,0.3);transition:all 0.3s}.footer-donate-btn:hover{background:rgba(102,126,234,0.1);border-color:#667eea}'
# Update contact-title alignment (remove text-align:right default)
c = c.replace('.footer-contact-title { color: #888; font-size: 0.82rem; margin-bottom: 10px; text-align: right; }',
'.footer-contact-title { color: #888; font-size: 0.82rem; margin-bottom: 10px; }')
# Insert donate CSS before .footer-qr
c = c.replace('.footer-qr {',
donate_css + ' .footer-qr {')
with open('/www/wwwroot/gaokao/index.html', 'w') as f:
f.write(c)
print('Done! Footer updated with donate button')
else:
print('Pattern not found')
# Debug: find footer-right
idx = c.find('footer-right')
if idx >= 0:
print('Context:', repr(c[idx-50:idx+150]))