Files

22 lines
1.8 KiB
JavaScript

import { listPages, wait } from '/home/admin9webs/shein建品/sh_lib.mjs';
import { CDP, SAN as S } from '/tmp/cdp3.mjs';
const t = (await listPages()).find(x=>/91miaoshou/i.test(x.url));
const c = await CDP.connect(t.webSocketDebuggerUrl);
await c.send('Page.enable'); await c.send('Runtime.enable'); await wait(1500);
// 关掉新手指南弹窗
await c.evalJS(`(()=>{const b=[...document.querySelectorAll('.jx-dialog__headerbtn,.jx-dialog__close,button')].find(e=>/关闭|知道了|确定/.test(e.innerText||'')||/close/i.test(String(e.className)));
if(b) b.click(); return 1;})()`);
await wait(1200);
console.log('点导入链接采集:', String(await c.evalJS(`(()=>{const h=[...document.querySelectorAll('*')].filter(e=>e.offsetParent!==null&&(e.innerText||'').trim()==='导入链接采集'&&e.children.length===0);
if(!h.length) return 'nf'; for(const ev of ['mousedown','mouseup','click']) h[0].dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 'clicked';})()`)));
await wait(4000);
const o = await c.evalJS(`(()=>{
const areas=[...document.querySelectorAll('textarea')].filter(e=>e.offsetParent!==null).map(e=>({ph:e.placeholder||'', rows:e.rows}));
const btns=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').trim()).filter(Boolean).slice(0,14);
const hints=[...document.querySelectorAll('*')].filter(e=>e.children.length===0&&/链接|一行|示例|模板|1688|淘宝|拼多多/.test(e.innerText||'')&&(e.innerText||'').length<60)
.map(e=>(e.innerText||'').trim()).slice(0,10);
return JSON.stringify({areas, btns:[...new Set(btns)], hints:[...new Set(hints)]});})()`);
console.log('链接采集面板:', S(String(o)).slice(0,1200));
try{ await c.shot('/tmp/ms_import2.jpg'); console.log('shot ok'); }catch(e){}
process.exit(0);