#!/usr/bin/env python3 import os import re import glob # The correct navbar HTML to insert navbar_html = '''
🏠 Home
QuickBooks Point of Sale Help
Note: All Online Services are disabled and won't work. This is Completely Offline and No subscription needed
''' os.chdir('/home/pts/Documents/QBPOS_Help_Web/QB_Help_Web/POS_Help') # Process all htm files except special ones files = [] for pattern in ['*/*.htm', '*/*/*.htm']: files.extend(glob.glob(pattern)) files = [f for f in files if not f.startswith('___')] print(f"Processing {len(files)} files...") for filepath in files: try: with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # Remove all mobile-nav and offline-notice divs content = re.sub(r'
.*?
\s*', '', content, flags=re.DOTALL) content = re.sub(r'
.*?
', '', content, flags=re.DOTALL) # Insert navbar after tag content = re.sub(r'(]*>)', r'\1\n' + navbar_html, content, count=1) with open(filepath, 'w', encoding='utf-8') as f: f.write(content) except Exception as e: print(f"Error processing {filepath}: {e}") print("Done!")