EmoteCloner: Use CDN_HOST variable to support unofficial backends (#356)

This commit is contained in:
V3L0C1T13S 2022-12-21 10:12:05 -05:00 committed by GitHub
parent 7e6077367a
commit 1f73cfa91a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,7 @@ function getGuildCandidates(isAnimated: boolean) {
}
async function doClone(guildId: string, id: string, name: string, isAnimated: boolean) {
const data = await fetch(`https://cdn.discordapp.com/emojis/${id}.${isAnimated ? "gif" : "png"}`)
const data = await fetch(`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${id}.${isAnimated ? "gif" : "png"}`)
.then(r => r.blob());
const reader = new FileReader();
@ -226,7 +226,7 @@ export default definePlugin({
<img
role="presentation"
aria-hidden
src={`https://cdn.discordapp.com/emojis/${id}.${isAnimated ? "gif" : "png"}`}
src={`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/emojis/${id}.${isAnimated ? "gif" : "png"}`}
alt=""
height={24}
width={24}