자유 게시판

전체보기

모바일 상단 메뉴

본문 페이지

[잡담] 과금량 참고

아이콘 나무할배
조회: 190
2026-05-16 10:49:17
계정정보 - 구매 사용내역 - 검사 한국 - F12 후 복붙



위와 같은 오류가 뜨면 콘솔창에 allow pasting을 입력 후 엔터치고 F5 누른후에 재시도 

let startYear = 2014;
let endYear = 2026;
let total = 0;

const today = new Date();
const todayYear = today.getFullYear();
const todayMonth = String(today.getMonth() + 1).padStart(2, '0');
const todayDate = String(today.getDate()).padStart(2, '0');
const endDateFormatted = `${todayYear}.${todayMonth}.${todayDate}`;

async function fetchAmountsForYear(year) {
    let yearTotal = 0;
    let page = 1;
    let hasNextPage = true;

    while (hasNextPage) {
        const startDate = `${year}.01.01`;
        const endDate = year === todayYear ? endDateFormatted : `${year}.12.31`;
        const baseUrl = `?startDate=${startDate}&endDate=${endDate}&Page=${page}`;
        const response = await fetch(baseUrl);
        const text = await response.text();
        const parser = new DOMParser();
        const doc = parser.parseFromString(text, 'text/html');

        var emptyMessageCell = doc.querySelector('td.empty');
        if (emptyMessageCell && emptyMessageCell.textContent.trim() === '해당이력이 없습니다.') {
            console.log(`년도 ${year}에 해당 이력이 없습니다. 다음 년도로 진행합니다.`);
            return null;
        }

        const amounts = doc.querySelectorAll('td.amount');
        amounts.forEach(amount => {
            const value = parseInt(amount.textContent.replace(/,/g, ''), 11);
            if (value > 0) {
                yearTotal += value;
            }
        });

        
        const nextButton = doc.querySelector('a.btn_arrow.next');
        hasNextPage = nextButton !== null;
        page++;
    }

    return yearTotal;
}


async function fetchAllAmounts() {
    for (let year = startYear; year <= endYear; year++) {
        const yearTotal = await fetchAmountsForYear(year);
        if (yearTotal !== null) {
            total += yearTotal;
            const formattedYearTotal = yearTotal.toString().replace(/B(?=(d{3})+(?!d))/g, ",");
            console.log(`${year}년의 총 금액: ${formattedYearTotal}원`);
        }
    }

    const formattedTotal = total.toString().replace(/B(?=(d{3})+(?!d))/g, ",");
    console.log("지금까지 사용한 총 금액 :", formattedTotal + "원");
}

fetchAllAmounts();

Lv22 나무할배

모바일 게시판 하단버튼

댓글

새로고침
새로고침

모바일 게시판 하단버튼

지금 뜨는 인벤

더보기+

모바일 게시판 리스트

모바일 게시판 하단버튼

글쓰기

모바일 게시판 페이징

최근 HOT한 콘텐츠

  • 검사
  • 게임
  • IT
  • 유머
  • 연예
AD