Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
97d6da6636 | |||
3fdca4b2ae | |||
2e5e690d46 | |||
dae532627c | |||
886c3bbb3a | |||
5eaa073061 | |||
e16fb553ae |
1 changed files with 6 additions and 5 deletions
11
galaxy.js
11
galaxy.js
|
@ -124,8 +124,9 @@ export function initGalaxy({
|
|||
onLoggedInChanged
|
||||
}) {
|
||||
return new Promise((accept, reject) => {
|
||||
acceptedOrigins = acceptedOrigins ?? ["https://galaxy.click"];
|
||||
if (acceptedOrigins.includes(window.origin)) {
|
||||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue