Compare commits

..

No commits in common. "9fdb774b5c8f8c2749bdec25d56258b8053e3969" and "9dd358e0977bba9bde83569bf85f5d6b6410c89c" have entirely different histories.

15 changed files with 74 additions and 297 deletions

View File

@ -11,15 +11,6 @@ body header h3 {
margin: 0; margin: 0;
} }
body div.content {
display: -ms-grid;
display: grid;
-ms-grid-columns: 50% 50%;
grid-template-columns: 50% 50%;
grid-template-areas: 'message message' 'left right';
width: 100%;
}
body div.content form label { body div.content form label {
font-size: small; font-size: small;
} }
@ -34,14 +25,10 @@ body div.content button {
} }
body div.content .message { body div.content .message {
-ms-grid-row: 1; min-width: 80%;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
grid-area: message;
width: calc(100% - 22px);
height: auto; height: auto;
margin: 5px auto; margin: 5px auto;
padding: 5px 10px 5px 10px; padding: 5px;
font-size: small; font-size: small;
color: white; color: white;
} }
@ -61,18 +48,6 @@ body div.content .message.success {
background: rgba(0, 255, 0, 0.5); background: rgba(0, 255, 0, 0.5);
} }
body div.content div.left {
-ms-grid-row: 2;
-ms-grid-column: 1;
grid-area: left;
}
body div.content div.right {
-ms-grid-row: 2;
-ms-grid-column: 2;
grid-area: right;
}
body div.content img.skin { body div.content img.skin {
width: 60%; width: 60%;
padding: 0 1em 1em 1em; padding: 0 1em 1em 1em;

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AAAA,AAAA,IAAI,CAAC;EACD,WAAW,EAAE,4BAA4B;EACzC,UAAU,EAAE,MAAM;CA+ErB;;AAjFD,AAIQ,IAJJ,CAGA,MAAM,CACF,EAAE,CAAC;EACC,aAAa,EAAE,CAAC;CACnB;;AANT,AAOQ,IAPJ,CAGA,MAAM,CAIF,EAAE,CAAC;EACC,MAAM,EAAE,CAAC;CACZ;;AATT,AAWI,IAXA,CAWA,GAAG,AAAA,QAAQ,CAAC;EACR,OAAO,EAAE,IAAI;EACb,qBAAqB,EAAE,OAAO;EAC9B,mBAAmB,EACf,+BAEJ;EACA,KAAK,EA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 body {
} }
} }
div.content { div.content {
display: grid;
grid-template-columns: 50% 50%;
grid-template-areas:
'message message'
'left right'
;
width: 100%;
form { form {
label { label {
font-size: small; font-size: small;
@ -30,11 +23,10 @@ body {
width: 50%; width: 50%;
} }
.message { .message {
grid-area: message; min-width: 80%;
width: calc(100% - 22px);
height: auto; height: auto;
margin: 5px auto; margin: 5px auto;
padding: 5px 10px 5px 10px; padding: 5px;
font-size: small; font-size: small;
color: white; color: white;
&.info { &.info {
@ -50,12 +42,6 @@ body {
background: rgba(0, 255, 0, 0.5); background: rgba(0, 255, 0, 0.5);
} }
} }
div.left {
grid-area: left;
}
div.right {
grid-area: right;
}
img.skin { img.skin {
width: 60%; width: 60%;
padding: 0 1em 1em 1em; padding: 0 1em 1em 1em;

View File

@ -1 +1 @@
{"theme":"dark","user":"arne.v.iterson@hotmail.nl","password":"","skinDefault":"http://assets.mojang.com/SkinTemplates/steve.png"} {"theme":"light","user":"arne.v.iterson@hotmail.nl","password":""}

View File

@ -1,41 +1,33 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
<h3>Login to Minecraft</h3> <h3>Login to Minecraft</h3>
</header> </header>
<div class="content"> <div class="content">
<p class="message"></p> <p class="message"></p>
<div class="left"> <form action="#">
<p class="message info"> <label for="user">Username or E-mail</label><br>
Your password will stored in plaintext because the Mojang API requires it, do not use this option unless <input type="text" id="user" placeholder="Username or E-mail" required><br>
you are on a private computer.
</p>
</div>
<div class="right">
<form action="#">
<label for="user">Username or E-mail</label><br>
<input type="text" id="user" placeholder="Username or E-mail" required><br>
<label for="password">Password:</label><br> <label for="password">Password:</label><br>
<input type="password" id="password" placeholder="Password" required><br> <input type="password" id="password" placeholder="Password" required><br>
<label for="save">Save password:</label> <label for="save">Save password:</label>
<input type="checkbox" id="save"><br> <input type="checkbox" id="save">
<button type="submit">Submit</button> <p class="message info">Your password will stored in plaintext because the Mojang API requires it, do not use this option unless you are on a private computer.</p>
</form>
</div> <button type="submit">Submit</button>
</form>
</div> </div>
<script src="../src/auth.js"></script> <script src="../src/auth.js"></script>
@ -44,5 +36,4 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,37 +1,26 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
<h3>Main menu</h3> <h3>Main menu</h3>
</header> </header>
<div class="content"> <div class="content">
<p class="message success"></p> <p class="message success"></p>
<div class="left"> <button id="current">Current Skin</button><br>
<p class="message info"> <button id="upload">Upload Skin</button><br>
Logging out will delete your password from storage, if you want it to autofill next time you can just <button id="random">Random Skin</button><br>
close this window when you are done. <button id="logout">Logout</button>
</p> <p class="message info">
<p class="message warning"> Logging out will delete your password from storage, if you want it to autofill next time you can just close this window when you are done.
Hecc inc. is not responsible for loss of data or explicit content (using random skin selection) seen </p>
when using this program.
</p>
</div>
<div class="right">
<button id="current">Current Skin</button><br>
<button id="upload">Upload Skin</button><br>
<button id="random">Random Skin</button><br>
<button id="logout">Logout</button>
</div>
</div> </div>
<script src="../src/main.js"></script> <script src="../src/main.js"></script>
@ -40,5 +29,4 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,32 +1,23 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
<h3>Current Skin</h3> <h3>Current Skin</h3>
</header> </header>
<div class="content"> <div class="content">
<p class="message"></p> <p class="message"></p>
<img src="" class="skin" alt="Current Skin">
<div class="left"> <button id="render">Switch to 3D</button>
<img src="" class="skin" id="flat" alt="Current Skin" style="display: none;"> <button id="download">Download</button>
<div id="mesh" style="display: inline;"></div> <button id="main">Back</button>
<button id="switch" style="display: none;">Switch to 2D</button>
</div>
<div class="right">
<button id="download">Download</button>
<button id="main">Back</button>
</div>
</div> </div>
<script src="../src/skin.js"></script> <script src="../src/skin.js"></script>
@ -35,5 +26,4 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,34 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
<h3>Random Skin</h3> <h3>Random Skin</h3>
</header> </header>
<div class="content" id="random"> <div class="content" id="current">
<p class="message"></p>
<div class="left">
<img src="" class="skin" id="flat" alt="Current Skin" style="display: none;">
<div id="mesh" style="display: inline;"></div>
<button id="switch" style="display: none;">Switch to 2D</button>
</div>
<div class="right">
<button id="random">Random</button>
<button id="set">Use this skin</button>
<button id="download">Download</button>
<button id="main">Back</button>
</div>
</div> </div>
<script src="../src/skin.js"></script> <script src="../src/skin.js"></script>
@ -37,5 +22,4 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -1,42 +1,22 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title> <title>{{ title }}</title>
<link rel="stylesheet" href="{{ css }}"> <link rel="stylesheet" href="{{ css }}">
</head> </head>
<body class="{{ theme }}"> <body class="{{ theme }}">
<header> <header>
<h1>{{ header }}</h1> <h1>{{ header }}</h1>
<h3>Upload Skin</h3> <h3>Upload Skin</h3>
</header> </header>
<div class="content" id="current"> <div class="content" id="current">
<p class="message"></p> <form action="#">
<input type="file" id="skin">
<div class="left"> <button type="submit">Submit</button>
<img src="" class="skin" id="flat" alt="Current Skin" style="display: none;"> </form>
<div id="mesh" style="display: inline;"></div>
<button id="switch" style="display: none;">Switch to 2D</button>
</div>
<div class="right">
<button id="remote">Fetch from URL</button>
<button id="local">Upload file</button>
<form action="#" id="remote" style="display: none;">
<input type="text" id="url" placeholder="URL">
<button type="submit">Submit</button>
</form>
<form action="#" id="local" style="display: none;">
<input type="file" id="skin">
<button type="submit">Submit</button>
</form>
<button id="main">Back</button>
</div>
</div> </div>
<script src="../src/skin.js"></script> <script src="../src/skin.js"></script>
@ -45,5 +25,4 @@
{{ footer }} {{ footer }}
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -12,8 +12,8 @@ if (process.env.NODE_ENV === "dev") {
function createWindow () { function createWindow () {
// Create the browser window. // Create the browser window.
const win = new BrowserWindow({ const win = new BrowserWindow({
width: 640, width: 320,
height: 520, height: 480,
backgroundColor: "#ffffff", backgroundColor: "#ffffff",
resizable: false, resizable: false,
frame: true, frame: true,

26
package-lock.json generated
View File

@ -2462,27 +2462,6 @@
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA=="
}, },
"skinview-utils": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/skinview-utils/-/skinview-utils-0.2.1.tgz",
"integrity": "sha512-WhXaKwYp1FBspaKq/AXb4EG3E2gaVpA57dXWvPgM7GP2F36E8Pfdg1MZESWpTMG2TGp8xKz5JELgKD3uXSG0EA=="
},
"skinview3d": {
"version": "2.0.0-alpha.1",
"resolved": "https://registry.npmjs.org/skinview3d/-/skinview3d-2.0.0-alpha.1.tgz",
"integrity": "sha512-HCA6nfBgr7SUwx+UYe8irNsHN0aVVKOplSPUVxEx5WRd9ZG5wpF4nXpObrKutfOz/TzYuxjdL0t1Th7E/noI/w==",
"requires": {
"skinview-utils": "^0.2.0",
"three": "^0.112.1"
},
"dependencies": {
"three": {
"version": "0.112.1",
"resolved": "https://registry.npmjs.org/three/-/three-0.112.1.tgz",
"integrity": "sha512-8I0O74hiYtKl3LgDNcPJbBGOlpekbcJ6fJnImmW3mFdeUFJ2H9Y3/UuUSW2sBdjrIlCM0gvOkaTEFlofO900TQ=="
}
}
},
"slice-ansi": { "slice-ansi": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
@ -2696,11 +2675,6 @@
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
"integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=" "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ="
}, },
"three": {
"version": "0.116.1",
"resolved": "https://registry.npmjs.org/three/-/three-0.116.1.tgz",
"integrity": "sha512-l2JCMiA/lVZAuSrLWRYMalvpR+0j8hbIhCpfs4V6JFnw2+JQEQJ5HltNpfFr+9TDpQts1BhtcISehWf/xBGPvQ=="
},
"through": { "through": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",

View File

@ -24,9 +24,7 @@
"electron-handlebars": "^2.0.0", "electron-handlebars": "^2.0.0",
"electron-reload": "^1.5.0", "electron-reload": "^1.5.0",
"eslint": "^7.0.0", "eslint": "^7.0.0",
"pngjs": "^5.0.0", "pngjs": "^5.0.0"
"skinview3d": "^2.0.0-alpha.1",
"three": "^0.116.1"
}, },
"devDependencies": {}, "devDependencies": {},
"repository": { "repository": {

View File

@ -54,7 +54,7 @@ async function authenticate(user, password) {
} }
// Get access token from Mojang Authserver // Get access token from Mojang Authserver
const form = document.querySelectorAll("div.content > div.right > form")[0]; const form = document.querySelectorAll("div.content > form")[0];
form.querySelectorAll("input#user")[0].value = authData.user; form.querySelectorAll("input#user")[0].value = authData.user;
form.querySelectorAll("input#password")[0].value = authData.password; form.querySelectorAll("input#password")[0].value = authData.password;

View File

@ -15,22 +15,22 @@ const msg = document.querySelectorAll("div.content > p.message")[0];
msg.classList.add("success"); msg.classList.add("success");
msg.innerHTML = `Logged in as ${session.selectedProfile.name}`; msg.innerHTML = `Logged in as ${session.selectedProfile.name}`;
document.querySelectorAll("div.content > div.right > button#current")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > button#current")[0].addEventListener("click", (e) => {
console.log("Clicked current button"); console.log("Clicked current button");
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_current.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_current.hbs`));
}); });
document.querySelectorAll("div.content > div.right > button#upload")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > button#upload")[0].addEventListener("click", (e) => {
console.log("Clicked upload button"); console.log("Clicked upload button");
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_upload.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_upload.hbs`));
}); });
document.querySelectorAll("div.content > div.right > button#random")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > button#random")[0].addEventListener("click", (e) => {
console.log("Clicked random button"); console.log("Clicked random button");
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_random.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/skin_random.hbs`));
}); });
document.querySelectorAll("div.content > div.right > button#logout")[0].addEventListener("click", (e) => { document.querySelectorAll("div.content > button#logout")[0].addEventListener("click", (e) => {
console.log("Clicked logout button"); console.log("Clicked logout button");
if (ipcRenderer.sendSync("setSession", {})) { if (ipcRenderer.sendSync("setSession", {})) {
var authData = ipcRenderer.sendSync("getAuth"); var authData = ipcRenderer.sendSync("getAuth");

View File

@ -1,14 +1,8 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
const { const { BrowserWindow, ipcRenderer, remote } = require("electron");
BrowserWindow,
ipcRenderer,
remote
} = require("electron");
const axios = require("axios").default; const axios = require("axios").default;
const path = require("path"); const path = require("path");
const skinview3d = require("skinview3d/dist/skinview3d.min.js");
const session = ipcRenderer.sendSync("getSession"); const session = ipcRenderer.sendSync("getSession");
if (!session.accessToken) { if (!session.accessToken) {
console.log("Session does not exist, return to auth"); console.log("Session does not exist, return to auth");
@ -19,36 +13,6 @@ if (!session.accessToken) {
const regex = /(?!\w*_)\w*(?=\.\w*)/g; const regex = /(?!\w*_)\w*(?=\.\w*)/g;
var action = __filename.match(regex)[0]; var action = __filename.match(regex)[0];
var parser = new DOMParser();
var randomUrls = [];
// Switch button and views
var btn = document.querySelectorAll("div.content > div.left > button#switch")[0];
var view = {
flat: document.querySelectorAll("div.content > div.left > img.skin#flat")[0],
mesh: document.querySelectorAll("div.content > div.left > div#mesh")[0]
};
function setView(url, controls = true) {
btn.style.display = "initial";
view.flat.src = url;
view.mesh.innerHTML = "";
// Set mesh view
let skinViewer = new skinview3d.SkinViewer({
domElement: view.mesh,
width: 300,
height: 250,
skinUrl: url
});
let control = skinview3d.createOrbitControls(skinViewer);
control.enableRotate = controls;
control.enableZoom = false;
control.enablePan = false;
}
switch (action) { switch (action) {
case "current": case "current":
@ -56,90 +20,38 @@ case "current":
method: "GET", method: "GET",
url: "https://sessionserver.mojang.com/session/minecraft/profile/" + session.selectedProfile.id url: "https://sessionserver.mojang.com/session/minecraft/profile/" + session.selectedProfile.id
}).then((data) => { }).then((data) => {
setView(JSON.parse(atob(data.data.properties[0].value)).textures.SKIN.url); 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; break;
case "upload": case "upload":
document.querySelectorAll("div.content > div.right > button").forEach(element => {
element.addEventListener("click", (e) => {
document.querySelectorAll("div.content > div.right > button").forEach(button => {
if (button.id != "main") {
button.style.display = "none";
}
});
document.querySelectorAll(`div.content > div.right > form#${element.id}`)[0].style.display = "block";
});
});
break; break;
case "random": case "random":
axios({
method: "GET",
url: "https://nl.namemc.com/minecraft-skins/random"
}).then((data) => {
var namemc = parser.parseFromString(data.data, "text/html");
namemc.querySelectorAll("a").forEach((e) => {
var href = e.getAttribute("href");
if (href.includes("skin")) {
var id = href.split("/")[2];
if (id && id.length == 16 && !(id.includes("-"))) {
randomUrls.push("https://nl.namemc.com/texture/" + id + ".png");
}
}
});
function random() {
console.log(randomUrls.length);
if (randomUrls.length == 0) {
window.location.reload();
} else {
var id = Math.floor(Math.random() * (randomUrls.length - 0)) + 0;
setView(randomUrls[id]);
randomUrls.splice(id, 1);
}
}
random();
document.querySelectorAll("div.content > div.right > button#random")[0].addEventListener("click", (e) => {
random();
});
});
break; break;
} }
// Download button action document.querySelectorAll("div.content > button#main")[0].addEventListener("click", (e) => {
document.querySelectorAll("div.content > div.right > button#download")[0].addEventListener("click", (e) => {
ipcRenderer.send("download", {
url: view.flat.src,
properties: {
saveAs: true
}
});
ipcRenderer.on("downloadResult", (event, arg) => {
var msg = document.querySelectorAll("div.content > p.message")[0];
console.log(msg);
msg.classList.add("success");
msg.innerHTML = "Downloaded successfully";
});
});
// Switch button action
btn.addEventListener("click", (e) => {
if (view.flat.style.display == "inline") {
view.flat.style.display = "none";
view.mesh.style.display = "inline";
btn.innerHTML = "Switch to 2D";
} else {
view.flat.style.display = "inline";
view.mesh.style.display = "none";
btn.innerHTML = "Switch to 3D";
}
});
// Back button action
document.querySelectorAll("div.content > div.right > button#main")[0].addEventListener("click", (e) => {
remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/main.hbs`)); remote.getCurrentWindow().loadURL(path.join(`file://${__dirname}/main.hbs`));
}); });