-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
189 lines (166 loc) · 3.69 KB
/
index.html
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!doctype html>
<meta charset="utf-8" />
<title>dom-destroyer test page</title>
<style>
body {
font-family: sans-serif;
}
h1 {
font-size: 1.5em;
margin: 0.5em 0 0;
}
.header .hint {
font-size: 0.85em;
font-style: italic;
margin: 0.5em 0;
}
.cases {
align-items: center;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.case {
background: #afb;
border: 0.5em solid #cef;
display: flex;
height: 200px;
flex: 0 0 300px;
justify-content: flex-grow;
margin: 0.5em;
position: relative;
}
.case:before {
align-items: center;
content: "✓";
color: #fff;
display: flex;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
justify-content: center;
font-size: 7em;
}
.target {
background: #eee;
flex-grow: 1;
padding: 1em;
position: relative;
}
.relative-2 {
display: block;
position: relative;
left: 0.5em;
top: 0.5em;
}
.absolute-3 {
display: block;
position: absolute;
right: 0;
top: -0.5em;
}
.fixed-4 {
display: block;
position: fixed;
right: 0.5em;
top: 5.5em;
z-index: 1;
}
.button-5 {
border-width: 0.5em;
font-size: inherit;
}
.link-6 a {
font-size: 1.5em;
}
.parent-7 {
padding: 0;
}
.parent-7 .nope {
position: absolute;
left: 1em;
top: 1em;
}
.parent-7 .child {
background: #ffc;
box-sizing: border-box;
padding: 1em;
height: 100%;
position: relative;
}
</style>
<link rel="stylesheet" href="./style.css" />
<div class="header">
<h1>dom destroyer target practice</h1>
<p class="hint">hint: refresh the page to get everything back. hit <code>esc</code> to stop destroying.</p>
</style>
<p><button id="toggle">enable</button></p>
<div class="cases">
<div class="case">
<div class="target">
<h3>1. Simple</h3>
<p>just a plain old div…</p>
</div>
</div>
<div class="case">
<div class="target relative-2">
<h3>2. Relative</h3>
<p>slightly offset</p>
</div>
</div>
<div class="case">
<div class="target absolute-3">
<h3>3. Absolute</h3>
<p>for some reason</p>
</div>
</div>
<div class="case">
<div class="target fixed-4">
<h3>4. Fixed</h3>
<p>luv takin up your screen space. bonus points: scroll page before destroying me.</p>
</div>
</div>
<div class="case">
<button onclick="alert('a complaint')" class="target button-5">
<h3>5. Button no-clicky</h3>
<p>destroy this button and don't let it complain:</p>
</button>
</div>
<div class="case">
<a href="https://example.com" class="target link-6">
<h3>6. Link please</h3>
<p>take out the link but don't go anywhere:</p>
</a>
</div>
<div class="case">
<div class="target parent-7">
<p class="nope">nope, still here</p>
<div class="child">
<h3>7. Annoying parent containers</h3>
<p>When this is removed, it should take its same-sized parent with it</p>
</div>
</div>
</div>
<div class="case">
<iframe class="target iframe-8" src="./framed-test.html"></iframe>
</div>
</div>
<script>;(w => {
const button = document.getElementById('toggle');
button.addEventListener('click', () => {
const s = w.document.createElement('script');
s.src = ('./destroyer.js');
w.document.body.appendChild(s);
});
// stub the extension api
w.chrome = { runtime: { sendMessage: ({ armed }) => {
if (armed) {
button.innerHTML = '<em>ready…</em>';
} else {
if (!w.document.body.contains(button)) w.document.body.appendChild(button);
button.innerText = 'enable';
}
} } };
})(window);</script>