58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
|
/* eslint-disable no-unused-vars */
|
||
|
const { BrowserWindow, ipcRenderer, remote } = require("electron");
|
||
|
const axios = require("axios").default;
|
||
|
const path = require("path");
|
||
|
|
||
|
const session = ipcRenderer.sendSync("getSession");
|
||
|
if (!session.accessToken) {
|
||
|
console.log("Session does not exist, return to auth");
|
||
|
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/auth.hbs`));
|
||
|
} else {
|
||
|
console.log("Session does exist, continue");
|
||
|
}
|
||
|
|
||
|
const regex = /(?!\w*_)\w*(?=\.\w*)/g;
|
||
|
var action = __filename.match(regex)[0];
|
||
|
|
||
|
switch (action) {
|
||
|
case "current":
|
||
|
axios({
|
||
|
method: "GET",
|
||
|
url: "https://sessionserver.mojang.com/session/minecraft/profile/" + session.selectedProfile.id
|
||
|
}).then((data) => {
|
||
|
const url = JSON.parse(atob(data.data.properties[0].value)).textures.SKIN.url;
|
||
|
document.querySelectorAll("div.content > img.skin")[0].src = url;
|
||
|
|
||
|
document.querySelectorAll("div.content > button#download")[0].addEventListener("click", (e) => {
|
||
|
ipcRenderer.send("download", {
|
||
|
url: url,
|
||
|
properties: {
|
||
|
saveAs: true
|
||
|
}
|
||
|
});
|
||
|
|
||
|
ipcRenderer.on("downloadResult", (event, arg) => {
|
||
|
const msg = document.querySelectorAll("div.content > p.message")[0];
|
||
|
console.log(msg);
|
||
|
msg.classList.add("success");
|
||
|
msg.innerHTML = "Downloaded successfully";
|
||
|
});
|
||
|
});
|
||
|
|
||
|
document.querySelectorAll("div.content > button#render")[0].addEventListener("click", (e) => {
|
||
|
console.log("Switch to 3D clicked");
|
||
|
});
|
||
|
});
|
||
|
break;
|
||
|
case "upload":
|
||
|
|
||
|
break;
|
||
|
case "random":
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
document.querySelectorAll("div.content > button#main")[0].addEventListener("click", (e) => {
|
||
|
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/main.hbs`));
|
||
|
});
|