Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Notplayingallday383 authored Jun 14, 2024
1 parent 8a34d83 commit 02b9926
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
42 changes: 41 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 02b9926

Please sign in to comment.