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

Commit

Permalink
Test Build again
Browse files Browse the repository at this point in the history
  • Loading branch information
Notplayingallday383 committed Jun 7, 2024
1 parent c44fdbd commit d5b1c4d
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 6 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.0-prev",
"version": "0.5.5-prev",
"author": "z1g Project",
"type": "module",
"main": "lib/index.cjs",
Expand Down
64 changes: 64 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 40 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LFS, FFS } from "./fs"
import { cfg } from "./types"
import { cfg, extdata } from "./types"
import { XOR } from "./encoders"
import axios from "axios"

Expand All @@ -16,8 +16,45 @@ export default async function injectify() {
throw new Error("You must specify where to inject items to.")
}
if (configuration.manifestLoc.includes("http")) {
axios.get(configuration.manifestLoc).then(() => {
// TODO
axios.get(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 {

Expand Down
12 changes: 10 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
interface cfg {
useProxy: boolean,
encoder: string,
manifestVer: number,
manifestLoc: string,
fsType: string,
fsItem: string,
Expand All @@ -10,13 +11,20 @@ interface cfg {
extraLogging: boolean
}

interface extdata {
url: URL,
name: string,
description: string,
version: number
}

interface Filer {
Filer,
fs,
promises,
readFile: string,
writeFile: string
}
export { cfg, Filer };

export { cfg, Filer, extdata };

0 comments on commit d5b1c4d

Please sign in to comment.