From f2a80521f6d7314934ff172a92a645ca90c13b5b Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 13 Jul 2024 17:40:01 -0400 Subject: Import existing code --- index.html | 19 ++++++++++++++++++ puppet.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 index.html create mode 100644 puppet.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..813d85a --- /dev/null +++ b/index.html @@ -0,0 +1,19 @@ + + + + + + + Cursed Pack Downloader + + + Manifest file: + +
+ Link file: + +
+ + + + \ No newline at end of file diff --git a/puppet.js b/puppet.js new file mode 100644 index 0000000..46d72c3 --- /dev/null +++ b/puppet.js @@ -0,0 +1,66 @@ +const URL_REGEX = /href=\"(.*)\"/; + +/** + * @param {String} text + */ +function getURLs(text) { + text.split("\n"); + let out = []; + + for (let i of text.split("\n")) + { + if (URL_REGEX.test(i)) + { + let url = URL_REGEX.exec(i)[1]; + out.push(url); + } + } + + return out; +} + +function reformFileList(list) +{ + let out = []; + + for (let i of list) + { + out.push(i.fileID); + } + + return out; +} + +window.addEventListener("load", _ => { + /** @type {HTMLButtonElement} */ + let start = document.getElementById("start"); + /** @type {HTMLButtonElement} */ + let next = document.getElementById("next"); + /** @type {HTMLInputElement} */ + let manifest = document.getElementById("manifest"); + /** @type {HTMLInputElement} */ + let links = document.getElementById("links"); + + var current = null; + + start.addEventListener("click", _ => { + links.files.item(0).text().then(link_val => { + manifest.files.item(0).text().then(manifest_val => { + current = [ + 0, + getURLs(link_val), + reformFileList(JSON.parse(manifest_val).files), + ]; + }); + }); + }); + + next.addEventListener("click", _ => { + for(let i = 0; i < 15; i++) { + if(current[0] < current[1].length) { + window.open(`${current[1][current[0]]}/download/${current[2][current[0]]}`); + current[0]++; + } + } + }); +}); \ No newline at end of file -- cgit v1.2.3