SHOW:
|
|
- or go back to the newest paste.
| 1 | function encodeImageFileAsURL(callback) {
| |
| 2 | var input = document.createElement('input');
| |
| 3 | input.type = 'file'; | |
| 4 | input.onchange = (e) => {
| |
| 5 | var reader = new FileReader(); | |
| 6 | reader.onloadend = function() {
| |
| 7 | callback(reader.result); | |
| 8 | } | |
| 9 | reader.readAsDataURL(e.target.files[0]); | |
| 10 | } | |
| 11 | input.click(); | |
| 12 | } | |
| 13 | ||
| 14 | function sendRequest(data){
| |
| 15 | var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance | |
| 16 | var theUrl = 'https://www.geoguessr.com/api/v4/avatar'; | |
| 17 | xmlhttp.open("POST", theUrl);
| |
| 18 | xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
| |
| 19 | xmlhttp.send(JSON.stringify({
| |
| 20 | "skin": 6, | |
| 21 | "equippedIds": [], | |
| 22 | "mugshotPin": data, | |
| 23 | "fullBodyPin": data, | |
| 24 | })); | |
| 25 | } | |
| 26 | ||
| 27 | encodeImageFileAsURL(d => sendRequest(d)); |