Created
April 12, 2026 02:36
-
-
Save copyleftdev/05bc06a3e9ab8c8c290ee90b36c419c1 to your computer and use it in GitHub Desktop.
Palimpsest: Browser Determinism Layer (JS Overrides)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Palimpsest Determinism Layer (Law 1) | |
| // Injected BEFORE page navigation to ensure all JS execution | |
| // is deterministic for a given seed. | |
| // Freeze Date.now() to the envelope timestamp. | |
| const __palimpsest_base_time = ENVELOPE_TIMESTAMP_MS; | |
| let __palimpsest_time_offset = 0; | |
| Date.now = function() { | |
| __palimpsest_time_offset += 1; | |
| return __palimpsest_base_time + __palimpsest_time_offset; | |
| }; | |
| // Seed Math.random() with a deterministic PRNG (xorshift64). | |
| let __palimpsest_rng_state = BigInt(CRAWL_SEED_VALUE) || 1n; | |
| Math.random = function() { | |
| __palimpsest_rng_state ^= __palimpsest_rng_state << 13n; | |
| __palimpsest_rng_state ^= __palimpsest_rng_state >> 7n; | |
| __palimpsest_rng_state ^= __palimpsest_rng_state << 17n; | |
| return Number(__palimpsest_rng_state & 0xFFFFFFFFn) / 4294967296; | |
| }; | |
| // Disable non-deterministic APIs. | |
| window.RTCPeerConnection = undefined; | |
| navigator.geolocation.getCurrentPosition = function() {}; | |
| Notification.requestPermission = () => Promise.resolve('denied'); | |
| // Override performance.now() entropy. | |
| let __perf_offset = 0; | |
| performance.now = function() { | |
| __perf_offset += 0.1; | |
| return __perf_offset; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment