- TikTok/Shopee/速卖通/Walmart 各 46-47 条已在待发布 - Ozon 47 条已建、改价 40/47 - SHEIN 配方跑通第一条;Temu 差「预览图」一步 - 核心产出:MYJ.message.error 钩子诊断法(解开了三个平台的保存静默拦截) - 含下一轮提示词 NEXT-ROUND-PROMPT.md
56 lines
4.0 KiB
JavaScript
56 lines
4.0 KiB
JavaScript
import { attach } from '/tmp/cdp3.mjs';
|
|
import fs from 'fs';
|
|
const wait = ms => new Promise(z => setTimeout(z, ms));
|
|
const c = await attach('/web/temu/add') || await attach('dianxiaomi.com');
|
|
const CAT=process.argv[2]||'发夹';
|
|
await c.evalJS(`document.body.dispatchEvent(new MouseEvent('mousedown',{bubbles:true}));document.body.click();`);
|
|
await wait(1200);
|
|
const pos = JSON.parse(String(await c.evalJS(`(()=>{const it=[...document.querySelectorAll('.ant-form-item')].filter(e=>e.offsetParent!==null)
|
|
.find(x=>{const l=x.querySelector('label'); return l&&/产品分类/.test(l.innerText||'');});
|
|
const el=it.querySelector('.ant-select-selector'); el.scrollIntoView({block:'center'});
|
|
const r=el.getBoundingClientRect(); return JSON.stringify([Math.round(r.x+r.width/2),Math.round(r.y+r.height/2)]);})()`)));
|
|
for(const t of ['mousePressed','mouseReleased']) await c.send('Input.dispatchMouseEvent',{type:t,x:pos[0],y:pos[1],button:'left',clickCount:1});
|
|
await wait(3000);
|
|
let res='nf';
|
|
for(let i=0;i<90;i++){
|
|
const r = await c.evalJS(`(()=>{const dd=[...document.querySelectorAll('.ant-select-dropdown')].filter(e=>e.offsetParent!==null).pop();
|
|
if(!dd)return'no-dd'; const target=${JSON.stringify(CAT)};
|
|
const hit=[...dd.querySelectorAll('.ant-select-item-option')].find(o=>(o.innerText||'').trim()===target);
|
|
if(!hit)return'scroll';
|
|
for(const ev of ['mousedown','mouseup','click']) hit.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window}));
|
|
return 'picked';})()`);
|
|
if(r==='picked'){res='picked';break;}
|
|
if(r==='no-dd'){res='no-dd';break;}
|
|
await c.evalJS(`(()=>{const dd=[...document.querySelectorAll('.ant-select-dropdown')].filter(e=>e.offsetParent!==null).pop();
|
|
if(!dd)return 0; const rc=dd.querySelector('.rc-virtual-list-holder')||dd; rc.scrollTop=rc.scrollTop+500; return rc.scrollTop;})()`);
|
|
await wait(280);
|
|
}
|
|
console.log('类目:', res, CAT);
|
|
if(res!=='picked') process.exit(1);
|
|
await wait(14000);
|
|
const o = await c.evalJS(`(()=>{
|
|
const p=document.querySelector('#app').__vue_app__.config.globalProperties.$pinia;
|
|
const items=[...document.querySelectorAll('.ant-form-item')].filter(e=>e.offsetParent!==null).map(x=>{
|
|
const l=x.querySelector('label'); const lab=l?(l.innerText||'').replace(/\\s+/g,' ').trim():'';
|
|
const req=!!x.querySelector('.ant-form-item-required');
|
|
const inp=x.querySelector('input:not([type=hidden])'); const ta=x.querySelector('textarea'); const sel=x.querySelector('.ant-select-selection-item');
|
|
return (req?'* ':' ')+lab.slice(0,22).padEnd(23)+'['+(ta?'ta':(sel?'select':(inp?'input':'-')))+'] '+(sel?sel.innerText.trim():(inp?inp.value:(ta?ta.value:''))).slice(0,22);
|
|
}).filter(x=>x.trim().length>4);
|
|
const tables=[...document.querySelectorAll('table')].filter(t=>t.offsetParent!==null).map(t=>({
|
|
th:[...t.querySelectorAll('th')].map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim()).slice(0,12),
|
|
rows:[...t.querySelectorAll('tbody tr')].filter(x=>x.querySelectorAll('input').length).length}));
|
|
const cut=(x,d=0)=>(d>3?'…':(Array.isArray(x)?(x.length?'['+x.length+'] '+JSON.stringify(x[0]).slice(0,260):'[]'):(x&&typeof x==='object'?Object.fromEntries(Object.entries(x).map(([k,v])=>[k,cut(v,d+1)])):x)));
|
|
const dump={};
|
|
for(const n of ['temuAddProductStore','temuAddSkuDataStore','temuAddSkuAttrStore','temuAddBasicStore','temuAddAttrStore'])
|
|
{ try{dump[n]=cut(JSON.parse(JSON.stringify(p._s.get(n).$state)));}catch(e){dump[n]='ERR';} }
|
|
const b=p._s.get('temuAddBasicStore').$state;
|
|
return JSON.stringify({items, tables, dump, catId:b.formState.categoryId, path:b.dataState.categoryPathName},null,1);})()`);
|
|
fs.writeFileSync('/tmp/temu_deep.json', String(o));
|
|
const j=JSON.parse(String(o));
|
|
console.log('catId:', j.catId, '| path:', j.path);
|
|
console.log('=== form ==='); j.items.forEach(x=>console.log(' '+x));
|
|
console.log('=== tables ==='); console.log(JSON.stringify(j.tables));
|
|
console.log('=== stores ===');
|
|
for(const [n,v] of Object.entries(j.dump)) console.log(' ##',n,JSON.stringify(v).slice(0,520));
|
|
process.exit(0);
|