Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<html>
<body>
<div id="captchaType" data-captcha-type="cf-turnstile"></div>
<template id="contents">
<div id="fail" style="display: none"></div>
<div id="success" style="display: none"></div>
</template>
<script>
const bodyShadowRoot = document.body.attachShadow({ mode: "closed" });
bodyShadowRoot.appendChild(
document.getElementById("contents").content.cloneNode(true)
);
// Mutation handler only fires when an attribute changes, so we need to change
// any attribute that's not in shadow DOM to trigger the mutation observer.
document.documentElement.dir = "ltr";
window.onmessage = function (event) {
if (event.data === "fail") {
bodyShadowRoot.getElementById("fail").style.display = "block";
} else if (event.data === "success") {
bodyShadowRoot.getElementById("success").style.display = "block";
}
};
// Tests pass ?state=success|fail to show the result while this document
// is still parsing, i.e. before the actor is created on DOMContentLoaded
// and starts observing. Covers the case where the result is already
// visible by the time the MutationObserver is registered.
const initialState = new URLSearchParams(location.search).get("state");
if (initialState === "success" || initialState === "fail") {
bodyShadowRoot.getElementById(initialState).style.display = "block";
}
window.parent.postMessage("ready", "*");
</script>
</body>
</html>