Skip to content

Commit

Permalink
fetch lib from remote - filesize reduced by ~1mb
Browse files Browse the repository at this point in the history
  • Loading branch information
SammCheese committed Dec 21, 2022
1 parent e737b1f commit a70785f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 66 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"discordID": "372148345894076416",
"github": "SammCheese"
},
"version": "1.0.4",
"version": "1.0.5",
"updater": {
"type": "github",
"id": "SammCheese/invisible-chat"
Expand Down
25 changes: 11 additions & 14 deletions src/assets/chatbarLock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import { buildEncModal } from "../components/EncryptionModal";

const { React } = common;

export const chatbarLock = React.createElement(
"svg",
{
key: "Encrypt Message",
fill: "#EBEBEB",
width: "30",
height: "30",
viewBox: "0 0 64 64",
style: { marginTop: 7 },
onClick: () => buildEncModal(),
},
React.createElement("path", {
d: "M 32 9 C 24.832 9 19 14.832 19 22 L 19 27.347656 C 16.670659 28.171862 15 30.388126 15 33 L 15 49 C 15 52.314 17.686 55 21 55 L 43 55 C 46.314 55 49 52.314 49 49 L 49 33 C 49 30.388126 47.329341 28.171862 45 27.347656 L 45 22 C 45 14.832 39.168 9 32 9 z M 32 13 C 36.963 13 41 17.038 41 22 L 41 27 L 23 27 L 23 22 C 23 17.038 27.037 13 32 13 z",
}),
export const chatbarLock = (
<svg
key="Encrypt Message"
fill="#EBEBEB"
width="30"
height="30"
viewBox={"0 0 64 64"}
style={{ marginTop: 7 }}
onClick={() => buildEncModal()}>
<path d="M 32 9 C 24.832 9 19 14.832 19 22 L 19 27.347656 C 16.670659 28.171862 15 30.388126 15 33 L 15 49 C 15 52.314 17.686 55 21 55 L 43 55 C 46.314 55 49 52.314 49 49 L 49 33 C 49 30.388126 47.329341 28.171862 45 27.347656 L 45 22 C 45 14.832 39.168 9 32 9 z M 32 13 C 36.963 13 41 17.038 41 22 L 41 27 L 23 27 L 23 22 C 23 17.038 27.037 13 32 13 z" />
</svg>
);
10 changes: 6 additions & 4 deletions src/assets/indicator.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { common } from "replugged";
const { React } = common;

export const Indicator = React.createElement("img", {
src: "https://cdn-icons-png.flaticon.com/32/3064/3064130.png",
width: "20",
});
export const Indicator = (
<img
src="https://cdn-icons-png.flaticon.com/32/3064/3064130.png"
width={20}
style={{ marginBottom: -4 }}></img>
);
18 changes: 5 additions & 13 deletions src/assets/popoverIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import { common } from "replugged";
const { React } = common;

export const popoverIcon = () =>
React.createElement(
"svg",
{
fill: "#EBEBEB",
width: "24",
height: "24",
viewBox: "0 0 64 64",
},
React.createElement("path", {
d: "M 32 9 C 24.832 9 19 14.832 19 22 L 19 27.347656 C 16.670659 28.171862 15 30.388126 15 33 L 15 49 C 15 52.314 17.686 55 21 55 L 43 55 C 46.314 55 49 52.314 49 49 L 49 33 C 49 30.388126 47.329341 28.171862 45 27.347656 L 45 22 C 45 14.832 39.168 9 32 9 z M 32 13 C 36.963 13 41 17.038 41 22 L 41 27 L 23 27 L 23 22 C 23 17.038 27.037 13 32 13 z",
}),
);
export const popoverIcon = () => (
<svg fill="#EBEBEB" width="24" height="24" viewBox="0 0 64 64">
<path d="M 32 9 C 24.832 9 19 14.832 19 22 L 19 27.347656 C 16.670659 28.171862 15 30.388126 15 33 L 15 49 C 15 52.314 17.686 55 21 55 L 43 55 C 46.314 55 49 52.314 49 49 L 49 33 C 49 30.388126 47.329341 28.171862 45 27.347656 L 45 22 C 45 14.832 39.168 9 32 9 z M 32 13 C 36.963 13 41 17.038 41 22 L 41 27 L 23 27 L 23 22 C 23 17.038 27.037 13 32 13 z" />
</svg>
);
33 changes: 22 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { Injector, common } from "replugged";
import { common } from "replugged";

import { popoverIcon } from "./assets/popoverIcon";
import { chatbarLock } from "./assets/chatbarLock";
import { Indicator } from "./assets/indicator";

import { buildDecModal, initDecModal } from "./components/DecryptionModal";
import { initModals } from "./components/Modals";

import StegCloak from "./lib/stegcloak.js";
import { initEncModal } from "./components/EncryptionModal";
import { buildDecModal, initDecModal } from "./components/DecryptionModal";

const getStegCloak: Promise<StegCloakImport> = import(
// @ts-expect-error SHUT UP
"https://unpkg.com/[email protected]/index.js"
);

const inject = new Injector();
const steggo: StegCloak = new StegCloak(true, false);
type Constructor<StegCloak> = new (encrypt: boolean, useHmac: boolean) => Promise<StegCloak>;

interface StegCloak {
hide: (secret: string, password: unknown, cover: string) => string;
reveal: (secret: string, password: unknown) => string;
hide: (secret: string, password: string, cover: string) => string;
reveal: (secret: string, password: string) => string;
}

interface StegCloakImport {
default: Constructor<StegCloak>;
}

const EMBED_URL = "https://embed.sammcheese.net";
Expand All @@ -24,7 +30,14 @@ const URL_DETECTION = new RegExp(
/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/,
);

let StegCloak: Constructor<StegCloak>;
let steggo: StegCloak;

export async function start(): Promise<void> {
// Prepare Lib
StegCloak = (await getStegCloak).default;
steggo = await new StegCloak(true, false);

// Prepare Modals
await initModals();
await initDecModal();
Expand Down Expand Up @@ -100,9 +113,7 @@ function updateMessage(message: unknown): void {
});
}

export function stop(): void {
inject.uninjectAll();
}
export function stop(): void {}

export function encrypt(secret: string, password: string, cover: string): string {
// Add Identifier unicode to secret (\u200b)
Expand Down
22 changes: 0 additions & 22 deletions src/lib/stegcloak.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const patches: types.PlaintextPatch[] = [
{
// Chatbar Lock
match: /.=.\.activeCommand,.=.\.activeCommandOption,.{0,155}(.)=\[\];/,
replace: "$&;$1.push(window.invisiblechat.chatbarLock);",
replace: "$&;try{$1.push(window.invisiblechat.chatbarLock)}catch{};",
},
{
// Message Indicator
Expand Down

0 comments on commit a70785f

Please sign in to comment.