Skip to content

Instantly share code, notes, and snippets.

@bang9
Last active April 28, 2022 08:42
Show Gist options
  • Save bang9/5a2a07156b5a30db13afc1edc4ce4e33 to your computer and use it in GitHub Desktop.
Save bang9/5a2a07156b5a30db13afc1edc4ce4e33 to your computer and use it in GitHub Desktop.
NaverPay Calculator
// 네이버 페이 사용금액 계산기
// 1. https://order.pay.naver.com/home 접속
// 2. 원하는 탭(쇼핑/콘텐츠) 들어가서, 모든 결제항목 더보기로 불러오기
// 3. 콘솔창 오픈 후 아래 코드 실행
const findElem = () => document.getElementsByClassName('button_viewmore')[0];
async function getAll() {
return new Promise(resolve => {
const intv = setInterval(() => {
const elem = findElem();
const finished = elem?.parentElement?.style?.display === 'none'
if(finished) {
console.log('fetch finished');
clearInterval(intv)
resolve();
} else {
console.log('load next');
elem.click();
window.scrollTo(0,Number.MAX_SAFE_INTEGER);
}
}, 500)
})
}
async function run() {
await getAll();
const priceInfo = Array.from(document.querySelectorAll('ul.info'))
const total = priceInfo.reduce((totalPrice,currentInfo)=>{
const currentPrice = parseInt(currentInfo.children[0].innerText.replace(/,|원/g,""));
return totalPrice + currentPrice;
},0)
console.warn(`네이버페이에 ${total}원 사용함`);
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment