mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-03 12:40:47 +00:00
Merge branch 'v25'
This commit is contained in:
+1011
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ import { UserMeResponse } from "../core/ApiSchemas";
|
||||
import "./components/Difficulties";
|
||||
import "./components/PatternButton";
|
||||
import { discordLogin, getApiBase, getUserMe, logOut } from "./jwt";
|
||||
import { translateText } from "./Utils";
|
||||
import { isInIframe, translateText } from "./Utils";
|
||||
|
||||
@customElement("account-modal")
|
||||
export class AccountModal extends LitElement {
|
||||
@@ -268,6 +268,10 @@ export class AccountButton extends LitElement {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (isInIframe()) {
|
||||
return html``;
|
||||
}
|
||||
|
||||
if (!this.isVisible) {
|
||||
return html``;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import { UsernameInput } from "./UsernameInput";
|
||||
import {
|
||||
generateCryptoRandomUUID,
|
||||
incrementGamesPlayed,
|
||||
isInIframe,
|
||||
translateText,
|
||||
} from "./Utils";
|
||||
import "./components/NewsButton";
|
||||
@@ -207,6 +208,10 @@ class Client {
|
||||
const patternButton = document.getElementById(
|
||||
"territory-patterns-input-preview-button",
|
||||
);
|
||||
if (isInIframe() && patternButton) {
|
||||
patternButton.style.display = "none";
|
||||
}
|
||||
|
||||
this.patternsModal instanceof TerritoryPatternsModal;
|
||||
if (patternButton === null)
|
||||
throw new Error("territory-patterns-input-preview-button");
|
||||
|
||||
@@ -235,3 +235,13 @@ export function incrementGamesPlayed(): void {
|
||||
console.warn("Failed to increment games played in localStorage:", error);
|
||||
}
|
||||
}
|
||||
|
||||
export function isInIframe(): boolean {
|
||||
try {
|
||||
return window.self !== window.top;
|
||||
} catch (e) {
|
||||
// If we can't access window.top due to cross-origin restrictions,
|
||||
// we're definitely in an iframe
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LitElement, TemplateResult, html } from "lit";
|
||||
import { customElement, state } from "lit/decorators.js";
|
||||
import { translateText } from "../../../client/Utils";
|
||||
import { isInIframe, translateText } from "../../../client/Utils";
|
||||
import { ColorPalette, Pattern } from "../../../core/CosmeticSchemas";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { GameUpdateType } from "../../../core/game/GameUpdates";
|
||||
@@ -36,6 +36,8 @@ export class WinModal extends LitElement implements Layer {
|
||||
|
||||
private _title: string;
|
||||
|
||||
private rand = Math.random();
|
||||
|
||||
// Override to prevent shadow DOM creation
|
||||
createRenderRoot() {
|
||||
return this;
|
||||
@@ -98,6 +100,9 @@ export class WinModal extends LitElement implements Layer {
|
||||
}
|
||||
|
||||
innerHtml() {
|
||||
if (isInIframe() || this.rand < 0.25) {
|
||||
return this.steamWishlist();
|
||||
}
|
||||
return this.renderPatternButton();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user