import re with open("/data/data/com.termux/files/home/wechat-viewer/templates/aichat.html") as f: html = f.read() # Extract JS scripts = re.findall(r"", html, re.DOTALL) js = "\n".join(scripts) # Bracket balance for tag, c in [("{", "}"), ("(", ")"), ("[", "]")]: cnt = js.count(tag) - js.count(c) if cnt != 0: print("WARNING: Unbalanced {0}{1}: {2:+d}".format(tag, c, cnt)) else: print("OK: Balanced {0}{1}".format(tag, c)) # Key functions functions = [ "sendMessage", "handleKeyDown", "loadMessages", "selectConversation", "renderMsg", "newConversation", "deleteConversation", "scrollToBottom" ] for fn in functions: pat1 = "function " + fn pat2 = fn + "(" if pat1 in js or pat2 in js: print("OK: " + fn + " exists") else: print("MISSING: " + fn) print("\nJS REVIEW DONE")