@@ -73,26 +73,23 @@ export async function DynamicOkjike(data: SyncData) {
7373
7474 // 填写内容
7575 async function fillContent ( ) {
76- const textarea = ( await waitForElement ( 'textarea[placeholder="分享你的想法..."]' ) ) as HTMLTextAreaElement ;
77- if ( textarea ) {
78- // 如果有标题,将标题和内容拼接
79- const fullContent = title ? `${ title } \n\n${ content } ` : content ;
80- textarea . value = fullContent ;
81- textarea . dispatchEvent ( new Event ( 'input' , { bubbles : true } ) ) ;
82- await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
83- }
84-
85- // 处理话题
86- // if (extra?.jike?.topic) {
87- // await handleTopicSelection(extra.jike.topic);
88- // }
76+ const inputElement = ( await waitForElement ( 'div[contenteditable="true"][role="textbox"]' ) ) as HTMLDivElement ;
77+ const fullContent = `${ title } \n${ content } ` ;
78+ const pasteEvent = new ClipboardEvent ( 'paste' , {
79+ bubbles : true ,
80+ cancelable : true ,
81+ clipboardData : new DataTransfer ( ) ,
82+ } ) ;
83+ pasteEvent . clipboardData . setData ( 'text/plain' , fullContent ) ;
84+ inputElement . focus ( ) ;
85+ inputElement . dispatchEvent ( pasteEvent ) ;
8986 }
9087
9188 // 修改文件上传函数
9289 async function uploadFiles ( ) {
9390 let fileInput : HTMLInputElement | null = null ;
9491
95- fileInput = document . querySelector ( 'input[type="file"][accept="image/*"] ' ) ;
92+ fileInput = document . querySelector ( 'input[type="file"]' ) ;
9693
9794 if ( ! fileInput ) {
9895 console . error ( '未找到文件输入元素' ) ;
@@ -135,7 +132,7 @@ export async function DynamicOkjike(data: SyncData) {
135132 await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
136133 const buttons = document . querySelectorAll ( 'button' ) ;
137134 const publishButton = Array . from ( buttons ) . find (
138- ( button ) => button . textContent ?. includes ( '发布 ' ) ,
135+ ( button ) => button . textContent ?. includes ( '发送 ' ) ,
139136 ) as HTMLButtonElement ;
140137
141138 if ( publishButton ) {
0 commit comments