#!/usr/bin/env python3 import glob, os REPO = os.path.dirname(os.path.abspath(__file__)) NEW_FOOTER = '' FOOTER_CSS = '\n .footer-contact { margin-top: 0.4rem; font-size: 12px; }\n .footer-contact a { color: #aaa; border-bottom: 1px solid transparent; }\n .footer-contact a:hover { color: #111; border-bottom-color: #111; }\n .footer-sep { color: #ccc; margin: 0 0.5rem; }' files = glob.glob(os.path.join(REPO, '**/*.html'), recursive=True) files = [f for f in files if '/examples/' not in f and '.git' not in f] changed = 0 for f in sorted(files): raw = open(f, 'rb').read() text = raw.decode('utf-8', errors='replace') if 'discord.gg' in text: continue original = text # Find and replace the footer - try every variant for old in [ '', '', ]: if old in text: text = text.replace(old, NEW_FOOTER) break # Add CSS if footer was replaced but CSS missing if text != original and 'footer-contact' not in text and '' in text: text = text.replace('', FOOTER_CSS + '\n ', 1) if text != original: open(f, 'w', encoding='utf-8').write(text) changed += 1 print(f' {os.path.relpath(f, REPO)}') print(f'\nUpdated {changed} files.')