diff --git a/api/accurateLeaderboard.js b/api/accurateLeaderboard.js index 19e25e9..24d3e1d 100644 --- a/api/accurateLeaderboard.js +++ b/api/accurateLeaderboard.js @@ -1,15 +1,23 @@ const request = require('request') +const {GoogleSpreadsheet} = require('google-spreadsheet'); +const sheet = new GoogleSpreadsheet('1ADIJvAkL0XHGBDhO7PP9aQOuK3mPIKB2cVPbshuBBHc'); // accurate leaderboard spreadsheet module.exports = async (app, req, res) => { - if (app.endpoint != "http://boomlings.com/database/") return res.send([]) + if (!app.sheetsKey || app.endpoint != "http://boomlings.com/database/") return res.send([]) let type = req.query.type ? req.query.type.toLowerCase() : '' if (type == "usercoins") type = "coins" if (type != "demons" && type != "coins") type = '' + + let cell = type == "demons" ? 2 : type == "coins" ? 1 : 0 + + sheet.useApiKey(app.sheetsKey) + sheet.loadInfo().then(async () => { + let tab = sheet.sheetsById[1555821000] + await tab.loadCells('A2:C2') + let topPlayers = tab.getCell(1, cell).value - request.get(`https://gdleaderboards.com/incl/lbxml.php${type ? `?${type}=1` : ''}`, function (err, resp, topPlayers) { - if (err || !topPlayers) topPlayers = "" let idArray = topPlayers.split(",") let leaderboard = [] diff --git a/api/leaderboardLevel.js b/api/leaderboardLevel.js index b1ea2f4..f57f4bc 100644 --- a/api/leaderboardLevel.js +++ b/api/leaderboardLevel.js @@ -1,4 +1,3 @@ - const request = require('request') module.exports = async (app, req, res) => { diff --git a/assets/ulButton.png b/assets/ulButton.png new file mode 100644 index 0000000..bb677a0 Binary files /dev/null and b/assets/ulButton.png differ diff --git a/html/leaderboard.html b/html/leaderboard.html index 5729fe9..6aad068 100644 --- a/html/leaderboard.html +++ b/html/leaderboard.html @@ -80,7 +80,7 @@ let top250Text = `The Top 250<> leaderboard contains the top 250 players<>, sorted by star<> value. However, due to hackers<> flooding the leaderboard, this leaderboard has been frozen<> for well over 2 years and displays very outdated information<>.` let accurateText = -`The Accurate Leaderboard<> is a highly accurate, hacker-proof leaderboard with proper stats and positioning<> (unlike the regular one). It is managed by SMJSGaming, XShadowWizardX, Pepper360, Octeract<>, and many many other helpers. You can check out their interactive leaderboard spreadsheet here<>.` +`The Accurate Leaderboard<> is a highly accurate, hacker-proof leaderboard with proper stats and positioning<> (unlike the regular one). It is managed by XShadowWizardX, Pepper360, Octeract<>, and many many other helpers. You can check out their interactive leaderboard spreadsheet here<>.` let creatorText = `The Creators Leaderboard<> is sorted by creator points<>, rather than stars. A player's creator points<> (CP) is calculated by counting their number of star rated<> levels, plus an extra point for every level that has been featured<>, plus an additional point for epic rated<> levels.` diff --git a/index.js b/index.js index 338b096..6953c9b 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,9 @@ try { const secrets = require("./misc/secretStuff.json") app.id = secrets.id app.gjp = secrets.gjp + app.sheetsKey = secrets.sheetsKey if (app.id == "account id goes here" || app.gjp == "account gjp goes here") console.warn("Warning: No account ID and/or GJP has been provided in secretStuff.json! These are required for level leaderboards to work.") + if (app.sheetsKey.startsWith("google sheets api key")) app.sheetsKey = undefined } catch(e) { diff --git a/misc/credits.json b/misc/credits.json index 5a86267..f1668d9 100644 --- a/misc/credits.json +++ b/misc/credits.json @@ -27,6 +27,23 @@ { "header": "Accurate Leaderboard", + "name": "XShadowWizardX", + "youtube": ["https://www.youtube.com/channel/UCaf3-yyZDsAwh1IlYte5VtA", "youtube"], + "twitter": ["https://twitter.com/XShadowWizardX", "twitter"], + "github": ["https://docs.google.com/spreadsheets/d/10lbPnDYJXhbtlA0ls0cGjjX_osFSG559IDrTbhgPHvc", "ulButton"] + }, + + { + "header": "Demon List", + "name": "stadust1971", + "ign": "stardust1971", + "youtube": ["https://youtube.com/user/stardust19710", "youtube"], + "twitter": ["https://twitter.com/stadust1971", "twitter"], + "github": ["https://pointercrate.com", "demonButton"] + }, + + { + "header": "API Help", "name": "SMJSGaming", "youtube": ["https://youtube.com/channel/UCwEsWDs9kGN2vvoiNTJKdaQ", "youtube"], "twitter": ["https://instagram.com/smjs_gaming", "instagram"], @@ -41,22 +58,6 @@ "github": ["https://github.com/Alex1304", "github"] }, - { - "header": "Web Design Help", - "name": "Ucrash", - "youtube": ["https://youtube.com/channel/UCfPgDZBhCodHIFo6OOVcH2A", "youtube"], - "twitter": ["https://twitter.com/GDUcrash", "twitter"], - "github": ["https://github.com/GDUcrash", "github"] - }, - - { - "header": "Demon List API", - "name": "stadust1971", - "ign": "stardust1971", - "youtube": ["https://youtube.com/user/stardust19710", "youtube"], - "twitter": ["https://twitter.com/stadust1971", "twitter"], - "github": ["https://pointercrate.com", "demonButton"] - }, { "header": "Everything Else", @@ -72,7 +73,7 @@ "AlFas", "ViPriN", "Cvolton", - "cos8o", + "Ucrash", "zmxmx" ] } \ No newline at end of file diff --git a/misc/secretStuff.json b/misc/secretStuff.json index 478db9f..687928a 100644 --- a/misc/secretStuff.json +++ b/misc/secretStuff.json @@ -1,4 +1,5 @@ { "id": "account id goes here", - "gjp": "account gjp goes here" -} + "gjp": "account gjp goes here", + "sheetsKey": "google sheets api key (for accurate leaderboard - delete this line if you don't need it)" +} \ No newline at end of file diff --git a/package.json b/package.json index 732b320..2e1583d 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "compression": "^1.7.4", "connect-timeout": "^1.9.0", "express": "^4.17.1", + "google-spreadsheet": "^3.0.11", "jimp": "^0.8.5", "plist": "^3.0.1", "request": "^2.88.2"