이전 버전은 이제 안되는거 같아서 GPT로 만들어봤습니다.

다들 확인해보시고 저랑 같이 대가리 봉합하시죠


1. https://payment.nexon.com/usage/ 로 접속



2. F12를 눌러 개발자도구 -> console 탭 선택





3. 아래 코드를 복사 붙여넣기 후 엔터


- 콘솔탭에서 표시한 화살표 옆에 붙여넣으시면 됩니다.


여기 아래부터=================================================================



(async function () {

    const END_YEAR = new Date().getFullYear();

    const START_YEAR = END_YEAR - 5;


    const API_URL =

'https://public.api.nexon.com/billing-bff/mycash';


    const query = `

        query getNxCashHistory(

            $serviceType: String!,

            $year: Int!

        ) {

            nexonCashHistory(

                serviceType: $serviceType,

                year: $year

            ) {

                loginAccount

                otherAccount

            }

        }

    `;


    function parseValue(value) {

        if (value == null) {

            return null;

        }


        if (typeof value !== 'string') {

            return value;

        }


        const trimmed = value.trim();


        if (!trimmed) {

            return null;

        }


        try {

            return JSON.parse(trimmed);

        } catch {

            return trimmed;

        }

    }


    function toMonthlyAmounts(value) {

        value = parseValue(value);


        const result = Array(12).fill(0);


        if (value == null) {

            return result;

        }


        // [1000, 2000, ...] 형태

        if (Array.isArray(value)) {

            value.slice(0, 12).forEach((item, index) => {

                if (typeof item === 'number') {

                    result[index] += item;

                    return;

                }


                if (typeof item === 'string') {

                    const amount = Number(

                        item.replace(/[^0-9.-]/g, '')

                    );


                    if (Number.isFinite(amount)) {

                        result[index] += amount;

                    }


                    return;

                }


                if (item && typeof item === 'object') {

                    const month = Number(

                        item.month ??

                        item.monthNo ??

                        item.chargedMonth ??

                        index + 1

                    );


                    const amount = Number(

                        item.amount ??

                        item.chargedAmount ??

                        item.totalAmount ??

                        item.value ??

                        0

                    );


                    if (

                        month >= 1 &&

                        month <= 12 &&

                        Number.isFinite(amount)

                    ) {

                        result[month - 1] += amount;

                    }

                }

            });


            return result;

        }


        // {"1": 1000, "2": 2000} 형태

        if (typeof value === 'object') {

            Object.entries(value).forEach(([key, item]) => {

                const monthMatch = String(key).match(

                    /(?:month)?0?([1-9]|1[0-2])/i

                );


                if (monthMatch) {

                    const month = Number(monthMatch[1]);

                    const amount = Number(item || 0);


                    if (Number.isFinite(amount)) {

                        result[month - 1] += amount;

                    }


                    return;

                }


                // 객체 안에 배열이나 월별 객체가 한 번 더 들어간 경우

                const nested = toMonthlyAmounts(item);


                nested.forEach((amount, index) => {

                    result[index] += amount;

                });

            });

        }


        return result;

    }


    const monthlyRows = [];


    for (let year = START_YEAR; year <= END_YEAR; year++) {

        const response = await fetch(API_URL, {

            method: 'POST',

            credentials: 'include',

            headers: {

                'Content-Type': 'application/json'

            },

            body: JSON.stringify({

                query,

                variables: {

                    serviceType: 'charge',

                    year

                },

                operationName: 'getNxCashHistory'

            })

        });


        if (!response.ok) {

            console.error(

                `${year}년 조회 실패: HTTP ${response.status}`

            );

            continue;

        }


        const json = await response.json();


        if (json.errors) {

            console.error(

                `${year}년 GraphQL 오류`,

                json.errors

            );

            continue;

        }


        const history =

            json?.data?.nexonCashHistory;


        console.log(`${year}년 원본 응답:`, history);


        const loginAmounts = toMonthlyAmounts(

            history?.loginAccount

        );


        const otherAmounts = toMonthlyAmounts(

            history?.otherAccount

        );


        for (let month = 1; month <= 12; month++) {

            const loginAmount = loginAmounts[month - 1] || 0;

            const otherAmount = otherAmounts[month - 1] || 0;


            monthlyRows.push({

                year,

                month,

                loginAmount,

                otherAmount,

                totalAmount: loginAmount + otherAmount

            });

        }

    }


    const yearlyRows = [];


    for (let year = START_YEAR; year <= END_YEAR; year++) {

        const rows = monthlyRows.filter(

            item => item.year === year

        );


        yearlyRows.push({

            year,

            loginAmount: rows.reduce(

                (sum, item) => sum + item.loginAmount,

                0

            ),

            otherAmount: rows.reduce(

                (sum, item) => sum + item.otherAmount,

                0

            ),

            totalAmount: rows.reduce(

                (sum, item) => sum + item.totalAmount,

                0

            )

        });

    }


    const grandTotal = yearlyRows.reduce(

        (sum, item) => sum + item.totalAmount,

        0

    );


    window.nexonCashMonthlyResult = monthlyRows;

    window.nexonCashYearlyResult = yearlyRows;


    console.log('월별 결과');


    console.table(

        monthlyRows.map(item => ({

            연도: item.year,

            월: item.month,

            로그인계정: item.loginAmount.toLocaleString() + '원',

            다른계정: item.otherAmount.toLocaleString() + '원',

            합계: item.totalAmount.toLocaleString() + '원'

        }))

    );


    console.log('연도별 결과');


    console.table(

        yearlyRows.map(item => ({

            연도: item.year,

            로그인계정: item.loginAmount.toLocaleString() + '원',

            다른계정: item.otherAmount.toLocaleString() + '원',

            합계: item.totalAmount.toLocaleString() + '원'

        }))

    );


console.log(

    `${START_YEAR}~${END_YEAR}년 총 충전금액: ` +

    `${grandTotal.toLocaleString()}원`

);


alert(

    `${START_YEAR}년부터 ${END_YEAR}년까지 총 충전금액은 ` +

    `${grandTotal.toLocaleString()}원입니다.`

);

})();



=====================================================================

이 위까지 복사


4. 결과


콘솔 창에 각 월별,연도별 집계되고 다른계정도 같이 집계되니 참고 바랍니다.


로그인 계정만 보고싶으시면 콘솔 결과 확인해주세요~


*** 모바일 mc 충전은 제외입니다

****모바일에서는 확인 불가합니다ㅜㅜ







***
개발자 도구의 콘솔에서 복사한 텍스트를 붙여 넣으려 할 때, 경고 메시지가 표시되면서 붙여넣기가 되지 않을 수 있습니다.



이런 경우 콘솔에 '붙여넣기 허용' 또는 'allow pasting'을 입력하면 정상적으로 붙여넣기를 할 수 있습니다.