Skip to content

Instantly share code, notes, and snippets.

@Blantas
Last active March 11, 2021 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blantas/7c1626e4c789ee73183aeb4a769c1b6c to your computer and use it in GitHub Desktop.
Save Blantas/7c1626e4c789ee73183aeb4a769c1b6c to your computer and use it in GitHub Desktop.
Format list of lootboy cards codes.
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