File size: 787 Bytes
bee6636
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { ScramjetClient } from "../client";
import { config } from "../../shared";

export const POLLUTANT = Symbol.for("scramjet realm pollutant");

export default function (client: ScramjetClient, self: typeof globalThis) {
	// object.$setrealm({}).postMessage(...)
	// the empty object is the "pollutant" which can reconstruct the real realm
	// i explain more in postmessage.ts
	Object.defineProperty(self.Object.prototype, config.globals.setrealmfn, {
		value(pollution: object) {
			// this is bad!! sites could detect this
			Object.defineProperty(this, POLLUTANT, {
				value: pollution,
				writable: false,
				configurable: true,
				enumerable: false,
			});

			return this;
		},
		writable: true,
		configurable: true,
		enumerable: false,
	});
}