diff --git a/api/download.js b/api/download.js index 4b8b08e..6f5224b 100644 --- a/api/download.js +++ b/api/download.js @@ -22,13 +22,22 @@ module.exports = async (app, req, res, api, ID, analyze) => { else return res.send("-1") } + let authorData = body.split("#")[3] // daily/weekly only, most likely + let levelInfo = app.parseResponse(body) let level = new Level(levelInfo, true) - request.post(app.endpoint + 'getGJUsers20.php', req.gdParams({ str: level.authorID }), function (err1, res1, b1) { - let gdSearchResult = app.parseResponse(b1) - request.post(app.endpoint + 'getGJUserInfo20.php', req.gdParams({ targetAccountID: gdSearchResult[16] }), function (err2, res2, b2) { - if (b2 != '-1') { + request.post(authorData ? "" : app.endpoint + 'getGJUsers20.php', authorData ? {} : req.gdParams({ str: level.authorID }), function (err1, res1, b1) { + let gdSearchResult = authorData ? "" : app.parseResponse(b1) + request.post(authorData ? "" : app.endpoint + 'getGJUserInfo20.php', authorData ? {} : req.gdParams({ targetAccountID: gdSearchResult[16] }), function (err2, res2, b2) { + + if (err2 && authorData) { + let authorInfo = authorData.split(":") + level.author = authorInfo[1] + level.accountID = authorInfo[0] + } + + else if (!err && b2 != '-1') { let account = app.parseResponse(b2) level.author = account[1] level.accountID = gdSearchResult[16] @@ -41,7 +50,7 @@ module.exports = async (app, req, res, api, ID, analyze) => { request.post(app.endpoint + 'getGJSongInfo.php', req.gdParams({ songID: level.customSong }), async function (err, resp, songRes) { - if (songRes != '-1') { + if (!err && songRes != '-1') { let songData = app.parseResponse(songRes, '~|~') level.songName = songData[2] || "Unknown" level.songAuthor = songData[4] || "Unknown" @@ -77,14 +86,24 @@ module.exports = async (app, req, res, api, ID, analyze) => { }) } - if (level.difficulty == "Extreme Demon") { + if (levelID < 0) { + request.post(app.endpoint + 'getGJDailyLevel.php', req.gdParams({ weekly: levelID == -2 ? "1" : "0" }), async function (err, resp, dailyInfo) { + if (err || dailyInfo == -1) return sendLevel() + let dailyTime = dailyInfo.split("|")[1] + level.nextDaily = +dailyTime + level.nextDailyTimestamp = Math.round((Date.now() + (+dailyTime * 1000)) / 100000) * 100000 + return sendLevel() + }) + } + + else if (level.difficulty == "Extreme Demon") { request.get('https://www.pointercrate.com/api/v1/demons/?name=' + level.name.trim(), function (err, resp, demonList) { if (err) return sendLevel() let demon = JSON.parse(demonList) if (demon[0] && demon[0].position <= 150) level.demonList = demon[0].position return sendLevel() }) - } + } else return sendLevel() diff --git a/assets/css/browser.css b/assets/css/browser.css index fed7732..d7c9df0 100644 --- a/assets/css/browser.css +++ b/assets/css/browser.css @@ -166,7 +166,7 @@ h2 { text-shadow: -0.275vh -0.275vh 0vh #000, 0.275vh -0.275vh 0vh #000, -0.275vh 0.275vh 0vh #000, 0.275vh 0.275vh 0vh #000, 0.5vh 0.5vh 0vh rgba(0,0,0,0.4); } -h3, input[type=text], input[type=password], input[type=number] { +h3, input[type=text], input[type=password], input[type=number], .h3Size { font-weight: normal; margin: 0 0; font-size: 3.5vh; diff --git a/classes/Level.js b/classes/Level.js index 638c6c4..9293b26 100644 --- a/classes/Level.js +++ b/classes/Level.js @@ -38,8 +38,8 @@ class Level { this.verifiedCoins = levelInfo[38] > 0 this.starsRequested = +levelInfo[39] this.ldm = levelInfo[40] > 0 - if (+levelInfo[41]) this.dailyNumber = (+levelInfo[41] > 100000 ? +levelInfo[41] - 100000 : +levelInfo[41]) if (+levelInfo[41] > 100000) this.weekly = true + if (+levelInfo[41]) { this.dailyNumber = (+levelInfo[41] > 100000 ? +levelInfo[41] - 100000 : +levelInfo[41]); this.nextDaily = null; this.nextDailyTimestamp = null } this.objects = +levelInfo[45] this.large = levelInfo[45] > 40000; this.cp = Number((this.stars > 0) + this.featured + this.epic) diff --git a/html/level.html b/html/level.html index 226d531..59f07d1 100644 --- a/html/level.html +++ b/html/level.html @@ -84,8 +84,8 @@


- -

#[[DAILYNUMBER]]

+ +

#[[DAILYNUMBER]]

@@ -156,8 +156,14 @@ let messageText = 'Your Geometry Dash password will not be stored anywhere on the site, both locally and server-side. You can view the code used for liking a level here.' $('#message').html(messageText) -function colonize(secs) { - return [Math.floor(+secs / 3600), Math.floor(+secs / 60) % 60, +secs % 60].map(v => v < 10 ? "0" + v : v).filter((v,i) => v !== "00" || i > 0).join(":") +function colonize(secs, timeUp) { + if (secs < 0) { + if (timeUp) return "Time's up!" + else secs = 0 + } + let days = Math.floor(secs / 86400) + if (days) secs -= days * 86400 + return `${days ? `${days}d + ` : ""}${[Math.floor(+secs / 3600), Math.floor(+secs / 60) % 60, +secs % 60].map(v => v < 10 ? "0" + v : v).filter((v,i) => v !== "00" || i > 0).join(":")}` } if (window.location.href.endsWith('?download')) $('#infoDiv').show() @@ -168,6 +174,7 @@ if (window.location.href.endsWith('?download')) $('#infoDiv').show() let copies = 0 let animated = false; let freeze = false; + let dailyTime = Number('[[NEXTDAILY]]') || null $('#playButton').click(function () { if (!($('#copied').is(':animated')) && !animated) { @@ -227,10 +234,17 @@ if (!'[[DEMONLIST]]'.startsWith("[")) { else $('.demonList').remove() if (!'[[DAILYNUMBER]]'.startsWith("[")) { - $('.dailyLevel').show() + $('#dailyTime').html(` (${colonize(dailyTime, true)})`) $('#dailyIcon').attr('src', `../assets/crown-${'[[WEEKLY]]'.startsWith("[") ? "daily" : "weekly"}.png`) + $('.dailyLevel').show() + + setInterval(() => { + dailyTime -= 1 + $('#dailyTime').html(` (${colonize(dailyTime, true)})`) + }, 1000); + } -else $('.demonList').remove() +else $('.dailyLevel').remove() if ("[[SONGID]]".startsWith("Level")) { $('#songInfo').text('[[SONGID]]')