From e0450531efa84c42e4857b78176f5e80de2ab12e Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 9 Nov 2022 17:30:37 +0100 Subject: [PATCH] StickerSpoof: fix small resolutions; AnonymiseFiles: fix extension logic --- src/plugins/anonymiseFileNames.ts | 4 +++- src/plugins/nitroBypass.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/anonymiseFileNames.ts b/src/plugins/anonymiseFileNames.ts index 5bae10aee..c7c3ed585 100644 --- a/src/plugins/anonymiseFileNames.ts +++ b/src/plugins/anonymiseFileNames.ts @@ -67,7 +67,9 @@ export default definePlugin({ anonymise(file: string) { let name = "image"; - const ext = file.match(/\..+$/g)?.[0] ?? ""; + const extIdx = file.lastIndexOf("."); + const ext = extIdx !== -1 ? file.slice(extIdx) : ""; + switch (Settings.plugins.AnonymiseFileNames.method) { case Methods.Random: const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; diff --git a/src/plugins/nitroBypass.ts b/src/plugins/nitroBypass.ts index be77a4cea..9e961a22a 100644 --- a/src/plugins/nitroBypass.ts +++ b/src/plugins/nitroBypass.ts @@ -169,14 +169,14 @@ export default definePlugin({ const resolution = Settings.plugins.NitroBypass.stickerSize; const canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; + canvas.width = resolution; + canvas.height = resolution; const ctx = canvas.getContext("2d", { willReadFrequently: true })!; - const scale = resolution / width; + const scale = resolution / Math.max(width, height); ctx.scale(scale, scale); let lastImg: HTMLImageElement | null = null;