@@ -6,17 +6,20 @@ export async function initializeConfigTab() {
66 const serverUrl = document . getElementById ( 'archivebox_server_url' ) ;
77 const apiKey = document . getElementById ( 'archivebox_api_key' ) ;
88 const matchUrls = document . getElementById ( 'match_urls' ) ;
9+ const excludeUrls = document . getElementById ( 'exclude_urls' ) ;
910
1011 // Load saved values
1112 const archivebox_server_url = await getArchiveBoxServerUrl ( ) ;
1213 const { archivebox_api_key, match_urls } = await chrome . storage . local . get ( [
1314 'archivebox_api_key' ,
14- 'match_urls'
15+ 'match_urls' ,
16+ 'exclude_urls' ,
1517 ] ) ;
1618
17- serverUrl . value = archivebox_server_url ;
18- apiKey . value = archivebox_api_key || '' ;
19- matchUrls . value = match_urls || '' ;
19+ serverUrl . value = savedConfig . archivebox_server_url || '' ;
20+ apiKey . value = savedConfig . archivebox_api_key || '' ;
21+ matchUrls . value = savedConfig . match_urls || '' ;
22+ excludeUrls . value = savedConfig . exclude_urls || '' ;
2023
2124 // Server test button handler
2225 document . getElementById ( 'testServer' ) . addEventListener ( 'click' , async ( ) => {
@@ -113,12 +116,13 @@ export async function initializeConfigTab() {
113116 } ) ;
114117
115118 // Save changes when inputs change
116- [ serverUrl , apiKey , matchUrls ] . forEach ( input => {
119+ [ serverUrl , apiKey , matchUrls , excludeUrls ] . forEach ( input => {
117120 input . addEventListener ( 'change' , async ( ) => {
118121 await chrome . storage . local . set ( {
119122 archivebox_server_url : serverUrl . value . replace ( / \/ $ / , '' ) ,
120123 archivebox_api_key : apiKey . value ,
121- match_urls : matchUrls . value
124+ match_urls : matchUrls . value ,
125+ exclude_urls : excludeUrls . value ,
122126 } ) ;
123127 } ) ;
124128 } ) ;
@@ -130,19 +134,44 @@ export async function initializeConfigTab() {
130134
131135 testButton . addEventListener ( 'click' , async ( ) => {
132136 const url = testUrlInput . value . trim ( ) ;
137+
138+ // test if the URL matches the regex match patterns
139+ const matchPattern = matchUrls . value . length ? new RegExp ( matchUrls . value ) : / ^ $ / ;
140+ if ( matchPattern . test ( url ) ) {
141+ testStatus . innerHTML = `
142+ <span class="status-indicator status-success"></span>
143+ ➕ URL would be auto-archived when visited<br/>
144+ ` ;
145+ } else {
146+ testStatus . innerHTML = `
147+ <span class="status-indicator status-warning"></span>
148+ ☝ URL does not match the auto-archive pattern (but it can still be saved manually)<br/>
149+ ` ;
150+ }
151+
152+ const excludePattern = excludeUrls . value . length ? new RegExp ( excludeUrls . value ) : / ^ $ / ;
153+ if ( excludePattern . test ( url ) ) {
154+ testStatus . innerHTML = `
155+ <span class="status-indicator status-warning"></span>
156+ 🚫 URL is excluded from auto-archiving (but it can still be saved manually)<br/>
157+ ` ;
158+ }
159+
133160 if ( ! url ) {
134161 testStatus . innerHTML = `
135162 <span class="status-indicator status-error"></span>
136- Please enter a URL to test
163+ ⌨️ Please enter a URL to test
137164 ` ;
138165 return ;
139166 }
140167
141168 // Show loading state
142169 testButton . disabled = true ;
143- testStatus . innerHTML = `
144- <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
145- Testing...
170+ testStatus . innerHTML += `
171+ <span id="inprogress-test">
172+ <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
173+ Submitting...
174+ </span>
146175 ` ;
147176
148177 try {
@@ -154,22 +183,23 @@ export async function initializeConfigTab() {
154183 } ;
155184
156185 const result = await syncToArchiveBox ( testEntry ) ;
186+ document . getElementById ( 'inprogress-test' ) . remove ( ) ;
157187
158188 if ( result . ok ) {
159- testStatus . innerHTML = `
160- <span class="status-indicator status-success"></span>
161- Success! URL was added to ArchiveBox
189+ testStatus . innerHTML + = `
190+ <span class="status-indicator status-success"></span>
191+ 🚀 URL was submitted and <a href=" ${ serverUrl . value } /" target="_blank">✓ queued for archiving</a> on the ArchiveBox server: <a href=" ${ serverUrl . value } /archive/ ${ testEntry . url } " target="_blank">📦 <code> ${ serverUrl . value } /archive/ ${ testEntry . url } </code></a>.
162192 ` ;
163193 // Clear the input on success
164194 testUrlInput . value = '' ;
165195 } else {
166- testStatus . innerHTML = `
196+ testStatus . innerHTML + = `
167197 <span class="status-indicator status-error"></span>
168198 Error: ${ result . status }
169199 ` ;
170200 }
171201 } catch ( error ) {
172- testStatus . innerHTML = `
202+ testStatus . innerHTML + = `
173203 <span class="status-indicator status-error"></span>
174204 Error: ${ error . message }
175205 ` ;
0 commit comments