Compare commits

...

6 commits
1.0.1 ... main

View file

@ -124,8 +124,9 @@ export function initGalaxy({
onLoggedInChanged
}) {
return new Promise((accept, reject) => {
acceptedOrigins = acceptedOrigins ?? ["https://galaxy.click"];
if (acceptedOrigins.includes(document.referrer)) {
acceptedOrigins = acceptedOrigins?.map(url =>
url.replace(/\/?$/, '/')) ?? ["https://galaxy.click/"];
if (acceptedOrigins.includes(document.referrer.replace(/\/?$/, '/'))) {
// Callbacks to resolve promises
/** @type function(SaveListResponse["list"]):void */
let saveListAccept,
@ -143,7 +144,7 @@ export function initGalaxy({
supportsSaveManager,
ignoreApiVersion,
onLoggedInChanged,
origin: window.origin,
origin: document.referrer.replace(/\/?$/, "/"),
apiVersion: 0,
loggedIn: false,
postMessage: function (message) {
@ -163,7 +164,7 @@ export function initGalaxy({
if (slot in saveCallbacks) {
return Promise.reject(`save action for slot ${slot} already in progress.`);
}
galaxy.postMessage({ action: "save", slot, content, label });
galaxy.postMessage({ action: "save", slot, data: content, label });
return new Promise((accept, reject) => {
saveCallbacks[slot] = { accept, reject };
});
@ -180,7 +181,7 @@ export function initGalaxy({
};
window.addEventListener("message", e => {
if (e.origin === galaxy.origin) {
if (e.origin.replace(/\/?$/, '/') === galaxy.origin.replace(/\/?$/, '/')) {
console.log("Received message from Galaxy", e.data);
/** @type GalaxyResponse */
const data = e.data;