- jsonic( // jsonic is used because JSON.parse() requires strict JSON and eval() allows for remote code execution
- cheerio.load(data, null, false) // parse HTML
- ("script") // find script tags
- .toArray() // convert cheerio list to array
- .map(script => script.children[0]?.data) // map script tags to their inline code
- .find(script => script?.startsWith("AF_initDataCallback")) // find script that contains init data
- .slice("AF_initDataCallback(".length, -");".length) // remove call to init function
- ).data[31][0][12][2].map(elem => new Object({ // map the parts of the init data we know/care about to something readable
- image: {
- url: elem[1][3][0],
- size: {
- width: elem[1][3][2],
- height: elem[1][3][1],
+ cheerio.load(data, null, false) // parse HTML
+ ("script") // find script tags
+ .toArray() // convert cheerio list to array
+ .map(script => script.children[0]?.data) // map script tags to their inline code
+ .filter(script => script?.startsWith("AF_initDataCallback")) // find script that contains init data
+ .map(script => script.slice("AF_initDataCallback(".length, -");".length)) // remove call to init function
+ .map(jsonic) // jsonic is used because JSON.parse() requires strict JSON and eval() allows remote code execution
+ .find(data => data.key == "ds:1") // for some reason there are two init datas, one is empty tho
+ .data[31][0][12][2].map(elem => new Object({ // map the parts of the init data we know/care about to something readable
+ image: {
+ url: elem[1][3][0],
+ size: {
+ width: elem[1][3][2],
+ height: elem[1][3][1],
+ },