diff options
author | Vendicated <vendicated@riseup.net> | 2022-09-28 13:39:13 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-09-28 13:39:13 +0200 |
commit | 0677df781840461f9a0b11ed08a2c9f72a521c84 (patch) | |
tree | 2a4f7f0fa729b7c7f3f09bec953c944250b294ad /src/plugins | |
parent | 48477e19594f6333cddf32efa4d210ab62aea371 (diff) | |
download | Vencord-0677df781840461f9a0b11ed08a2c9f72a521c84.tar.gz Vencord-0677df781840461f9a0b11ed08a2c9f72a521c84.tar.bz2 Vencord-0677df781840461f9a0b11ed08a2c9f72a521c84.zip |
BetterGifAltText sanity checks
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/betterGifAltText.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/plugins/betterGifAltText.ts b/src/plugins/betterGifAltText.ts index c49b3a1..3e40820 100644 --- a/src/plugins/betterGifAltText.ts +++ b/src/plugins/betterGifAltText.ts @@ -27,14 +27,19 @@ export default definePlugin({ altify(props: any) { if (props.alt !== "GIF") return; - const url = props.original || props.src; - const name = url + const url: string = props.original || props.src; + let name = url .slice(url.lastIndexOf("/") + 1) .replace(/\d/g, "") // strip numbers .replace(/.gif$/, "") // strip extension - .replace(/[,-_ ]+/g, " "); // Replace common delimiters with space + .split(/[,\-_ ]+/g) + .slice(0, 20) + .join(" "); + if (name.length > 300) { + name = name.slice(0, 300) + "..."; + } - if (name.length) props.alt += ` - ${name}`; + if (name) props.alt += ` - ${name}`; return props.alt; }, |