import os templates_to_update = [ 'src/main/resources/templates/dao-tao-detail.html', 'src/main/resources/templates/posts/full-width.html', 'src/main/resources/templates/posts/livestream.html', 'src/main/resources/templates/posts/sidebar.html', 'src/main/resources/templates/posts/standard.html' ] # We need to replace: # groupHtml += ''; # with: # groupHtml += ''; # And remove: # b.style.background = '#f8f9fa'; # b.style.color = 'black'; # btn.style.background = '#0055a5'; # btn.style.color = 'white'; for filepath in templates_to_update: if not os.path.exists(filepath): continue with open(filepath, 'r', encoding='utf-8') as f: content = f.read() # Replace the button HTML generator target_str = """groupHtml += '';""" new_str = """groupHtml += '';""" content = content.replace(target_str, new_str) # Remove the JS inline styles logic content = content.replace("b.style.background = '#f8f9fa';", "") content = content.replace("b.style.color = 'black';", "") content = content.replace("btn.style.background = '#0055a5';", "") content = content.replace("btn.style.color = 'white';", "") with open(filepath, 'w', encoding='utf-8') as f: f.write(content) print(f"Updated JS in {filepath}")