Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
97d6da6636 | |||
3fdca4b2ae | |||
2e5e690d46 | |||
dae532627c | |||
886c3bbb3a | |||
5eaa073061 |
1 changed files with 6 additions and 5 deletions
11
galaxy.js
11
galaxy.js
|
@ -124,8 +124,9 @@ export function initGalaxy({
|
||||||
onLoggedInChanged
|
onLoggedInChanged
|
||||||
}) {
|
}) {
|
||||||
return new Promise((accept, reject) => {
|
return new Promise((accept, reject) => {
|
||||||
acceptedOrigins = acceptedOrigins ?? ["https://galaxy.click"];
|
acceptedOrigins = acceptedOrigins?.map(url =>
|
||||||
if (acceptedOrigins.includes(document.referrer)) {
|
url.replace(/\/?$/, '/')) ?? ["https://galaxy.click/"];
|
||||||
|
if (acceptedOrigins.includes(document.referrer.replace(/\/?$/, '/'))) {
|
||||||
// Callbacks to resolve promises
|
// Callbacks to resolve promises
|
||||||
/** @type function(SaveListResponse["list"]):void */
|
/** @type function(SaveListResponse["list"]):void */
|
||||||
let saveListAccept,
|
let saveListAccept,
|
||||||
|
@ -143,7 +144,7 @@ export function initGalaxy({
|
||||||
supportsSaveManager,
|
supportsSaveManager,
|
||||||
ignoreApiVersion,
|
ignoreApiVersion,
|
||||||
onLoggedInChanged,
|
onLoggedInChanged,
|
||||||
origin: window.origin,
|
origin: document.referrer.replace(/\/?$/, "/"),
|
||||||
apiVersion: 0,
|
apiVersion: 0,
|
||||||
loggedIn: false,
|
loggedIn: false,
|
||||||
postMessage: function (message) {
|
postMessage: function (message) {
|
||||||
|
@ -163,7 +164,7 @@ export function initGalaxy({
|
||||||
if (slot in saveCallbacks) {
|
if (slot in saveCallbacks) {
|
||||||
return Promise.reject(`save action for slot ${slot} already in progress.`);
|
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) => {
|
return new Promise((accept, reject) => {
|
||||||
saveCallbacks[slot] = { accept, reject };
|
saveCallbacks[slot] = { accept, reject };
|
||||||
});
|
});
|
||||||
|
@ -180,7 +181,7 @@ export function initGalaxy({
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("message", e => {
|
window.addEventListener("message", e => {
|
||||||
if (e.origin === galaxy.origin) {
|
if (e.origin.replace(/\/?$/, '/') === galaxy.origin.replace(/\/?$/, '/')) {
|
||||||
console.log("Received message from Galaxy", e.data);
|
console.log("Received message from Galaxy", e.data);
|
||||||
/** @type GalaxyResponse */
|
/** @type GalaxyResponse */
|
||||||
const data = e.data;
|
const data = e.data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue