From 02b992615c4e58467c2c74dda4886173db2d6de2 Mon Sep 17 00:00:00 2001 From: John <72810050+Notplayingallday383@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:43:35 -0400 Subject: [PATCH] bump --- package.json | 2 +- src/index.ts | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8918649..41fc334 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@z1g-project/injectify", "description": "A improved version of Sodiums Plugin Injector ready to use in all your projects.", - "version": "0.5.5-prev", + "version": "0.5.7-prev", "author": "z1g Project", "type": "module", "main": "lib/index.cjs", diff --git a/src/index.ts b/src/index.ts index 4511c1e..d565ec8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,9 +57,49 @@ export default async function injectify() { } }) } else { - + fetch(configuration.manifestLoc).then(async (val: any) => { + let exts: (extdata | any)[] + try { + exts = JSON.parse(val) + } catch (err: any) { + throw new Error(err) + } + if (configuration.extraLogging === true) { + console.log(`Using Manifest v2 CFG from ${configuration.manifestLoc}`) + console.log(exts) + } + if (configuration.whereTo === 'head') { + exts.forEach((ext: extdata | any) => { + const script = document.createElement('script') + script.src = ext.url + console.log(`Injected: ${ext.name} v${ext.version} to Head`) + document.head.appendChild(script) + }); + } else { + if (document.getElementById(configuration.whereTo) === null || undefined) { + // @ts-expect-error + const to: HTMLElement = document.getElementById(configuration.whereTo) + exts.forEach((ext: extdata | any) => { + const script = document.createElement('script') + script.src = ext.url + console.log(`Injected: ${ext.name} v${ext.version} to Head`) + to.appendChild(script) + }); + } else { + // @ts-expect-error + const to: HTMLElement = document.querySelector(configuration.whereTo) + exts.forEach((ext: extdata | any) => { + const script = document.createElement('script') + script.src = ext.url + console.log(`Injected: ${ext.name} v${ext.version} to Head`) + to.appendChild(script) + }); + } + } + }) } } else { + console.warn('Manifest v1 will be dropped in 2025, only continue to use it if your using a legacy site such as sodium') if (configuration.fsType === "localstorage") { let plugins: any = await LFS(configuration.fsItem) let frameView: any = configuration.whereTo