import re # 1. CSS Injection css_to_add = """ /* Light Theme Variables */ [data-theme="light"] { --bayan-bg: #f9fafb; --bayan-surface: #ffffff; --bayan-surface-hover: #f3f4f6; --bayan-surface-active: #e5e7eb; --bayan-border: #e5e7eb; --bayan-border-light: #d1d5db; --bayan-text: #111827; --bayan-text-secondary: #4b5563; --bayan-text-muted: #9ca3af; --bayan-success: #16a34a; --bayan-warning: #d97706; } /* Theme Toggle Button Styles */ .theme-toggle-animated { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: none; border-radius: 50%; background: var(--bayan-surface-hover); color: var(--bayan-text-secondary); cursor: pointer; transition: background 0.3s ease, transform 0.3s ease, color 0.3s ease; position: relative; overflow: hidden; margin-right: 8px; } .theme-toggle-animated:hover { background: var(--bayan-primary); color: #fff; transform: rotate(15deg); } .theme-toggle-animated svg { transition: transform 0.4s ease, opacity 0.3s ease; position: absolute; } [data-theme="dark"] .theme-icon-sun { transform: rotate(90deg) scale(0); opacity: 0; } [data-theme="dark"] .theme-icon-moon { transform: rotate(0) scale(1); opacity: 1; } [data-theme="light"] .theme-icon-moon { transform: rotate(-90deg) scale(0); opacity: 0; } [data-theme="light"] .theme-icon-sun { transform: rotate(0) scale(1); opacity: 1; } """ def append_to_file(filepath, content): with open(filepath, 'a', encoding='utf-8') as f: f.write('\n' + content + '\n') append_to_file('extension/popup.css', css_to_add) append_to_file('extension/sidepanel/sidepanel.css', css_to_add) # 2. HTML Injection btn_html = """ """ def insert_html_button(filepath, pattern): with open(filepath, 'r', encoding='utf-8') as f: html = f.read() # We want to put the button next to the status indicator. # The pattern will match the