-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.html
More file actions
314 lines (288 loc) · 11.3 KB
/
popup.html
File metadata and controls
314 lines (288 loc) · 11.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Text Extractor</title>
<link rel="stylesheet" href="popup.css">
</head>
<body>
<div class="container" role="main">
<header class="header" role="banner">
<h1 id="app-title">Web Text Extractor</h1>
<button
id="extractBtn"
class="extract-btn"
aria-label="Extract text from current webpage"
aria-describedby="extract-help"
>
Extract Text
</button>
<button
id="downloadHeaderBtn"
class="extract-btn"
aria-label="Save extracted text to file"
title="Save .txt"
>
Save .txt
</button>
<button
id="scrapeLinksBtn"
class="extract-btn"
aria-label="Scrape external links in current page"
title="Open each link, extract, and auto-save"
>
Scrape Links
</button>
<div id="extract-help" class="sr-only">
Extracts visible text content from the current webpage for processing
</div>
</header>
<section id="settingsDiv" class="settings hidden" role="region" aria-labelledby="settings-title">
<h3 id="settings-title">Text Processing Options</h3>
<fieldset class="settings-grid" aria-describedby="settings-description">
<legend class="sr-only">Text processing configuration options</legend>
<div id="settings-description" class="sr-only">
Configure how the extracted text should be processed and cleaned
</div>
<label class="setting-item">
<input
type="checkbox"
id="removeDuplicates"
checked
aria-describedby="remove-duplicates-help"
>
<span>Remove Duplicates</span>
<div id="remove-duplicates-help" class="sr-only">
Remove duplicate sentences from extracted text
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="includeHidden"
aria-describedby="include-hidden-help"
>
<span>Include Hidden Elements</span>
<div id="include-hidden-help" class="sr-only">
Include text from elements not currently visible
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="autoScroll"
aria-describedby="auto-scroll-help"
>
<span>Auto-scroll Page</span>
<div id="auto-scroll-help" class="sr-only">
Automatically scroll the page to load lazy content
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="removeUrls"
checked
aria-describedby="remove-urls-help"
>
<span>Remove URLs</span>
<div id="remove-urls-help" class="sr-only">
Remove web addresses and links from text
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="removeNumbers"
aria-describedby="remove-numbers-help"
>
<span>Remove Numbers</span>
<div id="remove-numbers-help" class="sr-only">
Remove numeric values from extracted text
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="removeStopWords"
checked
aria-describedby="remove-stopwords-help"
>
<span>Remove Stop Words</span>
<div id="remove-stopwords-help" class="sr-only">
Remove common words like 'the', 'and', 'or' from text
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="extractSections"
checked
aria-describedby="extract-sections-help"
>
<span>Extract Sections</span>
<div id="extract-sections-help" class="sr-only">
Organize text into sections like title, content, and navigation
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="extractKeyPhrases"
checked
aria-describedby="extract-phrases-help"
>
<span>Extract Key Phrases</span>
<div id="extract-phrases-help" class="sr-only">
Identify and extract important phrases from the text
</div>
</label>
</fieldset>
<div class="output-format" role="group" aria-labelledby="format-label">
<label id="format-label" for="outputFormat">Output Format:</label>
<select
id="outputFormat"
aria-describedby="format-help"
>
<option value="raw">Raw Text</option>
<option value="clean" selected>Clean Text</option>
<option value="json">JSON Format</option>
</select>
<div id="format-help" class="sr-only">
Choose how the processed text should be formatted for output
</div>
</div>
<div class="settings-grid" aria-label="Full-page extraction options">
<label class="setting-item">
<input
type="checkbox"
id="fullPageExtract"
aria-describedby="fullpage-help"
>
<span>Full-Page Structured Extract</span>
<div id="fullpage-help" class="sr-only">
Extract full-page content structured into sections with metadata
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="excludeBoilerplate"
aria-describedby="exclude-boilerplate-help"
>
<span>Exclude Boilerplate</span>
<div id="exclude-boilerplate-help" class="sr-only">
Skip headers, footers, navigation and ads when extracting
</div>
</label>
<label class="setting-item">
<input
type="checkbox"
id="includeMetadataToggle"
checked
aria-describedby="include-metadata-help"
>
<span>Include Metadata</span>
<div id="include-metadata-help" class="sr-only">
Include meta description and Open Graph tags
</div>
</label>
</div>
<div class="save-location" role="group" aria-labelledby="location-label">
<label id="location-label" for="saveLocation">Save Location:</label>
<select
id="saveLocation"
aria-describedby="location-help"
>
<option value="downloads">Downloads Folder</option>
<option value="custom">Choose Custom Folder</option>
</select>
<div id="location-help" class="sr-only">
Select where to save the extracted text file
</div>
</div>
<div id="customPathGroup" class="custom-path hidden" role="group" aria-labelledby="custom-path-label">
<label id="custom-path-label" for="customPath">Custom Folder:</label>
<div class="path-input-group">
<input
type="text"
id="customPath"
placeholder="Select a folder..."
readonly
aria-describedby="path-help"
>
<button
type="button"
id="browsePathBtn"
class="browse-btn"
aria-label="Browse for custom save folder"
>
Browse
</button>
</div>
<small id="path-help" class="path-help">Files will be saved to the selected folder</small>
</div>
</section>
<main class="main">
<div id="loadingDiv" class="loading hidden">
<div class="spinner"></div>
<span id="loadingText">Extracting text...</span>
</div>
<div id="errorDiv" class="error hidden">
<span id="errorMessage"></span>
</div>
<div id="contentDiv" class="content hidden">
<div class="stats">
<span id="wordCount">0 words</span>
<span id="charCount">0 characters</span>
</div>
<textarea
id="extractedText"
class="text-area"
readonly
placeholder="Extracted text will appear here..."
></textarea>
<div class="actions">
<button id="settingsBtn" class="btn btn-settings">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.82,11.69,4.82,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z"/>
</svg>
Settings
</button>
<button id="copyBtn" class="btn btn-primary">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/>
</svg>
<span class="btn-label" id="copyBtnLabel">Copy All</span>
</button>
<button id="downloadBtn" class="btn btn-secondary">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>
</svg>
<span class="btn-label" id="downloadBtnLabel">Download</span>
</button>
<button id="clearBtn" class="btn btn-tertiary">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
</svg>
Clear
</button>
</div>
</div>
<div id="welcomeDiv" class="welcome">
<div class="welcome-icon">
<svg width="48" height="48" viewBox="0 0 24 24" fill="currentColor">
<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 2 2h10c1.1 0 2-.9 2-2V8l-4-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/>
</svg>
</div>
<h2>Web Text Extractor</h2>
<p>Extract clean text from any webpage. Click "Extract Text" to begin.</p>
<p style="font-size: 12px; margin-top: 8px; color: #888;">Works on most websites except Chrome system pages.</p>
</div>
</main>
</div>
<script src="text-processor.js"></script>
<script src="popup.js"></script>
</body>
</html>