Inital Commit:

This commit is contained in:
Li 2023-07-24 00:15:53 +12:00
commit 8707e18fa9
16 changed files with 2242 additions and 0 deletions

BIN
renderer/Thumbs.db Normal file

Binary file not shown.

BIN
renderer/decrypt.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

11
renderer/index.html Normal file
View file

@ -0,0 +1,11 @@
<html>
<head>
<link rel="stylesheet" href="./styles.css">
<meta http-equiv="Content-Security-Policy" content="script-src 'self';">
<title>MC Pack Decrypter</title>
</head>
<body>
<div id="categories"></div>
</body>
<script src="./script.js"></script>
</html>

BIN
renderer/pack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

117
renderer/script.js Normal file
View file

@ -0,0 +1,117 @@
electron.getPacks().then(ready)
const worker = new Worker('worker.js')
const queue = [];
function addToQueue(element, postFunc) {
queue.push({
element: element,
postFunc: postFunc
})
if (queue.length === 1) {
nextQueue();
}
}
function endQueue() {
queue.shift();
}
function nextQueue() {
const item = queue[0]
if (!item) return;
item.element.id = "pack-running";
item.postFunc();
}
worker.onmessage = (e) => {
if (e.data === "end") {
document.querySelector('#pack-running #pack-progress').style.width = "0%";
document.querySelector('#pack-running').id = "pack";
endQueue();
nextQueue();
if (queue.length === 0) {
alert("The pack(s) was decrypted.")
}
return;
}
document.querySelector('#pack-running #pack-progress').style.width = e.data + "%"
}
const categoriesEl = document.getElementById("categories");
function ready(categories) {
const order = ["worlds", "world_templates", "resource_packs", "skin_packs", "persona"];
const keys = Object.keys(categories).sort((a, b) => {
return order.indexOf(a) - order.indexOf(b)
});
if(keys.length > 0) {
for (let i = 0; i < keys.length; i++) {
const name = keys[i];
const categoryEl = createCategoryEl(name, categories[name])
categoriesEl.appendChild(categoryEl);
}
}
else {
displayError("No encrypted pack(s) were found.");
}
}
function displayError(msg) {
const errorEl = document.createElement("div");
errorEl.classList.add("error-msg")
const errorP = document.createElement("p");
errorP.textContent = msg;
errorEl.appendChild(errorP);
categoriesEl.appendChild(errorEl);
}
function createCategoryEl(name, packs) {
const categoryEl = document.createElement("div");
categoryEl.classList.add("category");
categoryEl.innerHTML = `<div class="category-title">${name.replace("_", " ")}</div>`
const packsEl = document.createElement("div");
packsEl.classList.add("packs");
for (let i = 0; i < packs.length; i++) {
const pack = packs[i];
const packEl = createPackEl(pack, name);
packsEl.appendChild(packEl);
}
categoryEl.appendChild(packsEl);
return categoryEl;
}
function createPackEl(pack, type) {
const packEl = document.createElement("div");
packEl.classList.add("pack");
const packClick = async() => {
const outPath = await electron.pickPath({path: pack.packPath, type, name: pack.name});
if (!outPath) return;
if(packEl.id === "pack-queued") return;
if(packEl.id === "pack-running") return;
packEl.id = "pack-queued"
addToQueue(packEl, () => worker.postMessage({outPath, path: pack.packPath, type, name: pack.name}))
}
packEl.addEventListener("click", packClick)
packEl.innerHTML = `
<div id="pack-progress"></div>
<img class="pack-icon ${!pack.packIcon ? 'pack-unknown-icon' : ''}" src="${pack.packIcon ? `data:image/png;base64,${pack.packIcon}` : './pack.png'}" class="pack-icon"></img>
<div class="pack-name">${pack.name}</div>
`
return packEl;
}

88
renderer/styles.css Normal file
View file

@ -0,0 +1,88 @@
body {
background-color: black;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
.category {
background: rgba(128, 128, 128, 0.2);
margin: 10px;
padding: 10px;
border-radius: 6px;
}
.category-title {
font-weight: bold;
margin-bottom: 10px;
text-transform: capitalize;
}
.packs {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.pack {
position: relative;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
width: 160px;
flex-shrink: 0;
background: rgba(255,255,255,0.1);
padding: 10px;
border-radius: 6px;
cursor: pointer;
}
.pack:hover {
background: rgba(255,255,255,0.2);
}
.pack-name {
text-align: center;
}
.pack-icon-container {
width: 64px;
height: 64px;
}
.error-msg {
text-align: center;
font-size: 200%;
color: #fbff00;
top: 50%;
background-color: #7e509b;
left: 50%;
border-radius: 50px;
padding: 20px;
transform: translate(-50%,-50%);
position: absolute;
}
.pack-icon {
width: 64px;
height: 64px;
}
.pack-unknown-icon {
filter: grayscale(100%);
}
#pack-progress {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 0%;
background-color: rgb(78, 78, 255);
z-index: -1;
}
#pack-queued {
background-color: rgb(25, 109, 78);
}

8
renderer/worker.js Normal file
View file

@ -0,0 +1,8 @@
const PackDecryptor = require("../packDecrypter");
self.addEventListener("message", async function(e) {
const decryptor = new PackDecryptor(e.data.path, e.data.outPath);
await decryptor.start();
self.postMessage("end");
});