Skip to content

Instantly share code, notes, and snippets.

@koreapyj
Last active April 6, 2024 08:38
Show Gist options
  • Save koreapyj/c7523a915be130d8abc3a101396cc7e1 to your computer and use it in GitHub Desktop.
Save koreapyj/c7523a915be130d8abc3a101396cc7e1 to your computer and use it in GitHub Desktop.
상품권 자동입력

각종 상품권 자동입력

/* https://m.happymoney.co.kr/svc/view/charge/charge/chargeHappyMoney */
/* 풀오토 */
{
const sleep = (ms) => new Promise(r => {
setTimeout(r, ms)
});
const list = [
['1234-5678-9012-3456', '20230101'],
]
const iframe = document.createElement('iframe')
iframe.setAttribute('src', 'https://m.happymoney.co.kr/svc/view/charge/charge/chargeHappyMoney')
iframe.setAttribute('style', 'width:100%;height:100%')
document.body.innerHTML = ''
document.body.setAttribute('style', 'overflow:hidden !important')
document.body.appendChild(iframe)
const ctx = {}
iframe.addEventListener('load', async e => {
const {contentWindow: window, contentDocument: document} = iframe
console.log(e, window.location.pathname)
switch(window.location.pathname) {
case '/svc/view/charge/charge/chargeResult': {
if(!document.querySelector('.chargeInfoUl') || document.querySelectorAll('.chargeInfoUl > li').length != 5) {
if(!confirm(`충전 검증실패\n\n충전결과열갯수불일치\n\n계속하시겠습니까?`)) {
console.error(`기대갯수 5 / 실제갯수 ${document.querySelectorAll('.chargeInfoUl > li').length}`)
return
}
}
if(ctx.lastCodes.length != 5) {
if(!confirm(`충전 검증실패\n\n상품권갯수불일치\n\n계속하시겠습니까?`)) {
console.error(`기대갯수 5 / 실제갯수 ${ctx.lastCodes.length}`, ctx.lastCodes)
return
}
}
const result = [...document.querySelectorAll('.chargeInfoUl .leftArea > p:nth-child(3)')].find(x=>x.innerHTML.replace(/^\s+|\s+$/g,'') != '충전완료')
if(result) {
if(!confirm(`충전 부분실패\n\n${result.innerHTML}\n\n계속하시겠습니까?`)) {
return
}
}
const success_codes = [...document.querySelectorAll('.chargeInfoUl .leftArea > h4')].map(x=>x.innerHTML.replace(/^\s+|\s+$/g,''))
const check = success_codes.find((code, i) => ctx.lastCodes[i] != code)
if(check) {
if(!confirm(`충전 검증실패\n\n상품권코드불일치 ${check} \n\n계속하시겠습니까?`)) {
return
}
}
window.location.href = '/svc/view/charge/charge/chargeHappyMoney'
} break
case '/svc/view/charge/charge/chargeHappyMoney': {
const {contentWindow: {
document,
mtk,
$
}} = iframe
ctx.lastCodes = []
for(let i=0;i<3;i++) document.getElementsByClassName('addSectionBtn')[0].click();
await (async ()=> {
for(const i of list.keys()) {
const [code, expire] = list[i]
const s_code = code.split('-')
for(const j of s_code.keys()) {
const code = s_code[j]
const elem = document.querySelector(`#pinNo${j+1}_${i}`)
if(!elem) return
if(j==0) {
mtk.onKeyboard(elem)
await sleep(30)
for(let k=0;k<code.length;k++) {
const event = $(`#mtk_pinNo${j+1}_${i}`).find('[onmousedown],[ontouchstart]').is('[onmousedown]') ? 'mousedown' : 'touchstart'
$(`#mtk_pinNo${j+1}_${i} [on${event}] [alt="${code[k]}"]`).closest(`[on${event}]`).trigger(event)
await sleep(30)
}
continue
}
elem.value = code
}
document.getElementById(`issuedDate_${i}`).value = expire
ctx.lastCodes.push(code)
}
})()
list.splice(0, ctx.lastCodes.length)
window.confirm = ()=>true
$('.btnOrange').click()
} break
default: {
console.error(`Unknown route ${window.location.pathname}`)
}
}
})
}
/* https://www.pointropay.co.kr/exchange */
(async () => {
const list = [
[ "1234567890123456", "7890", ],
]
const pins = []
for(const [code, pin] of list) {
pins.push({
pinNo: code.replace(/[^\d]/g,''),
pinPassword: pin,
})
}
{
const result = await (await fetch('https://www.pointropay.co.kr/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(pins.map(pin => {
return {
"operationName": "queryPin",
"variables": {
"input": {
"pointStore": "BOOKNLIFE",
...pin,
}
},
"query": "mutation queryPin($input: QueryPinInput!) {\n queryPin(input: $input) {\n result\n message\n balance\n error\n __typename\n }\n}\n"
}
}))
})).json()
result.forEach((row, index) => {
const prodBal = ~~(row.data.queryPin.balance*0.92)
Object.assign(pins[index], {
prodBal,
prodBalFee: row.data.queryPin.balance-prodBal
})
})
console.log(pins)
}
await fetch('https://www.pointropay.co.kr/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify([
{
"operationName": "usePin",
"variables": {
"input": {
"pointStore": "BOOKNLIFE",
pins,
}
},
"query": "mutation usePin($input: UsePinInput!) {\n usePin(input: $input) {\n result\n message\n error\n __typename\n }\n}\n"
}
])
})
})()
/* https://www.pointropay.co.kr/exchange */
{
const list = [
'123456789012-345678',
]
const pins = []
for(const code of list) {
pins.push({
pinNo: code.replace(/[^\d]/g,''),
pinPassword: "",
prodBal: 0,
prodBalFee: 0
})
}
await fetch('https://www.pointropay.co.kr/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify([
{
"operationName": "usePin",
"variables": {
"input": {
"pointStore": "CULTURE",
pins,
}
},
"query": "mutation usePin($input: UsePinInput!) {\n usePin(input: $input) {\n result\n message\n error\n __typename\n }\n}\n"
}
])
})
}
// ==UserScript==
// @name AutoInput StarBiz
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.star-biz.co.kr/html_file.php?file=charge_voucher.html
// @icon https://www.google.com/s2/favicons?sz=64&domain=www.star-biz.co.kr
// @grant none
// ==/UserScript==
(async () => {
const regex = /(\d{4}).?(\d{4}).?(\d{4}).?(\d{6})/g
const pinFields = (()=>{
const out = [
[],
[],
[],
[],
]
for(let i=1;i<=10;i++) {
Array.prototype.map.call(document.querySelectorAll(`[name="number_${i}[]"]`), (row, idx)=>{
out[idx].push(row)
})
}
return out
})()
document.addEventListener('keydown', async e => {
const {key, shiftKey, ctrlKey, altKey} = e
if(ctrlKey && key.toLowerCase() == 'v') {
const str = await navigator.clipboard.readText()
let idx = 0, res = null
while((res = regex.exec(str)) instanceof Array) {
try {
const [_, ...pinNumbers] = res
pinNumbers.forEach((num, key)=>pinFields[key][idx].value=num)
idx++
} catch {
alert(`AutoInput: idx range exceeded at '${idx}'`)
return
}
}
}
})
})()
// ==UserScript==
// @name TouchEn Transkey Auto input
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Input automatically on TouchEn Transkey
// @author koreapyj
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const {$, mtk} = window
if(!$ || !mtk || mtk.autoinput) return
mtk.autoinput = async(value, elem) => {
class ENOKEY extends Error{};
const sleep = (ms) => new Promise(r => {
setTimeout(r, ms)
});
const specialchars = {
"`": "어금기호",
"~": "물결표시",
"!": "느낌표",
"@": "골뱅이",
"#": "샾",
"$": "달러기호",
"%": "퍼센트",
"^": "꺽쇠",
"&": "엠퍼샌드",
"*": "별표",
"(": "왼쪽괄호",
")": "오른쪽괄호",
"-": "빼기",
"_": "밑줄",
"=": "등호",
"+": "더하기",
"[": "왼쪽대괄호",
"{": "왼쪽중괄호",
"]": "오른쪽대괄호",
"}": "오른쪽중괄호",
"\\": "역슬래시",
"|": "수직막대",
";": "세미콜론",
":": "콜론",
"/": "슬래시",
"?": "물음표",
",": "쉼표",
"<": "왼쪽꺽쇠괄호",
".": "마침표",
">": "오른쪽꺽쇠괄호",
"'": "작은따옴표",
"\"": "따옴표"
}
const $elem = $(elem || '#mtk_passwd')
const event = $elem.find('[onmousedown],[ontouchstart]').is('[onmousedown]') ? 'mousedown' : 'touchstart'
const mtk_presskey = (key) => {
const $key = $elem.find(`[on${event}] [alt="${key}"]`).closest(`[on${event}]`)
if(!$key.length) {
throw new ENOKEY(key)
}
$key.trigger(event)
}
for(let i=0;i<value.length;i++) {
let trial = 0;
do {
if(/[A-Z]/.test(value[i])) {
mtk_presskey(`쉬프트`)
mtk_presskey(`대문자${value[i]}`)
mtk_presskey(`쉬프트`)
}
else if(specialchars[value[i]]) {
mtk_presskey(`특수키`)
mtk_presskey(specialchars[value[i]])
mtk_presskey(`특수키`)
}
else {
mtk_presskey(value[i])
}
break
} while(trial<3);
await sleep(300)
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment