Skip to content

Commit

Permalink
update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ihsangan committed May 25, 2024
1 parent 2c1edda commit fe93c4f
Showing 1 changed file with 30 additions and 43 deletions.
73 changes: 30 additions & 43 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Honkai: Star Rail","server":"${sn}","id":${id},"name":"${data.confirmationFields.username}"}`
return result
return `{"success":true,"game":"Honkai: Star Rail","server":"${sn}","id":${id},"name":"${data.confirmationFields.username}"}`
}
if (path.includes('/gi')) {
if (id. startsWith('6')) {
Expand Down Expand Up @@ -67,8 +66,7 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Genshin Impact","server":"${sn}","id":${id},"name":"${data.confirmationFields.username}"}`
return result
return `{"success":true,"game":"Genshin Impact","server":"${sn}","id":${id},"name":"${data.confirmationFields.username}"}`
}
if (path.includes('/hi')) {
const body = `voucherPricePoint.id=48160&voucherPricePoint.price=16500.0&voucherPricePoint.variablePrice=0&user.userId=${id}&user.zoneId=&voucherTypeName=HONKAI_IMPACT&shopLang=id_ID`
Expand All @@ -81,8 +79,7 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Honkai Impact 3rd","id":${id},"name":"${data.confirmationFields.username}"}`
return result
return `{"success":true,"game":"Honkai Impact 3rd","id":${id},"name":"${data.confirmationFields.username}"}`
}
if (path.includes('/ml') && !zone) {
return `{"success":false,"message":"Bad Request"}`
Expand All @@ -98,11 +95,10 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Mobile Legends: Bang Bang","id":${id},"zoneId":${zone},"name":"${data.confirmationFields.username}"}`
return result
return `{"success":true,"game":"Mobile Legends: Bang Bang","id":${id},"zoneId":${zone},"name":"${data.confirmationFields.username}"}`
}
if (path.includes('/valo')) {
const body = `voucherPricePoint.id=115691&voucherPricePoint.price=15000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&voucherTypeName=VALORANT&voucherTypeId=109&gvtId=139&shopLang=id_ID`
if (path.includes('/sm')) {
const body = `voucherPricePoint.id=256513&voucherPricePoint.price=16000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&user.zoneId=global-release&voucherTypeName=SAUSAGE_MAN&shopLang=id_ID`
const request = new Request(endpoint, {
method: 'POST',
headers: {
Expand All @@ -112,19 +108,10 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
if (data.success == true) {
let result = `{"success":true,"game":"VALORANT","id":"${id}","region": "Indonesia","name":"${data.confirmationFields.username}"}`
return result
} else if (data.errorCode == -200) {
let result = `{"success":true,"game":"VALORANT","id":"${id}","region": "unknown","name":"${data.confirmationFields.userId}"}`
return result
} else {
let result = `{"success":false,"message":"Cannot find nickname from your request."}`
return result
}
return `{"success":true,"game":"Sausage Man","id":"${id}","name":"${data.confirmationFields.username}"}`
}
if (path.includes('/sm')) {
const body = `voucherPricePoint.id=256513&voucherPricePoint.price=16000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&user.zoneId=global-release&voucherTypeName=SAUSAGE_MAN&shopLang=id_ID`
if (path.includes('/valo')) {
const body = `voucherPricePoint.id=115691&voucherPricePoint.price=15000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&voucherTypeName=VALORANT&voucherTypeId=109&gvtId=139&shopLang=id_ID`
const request = new Request(endpoint, {
method: 'POST',
headers: {
Expand All @@ -134,8 +121,13 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Sausage Man","id":"${id}","name":"${data.confirmationFields.username}"}`
return result
if (data.success == true) {
return `{"success":true,"game":"VALORANT","id":"${id}","region": "Indonesia","name":"${data.confirmationFields.username}"}`
} else if (data.errorCode == -200) {
return `{"success":true,"game":"VALORANT","id":"${id}","region": "unknown","name":"${data.confirmationFields.userId}"}`
} else {
return `{"success":false,"message":"Cannot find nickname from your request."}`
}
}
if (path.includes('/ff')) {
const body = `voucherPricePoint.id=8050&voucherPricePoint.price=1000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&voucherTypeName=FREEFIRE&shopLang=id_ID&voucherTypeId=1&gvtId=1`
Expand All @@ -148,8 +140,7 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Garena Free Fire","id":${id},"name":"${data.confirmationFields.roles[0].role}"}`
return result
return `{"success":true,"game":"Garena Free Fire","id":${id},"name":"${data.confirmationFields.roles[0].role}"}`
}
if (path.includes('/cod')) {
const body = `voucherPricePoint.id=46114&voucherPricePoint.price=5000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&voucherTypeName=CALL_OF_DUTY&shopLang=id_ID&voucherTypeId=1&gvtId=1`
Expand All @@ -162,8 +153,7 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Call Of Duty","id":${id},"name":"${data.confirmationFields.roles[0].role}"}`
return result
return `{"success":true,"game":"Call Of Duty","id":${id},"name":"${data.confirmationFields.roles[0].role}"}`
}
if (path.includes('/aov')) {
const body = `voucherPricePoint.id=7946&voucherPricePoint.price=10000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&voucherTypeName=AOV&shopLang=id_ID&voucherTypeId=1&gvtId=1`
Expand All @@ -176,8 +166,7 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Garena AOV (Arena of Valor)","id":${id},"name":"${data.confirmationFields.roles[0].role}"}`
return result
return `{"success":true,"game":"Garena AOV (Arena of Valor)","id":${id},"name":"${data.confirmationFields.roles[0].role}"}`
}
if (path.includes('/sus')) {
const body = `voucherPricePoint.id=266077&voucherPricePoint.price=13000.0&voucherPricePoint.variablePrice=0&user.userId=${id}&user.zoneId=&voucherTypeName=SUPER_SUS&shopLang=id_ID`
Expand All @@ -190,49 +179,47 @@ async function callAPI(request) {
})
const response = await fetch(request)
const data = await response.json()
let result = `{"success":true,"game":"Super Sus","id":${id},"name":"${data.confirmationFields.username}"}`
return result
return `{"success":true,"game":"Super Sus","id":${id},"name":"${data.confirmationFields.username}"}`
}
else {
let result = `{"success":false,"message":"Bad request"}`
return result
return `{"success":false,"message":"Bad request"}`
}
}
catch (error) {
let result = `{"success":false,"message":"Cannot find nickname from your request."}`
return result
return `{"success":false,"message":"Cannot find nickname from your request."}`
}
}
async function serveResult(request) {
let dc = new URL(request.url).searchParams.get('decode')
let code = 200
let result = await callAPI(request)
if (result.includes(`"undef`)){
if (result.includes(`"undefined"`)) {
result = `{"success":false,"message":"Cannot find nickname from your request."}`
}
if (JSON.parse(result).success == false) {
code = 400
}
result = result.replace(/\u002B/g, ' ')
if (dc == false){
result = result.replace(/\u002B/g, '%20')
if (dc == false) {
result = result
}
if (!dc || dc == true){
if (!dc || dc == true) {
result = decodeURIComponent(result)
}
let response = new Response(result, {
status: code,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Method': 'GET',
'Cache-Control': 'max-age=60',
'Access-Control-Allow-Method': 'GET, HEAD',
'Cache-Control': 'public, max-age=43200',
'Content-Length': result.length,
'Content-Type': 'application/json; charset=utf-8',
}
})
return response
}
async function checkCache(request) {
if (request.method !== 'GET') {
if (request.method !== 'GET' || request.method !== 'HEAD') {
return new Response('Method Not Allowed', {
status: 405
})
Expand Down

0 comments on commit fe93c4f

Please sign in to comment.