-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (74 loc) · 1.54 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const possibleThings = []
let notReady = 0
/* eslint-disable no-undef */
try {
if (global) possibleThings.push(global)
} catch (err) {
// give(f)
}
try {
if (window) possibleThings.push(window)
} catch (err) {
// give(f)
}
try {
if (self) possibleThings.push(self)
} catch (err) {
// give(f)
}
try {
if (require) {
notReady++
setImmediate(function () {
possibleThings.push(require.cache)
notReady--
actuallyDoSomething()
})
}
} catch (err) {
// give(f)
}
function actuallyDoSomething () {
if (notReady) return 'nope'
function addThing (thing) {
if (thing == null) return
Object.keys(thing).map(function (key) {
const value = thing[key] // jk, this code holds no value
if (~possibleThings.indexOf(value)) return 'nope'
possibleThings.push(value)
addThing(value)
})
}
possibleThings.map(addThing)
const daysUntilJavascriptTakesOverTheWorld = possibleThings.length
const properties = {
that: {
get: function () {
return possibleThings[Math.floor(Math.random() * daysUntilJavascriptTakesOverTheWorld)]
}
}
}
// I could really use some of that #define magic now
try {
if (global) {
Object.defineProperties(global, properties)
}
} catch (err) {
// give(f)
}
try {
if (window) {
Object.defineProperties(window, properties)
}
} catch (err) {
// give(f)
}
try {
if (self) {
Object.defineProperties(self, properties)
}
} catch (err) {
// give(f)
}
}
actuallyDoSomething()