@@ -19,97 +19,20 @@ export const copilot: Chatbot = {
1919 check_for_element ( )
2020 } )
2121 } ,
22- set_model : async ( chat ) => {
23- const model = chat . model
24- if ( ! model ) return
25-
26- const model_selector_button = document . querySelector (
27- 'button[data-testid="composer-chat-mode-smart-button"]'
28- ) as HTMLButtonElement
29- if ( ! model_selector_button ) {
30- report_initialization_error ( {
31- function_name : 'set_model' ,
32- log_message : 'Model selector button not found'
33- } )
34- return
35- }
36-
37- const model_label_to_find = CHATBOTS [ 'Copilot' ] . models ?. [ model ] ?. label
38- if ( ! model_label_to_find ) return
39-
40- // The current model text is inside the button
41- if ( model_selector_button . textContent ?. includes ( model_label_to_find ) ) {
42- return
43- }
44-
45- model_selector_button . click ( )
46- await new Promise ( ( r ) => requestAnimationFrame ( r ) )
47-
48- const options_container = document . querySelector ( 'div[id="popoverPortal"]' )
49- if ( ! options_container ) {
50- report_initialization_error ( {
51- function_name : 'set_model' ,
52- log_message : 'Model options container not found'
53- } )
54- // click again to close
55- model_selector_button . click ( )
56- return
57- }
58-
59- const options = options_container . querySelectorAll (
60- 'button[role="menuitem"]'
61- )
62-
63- let found = false
64- for ( const option of Array . from ( options ) ) {
65- if ( option . textContent ?. includes ( model_label_to_find ) ) {
66- ; ( option as HTMLElement ) . click ( )
67- found = true
68- break
69- }
70- }
71-
72- if ( ! found ) {
73- report_initialization_error ( {
74- function_name : 'set_model' ,
75- log_message : `Model option "${ model_label_to_find } " not found`
76- } )
77- // click again to close dropdown
78- model_selector_button . click ( )
79- }
80-
81- await new Promise ( ( r ) => requestAnimationFrame ( r ) )
82- } ,
83- enter_message_and_send : async ( params ) => {
22+ enter_message : async ( params ) => {
8423 const input_element = document . querySelector (
8524 'textarea'
8625 ) as HTMLTextAreaElement
8726 if ( ! input_element ) {
8827 report_initialization_error ( {
89- function_name : 'enter_message_and_send ' ,
28+ function_name : 'enter_message ' ,
9029 log_message : 'Message input textarea not found for Copilot'
9130 } )
9231 return
9332 }
9433 input_element . value = params . message
9534 input_element . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) )
9635 input_element . dispatchEvent ( new Event ( 'change' , { bubbles : true } ) )
97- await new Promise ( ( r ) => requestAnimationFrame ( r ) )
98-
99- if ( params . without_submission ) return
100-
101- const send_button = document . querySelector (
102- 'button[data-testid="submit-button"]'
103- ) as HTMLElement
104-
105- if ( ! send_button || send_button . hasAttribute ( 'disabled' ) ) {
106- report_initialization_error ( {
107- function_name : 'enter_message_and_send' ,
108- log_message : 'Send button not found or disabled for Copilot'
109- } )
110- return
111- }
112- send_button . click ( )
11336 } ,
11437 inject_apply_response_button : (
11538 client_id : number ,
0 commit comments