-
-
Save lijinma/82aa4e3419b948c54d991d28fdd8c784 to your computer and use it in GitHub Desktop.
Blast Airdrop Lucky/Twitter/Super Spin AUTO Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = { | |
get(url, { headers = {} }) { | |
return new Promise((resolve, reject) => { | |
const xhr = window.XMLHttpRequest | |
? new XMLHttpRequest() | |
: new ActiveXObject("Microsoft.XMLHTTP"); | |
xhr.open("get", url); | |
xhr.withCredentials = true; | |
// Object.entries(headers).forEach(([key,value]) => xhr.setRequestHeader(key, value)); | |
xhr.send(null); | |
xhr.onreadystatechange = function () { | |
if (this.readyState === 4) { | |
const data = JSON.parse(this.responseText); | |
return resolve({ data }) | |
} | |
} | |
xhr.onerror = function (error) { | |
return reject(error); | |
} | |
}) | |
}, | |
post(url, data, { headers = {} }) { | |
return new Promise((resolve, reject) => { | |
const xhr = window.XMLHttpRequest | |
? new XMLHttpRequest() | |
: new ActiveXObject("Microsoft.XMLHTTP"); | |
xhr.open("post", url); | |
xhr.withCredentials = true; | |
xhr.setRequestHeader("Content-Type","application/json"); | |
// Object.entries(headers).forEach(([key,value]) => xhr.setRequestHeader(key, value)); | |
xhr.send(JSON.stringify(data)); | |
xhr.onreadystatechange = function () { | |
if (this.readyState === 4) { | |
const data = JSON.parse(this.responseText); | |
return resolve({ data }) | |
} | |
} | |
xhr.onerror = function (error) { | |
return reject(error); | |
} | |
}) | |
} | |
} | |
async function run() { | |
const spinList = await getSpinList(); | |
log('spinList -> ', spinList); | |
if (!spinList.length) { | |
log('no spin, wating next polling...'); | |
return; | |
} | |
// [ { spinType: 'tweet-spin', spinMultiplier: 1 } ] | |
const splitSpinList = []; | |
for (const { spinType, spinAmount } of spinList) { | |
for (let i = 0; i < spinAmount; i++) { | |
let spinMultiplier; | |
if (spinType === 'super-spin') { | |
const superSpinMultiplier = await getSuperSpinMultiplier(); | |
spinMultiplier = superSpinMultiplier; | |
} else { | |
spinMultiplier = 1; | |
} | |
splitSpinList.push({ | |
spinType: spinType, | |
spinMultiplier: spinMultiplier | |
}); | |
} | |
} | |
log('splitSpinList -> ', splitSpinList); | |
for (let i = 0; i < splitSpinList.length; i++) { | |
try { | |
const { data: { result: { numberPoints, rarity } } } = await axios.post('https://waitlist-api.prod.blast.io/v1/spins/execute', splitSpinList[i], { | |
// headers: { | |
// 'cookie': `accessToken=${accessToken}`, | |
// } | |
}); | |
log(`${i} => rarity ${rarity} => numberPoints ${numberPoints}`); | |
} catch (error) { | |
log('❌ spin failed', error.response?.data?.message || 'unknown reason', error.toString()); | |
} | |
} | |
} | |
function getSpinList() { | |
log('get spinList ...'); | |
return new Promise(resolve => { | |
const request = async () => { | |
try { | |
const { data: { | |
spins | |
} } = await axios.get('https://waitlist-api.prod.blast.io/v1/user/dashboard', { | |
// headers: { | |
// 'cookie': `accessToken=${accessToken}`, | |
// } | |
}); | |
const spinList = Object.entries(spins).map(([key, value]) => ({ | |
spinType: key, | |
spinAmount: value | |
})).filter(item => item.spinAmount > 0) | |
resolve(spinList); | |
} catch (error) { | |
log('get spinList error', error.toString(), ' retring...'); | |
setTimeout(request, 2000); | |
} | |
} | |
request(); | |
}) | |
} | |
function getSuperSpinMultiplier() { | |
log('get getSuperSpinMultiplier ...'); | |
return new Promise(resolve => { | |
const request = async () => { | |
try { | |
const { data: | |
sampleSuperSpin | |
} = await axios.post('https://waitlist-api.prod.blast.io/v1/spins/sample-superspin', {}, { | |
// headers: { | |
// 'cookie': `accessToken=${accessToken}`, | |
// } | |
}); | |
log('get getSuperSpinMultiplier, sampleSuperSpin spinMultiplier ...', sampleSuperSpin['spinMultiplier']); | |
const superSpinMultiplier = sampleSuperSpin['spinMultiplier']; | |
resolve(superSpinMultiplier); | |
} catch (error) { | |
log('get getSuperSpinMultiplier error', error.toString(), ' retry...'); | |
setTimeout(request, 2000); | |
} | |
} | |
request(); | |
}) | |
} | |
function log(...msgs) { | |
const date = new Date(); | |
console.log(`${getDateTime()}`, ...msgs); | |
} | |
function getDateTime() { | |
const date = new Date(); | |
const now = date.getTime(); | |
const ms = String(now).slice(-3); | |
return `[${date.toLocaleString()}.${ms}]`; | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment