import os import re def port_html(): source_path = r"C:\Users\naman\OneDrive\Desktop\pragativeer-v2\pragativeer-celebration_1.html" dest_path = r"C:\Users\naman\OneDrive\Desktop\pragativeer-v2\public\streak-animation.html" with open(source_path, 'r', encoding='utf-8') as f: html = f.read() # 1. Inject CSS to make background transparent and hide stage layout hide_css = """ body { background: transparent !important; } body.sad { background: transparent !important; } body::after { display: none !important; } #stage, .hint { background: transparent !important; box-shadow: none !important; } .count, .panel, .hint { display: none !important; } """ # Insert hide_css inside " html = html.replace(style_tag, hide_css + "\n", 1) # 2. Replace parseTarget to read from URL search params parse_target_replacement = """ const parseTarget=()=>{ const params = new URLSearchParams(window.location.search); const s = params.get('streak'); const v=parseFloat(s); return isFinite(v)?v:0; }; """ html = re.sub(r"const parseTarget=\(\)=>\{.*?\};", parse_target_replacement, html, flags=re.DOTALL) # 3. Replace the huge base64 logo image in .badge class with the local PragatiVeer SVG logo new_badge_css = """ .badge{ position:absolute; inset:0; border-radius:50%; background: url('/PragatiVeer_Logo/SVG_Logos/Square_dark_background.svg') center/cover no-repeat !important; }""" html = re.sub(r"\.badge\s*\{[^}]*\}", new_badge_css, html, flags=re.DOTALL) # 4. Modify sad threshold and intensity scaling html = html.replace("const sad = target<5;", "const sad = target<=2;") html = html.replace("Math.max(target,5)/5", "Math.max(target,3)/3") html = html.replace("(4 - target) / 3", "(3 - target) / 3") with open(dest_path, 'w', encoding='utf-8') as f: f.write(html) print("Ported successfully to public/streak-animation.html") if __name__ == "__main__": port_html()