Skip to content

Commit

Permalink
optimize plaintext patches
Browse files Browse the repository at this point in the history
  • Loading branch information
SammCheese committed May 31, 2023
1 parent 47a0885 commit a07b7f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 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.2.6",
"version": "1.2.7",
"updater": {
"type": "github",
"id": "SammCheese/invisible-chat"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "invisible-chat",
"version": "1.2.6",
"version": "1.2.7",
"description": "Encrypt your Discord Messages",
"engines": {
"node": ">=14.0.0"
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export async function start(): Promise<void> {
Indicator,
};
}

export function stop(): void {
injector.uninjectAll();
}
Expand Down Expand Up @@ -79,3 +80,7 @@ export async function buildEmbed(message: DiscordMessage, revealed: string): Pro
}

export { Settings } from "./components/Settings";

export { chatbarLock } from "./assets/chatbarLock";

export { popoverIcon } from "./assets/popoverIcon";
16 changes: 11 additions & 5 deletions src/plaintextPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import { types } from "replugged";

const patches: types.PlaintextPatch[] = [
{
find: ".Messages.SOURCE_MESSAGE_DELETED",
replacements: [
{
// Chatbar Lock
match: /(.)\.push.{1,}\(.{1,3},\{.{1,30}\},"gift"\)\)/,
replace: "$&;try{$1.push(window.invisiblechat?.chatbarLock)}catch{}",
},
{
// Message Indicator
match: /var .,.,.=(.)\.className,.=.\.message,.=.\.children,.=.\.content,.=.\.onUpdate/,
Expand All @@ -16,6 +12,16 @@ const patches: types.PlaintextPatch[] = [
},
],
},
{
find: "GIFT_BUTTON).analyticsLocations",
replacements: [
{
// Chatbar Lock
match: /(.)\.push.{1,}\(.{1,3},\{.{1,30}\},"gift"\)\)/,
replace: "$&;try{$1.push(window.invisiblechat?.chatbarLock)}catch{}",
},
],
},
];

export default patches;
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-undefined */
/* eslint-disable @typescript-eslint/naming-convention */

import { common, settings, webpack } from "replugged";
import { common, settings } from "replugged";

const EMBED_URL = `/unfurler/embed-urls`;

Expand Down Expand Up @@ -123,7 +123,7 @@ export async function getEmbed(url: URL): Promise<DiscordEmbed> {
url: EMBED_URL,
body: {
urls: [url],
}
},
})
.then((res) => {
return res.body.embeds[0];
Expand Down

0 comments on commit a07b7f2

Please sign in to comment.