Skip to content

Instantly share code, notes, and snippets.

@bettywolfy
Created July 26, 2026 02:32
Show Gist options
  • Select an option

  • Save bettywolfy/2af66753e2b1a157b33f7e8144a230b0 to your computer and use it in GitHub Desktop.

Select an option

Save bettywolfy/2af66753e2b1a157b33f7e8144a230b0 to your computer and use it in GitHub Desktop.
tic80 avatar uploader
/*
execute this script on the page 'https://tic80.com/profile'
android users: 'javascript:(function(){var script=document.createElement("script");script.src="https://cdn.jsdelivr.net/npm/eruda";document.head.append(script);script.onload=function(){eruda.init();eruda.show();}})();'
* favorite the url between the single quotes and then open it the profile page
*/
const mf = document.createElement("input");
mf.type = "file";
mf.accept = "image/png";
const fr = new FileReader();
fr.onload = async () => {
try {
const body = new URLSearchParams();
body.append("avatar", fr.result);
const res = await fetch("/ajax?fn=avatar", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
body
});
const data = await res.json();
if(data.error) {
alert("failed :(\n\n"+data.error);
} else {
alert("success! :D");
}
} catch(e) {
alert("failed :(\n\n"+e.toString());
}
}
mf.onchange = () => {
if(!mf.files.length) return;
if(mf.files[0].type==="image/png") {
fr.readAsDataURL(mf.files[0]);
}
mf.value = "";
}
mf.click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment