Skip to content

Instantly share code, notes, and snippets.

@alberto98fx
Last active December 3, 2017 14:23
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 alberto98fx/f90d29cfaf8013aa0de44e7dbe6e6fef to your computer and use it in GitHub Desktop.
Save alberto98fx/f90d29cfaf8013aa0de44e7dbe6e6fef to your computer and use it in GitHub Desktop.
DevRant banner thingy javascript
<canvas id="banner" width="1200" height="400">
Your browser does not support the canvas element.
</canvas>
<script>
function banner(username,text){
fetch("https://devrant.com/api/get-user-id?app=3&username="+username).then(function(response) {
return response.json()
}).then(function(data){
return fetch("https://www.devrant.io/api/users/"+data.user_id+"?app=3&plat=2&content=all&skip=0");
}).then(function(resp){
return resp.json()
}).then(function(user){
console.log(user.profile.avatar);
var canvas = document.getElementById("banner");
var ctx = canvas.getContext("2d");
var image = new Image();
ctx.textAlign = "center";
ctx.fillStyle = "white";
ctx.textBaseline = 'middle';
canvas.style.backgroundColor = "#"+user.profile.avatar.b;
ctx.font = "50px Arial";
ctx.fillText(user.profile.username,600,140);
image.src = 'https://avatars.devrant.com/'+user.profile.avatar.i;
image.onload = function(){
ctx.drawImage(image, 69, 70, 300,300);
}
ctx.fillText(text, 600,230);
ctx.fillText("devRant",1000,350)
})
}
banner("CozyPlanes", "This is a test");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment