Skip to content

Commit b0ddb03

Browse files
authored
Update big_game_script.js
1 parent 6bd5f1f commit b0ddb03

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

static/big_game_script.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const framed = pageInIframe();
1111
const glocation = (!framed) ? window.location.hostname : document.location.ancestorOrigins[0];
1212
const gameIDExtractRG = /\/(game_\w+)\//;
1313
const gameIDExtract = gameIDExtractRG.exec(window.location.pathname);
14+
const parentOrigin = (framed && document.location.ancestorOrigins.length > 0) ? new URL(document.location.ancestorOrigins[0]).origin : null;
1415
const gameID = window.ccPorted.gameID || window.gameID || ((gameIDExtract) ? gameIDExtract[1] : "Unknown Game");
1516

1617
let trackingInterval = null;
@@ -2246,7 +2247,7 @@ async function getTokensFromParent(timeout = 5000) {
22462247
// Set up message handler
22472248
const messageHandler = (event) => {
22482249
// Only accept messages from the parent origin
2249-
if (event.origin !== window.parent.origin) return;
2250+
if (event.origin !== parentOrigin) return;
22502251

22512252
const data = event.data;
22522253

@@ -2280,7 +2281,7 @@ async function getTokensFromParent(timeout = 5000) {
22802281
window.parent.postMessage({
22812282
action: "GET_TOKENS",
22822283
requestId: requestId
2283-
}, window.parent.origin);
2284+
}, parentOrigin);
22842285

22852286
// Set timeout
22862287
setTimeout(() => {

0 commit comments

Comments
 (0)