Skip to content

Instantly share code, notes, and snippets.

@jgensler8
Last active December 3, 2022 23:30
Show Gist options
  • Save jgensler8/8492ffcc92b838200a74be0bb4835ec7 to your computer and use it in GitHub Desktop.
Save jgensler8/8492ffcc92b838200a74be0bb4835ec7 to your computer and use it in GitHub Desktop.
fortnite scraper

fortnite chapter 4 scraper

#fortnitechapter4

notes

only searchs alphabet (A-Z) and does not include numbers or other special symbols: https://en.wikipedia.org/wiki/ASCII#Character_set

instructions

  1. navigate to https://www.fortnitechapter4.com/
  2. copy/paste individual functions
  3. run search (can modify start of array and set number)
  4. check localstorage in the developer tool section. codes are prefixed with code- so search is a bit easier
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function searchCode(digit, codes) {
if(digit > 7) {
// fetch
if(codes.length == 8) {
await fetch(`https://www.fortnitechapter4.com/api/codes/${codes[0]}${codes[1]}${codes[2]}-${codes[3]}${codes[4]}-${codes[5]}${codes[6]}${codes[7]}/data.json`).then(res => {
if(res.status == 200) {
// console.debug(codes)
localStorage.setItem("code-" + codes, 1)
}
})
} else {
console.debug(digit, codes.length, codes)
}
await sleep(300)
return
} else {
let char_code_start = 65
let char_code_end = 90
// XXX: off by one with 90 == Z, should be less than 91 "["
for(let char_code = char_code_start ; char_code < char_code_end; char_code ++ ) {
let char_value = String.fromCharCode(char_code)
// console.debug(char_value)
let new_codes = JSON.parse(JSON.stringify(codes))
new_codes.push(char_value)
await searchCode(digit+1, new_codes)
}
}
}
// searchCode(7, [])
// searchCode(7, ["K","N","E", "L","B", "4","M","E"])
// known existing code: KNE-LB-4ME
// 6HU-TQ-4BY
searchCode(7, ["K","N","E", "L","B", "4","M"])
// searchCode(6, [])
// complete scrape
// searchCode(0, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment