-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.html
More file actions
327 lines (317 loc) 路 12.4 KB
/
Copy pathpopup.html
File metadata and controls
327 lines (317 loc) 路 12.4 KB
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Network Overrides API</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body class="popup-body">
<div class="header-row">
<h2>Network Overrides API</h2>
<div class="header-actions" aria-label="Popup actions">
<button
id="refresh-apis"
type="button"
class="header-btn"
title="Refresh captured requests"
aria-label="Refresh captured requests"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M20 6v5h-5"></path>
<path d="M4 18v-5h5"></path>
<path d="M6.1 9a7 7 0 0 1 11.5-2.6L20 9"></path>
<path d="M17.9 15a7 7 0 0 1-11.5 2.6L4 15"></path>
</svg>
</button>
<button
id="info-btn"
type="button"
class="header-btn info-btn"
title="Open user guide"
aria-label="Open user guide"
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="9"></circle>
<path d="M12 11v6"></path>
<path d="M12 7.5h.01"></path>
</svg>
</button>
</div>
</div>
<div class="switch-container">
<label class="switch">
<input id="enable" type="checkbox" />
<span class="switch-slider"></span>
</label>
<label for="enable" class="switch-label">Enable Overrides</label>
<span id="attach-status" class="attach-status" style="display: none"></span>
</div>
<p class="hint">
Tip: use <code>*</code> as wildcard in patterns (e.g.,
<code>https://old.com/api/*/users</code>), <code>*</code>/<code>all</code> for all requests,
or regex <code>/pattern/flags</code>. Use <code>*</code> in Redirect URL to substitute
captured wildcards.
</p>
<div id="override-modal" class="modal" style="display: none">
<div class="modal-content modal-content--override">
<header class="modal-header">
<h4 class="modal-title">
<span id="modal-title-text"></span>
<span id="modal-url"></span>
</h4>
<button class="close modal-close" type="button" aria-label="Close override editor">
×
</button>
</header>
<div class="modal-scroll-body">
<label class="modal-field">
<span>Pattern</span>
<input id="modal-pattern" type="text" />
</label>
<label class="modal-field">
<span>Method</span>
<select id="modal-method">
<option value="ANY">Any</option>
<option value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
<option value="PATCH">PATCH</option>
<option value="DELETE">DELETE</option>
</select>
</label>
<label class="modal-field">
<span>GraphQL Operation (optional)</span>
<input
id="modal-graphql-op"
type="text"
placeholder="e.g. GetUserProfile or query name"
/>
</label>
<div class="override-type-selector">
<label class="type-radio">
<input type="radio" name="modal-override-type" value="body" checked />
<span>Override body</span>
</label>
<label class="type-radio">
<input type="radio" name="modal-override-type" value="redirect" />
<span>Redirect to URL</span>
</label>
<label class="type-radio">
<input type="radio" name="modal-override-type" value="fail" />
<span>Fail request</span>
</label>
</div>
<div id="modal-body-fields">
<label class="modal-field">
<span>Response body</span>
<select id="modal-mode">
<option value="text">Text</option>
<option value="file">Raw base64</option>
</select>
<textarea id="modal-body" rows="8" placeholder="Custom response body"></textarea>
<div class="modal-body-footer">
<button
id="format-json-btn"
type="button"
class="modal-action-btn body-format-btn"
style="display: none"
title="Pretty-print the JSON response body"
>
Format JSON
</button>
</div>
<div
id="modal-preview-container"
class="modal-preview-container"
style="display: none"
></div>
</label>
</div>
<div id="modal-redirect-fields" style="display: none">
<label class="modal-field">
<span>Redirect URL (uses * for captured wildcards)</span>
<input
id="modal-redirect-url"
type="text"
placeholder="e.g. https://new-api.example.com/api/*"
/>
</label>
</div>
<div id="modal-fail-fields" style="display: none">
<label class="modal-field">
<span>Fail reason</span>
<select id="modal-fail-reason">
<option value="Failed">Failed</option>
<option value="TimedOut">TimedOut</option>
<option value="ConnectionRefused">ConnectionRefused</option>
<option value="NameNotResolved">NameNotResolved</option>
<option value="InternetDisconnected">InternetDisconnected</option>
</select>
</label>
</div>
<div id="modal-advanced-fields">
<label class="modal-field" id="modal-request-headers-field">
<span>Override Request Headers (Key-Value or Raw)</span>
<textarea
id="modal-request-headers"
rows="2"
placeholder="Authorization: Bearer mock-token"
></textarea>
<div id="modal-request-headers-table" class="modal-headers-table"></div>
</label>
<label class="modal-field" id="modal-status-field">
<span>Status (blank = keep original)</span>
<input id="modal-status" type="number" min="100" max="599" placeholder="e.g. 500" />
</label>
<label class="modal-field">
<span>Delay (ms)</span>
<input id="modal-delay" type="number" min="0" max="120000" placeholder="0" />
</label>
<label class="modal-field" id="modal-headers-field">
<span>Extra Response Headers (Key-Value or Raw)</span>
<textarea id="modal-headers" rows="3" placeholder="X-Custom: value"></textarea>
<div id="modal-response-headers-table" class="modal-headers-table"></div>
</label>
</div>
</div>
<footer class="modal-footer">
<div id="modal-feedback" class="modal-feedback" role="status" aria-live="polite"></div>
<button id="save-override">Save Override</button>
</footer>
</div>
</div>
<!-- cURL / Swagger Import Modal -->
<div id="curl-swagger-modal" class="modal" style="display: none">
<div class="modal-content">
<span id="curl-swagger-close" class="close">×</span>
<h3>Import Rules from cURL or OpenAPI / Swagger Spec</h3>
<label class="modal-field">
<span>Paste cURL command or OpenAPI/Swagger JSON/YAML spec:</span>
<textarea
id="curl-swagger-textarea"
rows="6"
placeholder='curl -X POST https://api.example.com/users -H "Authorization: Bearer token" -d '{"name":"John"}' Or paste Swagger/OpenAPI JSON content...'
></textarea>
</label>
<div class="curl-swagger-file-row">
<span>Or choose file (.json, .yaml, .yml, .curl, .txt):</span>
<input id="curl-swagger-file-input" type="file" accept=".json,.yaml,.yml,.curl,.txt" />
</div>
<button
id="curl-swagger-import-btn"
type="button"
class="btn btn-primary"
style="margin-top: 10px"
>
Import Rules
</button>
</div>
</div>
<div class="tabs">
<button class="tab-btn active" data-tab="other">Captured APIs</button>
<button class="tab-btn" data-tab="overridden">Overridden</button>
<button class="tab-btn" data-tab="overrides">Rules</button>
</div>
<div id="new-row" class="tab-content" style="display: none">
<input id="pattern" placeholder="URL pattern" />
<input
id="redirect-url"
type="text"
placeholder="Optional redirect URL (use * for wildcards)"
/>
<select id="mode">
<option value="text">Text</option>
<option value="file">Raw base64</option>
</select>
<textarea id="body" rows="6" placeholder="Response body"></textarea>
<button id="add">Add Manual</button>
</div>
<div id="apis-section" class="tab-content" style="display: none">
<div class="api-controls">
<div class="api-search-row">
<input id="api-search" type="search" placeholder="Search APIs..." />
<button id="add-api-btn" type="button" class="add-api-btn" title="Add custom API">
+
</button>
</div>
<div class="captured-types-bar">
<span class="captured-types-label">Capture Body:</span>
<label class="type-check"
><input type="checkbox" class="capture-type-cb" value="xhr" checked /> XHR</label
>
<label class="type-check"
><input type="checkbox" class="capture-type-cb" value="fetch" checked /> Fetch</label
>
<label class="type-check"
><input type="checkbox" class="capture-type-cb" value="document" /> Doc</label
>
<label class="type-check"
><input type="checkbox" class="capture-type-cb" value="script" /> JS</label
>
<label class="type-check"
><input type="checkbox" class="capture-type-cb" value="stylesheet" /> CSS</label
>
</div>
</div>
<div id="apis-list"></div>
</div>
<div id="overrides-section" class="tab-content" style="display: none">
<div class="rules-io-row">
<button id="export-rules-btn" type="button" class="rules-io-btn">Export</button>
<button id="import-rules-btn" type="button" class="rules-io-btn">Import</button>
<button id="import-curl-swagger-btn" type="button" class="rules-io-btn">
cURL / Swagger
</button>
<input
id="import-rules-input"
type="file"
accept="application/json"
style="display: none"
/>
</div>
<div class="profiles-row">
<select id="profiles-select" class="profiles-select">
<option value="">-- Rule Profiles --</option>
</select>
<button
id="save-profile-btn"
type="button"
class="profile-btn"
title="Save current rules as Profile"
>
Save Profile
</button>
<button
id="delete-profile-btn"
type="button"
class="profile-btn"
title="Delete selected Profile"
>
Delete
</button>
</div>
<ul id="list"></ul>
</div>
<script src="dist/utils.js"></script>
<script src="dist/shared.js"></script>
<script src="dist/ui/types.js"></script>
<script src="dist/ui/view-utils.js"></script>
<script src="dist/ui/primitives.js"></script>
<script src="dist/ui/notifications.js"></script>
<script src="dist/ui/dialogs.js"></script>
<script src="dist/ui/persistence.js"></script>
<script src="dist/ui/attach-status.js"></script>
<script src="dist/ui/curl.js"></script>
<script src="dist/ui/swagger.js"></script>
<script src="dist/ui/headers-editor.js"></script>
<script src="dist/ui/modal.js"></script>
<script src="dist/ui/rules-list.js"></script>
<script src="dist/ui/api-list.js"></script>
<script src="dist/ui/profiles.js"></script>
<script src="dist/ui/modal-controller.js"></script>
<script src="dist/ui/rules-io-controller.js"></script>
<script src="dist/ui/toolbar-controller.js"></script>
<script src="dist/ui.js"></script>
<script src="dist/popup.js"></script>
</body>
</html>