root 2 долоо хоног өмнө
parent
commit
8c9afe39c2
1 өөрчлөгдсөн 21 нэмэгдсэн , 24 устгасан
  1. 21 24
      plugins/tls_plugin.py

+ 21 - 24
plugins/tls_plugin.py

@@ -506,9 +506,13 @@ class TlsPlugin(IVSPlg):
             
             js_update_form = f"""
             try {{
-                const form = document.querySelector('form');
-                if (!form) return 'Form not found';
-
+                const buttons = Array.from(document.querySelectorAll('button[type="submit"]'));
+                const submitBtn = buttons.find(btn => {{
+                    return btn.textContent.trim().toLowerCase().includes('book your appointment');
+                }});
+                if (!submitBtn) return 'Submit button not found';
+                const form = submitBtn.closest('form');
+                if (!form) return 'Correct form not found';
                 function setReactValue(input, value) {{
                     if (!input) return;
                     input.value = value;
@@ -518,14 +522,9 @@ class TlsPlugin(IVSPlg):
                 setReactValue(form.querySelector('input[name="date"]'), '{selected_date}');
                 setReactValue(form.querySelector('input[name="time"]'), '{selected_time.time}');
                 setReactValue(form.querySelector('input[name="appointmentLabel"]'), '{selected_label}');
-                const submitBtn = form.querySelector('button[type="submit"]');
-                if (submitBtn) {{
-                    submitBtn.removeAttribute('disabled');
-                    submitBtn.classList.remove('opacity-50', 'cursor-not-allowed'); 
-                    return 'form_updated';
-                }} else {{
-                    return 'Submit button not found';
-                }}
+                submitBtn.removeAttribute('disabled');
+                submitBtn.classList.remove('opacity-50', 'cursor-not-allowed'); 
+                return 'form_updated';
             }} catch (e) {{
                 return e.toString();
             }}
@@ -536,7 +535,7 @@ class TlsPlugin(IVSPlg):
             if update_res != 'form_updated':
                 raise BizLogicError(message=f"Failed to update form in Mode 1: {update_res}")
             
-            submit_btn = self.page.ele('tag:button@@type=submit')
+            submit_btn = self.page.ele('tag:button@@type=submit@@text():Book your appointment')
             if not submit_btn:
                 raise BizLogicError(message="Submit button not found for mouse click")
                 
@@ -547,9 +546,13 @@ class TlsPlugin(IVSPlg):
         else:
             js_inject_and_click = f"""
             try {{
-                const form = document.querySelector('form');
-                if (!form) return 'Form not found';
-
+                const buttons = Array.from(document.querySelectorAll('button[type="submit"]'));
+                const submitBtn = buttons.find(btn => {{
+                    return btn.textContent.trim().toLowerCase().includes('book your appointment');
+                }});
+                if (!submitBtn) return 'Submit button not found';
+                const form = submitBtn.closest('form');
+                if (!form) return 'Correct form not found';
                 function setReactValue(input, value) {{
                     if (!input) return;
                     input.value = value;
@@ -559,15 +562,9 @@ class TlsPlugin(IVSPlg):
                 setReactValue(form.querySelector('input[name="date"]'), '{selected_date}');
                 setReactValue(form.querySelector('input[name="time"]'), '{selected_time.time}');
                 setReactValue(form.querySelector('input[name="appointmentLabel"]'), '{selected_label}');
-                const submitBtn = form.querySelector('button[type="submit"]');
-                if (submitBtn) {{
-                    submitBtn.removeAttribute('disabled');
-                    submitBtn.classList.remove('opacity-50', 'cursor-not-allowed'); 
-                    submitBtn.click();
-                    return 'clicked';
-                }} else {{
-                    return 'Submit button not found';
-                }}
+                submitBtn.removeAttribute('disabled');
+                submitBtn.click();
+                return 'clicked';
             }} catch (e) {{
                 return e.toString();
             }}