function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getFlakeCount() {
const flakeWrapper = document.querySelector('span.item-content-text');
if (!flakeWrapper) return null;
const innerSpan = flakeWrapper.querySelector('span');
if (!innerSpan) return null;
const rawText = innerSpan.innerText;
const numeric = parseInt(rawText.replace(/,/g, '') || '0');
return isNaN(numeric) ? null : numeric;
}
async function runDrawLoop() {
console.clear();
const startFlake = getFlakeCount();
if (startFlake === null || isNaN(startFlake)) {
alert('❌ 시작 보유량을 찾을 수 없습니다.');
return;
}
console.log(`▶️ 시작 플레이크 보유량: ${startFlake.toLocaleString()}`);
const firstDrawButtons = document.querySelectorAll('span.button-draw-hover-text');
let initialButton = null;
for (const btn of firstDrawButtons) {
if (btn.innerText.trim() === '100 뽑기') {
initialButton = btn;
break;
}
}
if (!initialButton) {
alert('❌ 초기 "100 뽑기" 버튼을 찾을 수 없습니다.');
return;
}
initialButton.click();
await delay(getRandom(4000, 4200)); // 첫 팝업 대기
const rewards = [];
let actualDrawCount = 0;
let hasMissingReward = false;
for (let i = 0; i < 30; i++) {
actualDrawCount = i + 1;
const rewardElement = document.querySelector('.l1l2-flakehub-popup-common-received_reward');
const rewardText = rewardElement ? rewardElement.innerText.trim() : '';
let message = '';
if (rewardText) {
message = `🎁 ${actualDrawCount}회차 보상: ${rewardText}`;
} else {
message = `⚠️ ${actualDrawCount}회차: 보상 텍스트를 찾지 못했습니다.`;
hasMissingReward = true;
}
console.log(message);
rewards.push(message);
const repeatButtons = document.querySelectorAll('span.block.whitespace-nowrap');
let clicked = false;
for (const span of repeatButtons) {
if (span.innerText.trim() === '100 뽑기 한번 더!') {
span.click();
clicked = true;
break;
}
}
if (!clicked) {
console.log(`❌ ${actualDrawCount}회차: "100 뽑기 한번 더!" 버튼을 찾지 못했습니다.`);
break;
}
await delay(2700); // 각 뽑기 후 대기 시간
}
const endFlake = getFlakeCount();
if (endFlake === null || isNaN(endFlake)) {
alert('❌ 종료 보유량을 찾을 수 없습니다.');
return;
}
const gained = endFlake - startFlake;
const absGained = Math.abs(gained);
const gainSign = gained > 0 ? '+' : gained < 0 ? '-' : '±';
// 포인트 계산
const startPoint = Math.floor(startFlake / 25);
const endPoint = Math.floor(endFlake / 25);
const pointDiff = endPoint - startPoint;
const pointSign = pointDiff > 0 ? '+' : pointDiff < 0 ? '-' : '±';
const finalPointMessage = `${pointSign}${endPoint.toLocaleString()}`;
// 손익 계산 줄
const flakeResultLine =
gained > 0
? `📈 이익: +${endFlake.toLocaleString()}`
: gained < 0
? `📉 손해: -${endFlake.toLocaleString()}`
: `➖ 손익 없음: ±${endFlake.toLocaleString()}`;
// ✅ 콘솔 출력
console.log('✅ 30회 완료!');
console.log(`▶️ 종료 후 플레이크 보유량: ${endFlake.toLocaleString()}`);
console.log(`🎉 오늘 획득한 플레이크 수: ${gained.toLocaleString()}`);
console.log(`🏅 오늘 획득한 포인트: ${finalPointMessage}`);
console.log(flakeResultLine);
if (hasMissingReward) {
console.log('n🔁 보상 텍스트 누락 감지 — 받은 보상 전체 다시 출력 🔁');
rewards.forEach(r => console.log(r));
}
// 📢 alert 메시지 구성
let alertMessage = '';
alertMessage += `▶️ 시작 플레이크 보유량: ${startFlake.toLocaleString()}n`;
alertMessage += `✅ ${actualDrawCount}회 완료!n`;
alertMessage += `▶️ 종료 후 플레이크 보유량: ${endFlake.toLocaleString()}n`;
alertMessage += `🎉 오늘 획득한 플레이크 수: ${gained.toLocaleString()}n`;
alertMessage += `🏅 오늘 획득한 포인트: ${finalPointMessage}n`;
alertMessage += `${flakeResultLine}`;
const fullAlert = [...rewards, '', alertMessage].join('n');
alert(fullAlert);
}
void runDrawLoop();