This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b9927a
commit 057c658
Showing
3 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('?') : '') | ||
) | ||
} | ||
} |