← 쇼룸

더셀 · 쿠팡 원클릭사장님 전용 · 원가·마진은 여기만

1상품

도매 링크는 자동으로 읽지 않습니다(브라우저 보안·도매처 약관). 상품번호만 뽑아 드립니다 — 상품명·매입가 2칸만 붙여넣으면 끝입니다.

2기본 정보

3가격 조건

[1방 생성]을 누르면 쿠팡 규칙에 맞춘 상품명 3안이 나옵니다.
검색 태그 20개가 여기에 나옵니다.
상세페이지(HTML·PNG)가 여기에 나옵니다.
마진 가격표가 여기에 나옵니다.
Wing 엑셀·오픈 API 파일이 여기에 나옵니다.
'; } /* 캔버스로 같은 블록을 같은 순서로 그림 — 폭 780 고정, 높이는 내용만큼(≤12,000) */ function wrapLines(ctx, text, maxW){ var words = String(text).split(' '), lines = [], cur = ''; words.forEach(function(w){ var t = cur ? cur + ' ' + w : w; if (ctx.measureText(t).width <= maxW){ cur = t; return; } if (cur) lines.push(cur); if (ctx.measureText(w).width <= maxW){ cur = w; return; } var part = ''; w.split('').forEach(function(ch){ if (ctx.measureText(part + ch).width > maxW){ lines.push(part); part = ch; } else part += ch; }); cur = part; }); if (cur) lines.push(cur); return lines; } function paint(ctx, blocks, imgs, draw, texts){ var W = 780, P = 48, IN = W - P * 2, y = 0, FF = '"Malgun Gothic","Apple SD Gothic Neo",sans-serif'; function font(px, b){ ctx.font = (b ? 'bold ' : '') + px + 'px ' + FF; } function rect(x, yy, w, h, c){ if (draw){ ctx.fillStyle = c; ctx.fillRect(x, yy, w, h); } } function text(str, px, bold, color, lh, x, maxW, align){ font(px, bold); var ls = wrapLines(ctx, str, maxW); if (draw){ texts.push(str); ctx.fillStyle = color; ctx.textBaseline = 'top'; ctx.textAlign = align || 'left'; ls.forEach(function(l, i){ ctx.fillText(l, align === 'center' ? x + maxW / 2 : x, y + i * lh + (lh - px) / 2); }); } y += ls.length * lh; return ls.length; } function measure(str, px, bold, lh, maxW){ font(px, bold); return wrapLines(ctx, str, maxW).length * lh; } function img(url, maxW, maxH, bg){ var im = imgs[url]; if (!im) return; var s = Math.min(maxW / im.width, maxH / im.height), w = im.width * s, h = im.height * s; if (bg) rect(0, y, W, h, bg); if (draw) ctx.drawImage(im, (W - w) / 2, y, w, h); y += h; } blocks.forEach(function(b){ var y0 = y, tx = blockTexts(b); if (b.t === 'hero'){ if (b.img) img(b.img, W, 860, '#EEF1F6'); var pad = b.img ? 44 : 114, yb = y; var bh = pad + measure(tx[0], 40, true, 54, IN) + 12 + measure(tx[1], 22, false, 32, IN) + pad; rect(0, yb, W, bh, '#0A1128'); y += pad; text(tx[0], 40, true, '#FFFFFF', 54, P, IN); y += 12; text(tx[1], 22, false, '#FFA24D', 32, P, IN); y = yb + bh; return; } if (b.t === 'problem'){ var hh = 56 + measure(tx[0], 34, true, 46, IN) + 24; tx.slice(1).forEach(function(l){ hh += measure(l, 24, false, 34, IN - 60) + 36 + 14; }); hh += 42; rect(0, y, W, hh, '#F4F6FA'); y += 56; text(tx[0], 34, true, '#0A1128', 46, P, IN, 'center'); y += 24; tx.slice(1).forEach(function(l){ var ch = measure(l, 24, false, 34, IN - 60) + 36; if (draw){ ctx.fillStyle = '#FFFFFF'; ctx.beginPath(); if (ctx.roundRect) ctx.roundRect(P, y, IN, ch, 14); else ctx.rect(P, y, IN, ch); ctx.fill(); ctx.fillStyle = '#FF6B00'; ctx.beginPath(); ctx.arc(P + 26, y + 35, 6, 0, Math.PI * 2); ctx.fill(); } y += 18; text(l, 24, false, '#1b2333', 34, P + 44, IN - 60); y += 18 + 14; }); y = y0 + hh; return; } if (b.t === 'point'){ var ph = 56 + 32 + 10 + measure(tx[1], 34, true, 46, IN) + 20 + 24 + 56; if (b.img && imgs[b.img]){ var im = imgs[b.img], sc = Math.min(IN / im.width, 640 / im.height); ph += im.height * sc; } tx.slice(2).forEach(function(l){ ph += measure(l, 23, false, 36, IN); }); rect(0, y, W, ph, b.img ? '#FFFFFF' : '#FFF5EC'); y += 56; text(tx[0], 22, true, '#FF6B00', 32, P, IN); y += 10; text(tx[1], 34, true, '#0A1128', 46, P, IN); y += 20; if (b.img) img(b.img, IN, 640); y += 24; tx.slice(2).forEach(function(l){ text(l, 23, false, '#33405a', 36, P, IN); }); y = y0 + ph; return; } if (b.t === 'spec'){ var sh = 56 + measure(tx[0], 34, true, 46, IN) + 20 + 56, KW = 200; b.rows.forEach(function(r){ sh += Math.max(measure(r[0], 21, true, 30, KW - 28), measure(r[1], 21, false, 30, IN - KW - 28)) + 24; }); rect(0, y, W, sh, '#F4F6FA'); y += 56; text(tx[0], 34, true, '#0A1128', 46, P, IN); y += 20; b.rows.forEach(function(r){ var rh = Math.max(measure(r[0], 21, true, 30, KW - 28), measure(r[1], 21, false, 30, IN - KW - 28)) + 24, ry = y; rect(P, ry, KW, rh, '#E8ECF3'); rect(P + KW, ry, IN - KW, rh, '#FFFFFF'); if (draw){ ctx.strokeStyle = '#D5DBE6'; ctx.lineWidth = 1; ctx.strokeRect(P + .5, ry + .5, IN - 1, rh - 1); ctx.beginPath(); ctx.moveTo(P + KW + .5, ry); ctx.lineTo(P + KW + .5, ry + rh); ctx.stroke(); } y = ry + 12; text(r[0], 21, true, '#0A1128', 30, P + 14, KW - 28); y = ry + 12; text(r[1], 21, false, '#1b2333', 30, P + KW + 14, IN - KW - 28); y = ry + rh; }); y = y0 + sh; return; } if (b.t === 'cta'){ var cth = 56 + measure(tx[0], 32, true, 44, IN) + 12 + measure(tx[1], 22, false, 32, IN) + 56; rect(0, y, W, cth, '#FF6B00'); y += 56; text(tx[0], 32, true, '#0A1224', 44, P, IN, 'center'); y += 12; text(tx[1], 22, false, '#0A1224', 32, P, IN, 'center'); y = y0 + cth; return; } var lh2 = 56 + measure(tx[0], 30, true, 42, IN) + 18 + 56; tx.slice(1).forEach(function(l){ lh2 += measure(l, 23, false, 36, IN - 24) + 8; }); rect(0, y, W, lh2, '#FFFFFF'); if (draw && b.t === 'caution') rect(0, y, W, 2, '#E8ECF3'); y += 56; text(tx[0], 30, true, b.t === 'caution' ? '#C2410C' : '#0A1128', 42, P, IN); y += 18; tx.slice(1).forEach(function(l){ if (draw){ ctx.fillStyle = '#FF6B00'; ctx.beginPath(); ctx.arc(P + 5, y + 18, 5, 0, Math.PI * 2); ctx.fill(); } text(l, 23, false, '#33405a', 36, P + 24, IN - 24); y += 8; }); y = y0 + lh2; }); return Math.ceil(y); } async function detailPng(blocks){ var imgs = {}, urls = K.uniq(blocks.map(function(b){ return b.img; }).filter(Boolean)); for (var i = 0; i < urls.length; i++) imgs[urls[i]] = await K.loadImg(urls[i]); var cv = document.createElement('canvas'); cv.width = 780; cv.height = 10; var h = Math.min(12000, paint(cv.getContext('2d'), blocks, imgs, false, [])); cv.height = h; var ctx = cv.getContext('2d'), texts = []; ctx.fillStyle = '#FFFFFF'; ctx.fillRect(0, 0, 780, h); paint(ctx, blocks, imgs, true, texts); return { canvas: cv, w: 780, h: h, texts: texts, url: cv.toDataURL('image/png') }; } /* ---------- 탭 ④ 마진표 ---------- */ function marginCalc(inp){ var cats = K.D.fees.coupang.categories, rate = K.D.fees.coupang.defaultRate; cats.forEach(function(c){ if (c.name === inp.cat) rate = c.rate; }); var ret = inp.ret, vatOn = inp.vat === 'tax', vr = vatOn ? 1 / 11 : 0, base = inp.cost + inp.ship; var den = 1 - rate - vr - ret, be = base / den; function row(label, P){ var fee = Math.round(P * rate), vat = vatOn ? Math.round(P / 11) : 0, rv = Math.round(P * ret); var profit = P - inp.cost - inp.ship - fee - vat - rv; return { label: label, price: P, cost: inp.cost, ship: inp.ship, fee: fee, vat: vat, ret: rv, profit: profit, mr: profit / P, lock: profit < 0 || P < be }; } function priceFor(m){ var d = den - m; return d > 0 ? Math.ceil(base / d / 10) * 10 : 0; } var tiers = [['최저(마진 10%)', 0.10], ['권장(목표 ' + inp.margin + '%)', inp.margin / 100], ['프리미엄(마진 35%)', 0.35]]; return { rate: rate, ret: ret, vatOn: vatOn, be: be, beCeil: Math.ceil(be), rows: tiers.map(function(t){ return row(t[0], priceFor(t[1])); }), row: row }; } /* ---------- 탭 ⑤ 등록 파일 ---------- */ var WING_HEAD = ['노출상품명', '등록상품명', '브랜드', '카테고리코드', '판매가', '재고수량', '배송방법', '배송비', '상품상태', '대표이미지', '상세설명', '원산지', '상품코드', '옵션명', '중량']; function wingRow(inp, r){ var price = S.priceSel || r.margin.rows[1].price, g = (String(inp.spec).match(/(\d+(?:\.\d+)?)\s*g/i) || [])[1]; return [r.titles[0].t, inp.name, '브랜드없음', '', price, 100, '택배', inp.ship, '새상품', S.photos[0] ? S.photos[0].name : '', '상세_' + K.safeName(inp.name) + '.png 첨부', '상세페이지 참조', r.code, '단일상품', g ? Number(g) : '']; } function apiBody(inp, r){ var price = S.priceSel || r.margin.rows[1].price, vendor = ($('#apiVendor') && $('#apiVendor').value.trim()) || 'VENDOR_ID'; return { displayCategoryCode: 0, categoryId: 0, sellerProductName: r.titles[0].t, vendorId: vendor, saleStartedAt: '2026-11-20T00:00:00', saleEndedAt: '2099-01-01T23:59:59', displayProductName: r.titles[0].t, brand: '', generalProductName: inp.name, deliveryMethod: 'SEQUENCIAL', deliveryCompanyCode: 'CJGLS', deliveryChargeType: inp.ship > 0 ? 'NOT_FREE' : 'FREE', deliveryCharge: inp.ship, freeShipOverAmount: 0, deliveryChargeOnReturn: 3000, remoteAreaDeliverable: 'N', unionDeliveryType: 'UNION_DELIVERY', returnCenterCode: 'RETURN_CENTER_CODE', outboundShippingPlaceCode: 'OUTBOUND_PLACE_CODE', returnCharge: 3000, requested: false, items: [{ itemName: '단일상품', sellerProductItemName: inp.name, originalPrice: price, salePrice: price, maximumBuyCount: 100, maximumBuyForPerson: 0, maximumBuyForPersonPeriod: 1, outboundShippingTimeDay: 1, unitCount: 1, adultOnly: 'EVERYONE', taxType: inp.vat === 'free' ? 'FREE' : 'TAX', parallelImported: 'NOT_PARALLEL_IMPORTED', overseasPurchased: 'NOT_OVERSEAS_PURCHASED', externalVendorSku: r.code, emptyBarcode: true, emptyBarcodeReason: '바코드 없음', searchTags: r.tags.map(function(x){ return x.t; }), images: [{ imageOrder: 0, imageType: 'REPRESENTATION', vendorPath: 'https://내-이미지-호스팅/' + (S.photos[0] ? S.photos[0].name : 'main.jpg') }], notices: [{ noticeCategoryName: '기타 재화', noticeCategoryDetailName: '품명 및 모델명', content: inp.name }, { noticeCategoryName: '기타 재화', noticeCategoryDetailName: 'A/S 책임자와 전화번호', content: '판매자 문의' }], attributes: [{ attributeTypeName: '수량', attributeValueName: '1개' }], contents: [{ contentsType: 'IMAGE_NO_SPACE', contentDetails: [{ content: 'https://내-이미지-호스팅/상세.png', detailType: 'IMAGE' }] }] }] }; } function signedDateNow(){ var d = new Date(); function p(n){ return (n < 10 ? '0' : '') + n; } return String(d.getUTCFullYear()).slice(2) + p(d.getUTCMonth() + 1) + p(d.getUTCDate()) + 'T' + p(d.getUTCHours()) + p(d.getUTCMinutes()) + p(d.getUTCSeconds()) + 'Z'; } function coupangSign(secret, signedDate, method, path, query){ var message = signedDate + method + path + (query || ''); return { message: message, signature: K.hex(K.hmacSha256(secret, message)) }; } window.coupangSign = coupangSign; /* ---------- 입력 ---------- */ function readInp(){ return { name: $('#inName').value.trim(), cost: K.num($('#inCost').value), cat: $('#inCat').value, spec: $('#inSpec').value.trim(), ship: K.num($('#inShip').value), margin: K.num($('#inMargin').value) || 22, vat: $('#inVat').value, link: $('#inLink').value.trim(), ret: K.D.fees.coupang.returnReserve }; } function linkInfo(){ var v = $('#inLink').value.trim(), el = $('#linkInfo'); if (!v){ el.textContent = ''; return ''; } var m = v.match(/[?&](?:goodsNo|productNo|productId|itemId|item_id|goods_no|no|id|pid)=(\d{4,})/i) || v.match(/\/(\d{5,})(?:[/?#]|$)/); var id = m ? m[1] : ''; el.textContent = id ? '상품번호: ' + id + ' — 이 번호로 도매처에서 상품명·매입가를 확인해 붙여넣으세요' : '상품번호를 찾지 못했습니다 — 상품명·매입가만 직접 넣어 주세요'; return id; } /* ---------- 그리기 ---------- */ function chips(c){ return '
글자수 ' + c.len + '/100' + (c.len >= 45 && c.len <= 55 ? ' · 권장' : ' · 권장 45~55') + '' + '중복단어 ' + c.dup + '금지어 ' + c.ban + '' + '특수문자 ' + c.sp + '
'; } function drawTitles(r){ $('#tabTitle').innerHTML = r.titles.map(function(o){ var c = titleCheck(o.t); return '
' + o.label + '
' + K.esc(o.t) + '
' + chips(c) + '
'; }).join('') + '

규칙: 핵심 키워드 맨 앞 · 100자 이내(권장 45~55) · 특수문자·중복 단어·과장어 금지 · 속성+대상+용도+수량 순서

' + '

'; $('#btnAiTitle').onclick = aiPolish; K.aiBadge(); } function drawTags(r){ $('#tabTag').innerHTML = '

정확히 ' + r.tags.length + '개 · 중복 0 · 2~10자 · # 없이

' + r.tags.map(function(x){ return '' + K.esc(x.t) + '' + x.g + ''; }).join('') + '
' + '

구성: 카테고리 4 · 속성 4 · 대상 4 · 상황 4 · 동의어 2 · 규격 2

'; $('#btnTagCopy').onclick = function(){ K.copy(r.tags.map(function(x){ return x.t; }).join('\n')); }; } function drawDetail(r){ $('#tabDetail').innerHTML = '

상세 HTML 1개 · PNG 1장 (폭 ' + r.png.w + 'px × 높이 ' + K.fmt(r.png.h) + 'px) · 블록 ' + r.blocks.length + '개 · 같은 내용

' + '
' + '

이 상세페이지에는 원가·마진·연락처가 들어가지 않습니다 (원가·마진 단어 ' + r.cust.ban.length + '건 · 전화번호 ' + r.cust.phone + '건 · 문의는 "판매자 문의"로 표기)

' + '
상세페이지 미리보기
'; $('#btnHtml').onclick = dlHtml; $('#btnPng').onclick = dlPng; } function drawMargin(r){ var m = r.margin; function tr(x, i){ return '' + x.label + '' + K.fmt(x.price) + '' + K.fmt(x.fee) + '' + K.fmt(x.vat) + '' + K.fmt(x.profit) + '' + K.pct(x.mr) + '' + (x.lock ? '' : '') + ''; } $('#tabMargin').innerHTML = '

요율 ' + K.pct(m.rate) + ' (' + K.esc(r.inp.cat) + ' 기준) · 부가세 ' + (m.vatOn ? '판매가÷11' : '0') + ' · 반품충당 ' + K.pct(m.ret) + '

' + '

손익분기가 ' + K.won(m.beCeil) + ' — 이 아래 가격은 어떤 버튼도 눌리지 않습니다

' + '
' + '' + m.rows.map(tr).join('') + (S.custom ? tr(S.custom) : '') + '
구분판매가수수료부가세순익마진율등록
' + '' + '
' + '

계산식: 순익 = 판매가 − 매입가(' + K.fmt(r.inp.cost) + ') − 배송비(' + K.fmt(r.inp.ship) + ') − 수수료 − 부가세 − 반품충당 · 반올림은 원 단위

'; K.$$('#marginTable [data-price]').forEach(function(b){ b.onclick = function(){ S.priceSel = Number(b.getAttribute('data-price')); drawMargin(r); drawExcel(r); K.toast(K.won(S.priceSel) + '으로 등록 파일을 만듭니다'); }; }); $('#btnTry').onclick = function(){ var p = K.num($('#inTry').value); if (!p) return; S.custom = m.row('직접 입력', Math.round(p)); drawMargin(r); }; $('#btnMarginCsv').onclick = dlMarginCsv; } function drawExcel(r){ var row = wingRow(r.inp, r), body = JSON.stringify(apiBody(r.inp, r), null, 2), F = K.D.fees.coupang.api; $('#tabExcel').innerHTML = '

(가) 일반용 — Wing 일괄등록 엑셀

' + '

15열 × 1행 · 판매가 ' + K.won(row[4]) + ' (④ 마진표에서 고른 가격)

' + '
' + '

Wing 공식 업로드 양식은 판매자센터에서 내려받아야 합니다. 이 파일은 그 양식에 붙여넣기 좋은 평면 표이고, 열 이름 대응표는 쿠팡 열 매핑에 있습니다.

' + '

(나) 사업자용 — 오픈 API 직통 업로드

' + '' + '
' + '
' + '

세 칸은 저장하지 않습니다(새로고침하면 사라짐). 서명 계산에만 이 화면 메모리에서 씁니다.

' + '
' + '
서명 규칙: message = signed-date + method + path + query\nHMAC-SHA256(SECRET) → hex · 헤더 ' + K.esc(F.header.replace('{accessKey}', '***')) + '
' + '' + '
' + '

프록시 주소가 없어 전송 버튼이 잠겨 있습니다 — 브라우저는 쿠팡 서버로 직접 보낼 수 없습니다(CORS). 업로드 스크립트로 PC에서 보내세요.

' + '

요청 본문 미리보기 (' + F.method + ' ' + F.createPath + ')

' + K.esc(body) + '
' + '

서명 자체 시험(고정 입력 signed-date=261120T000000Z · secret=kts-test-secret): ' + r.sigTest + '

'; $('#btnXlsx').onclick = dlXlsx; $('#btnCsv').onclick = dlCsv; $('#btnSign').onclick = doSign; $('#btnBody').onclick = dlBody; $('#btnPs1').onclick = dlPs1; $('#apiProxy').oninput = function(){ var u = $('#apiProxy').value.trim(); $('#btnProxy').disabled = !/^https:\/\//.test(u); $('#proxyWhy').textContent = $('#btnProxy').disabled ? '프록시 주소(https://)가 없어 전송 버튼이 잠겨 있습니다 — 업로드 스크립트로 PC에서 보내세요.' : '프록시로 보낼 준비가 되었습니다(ACCESS·SECRET·업체코드 필요).'; }; $('#btnProxy').onclick = sendProxy; } /* ---------- 동작 ---------- */ function doSign(){ var F = K.D.fees.coupang.api, sec = $('#apiSecret').value, acc = $('#apiAccess').value; if (!sec || !acc){ K.toast('ACCESS KEY·SECRET KEY를 넣어 주세요'); return null; } var sd = signedDateNow(), s = coupangSign(sec, sd, F.method, F.createPath, ''); $('#sigOut').textContent = 'signed-date: ' + sd + '\nmessage: ' + s.message + '\nsignature: ' + s.signature + '\nAuthorization: CEA algorithm=HmacSHA256, access-key=***, signed-date=' + sd + ', signature=' + s.signature; return { sd: sd, sig: s.signature, auth: 'CEA algorithm=HmacSHA256, access-key=' + acc + ', signed-date=' + sd + ', signature=' + s.signature }; } async function sendProxy(){ var u = $('#apiProxy').value.trim(), F = K.D.fees.coupang.api; if (!/^https:\/\//.test(u)) return; if (!$('#apiVendor').value.trim()){ K.toast('업체코드를 넣어 주세요'); return; } var s = doSign(); if (!s) return; try { var r = await fetch(u, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Coupang-Path': F.createPath, 'X-Coupang-Authorization': s.auth }, body: JSON.stringify(apiBody(S.res.inp, S.res)) }); K.toast('프록시 응답 ' + r.status); } catch(e){ K.toast('프록시 전송 실패 — 주소를 확인해 주세요'); } } function base(){ return K.safeName(S.res.inp.name); } function dlHtml(){ K.download(new Blob([S.res.html], { type: 'text/html;charset=utf-8' }), '상세_' + base() + '.html'); } function dlPng(){ S.res.png.canvas.toBlob(function(b){ K.download(b, '상세_' + base() + '.png'); }, 'image/png'); } var M_HEAD = ['구분', '판매가', '매입가', '배송비', '수수료', '부가세', '반품충당', '순익', '마진율(%)']; function mRows(){ return S.res.margin.rows.map(function(x){ return [x.label, x.price, x.cost, x.ship, x.fee, x.vat, x.ret, x.profit, Math.round(x.mr * 1000) / 10]; }); } function dlMarginCsv(){ K.download(K.csvBlob(M_HEAD, mRows()), '쿠팡_마진표_' + base() + '.csv'); } function dlXlsx(){ K.download(KTS_XLSX.xlsxBlob('쿠팡Wing', WING_HEAD, [wingRow(S.res.inp, S.res)]), '쿠팡_Wing등록_' + base() + '.xlsx'); } function dlCsv(){ K.download(K.csvBlob(WING_HEAD, [wingRow(S.res.inp, S.res)]), '쿠팡_Wing등록_' + base() + '.csv'); } function dlBody(){ K.download(new Blob([JSON.stringify(apiBody(S.res.inp, S.res), null, 2)], { type: 'application/json' }), 'coupang_body.json'); } function dlPs1(){ K.download(new Blob(['' + (window.KTS_DATA.upload_ps1 || '')], { type: 'text/plain;charset=utf-8' }), 'upload_coupang.ps1'); } async function aiPolish(){ var msg = $('#aiMsg'); try { var o = await aiJson('다음 쿠팡 상품명 3개를 더 자연스럽게 다듬어 JSON {"titles":["..","..",".."]} 로만 답하세요. 규칙: 핵심 키워드 "' + S.res.kw + '"를 맨 앞, 100자 이내, 특수문자·같은 단어 반복·과장어(최고·완벽·1위·100%) 금지.\n' + S.res.titles.map(function(t){ return t.t; }).join('\n')); var n = 0; (o.titles || []).slice(0, 3).forEach(function(t, i){ t = String(t || '').trim(); var c = titleCheck(t); if (c.ok && t.indexOf(S.res.kw) === 0){ S.res.titles[i].t = t; n++; } }); drawTitles(S.res); $('#aiMsg').textContent = 'AI 다듬기: ' + n + '안 채택 (규칙 검사 통과분만) · ' + (window.__aiModel || ''); } catch(e){ msg.textContent = aiErr(e); K.toast(aiErr(e)); } } async function go(){ if ($('#btnGo').disabled) return; var inp = readInp(), L = lookup(inp.name, inp.cat); S.priceSel = null; S.custom = null; var r = { inp: inp, kw: L.kw }; r.titles = makeTitles(inp, L); r.tags = makeTags(inp, L); r.blocks = makeBlocks(inp, L); r.html = detailHtml(r.blocks, inp.name); r.png = await detailPng(r.blocks); r.cust = K.customerCheck(r.html.replace(/src="data:[^"]+"/g, '') + '\n' + r.png.texts.join('\n')); r.margin = marginCalc(inp); r.code = 'KTS-' + K.stamp() + '-' + (K.seed(inp.name) % 100000); r.sigTest = coupangSign('kts-test-secret', '261120T000000Z', 'POST', K.D.fees.coupang.api.createPath, '').signature; S.res = r; drawTitles(r); drawTags(r); drawDetail(r); drawMargin(r); drawExcel(r); var htmlTexts = Array.prototype.map.call(new DOMParser().parseFromString(r.html, 'text/html').querySelectorAll('[data-t]'), function(e){ return e.textContent; }); window.__res = { titles: r.titles.map(function(t){ var c = titleCheck(t.t); return { t: t.t, len: c.len, dup: c.dup, ban: c.ban, sp: c.sp }; }), tags: r.tags.map(function(x){ return x.t; }), png: { w: r.png.w, h: r.png.h, texts: r.png.texts.length }, htmlTexts: htmlTexts.length, sameOrder: htmlTexts.join('\u0001') === r.png.texts.join('\u0001'), blocks: r.blocks.map(function(b){ return b.t; }), cust: r.cust, margin: { rate: r.margin.rate, ret: r.margin.ret, vatOn: r.margin.vatOn, be: r.margin.be, cost: inp.cost, ship: inp.ship, rows: r.margin.rows }, sigTest: r.sigTest, wingCols: WING_HEAD.length, wingRow: wingRow(inp, r), photos: S.photos.length }; window.__done = true; K.goTab('tabTitle'); K.toast('5탭을 모두 만들었습니다'); } /* 현재 탭 복사·받기 */ function curCopy(){ if (!S.res){ K.toast('먼저 [1방 생성]을 눌러 주세요'); return; } var t = K.activeTab, r = S.res; if (t === 'tabTitle') K.copy(r.titles.map(function(x){ return x.t; }).join('\n')); else if (t === 'tabTag') K.copy(r.tags.map(function(x){ return x.t; }).join('\n')); else if (t === 'tabDetail') K.copy(r.html); else if (t === 'tabMargin') K.copy([M_HEAD.join('\t')].concat(mRows().map(function(x){ return x.join('\t'); })).join('\n')); else K.copy([WING_HEAD.join('\t'), wingRow(r.inp, r).join('\t')].join('\n')); } function curDl(){ if (!S.res){ K.toast('먼저 [1방 생성]을 눌러 주세요'); return; } var t = K.activeTab, r = S.res; if (t === 'tabTitle') K.download(new Blob(['' + r.titles.map(function(x){ return x.label + '\t' + x.t; }).join('\r\n')], { type: 'text/plain' }), '쿠팡_상품명_' + base() + '.txt'); else if (t === 'tabTag') K.download(new Blob(['' + r.tags.map(function(x){ return x.t; }).join('\r\n')], { type: 'text/plain' }), '쿠팡_태그20_' + base() + '.txt'); else if (t === 'tabDetail') dlPng(); else if (t === 'tabMargin') dlMarginCsv(); else dlXlsx(); } /* ---------- 시작 ---------- */ async function boot(){ await K.loadData(['fees', 'tags_ko', 'copy_ko', 'sample_products']); $('#inCat').innerHTML = K.D.fees.coupang.categories.map(function(c){ return ''; }).join(''); K.shell(); K.tabs('#tabs'); K.gate('#btnGo', '#need', function(){ var m = []; if (!$('#inName').value.trim()) m.push('상품명'); if (!K.num($('#inCost').value)) m.push('매입가'); return m.length ? m.join('·') + ' — 넣어 주세요' : ''; }); $('#inLink').addEventListener('input', linkInfo); $('#inPhoto').addEventListener('change', async function(){ S.photos = await K.readPhotos(this.files, 6); $('#thumbs').innerHTML = S.photos.map(function(p, i){ return '사진 ' + (i + 1) + ''; }).join(''); K.toast('사진 ' + S.photos.length + '장 — 첫 장이 대표 사진입니다'); }); $('#btnGo').addEventListener('click', go); $('#btnCopy').addEventListener('click', curCopy); $('#btnDl').addEventListener('click', curDl); if (K.qs('sample') === '1'){ var idx = Math.min(2, Math.max(0, parseInt(K.qs('s') || '0', 10) || 0)), p = K.D.sample_products.products[idx]; $('#inName').value = p.name; $('#inCost').value = p.cost; $('#inCat').value = p.cat; $('#inSpec').value = p.spec; $('#inShip').value = p.ship; $('#inMargin').value = p.margin; $('#inLink').value = p.link || ''; linkInfo(); if (K.qs('nophoto') !== '1'){ S.photos = [K.samplePhoto(p.name, [28, 210, 140][idx])]; $('#thumbs').innerHTML = '샘플 사진'; } K.regate(); if (K.qs('auto') === '1') await go(); } } boot(); })();