Last active
March 11, 2021 08:07
-
-
Save Blantas/7c1626e4c789ee73183aeb4a769c1b6c to your computer and use it in GitHub Desktop.
Format list of lootboy cards codes.
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
var AUTH_HEADER = 'Bearer ____'; // <<-- PASTE YOUR BEARER TOKEN HERE | |
// 1. Acquire your Bearer token from Network Tab in Developer Tools window in your browser, ie. https://i.imgur.com/RTzD1pX.png | |
// 2. Paste the token in the first line of the code ^ | |
// 3. Finally, just paste the code in the Console tab: https://i.imgur.com/jMqtMZ4.png | |
// NEVER SHARE YOUR TOKEN PUBLICLY! | |
fetch('https://api.lootboy.de/v1/cards?lang=en', {method: 'GET',headers: {'authorization': AUTH_HEADER}}) | |
.then(response => response.json()) | |
.then(function(data){ | |
var i = 1, r = ''; | |
for(var p in data){ | |
if(data[p].reward?.code == undefined) continue; | |
r += (i + '. ' + (data[p].cardTemplate.name || '') + ' - ' + data[p].reward?.code + ' ' + (data[p].cardTemplate.availableUntil != undefined ? '(expires ' + new Date(data[p].cardTemplate.availableUntil).toLocaleDateString() + ')' : '')) + '\n'; | |
i++; | |
} | |
console.log(r); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment