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

Commit

Permalink
0.5.0-prev1
Browse files Browse the repository at this point in the history
  • Loading branch information
Notplayingallday383 authored Jun 2, 2024
1 parent 3471a4f commit c44fdbd
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 84 deletions.
75 changes: 72 additions & 3 deletions docs/configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 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.2.1-patch",
"version": "0.5.0-prev",
"author": "z1g Project",
"type": "module",
"main": "lib/index.cjs",
Expand All @@ -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"
}
Expand Down
6 changes: 2 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
167 changes: 91 additions & 76 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
1 change: 1 addition & 0 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,
manifestLoc: string,
fsType: string,
fsItem: string,
location: string,
Expand Down

0 comments on commit c44fdbd

Please sign in to comment.