Skip to content

Commit daee17e

Browse files
authored
Use new subdomains (#773)
* Use new subdomains * Set crossOrigin on images * Fix more URLs
1 parent b395b12 commit daee17e

9 files changed

Lines changed: 27 additions & 21 deletions

File tree

chat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ function tryEmbedScreenshot(node, uuid) {
896896
const imageNode = document.createElement('img');
897897
imageNode.classList.add('screenshotEmbed');
898898
imageNode.classList.toggle('screenshotBlur', globalConfig.blurScreenshotEmbeds || !!(flags & SCREENSHOT_FLAGS.SPOILER));
899-
imageNode.src = `${serverUrl}/screenshots/${isTemp ? 'temp/' : ''}${uuid}/${screenshotResult[2]}.png`;
899+
imageNode.src = `${ugcUrl}/screenshots/${isTemp ? 'temp/' : ''}${uuid}/${screenshotResult[2]}.png`;
900900
const date = new Date();
901901
imageNode.onclick = function () {
902902
sendSessionCommand('psi', [ uuid, screenshotResult[2] ], args => {

init.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,26 @@ Object.defineProperty(String.prototype, 'title', {
5757
get() { return this; },
5858
})
5959

60+
const loggedInKey = 'ynoproject_loggedIn';
61+
const hostBase = 'ynoproject.net';
62+
const serverUrlBase = `api.${hostBase}`;
63+
const serverUrl = `https://${serverUrlBase}/${ynoGameId}`;
64+
const authApiUrl = `https://auth.${hostBase}`;
65+
const cdnUrl = `https://cdn.${hostBase}`;
66+
const ugcUrl = `https://ugc.${hostBase}`;
67+
const rankUrl = `https://rank.${hostBase}`
68+
const apiUrl = `${serverUrl}/api`;
69+
const adminApiUrl = `${serverUrl}/admin`;
70+
const ynomojiUrlPrefix = 'images/ynomoji/';
71+
6072
let easyrpgPlayer = {
6173
initialized: false,
6274
game: ynoGameId,
6375
saveFs: undefined,
64-
wsUrl: 'wss://connect.ynoproject.net/' + ynoGameId + '/'
76+
wsUrl: `wss://${serverUrlBase}/${ynoGameId}/`
6577
};
6678
let easyrpgPlayerLoadFuncs = [];
6779

68-
const loggedInKey = 'ynoproject_loggedIn';
69-
const serverUrlBase = 'https://connect.ynoproject.net';
70-
const serverUrl = `${serverUrlBase}/${ynoGameId}`;
71-
const apiUrl = `${serverUrl}/api`;
72-
const authApiUrl = `${serverUrlBase}/seiko`;
73-
const adminApiUrl = `${serverUrl}/admin`;
74-
const ynomojiUrlPrefix = 'images/ynomoji/';
75-
7680
let initBlocker = Promise.resolve();
7781

7882
async function injectScripts() {
@@ -89,7 +93,7 @@ async function injectScripts() {
8993
}
9094
for (let script of scripts)
9195
dependencyFiles[script] = null;
92-
dependencyFiles[`${window.location.origin}/data/${ynoGameId}/index.json`] = null;
96+
dependencyFiles[`${cdnUrl}/${ynoGameId}/index.json`] = null;
9397
dependencyFiles[`ynoengine${supportsSimd ? '-simd' : ''}.wasm`] = null;
9498

9599
const injectScript = function (index) {

loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ async function getLoaderSpriteImg(sprite, idx, frameIdx, dir) {
125125
if (spriteUrl)
126126
return resolve(spriteUrl);
127127
const img = new Image();
128+
img.setAttribute('crossOrigin', 'anonymous');
128129
img.onload = function () {
129130
getSpriteImg(img, spriteData, sprite, idx, frameIdx, 24, 32, 0, false, isBrave)
130131
.then(url => resolve(url));
131132
};
132133
if (!dir) {
133-
dir = `../data/${ynoGameId}/CharSet/`;
134+
dir = `${cdnUrl}/${ynoGameId}/CharSet/`;
134135
img.onerror = () => getLoaderSpriteImg(sprite, idx, frameIdx, `images/charsets/${ynoGameId}/`).then(url => resolve(url));
135136
} else {
136137
img.onerror = () => {

play.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ populateUiThemes();
375375

376376
const gameLogoUrl = `../images/logo_${gameId}.png`;
377377
const gameLogoImg = new Image();
378+
gameLogoImg.setAttribute('crossOrigin', 'anonymous');
378379
gameLogoImg.onload = function () {
379380
let width = gameLogoImg.width;
380381
let height = gameLogoImg.height;
@@ -1990,7 +1991,7 @@ function setLang(lang, isInit) {
19901991

19911992
globalConfig.lang = lang;
19921993
initBlocker = initBlocker.then(() => withTimeout(800,
1993-
fetchNewest(`../data/${gameId}/Language/${lang}/meta.ini`).then(response => { // Prevent a crash when the --language argument is used and the game doesn't have a Language folder
1994+
fetchNewest(`${cdnUrl}/${gameId}/Language/${lang}/meta.ini`).then(response => { // Prevent a crash when the --language argument is used and the game doesn't have a Language folder
19941995
if (response.ok && response.status < 400 && isInit && gameIds.indexOf(gameId) > -1) {
19951996
easyrpgPlayer.language = (gameDefaultLangs.hasOwnProperty(gameId) ? gameDefaultLangs[gameId] !== lang : lang !== 'en') ? lang : 'default';
19961997
}
@@ -2272,7 +2273,7 @@ function initLocalization(isInitial) {
22722273
for (let langOpt of languages) {
22732274
const lang = langOpt.value;
22742275
if (gameDefaultLangs.hasOwnProperty(gameId) ? gameDefaultLangs[gameId] !== lang : lang !== 'en')
2275-
fetchNewest(`../data/${gameId}/Language/${lang}/meta.ini`).then(response => {
2276+
fetchNewest(`${cdnUrl}/${gameId}/Language/${lang}/meta.ini`).then(response => {
22762277
if (!response.ok && response.status === 404 && gameId !== 'tsushin') { // Don't display that the game is not localized for Yume Tsushin since it uses a conlang
22772278
langOpt.innerText += '*';
22782279
langOpt.dataset.noGameLoc = true;

playerlist.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,12 +988,13 @@ async function getSpriteProfileImg(sprite, idx, favicon, dir, gameId) {
988988
if (!sprite || idx === -1)
989989
return getDefaultSpriteImg.then(defaultSpriteImg => resolve(defaultSpriteImg));
990990
const img = new Image();
991+
img.setAttribute('crossOrigin', 'anonymous');
991992
img.onload = function () {
992993
getSpriteImg(img, spriteData[cacheKey], sprite, idx, 1, favicon ? 16 : 20, 16, favicon ? 4 : 2, true, isBrave)
993994
.then(url => resolve(url));
994995
};
995996
if (!dir) {
996-
dir = `../data/${gameId}/CharSet/`;
997+
dir = `${cdnUrl}/${gameId}/CharSet/`;
997998
img.onerror = () => getSpriteProfileImg(sprite, idx, favicon, `images/charsets/${gameId}/`, gameId).then(url => resolve(url));
998999
} else {
9991000
img.onerror = () => {

preloads.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function preloadFilesFromMapId(mapId) {
180180
}
181181

182182
function getFilePathForPreloads(path) {
183-
return path.replace(`/data/${gameId}`, "").replace("Language/", "");
183+
return path.replace(`${cdnUrl}/${gameId}`, "").replace("Language/", "");
184184
}
185185

186186
let preloadsGameLang = "default";

rankings.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const rankingsUrl = `https://connect.ynoproject.net/rankings`;
2-
31
const perGameCategoryIds = [];
42

53
let rankingCategoryCache = [];
@@ -27,7 +25,7 @@ function initRankingControls() {
2725

2826
function rankingsApiFetch(path) {
2927
return new Promise((resolve, reject) => {
30-
fetch(`${rankingsUrl}/${path}`, { credentials: "include" })
28+
fetch(`${rankUrl}/${path}`, { credentials: "include" })
3129
.then(response => resolve(response))
3230
.catch(err => reject(err));
3331
});

screenshots.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ async function downloadScreenshot(url, date, screenshotData, resized) {
262262
scaleContext.imageSmoothingEnabled = false;
263263

264264
const img = new Image(320, 240);
265+
img.setAttribute('crossOrigin', 'anonymous');
265266
img.onload = async () => {
266267
scaleContext.drawImage(img, 0, 0, width, height);
267268
scaleCanvas.toBlob(async blob => {
@@ -447,7 +448,7 @@ function initScreenshotsModal(isCommunity) {
447448

448449
const screenshotThumbnail = document.createElement('img');
449450
screenshotThumbnail.classList.add('screenshotThumbnail', 'imageThumbnail', 'unselectable');
450-
screenshotThumbnail.src = `${serverUrl}/screenshots/${uuid}/${screenshot.id}.png`;
451+
screenshotThumbnail.src = `${ugcUrl}/screenshots/${uuid}/${screenshot.id}.png`;
451452
screenshotThumbnail.onclick = () => viewScreenshot(screenshotThumbnail.src, new Date(screenshot.timestamp), screenshot, screenshotsModal.id);
452453

453454
screenshotThumbnailContainer.append(screenshotThumbnail);

session.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function initSessionWs(attempt) {
1414
resolve();
1515
return;
1616
}
17-
let url = `wss://connect.ynoproject.net/${ynoGameId}/session`;
17+
let url = `wss://${serverUrlBase}/${ynoGameId}/session`;
1818
sessionWs = new WebSocket(url);
1919
sessionWs.onclose = e => {
2020
if (e.code === 1028)

0 commit comments

Comments
 (0)