aboutsummaryrefslogtreecommitdiff
path: root/src/fallback.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/fallback.ts')
-rw-r--r--src/fallback.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/fallback.ts b/src/fallback.ts
new file mode 100644
index 000000000..cf4195c4d
--- /dev/null
+++ b/src/fallback.ts
@@ -0,0 +1,24 @@
+import { ByteBuffer } from "peechy";
+import { FallbackStep } from "./api/schema";
+import {
+ decodeFallbackMessageContainer,
+ FallbackMessageContainer,
+} from "./api/schema";
+
+function getFallbackInfo(): FallbackMessageContainer {
+ var binary_string = window.atob(
+ document.querySelector("#__bunfallback").textContent.trim()
+ );
+ document.querySelector("#__bunfallback").remove();
+
+ var len = binary_string.length;
+ var bytes = new Uint8Array(len);
+ for (var i = 0; i < len; i++) {
+ bytes[i] = binary_string.charCodeAt(i);
+ }
+
+ return decodeFallbackMessageContainer(new ByteBuffer(bytes));
+}
+
+globalThis.__BUN_DATA__ = getFallbackInfo();
+document.getElementById("__bun_fallback_script")?.remove();