window.OzonStrategies=window.OzonStrategies||{},window.OzonStrategies.pdd={name:"Pinduoduo",matches:e=>e.includes("yangkeduo.com")||e.includes("pinduoduo.com"),scrape:function(){const e=e=>{if(!e)return null;let t=e.split("?")[0].replace(/\.webp$/,"").replace(/_\.webp$/,"");return t.startsWith("//")&&(t="https:"+t),t};let t="";const n=document.querySelector("span.enable-select span")||document.querySelector(".goods-name");t=n?n.innerText.trim():document.title;const r=[];document.querySelectorAll('div[tabindex="-1"]').forEach(e=>{const t=e.querySelectorAll('[aria-hidden="true"]');t.length>=2&&r.push({name:t[0].innerText.trim(),value:t[1].innerText.trim()})}),0===r.length&&document.querySelectorAll(".goods-details-params .param-item").forEach(e=>{const t=e.querySelector(".param-key"),n=e.querySelector(".param-value");t&&n&&r.push({name:t.innerText.trim(),value:n.innerText.trim()})});const a=[];document.querySelectorAll('img[aria-label="商品大图"], .swiper-wrapper img').forEach(t=>{const n=t.getAttribute("data-src")||t.src,r=e(n);r&&a.push(r)});const i=[],o=['img[aria-label="查看图片"]',".detail-video-wrapper img",".goods-detail-content img",'div[aria-label="点击查看大图"] img'].join(", ");document.querySelectorAll(o).forEach(t=>{const n=t.getAttribute("data-src")||t.src,r=e(n);r&&!a.includes(r)&&(i.includes(r)||i.push(r))});const l=t,c=[];document.querySelectorAll("span.sku-specs-key, .spec-title").forEach(t=>{const n=t.innerText.replace(/：|:/g,"").trim(),r=t.nextElementSibling||t.parentElement.querySelector(".spec-items"),a=[];r&&r.querySelectorAll('[role="button"], .spec-item').forEach(t=>{const n=t.getAttribute("aria-label")||t.innerText.trim();let r=null;const i=t.querySelector("img");i&&(r=e(i.src)),n&&a.push({name:n,image:r})}),a.length>0&&c.push({label:n,options:a})});let s=-1;for(let m=0;m<c.length;m++)if(c[m].options.some(e=>e.image)){s=m;break}-1===s&&c.length>0&&(s=0);let u=[];if(0===c.length)u.push({row_id:1,sku_unique_id:`sku_pdd_single_${Date.now()}`,specs:{color_name_cn:"默认",size_name_cn:"均码"},price:{amount:"0",currency:"CNY"},stock_quantity:999,sku_image_url:a[0]});else{const e=c[s].options,t=c.filter((e,t)=>t!==s);let n=[];n=t.length>0?function(e){if(!e||0===e.length)return[{name:"均码"}];const t=(e,n)=>{if(0===n.length)return e.map(e=>({name:e.name}));const r=n[0],a=t(r.options,n.slice(1)),i=[];return e.forEach(e=>{a.forEach(t=>{i.push({name:`${e.name} ${t.name}`})})}),i};return t(e[0].options,e.slice(1))}(t):[{name:"均码"}];let r=1;e.forEach(e=>{n.forEach(t=>{u.push({row_id:r++,sku_unique_id:`sku_pdd_${Date.now()}_${r}`,specs:{color_name_cn:e.name,size_name_cn:t.name},price:{amount:"0",currency:"CNY"},stock_quantity:999,sku_image_url:e.image||a[0]})})})}return{__instruction__:"PDD Generic -> Ozon",meta_info:{source_url:window.location.href,crawl_timestamp:Date.now()},global_data:{product_name:t,description_clean_text:l,category_hint:"",features:r,packaging:{defaults:{weight_g:500,length_mm:300,width_mm:200,height_mm:100},full_table:[]},media_gallery:{main_images:[...new Set(a)],detail_images:[...new Set(i)]}},sku_matrix:u}}};
