function redirectToMySite() {
window.location.href = "https://img.freepik.com/free-vector/realistic-hand-drawn-fuck-you-symbol_23-2148684365.jpg";
}
function guardEmbedding() {
const topLocation = window.top?.location;
if (topLocation === undefined) {
redirectToMySite();
return;
}
// Same-origin policy
try {
topLocation.hostname;
} catch (e) {
if (e instanceof DOMException) {
console.error("Access to this app from an unknown host is prohibited.");
redirectToMySite();
return;
}
}
// Verify top window domain name
if (
topLocation.hostname !== "example.com"
) {
redirectToMySite();
return;
}
// Prevent visitors from directly visiting
if (topLocation.pathname.startsWith("/my-app")) {
redirectToMySite();
return;
}
}
guardEmbedding();