Skip to content

Commit 37ef5b0

Browse files
committed
Fix some more csp issues
1 parent ed428c6 commit 37ef5b0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

scripts/index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,11 @@ function gameWinDaily() {
621621

622622
}
623623

624+
let imgSrc = 'https://storage.ko-fi.com/cdn/cup-border.png';
625+
if (window.isDiscord) {
626+
imgSrc = getDiscordProxiedUrl(imgSrc);
627+
};
628+
624629
window.dailyModal = $.confirm({
625630
title: `<span class=\"modalText\">${getWinTerms(wr)}${(wr != 0 ? (` — ${wr} wrong`) : '')}</span>`,
626631
content: `${getCardHtml()}<div id="dailyTimerDisplay"></div>`,
@@ -635,7 +640,7 @@ function gameWinDaily() {
635640
closeIcon: true,
636641
buttons: {
637642
kofi: {
638-
text: '<img src="https://storage.ko-fi.com/cdn/cup-border.png" alt="Ko-Fi">',
643+
text: `<img src="${imgSrc}" alt="Ko-Fi">`,
639644
btnClass: 'btn-blue kofi-btn',
640645
action: function () {
641646
buyDrink();
@@ -1581,6 +1586,15 @@ function reportBug() {
15811586

15821587
//function to buy drink
15831588
function buyDrink() {
1589+
if (isDiscord) {
1590+
try {
1591+
discordSdk.commands.openExternalLink({ url: 'https://ko-fi.com/suitangi' });
1592+
} catch (error) {
1593+
console.error("Could not open link in Discord:", error);
1594+
}
1595+
return;
1596+
}
1597+
15841598
let src = "https://ko-fi.com/suitangi/?hidefeed=true&amp;widget=true&amp;embed=true&amp;preview=true";
15851599
if (window.isDiscord) {
15861600
src = getDiscordProxiedUrl(src);
@@ -2148,12 +2162,12 @@ function submitDailyData(win) {
21482162

21492163
function getDiscordProxiedUrl(originalUrl) {
21502164
if (!originalUrl) return '';
2151-
2165+
21522166
return originalUrl
21532167
.replace("https://api.scryfall.com", "/scry-com/api")
21542168
.replace("https://c2.scryfall.com", "/scry-com/c2")
21552169
.replace("https://cards.scryfall.io", "/scry-io/cards")
2156-
.replace("https://svgs.scryfall.io", "/scry-io/svg")
2170+
.replace("https://svgs.scryfall.io", "/scry-io/svgs")
21572171
.replace("https://docs.google.com/forms", "/google/forms")
21582172
.replace("https://ko-fi.com", "/kofi")
21592173
.replace("https://storage.ko-fi.com", "/kofi-storage");

0 commit comments

Comments
 (0)