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

Commit

Permalink
womp womp
Browse files Browse the repository at this point in the history
  • Loading branch information
Notplayingallday383 authored May 7, 2024
1 parent 9b9927a commit 057c658
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
3 changes: 2 additions & 1 deletion build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import esbuild from "esbuild"
import { build } from "esbuild"
import { rimraf } from "rimraf"
import { copyFile, mkdir, readFile } from 'node:fs/promises';
await rimraf('dist');
await mkdir('dist');
Expand Down
75 changes: 74 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,86 @@
import { LFS, FFS } from "./fs"
import { cfg } from "./types"
import XOR from "./xor"

const cfg: cfg = self.__injectify$cfg

if (cfg.fsType === "localstorage") {
let plugins = await LFS(cfg.fsItem)
let frameView = cfg.whereTo
let blacklist = cfg.blacklist
plugins.forEach(script => {
if (blacklist && blacklist.includes(script)) {
return
}
const encodedScript = cfg.useProxy ? XOR.encode(script) : script
const scriptElement = document.createElement("script")
scriptElement.src = encodedScript
if (cfg.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 = cfg.useProxy ? XOR.encode(script) : script
if (cfg.whereTo === "head") {
if (!document.querySelector(`script[src="${encodedScript}"]`)) {
const scriptElement = document.createElement("script")
scriptElement.src = encodedScript
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 (cfg.fsType === "filer") {
let plugins = await FFS(cfg.fsItem)
// Filer is very slow so this may take up some time. This is not suitible for injecting things such as Vencord. Read the docs for more info
let frameView = cfg.whereTo
let blacklist = cfg.blacklist
plugins.forEach(script => {
if (blacklist && blacklist.includes(script)) {
return
}
const encodedScript = cfg.useProxy ? XOR.encode(script) : script
const scriptElement = document.createElement("script")
scriptElement.src = encodedScript
if (cfg.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 = cfg.useProxy ? XOR.encode(script) : script
if (cfg.whereTo === "head") {
if (!document.querySelector(`script[src="${encodedScript}"]`)) {
const scriptElement = document.createElement("script")
scriptElement.src = encodedScript
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?")
throw new Error("Cannot read Injectify Config. Does it exist?")
}
20 changes: 20 additions & 0 deletions src/xor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const XOR = {
encode(input: string): string {
return input
.toString()
.split('')
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char))
.join('')
},
decode(input: string): string {
if (!input) return input
const [str, ...search] = input.split('?')

return (
str
.split('')
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char))
.join('') + (search.length ? '?' + search.join('?') : '')
)
}
}

0 comments on commit 057c658

Please sign in to comment.