From c2d6d2bef152fa36db7d5f6db11baeff4de2a4c5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 2 Apr 2018 23:13:35 +0100 Subject: few changes --- README.md | 2 +- main-repo/test/delet.js | 1 + main-repo/test/package.json | 5 +++++ main-repo/test/rmtest.js | 1 + main-repo/wget93/package.json | 1 + pkg93.js | 24 ++++++++++++++++++------ 6 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 main-repo/test/delet.js create mode 100644 main-repo/test/package.json create mode 100644 main-repo/test/rmtest.js diff --git a/README.md b/README.md index 06afeb1..cb1bc1e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ example-repo │ │ (package files go here) │   └── package.json └── examplepkg3 -│ │ (package files go here) + │ (package files go here)    └── package.json ``` diff --git a/main-repo/test/delet.js b/main-repo/test/delet.js new file mode 100644 index 0000000..f30b622 --- /dev/null +++ b/main-repo/test/delet.js @@ -0,0 +1 @@ +$log("ok y u hat me ok"); diff --git a/main-repo/test/package.json b/main-repo/test/package.json new file mode 100644 index 0000000..e2164ab --- /dev/null +++ b/main-repo/test/package.json @@ -0,0 +1,5 @@ +{ + "name": "test", + "inject": "test.js", + "uninstall": "delet.js" +} diff --git a/main-repo/test/rmtest.js b/main-repo/test/rmtest.js new file mode 100644 index 0000000..81fdb66 --- /dev/null +++ b/main-repo/test/rmtest.js @@ -0,0 +1 @@ +$log("ok you just installed the test pacakge ok") diff --git a/main-repo/wget93/package.json b/main-repo/wget93/package.json index e3677ec..11a6676 100644 --- a/main-repo/wget93/package.json +++ b/main-repo/wget93/package.json @@ -1,4 +1,5 @@ { "name": "wget93", + "version": "0.1.0", "inject": "wget93.js" } diff --git a/pkg93.js b/pkg93.js index 74476d6..683e847 100644 --- a/pkg93.js +++ b/pkg93.js @@ -45,7 +45,7 @@ console.log("[pkg93] Injecting packages..."); try { var config = JSON.parse(localStorage[".pkg93/config.json"]); config.installed.forEach(function (pkg) { - eval(localStorage[".pkg93/downloaded/" + pkg + ".js"]); + eval(localStorage[".pkg93/packages/" + pkg + ".js"]); }); } catch (err) { console.error("[pkg93] Couldn't load package information."); @@ -62,8 +62,8 @@ le._apps.pkg93 = { if (localStorage[".pkg93/config.json"] === undefined) { localStorage[".pkg93/config.json"] = '{"repos": ["http://codinggamerhd.com/main-repo"], "installed": [], "pkglist": []}'; } - if (localStorage[".pkg93/downloaded/"] === undefined) { - localStorage[".pkg93/downloaded/"] = ""; + if (localStorage[".pkg93/packages/"] === undefined) { + localStorage[".pkg93/packages/"] = ""; } localStorage[".pkg93/README.txt"] = "WARNING!\nThis folder contains important data about pkg93. Do not edit anything in here unless you want pkg93 to not work!\n\n~1024x2"; var config = JSON.parse(localStorage[".pkg93/config.json"]); @@ -126,9 +126,15 @@ pkg93 rm kebab try { request.send(null); var json = JSON.parse(request.responseText); + localStorage[".pkg93/packages/" + pkgname + ".json"] = request.responseText; request.open('GET', pkgsource + "/" + pkgname + "/" + json.inject, false); request.send(null); - localStorage[".pkg93/downloaded/" + pkgname + ".js"] = request.responseText; + localStorage[".pkg93/packages/" + pkgname + ".js"] = request.responseText; + if (!!json.uninstall) { + request.open('GET', pkgsource + "/" + pkgname + "/" + json.inject, false); + request.send(null); + localStorage[".pkg93/packages/" + pkgname + ".rm.js"] = request.responseText; + } eval(request.responseText); $log("OK Injected package!"); config.installed.push(pkgname); @@ -142,8 +148,11 @@ pkg93 rm kebab $log("ERR No package specified."); } else if (protected.includes(args[1])) { $log("ERR You're trying to modify a pre-installed Windows93 app.\n Don't do that!"); - } else if (!!localStorage[".pkg93/downloaded/un" + args[1] + ".js"]) { - eval(localStorage[".pkg93/downloaded/un" + args[1] + ".js"]); // Typing eval makes me feel dirty. + } else if (!!localStorage[".pkg93/packages/" + args[1] + ".rm.js"]) { + eval(localStorage[".pkg93/packages/" + args[1] + ".rm.js"]); // Typing eval makes me feel dirty. + localStorage[".pkg93/packages/" + args[1] + ".rm.js"] = null; + localStorage[".pkg93/packages/" + args[1] + ".js"] = null; + localStorage[".pkg93/packages/" + args[1] + ".json"] = null; } else { var index = config.installed.indexOf(args[1]); if (index < 0) { @@ -154,6 +163,9 @@ pkg93 rm kebab $log("ERR Already removed."); } else { le._apps[config.installed[index]] = null; + localStorage[".pkg93/packages/" + config.installed[index]] + ".rm.js"] = null; + localStorage[".pkg93/packages/" + config.installed[index]] + ".js"] = null; + localStorage[".pkg93/packages/" + config.installed[index]] + ".json"] = null; config.installed = config.installed.splice(index, 1); $log("OK Removed!"); } -- cgit v1.2.3