let owoLoadList = [] function loadCSS (url) { if (owoLoadList.includes(url)) { return } owoLoadList.push(url) var link = document.createElement("link"); link.rel = "stylesheet"; link.type = "text/css"; link.href = url; document.getElementsByTagName("head")[0].appendChild(link); } if (document.querySelector('.puge-box')) document.querySelector('.puge-box').outerHTML = '' setTimeout(() => { var box = document.getElementsByClassName('puge-box') if (!box[0]) { var insertElement = document.createElement("div"); insertElement.style.display = 'none' insertElement.classList.add('puge-box') insertElement.style.zIndex = '9665' insertElement.style.width = '210px' insertElement.style.height = '300px' insertElement.style.position = 'fixed' insertElement.style.right = '0' insertElement.style.top = '0' insertElement.style.backgroundColor = 'white' document.body.appendChild(insertElement); if (window.pugeCreated) { window.pugeCreated(insertElement) window.pugeCreated = null } } }, 1000) var box = document.getElementsByClassName('puge-menu') if (!box[0]) { var insertElement = document.createElement("div"); insertElement.classList.add('puge-menu') insertElement.innerHTML = `
` document.body.appendChild(insertElement); } function owostart () { const box = document.getElementsByClassName('puge-box')[0] // alert(box.style.display) if (box.style.display == 'none') { box.style.display = 'block' if (window.pugeCreated) { window.pugeCreated(document.getElementsByClassName('puge-box')[0]) window.pugeCreated = null } } else { box.style.display = 'none' } window.loadingDialog = function () { return } window.alertDialog = function (text) { window.logBox.add(text) } } function simulateTyping(searchBox, text, callBack) { if (!searchBox) return; // 确保搜索框获得焦点 searchBox.focus(); // 模拟逐个字符输入 text.split('').forEach((char, index) => { setTimeout(() => { // 创建键盘事件 const keyDownEvent = new KeyboardEvent('keydown', { key: char, code: `Key${char.toUpperCase()}`, bubbles: true }); const keyPressEvent = new KeyboardEvent('keypress', { key: char, bubbles: true }); const keyUpEvent = new KeyboardEvent('keyup', { key: char, bubbles: true }); // 触发事件 searchBox.dispatchEvent(keyDownEvent); searchBox.dispatchEvent(keyPressEvent); // 插入字符 document.execCommand('insertText', false, char); searchBox.dispatchEvent(keyUpEvent); // 如果是最后一个字符,触发搜索 if (index === text.length - 1) { const inputEvent = new Event('input', { bubbles: true }); searchBox.dispatchEvent(inputEvent); } }, index * 100 + 500); // 100ms 间隔模拟打字 }); setTimeout(() => { // 触发所有可能的事件 const events = ['input', 'change', 'keyup', 'keydown', 'keypress', 'blur', 'focus']; events.forEach(eventType => { const event = eventType.startsWith('key') ? new KeyboardEvent(eventType, { bubbles: true }) : new Event(eventType, { bubbles: true }); searchBox.dispatchEvent(event); }); if (callBack) callBack() }, text.split('').length * 100); } function simulateFullClick(element) { // 鼠标按下 const mouseDownEvent = new MouseEvent('mousedown', { view: window, bubbles: true, cancelable: true, buttons: 1 }); // 鼠标抬起 const mouseUpEvent = new MouseEvent('mouseup', { view: window, bubbles: true, cancelable: true, buttons: 1 }); // 点击事件 const clickEvent = new MouseEvent('click', { view: window, bubbles: true, cancelable: true, buttons: 1 }); // 按顺序触发事件 element.dispatchEvent(mouseDownEvent); element.dispatchEvent(mouseUpEvent); element.dispatchEvent(clickEvent); } function searchText(text, sendText) { const searchBox = document.querySelector('div[contenteditable="true"]'); if (document.querySelector('._ah_y.x1eu8d0j')) { document.querySelector('._ah_y.x1eu8d0j').click() } setTimeout(() => { simulateTyping(searchBox, text, () => { setTimeout(() => { const gridcellList = document.querySelectorAll('.x1n2onr6[role="gridcell"]') if (gridcellList.length > 0) { simulateFullClick(gridcellList[0].querySelector('._ak72')) setTimeout(() => { simulateTyping(document.querySelectorAll('[aria-placeholder]')[1], sendText, () => { setTimeout(() => { document.querySelectorAll('[aria-expanded="false"][aria-label]')[6].click() }, 1000); }) }, 2000); } }, 2000); }); }, 1000); } window.pugeCreated = function (el) { el.innerHTML = `
用户名
发送内容
日志输出
停止
启动
` } function sendMessage() { searchText(window.yhm.value, window.fsnr.value) }