// 캐릭터명 응모 가능 여부 / 응모 인원 확인 (검색만, 응모하지 않음)
// 사용법: lostark.game.onstove.com/Promotion/Draw/261202 에 로그인한 뒤
// 개발자 도구 콘솔에 이 파일 전체를 붙여 넣고 실행 → 오른쪽 위 창에 닉네임 붙여넣고 시작.
// 보내는 요청: POST /Promotion/Draw/Search261202 (공식 페이지의 검색 버튼과 같은 요청) 하나뿐.
// 간격: 1~2초 무작위. 이상 응답이 오면 즉시 멈춤.
// 외부 전송·저장 없음: 요청은 같은 사이트 검색 하나, 결과는 이 창과 복사 버튼으로만 나감.
(() => {
document.getElementById('ndc')?.remove();
const box = document.createElement('div');
box.id = 'ndc';
box.innerHTML = `
<style>
#ndc{position:fixed;top:16px;right:16px;z-index:99999;width:560px;max-height:85vh;display:flex;flex-direction:column;gap:8px;
padding:14px;background:#1b1d22;color:#e8e8e8;border:1px solid #444;border-radius:8px;font:13px/1.4 sans-serif;box-shadow:0 8px 30px #0008}
#ndc textarea{height:80px;resize:vertical;background:#111;color:#eee;border:1px solid #444;border-radius:4px;padding:6px}
#ndc .bar{display:flex;gap:6px;align-items:center}
#ndc button{padding:4px 10px;border:1px solid #555;border-radius:4px;background:#2a2d34;color:#eee;cursor:pointer}
#ndc button:disabled{opacity:.4;cursor:default}
#ndc .st{margin-left:auto;color:#aaa}
#ndc .wrap{overflow:auto}
#ndc table{width:100%;border-collapse:collapse}
#ndc th,#ndc td{padding:3px 6px;border-bottom:1px solid #333;text-align:left}
#ndc th{position:sticky;top:0;background:#1b1d22}
#ndc .가능{color:#6fdc8c} #ndc .불가,#ndc .형식{color:#ff7b7b} #ndc .알{color:#f0c060}
</style>
<textarea placeholder="닉네임 목록 (줄바꿈·쉼표·공백 구분)"></textarea>
<div class="bar">
<button data-a="go">시작</button><button data-a="stop" disabled>중지</button>
<button data-a="copy">복사 (TSV)</button><button data-a="only">가능만 보기</button>
<button data-a="x">닫기</button><span class="st"></span>
</div>
<div class="wrap"><table><thead><tr><th>이름</th><th>상태</th><th>응모인원</th><th>메모</th></tr></thead><tbody></tbody></table></div>`;
document.body.append(box);
const $ = s => box.querySelector(s);
const btn = a => $(`[data-a=${a}]`);
const status = t => { $('.st').textContent = t; };
const sleep = ms => new Promise(r => setTimeout(r, ms));
const valid = n => n.length >= 2 && n.length <= 12 && /^[가-힣a-zA-Z0-9]+$/.test(n);
let rows = [], running = false, onlyOk = false;
const addRow = r => {
rows.push(r);
const tr = document.createElement('tr');
for (const v of [r.이름, r.상태, r.응모인원, r.메모]) {
const td = document.createElement('td');
td.textContent = v;
tr.append(td);
}
tr.children[1].className = r.상태.slice(0, 2).replace('알 ', '알');
tr.hidden = onlyOk && r.상태 !== '가능';
$('tbody').append(tr);
};
async function check(name) {
const res = await fetch('/Promotion/Draw/Search261202', {
method: 'POST',
headers: { 'X-Requested-With': 'XMLHttpRequest' },
body: new URLSearchParams({ search: name }),
});
const text = await res.text();
if (!res.ok) throw new Error(`HTTP ${res.status}`);
let json = null;
try { json = JSON.parse(text); } catch {}
if (json) throw new Error(json.message || JSON.stringify(json));
const doc = new DOMParser().parseFromString(text, 'text/html');
const r = [...doc.querySelectorAll('.search-result')]
.find(e => e.querySelector('.result')?.textContent.trim() === name) || doc.querySelector('.search-result');
if (!r) return { 이름: name, 상태: '알 수 없음', 응모인원: '', 메모: '응답 형식 모름' };
const b = r.querySelector('.button--event-enter');
const 상태 = !b ? '불가' : b.classList.contains('complete') ? '응모함' : b.disabled ? '불가' : '가능';
return {
이름: name, 상태,
응모인원: r.querySelector('.state em')?.textContent.trim() ?? '',
메모: r.querySelector('.possibility')?.textContent.trim() ?? '',
};
}
btn('go').onclick = async () => {
const names = [...new Set($('textarea').value.split(/[s,]+/).filter(Boolean))];
if (!names.length) return;
if (names.length > 200 && !confirm(`${names.length}개 — 요청이 많습니다. 계속할까요?`)) return;
rows = []; $('tbody').textContent = '';
running = true; btn('go').disabled = true; btn('stop').disabled = false;
let sent = 0, unknown = 0;
for (const [i, name] of names.entries()) {
if (!running) { status(`중지됨 (${i}/${names.length})`); break; }
if (!valid(name)) { addRow({ 이름: name, 상태: '형식 오류', 응모인원: '', 메모: '' }); continue; }
if (sent) {
await sleep(1000 + Math.random() * 1000); // 지연시간 조정은 여기 건드리시면 됨
if (!running) { status(`중지됨 (${i}/${names.length})`); break; }
}
sent++;
let r;
try { r = await check(name); } catch (e) { status(`중단: ${e.message} (${name})`); break; }
addRow(r);
status(`${i + 1}/${names.length}`);
// 결과 형식을 못 읽는 응답이 연달아 오면 페이지가 바뀐 것: 멈춤
unknown = r.상태 === '알 수 없음' ? unknown + 1 : 0;
if (unknown >= 3) { status('중단: 결과 형식을 읽지 못함 (3회 연속)'); break; }
if (i + 1 === names.length) status(`완료 ${names.length}개, 가능 ${rows.filter(x => x.상태 === '가능').length}개`);
}
running = false; btn('go').disabled = false; btn('stop').disabled = true;
};
btn('stop').onclick = () => { running = false; };
btn('copy').onclick = async () => {
const tsv = ['이름t상태t응모인원t메모', ...rows.map(r => [r.이름, r.상태, r.응모인원, r.메모].join('t'))].join('n');
await navigator.clipboard.writeText(tsv);
status('복사함');
};
btn('only').onclick = () => {
onlyOk = !onlyOk;
btn('only').textContent = onlyOk ? '전체 보기' : '가능만 보기';
[...$('tbody').children].forEach((tr, i) => { tr.hidden = onlyOk && rows[i].상태 !== '가능'; });
};
btn('x').onclick = () => { running = false; box.remove(); };
})();