diff --git a/docs/configurations.md b/docs/configurations.md index ac92795..5ba0422 100644 --- a/docs/configurations.md +++ b/docs/configurations.md @@ -12,10 +12,79 @@ self.__injectify$cfg = { } ``` -### Options +### Options (Manifest v1) + +> [!NOTE] +> Manifest v1 is deprecated and is just for legacy sites such as sodium. If for some reason you dont like Manifest v2 you can still use Manifest v1. It will be supported untill Q1 of 2025 #### UseProxy -- Description: This enables the use of encoding and loading the injected scripts using UV with XOR (**NOTE** This will soon be depreccated this is just here for backwards compatability with older versions of sites like sodium) +- Accepts: Booleans +- Description: This enables the use of encoding and loading the injected scripts using UV with XOR + +#### Encoder + +- Options: `XOR` +- Description: Connected to `UseProxy`, Basically what it should encode the proxied url in. + +#### fsItem + +- Accepts: Strings +- Description: The item (either local storage item or filerJS file) that injectify can load its scripts from. This was superceeded by Manifests in Manifest v2 + +#### fsType + +- Description: Weither or not Injectify should use `localstorage` or `filer` + +#### WhereTo + +- Accepts: Strings +- Descriotion: This is where injectify should inject its scripts to. + +#### Location + +- Accepts: Strings +- Description: Where injectify files can be found (ignore this setting if using a blunder) + +#### BlackList + +- Accepts: JSON +- Description: If your using a public injectify manifest you can block scripts from being injected. + +#### ExtraLogging + +- Accepts: Boolean +- Description: For debugging purposes in case your trying to figure out where a bug is coming from. + +### Options (Manifest v2) + +#### ManifestVer + +- Description: Toggle for which manifest version to use. + +#### ManifestLoc + +- Description: Defines where in the injectify folder the manifest is or where the manifest is. + +> [!NOTE] +> Fetching for that if its an external url will be using axios. + +#### WhereTo + +- Accepts: Strings +- Descriotion: This is where injectify should inject its scripts to. + +#### Location + +- Accepts: Strings +- Description: Where injectify files can be found (ignore this setting if using a blunder) + +#### BlackList + +- Accepts: JSON +- Description: If your using a public injectify manifest you can block scripts from being injected. + +#### ExtraLogging -#### TODO +- Accepts: Booleans +- Description: For debugging purposes in case your trying to figure out where a bug is coming from. diff --git a/package.json b/package.json index f0872c9..7f75271 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.2.1-patch", + "version": "0.5.0-prev", "author": "z1g Project", "type": "module", "main": "lib/index.cjs", @@ -17,6 +17,7 @@ "devDependencies": { "esbuild": "^0.21.3", "prettier": "^3.2.5", + "axios": "^1.7.2", "rimraf": "^5.0.7", "tsx": "^4.10.3" } diff --git a/src/config.js b/src/config.js index 18a950b..5d2ea70 100644 --- a/src/config.js +++ b/src/config.js @@ -1,9 +1,7 @@ // Stock Settings, Refer to /docs to configure this correctly self.__injectify$cfg = { - useProxy: false, // Weither or not it should use UV to inject scripts (proxied injection) - encoder: "XOR", // Encoder for useProxy to use to encode urls. - fsType: "localstorage", // Defines the FS to use. Make sure you know what your doing - fsItem: "injectifyPlugins", // Defines where to find the plugins to inject. + manifestVer: 2, // The version of Injectfy manifests to load. + manifestLoc: "manifest.json", // Defines the manifest files name. Tied to the location tag as it should be in the same folder. location: "/injectify/", // Defines where injectify can find its files. whereTo: "head", // Defines where to inject. Either use the iframe's ID or just leave it at "head" blacklist: [], // Blacklist of Plugin URLS (So if someone publishes a token logger you can block it) diff --git a/src/index.ts b/src/index.ts index bf23b88..ddc65f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import { LFS, FFS } from "./fs" import { cfg } from "./types" import { XOR } from "./encoders" +import axios from "axios" export default async function injectify() { // @ts-ignore @@ -9,104 +10,118 @@ export default async function injectify() { console.log('Injectify has been inited') console.log(`Configuration:`, configuration) } - if (configuration.fsType === "localstorage") { - let plugins: any = await LFS(configuration.fsItem) - let frameView: any = configuration.whereTo - let blacklist: any = configuration.blacklist - if (configuration.extraLogging === true) { - console.log(frameView) + if (configuration.manifestVer === 2) { + console.warn('Manifest v2 Support is in early beta') + if (configuration.whereTo === null) { + throw new Error("You must specify where to inject items to.") } - plugins.forEach(script => { - if (blacklist && blacklist.includes(script)) { - return - } - const encodedScript = configuration.useProxy ? XOR.encode(script) : script - const scriptElement = document.createElement("script") - scriptElement.src = encodedScript + if (configuration.manifestLoc.includes("http")) { + axios.get(configuration.manifestLoc).then(() => { + // TODO + }) + } else { + + } + } else { + if (configuration.fsType === "localstorage") { + let plugins: any = await LFS(configuration.fsItem) + let frameView: any = configuration.whereTo + let blacklist: any = configuration.blacklist if (configuration.extraLogging === true) { - console.log(scriptElement.src) - } - if (configuration.whereTo === "head") { - document.head.appendChild(scriptElement) - } else { - frameView.contentWindow.document.head.appendChild(scriptElement) + console.log(frameView) } - }) - setInterval(() => { plugins.forEach(script => { if (blacklist && blacklist.includes(script)) { - return + return } const encodedScript = configuration.useProxy ? XOR.encode(script) : script + const scriptElement = document.createElement("script") + scriptElement.src = encodedScript + if (configuration.extraLogging === true) { + console.log(scriptElement.src) + } if (configuration.whereTo === "head") { - if (!document.querySelector(`script[src="${encodedScript}"]`)) { - const scriptElement = document.createElement("script") - scriptElement.src = encodedScript - if (configuration.extraLogging === true) { - console.log(scriptElement.src) - } - document.head.appendChild(scriptElement) - } + document.head.appendChild(scriptElement) } else { - if (!frameView.contentWindow.document.querySelector(`script[src="${encodedScript}"]`)) { - const scriptElement = frameView.contentWindow.document.createElement("script") - scriptElement.src = encodedScript - frameView.contentWindow.document.head.appendChild(scriptElement) - } + frameView.contentWindow.document.head.appendChild(scriptElement) } }) - }, 1000) - } else if (configuration.fsType === "filer") { - let plugins: any = await FFS(configuration.fsItem) - // Filer is very slow so this may take up some time. This is not suitable for injecting things such as Vencord. Read the docs for more info - let frameView: any = configuration.whereTo - let blacklist: any = configuration.blacklist - if (configuration.extraLogging === true) { - console.log(frameView) - } - plugins.forEach(script => { - if (blacklist && blacklist.includes(script)) { - return - } - const encodedScript = configuration.useProxy ? XOR.encode(script) : script - const scriptElement = document.createElement("script") - scriptElement.src = encodedScript + setInterval(() => { + plugins.forEach(script => { + if (blacklist && blacklist.includes(script)) { + return + } + const encodedScript = configuration.useProxy ? XOR.encode(script) : script + if (configuration.whereTo === "head") { + if (!document.querySelector(`script[src="${encodedScript}"]`)) { + const scriptElement = document.createElement("script") + scriptElement.src = encodedScript + if (configuration.extraLogging === true) { + console.log(scriptElement.src) + } + document.head.appendChild(scriptElement) + } + } else { + if (!frameView.contentWindow.document.querySelector(`script[src="${encodedScript}"]`)) { + const scriptElement = frameView.contentWindow.document.createElement("script") + scriptElement.src = encodedScript + frameView.contentWindow.document.head.appendChild(scriptElement) + } + } + }) + }, 1000) + } else if (configuration.fsType === "filer") { + let plugins: any = await FFS(configuration.fsItem) + // Filer is very slow so this may take up some time. This is not suitable for injecting things such as Vencord. Read the docs for more info + let frameView: any = configuration.whereTo + let blacklist: any = configuration.blacklist if (configuration.extraLogging === true) { - console.log(scriptElement.src) + console.log(frameView) } - if (configuration.whereTo === "head") { - document.head.appendChild(scriptElement) - } else { - frameView.contentWindow.document.head.appendChild(scriptElement) - } - }) - setInterval(() => { plugins.forEach(script => { if (blacklist && blacklist.includes(script)) { return } const encodedScript = configuration.useProxy ? XOR.encode(script) : script + const scriptElement = document.createElement("script") + scriptElement.src = encodedScript + if (configuration.extraLogging === true) { + console.log(scriptElement.src) + } if (configuration.whereTo === "head") { - if (!document.querySelector(`script[src="${encodedScript}"]`)) { - const scriptElement = document.createElement("script") - scriptElement.src = encodedScript - if (configuration.extraLogging === true) { - console.log(scriptElement.src) - } - document.head.appendChild(scriptElement) - } + document.head.appendChild(scriptElement) } else { - if (!frameView.contentWindow.document.querySelector(`script[src="${encodedScript}"]`)) { - const scriptElement = frameView.contentWindow.document.createElement("script") - scriptElement.src = encodedScript - frameView.contentWindow.document.head.appendChild(scriptElement) - } + frameView.contentWindow.document.head.appendChild(scriptElement) } }) - }, 1000) - } else { - throw new Error("Cannot read Injectify Config. Does it exist?") - } + setInterval(() => { + plugins.forEach(script => { + if (blacklist && blacklist.includes(script)) { + return + } + const encodedScript = configuration.useProxy ? XOR.encode(script) : script + if (configuration.whereTo === "head") { + if (!document.querySelector(`script[src="${encodedScript}"]`)) { + const scriptElement = document.createElement("script") + scriptElement.src = encodedScript + if (configuration.extraLogging === true) { + console.log(scriptElement.src) + } + document.head.appendChild(scriptElement) + } + } else { + if (!frameView.contentWindow.document.querySelector(`script[src="${encodedScript}"]`)) { + const scriptElement = frameView.contentWindow.document.createElement("script") + scriptElement.src = encodedScript + frameView.contentWindow.document.head.appendChild(scriptElement) + } + } + }) + }, 1000) + } else { + throw new Error("Cannot read Injectify Config. Does it exist?") + } + } } injectify() diff --git a/src/types.d.ts b/src/types.d.ts index ce9f890..27c345c 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,6 +1,7 @@ interface cfg { useProxy: boolean, encoder: string, + manifestLoc: string, fsType: string, fsItem: string, location: string,