@@ -199,7 +199,12 @@ async function calcCustomInstances(frontend) {
199199 if ( index > - 1 ) customInstances . splice ( index , 1 )
200200 options = await utils . getOptions ( )
201201 options [ frontend ] = customInstances
202- browser . storage . local . set ( { options } , ( ) => calcCustomInstances ( frontend ) )
202+ browser . storage . local . set ( { options } , async ( ) => {
203+ calcCustomInstances ( frontend )
204+ const blacklist = await utils . getBlacklist ( options )
205+ const redirects = await utils . getList ( options )
206+ createList ( frontend , config . networks , document , redirects , blacklist )
207+ } )
203208 } )
204209 }
205210}
@@ -232,7 +237,7 @@ async function processCustomInstances(frontend, document) {
232237 } )
233238}
234239
235- function createList ( frontend , networks , document , redirects , blacklist ) {
240+ async function createList ( frontend , networks , document , redirects , blacklist ) {
236241 for ( const network in networks ) {
237242 const checklist = document . getElementById ( frontend )
238243 . getElementsByClassName ( network ) [ 0 ]
@@ -250,10 +255,8 @@ function createList(frontend, networks, document, redirects, blacklist) {
250255 . getElementsByClassName ( "custom-instance" ) [ 0 ]
251256 . placeholder = redirects [ frontend ] . clearnet [ 0 ]
252257
253- const sortedInstances = instances
254- . sort ( ( a , b ) => {
255- return ( blacklist . cloudflare . includes ( a ) && ! blacklist . cloudflare . includes ( b ) )
256- } )
258+ const sortedInstances = instances . sort ( ( a , b ) => blacklist . cloudflare . includes ( a ) && ! blacklist . cloudflare . includes ( b ) )
259+ const options = await utils . getOptions ( )
257260
258261 const content = sortedInstances
259262 . map ( x => {
@@ -262,7 +265,9 @@ function createList(frontend, networks, document, redirects, blacklist) {
262265 <span style="color:red;">cloudflare</span>
263266 </a>` : ""
264267
265- const warnings = [ cloudflare ] . join ( " " )
268+ const chosen = options [ frontend ] . includes ( x ) ? `<span style="color:grey;">chosen</span>` : ""
269+
270+ const warnings = [ cloudflare , chosen ] . join ( " " )
266271 return `<div class="frontend">
267272 <x>
268273 <a href="${ x } " target="_blank">${ x } </a>
@@ -290,7 +295,10 @@ function createList(frontend, networks, document, redirects, blacklist) {
290295 let options = await utils . getOptions ( )
291296 if ( ! options [ frontend ] . includes ( instance ) ) {
292297 options [ frontend ] . push ( instance )
293- browser . storage . local . set ( { options } , ( ) => calcCustomInstances ( frontend ) )
298+ browser . storage . local . set ( { options } , ( ) => {
299+ calcCustomInstances ( frontend )
300+ createList ( frontend , config . networks , document , redirects , blacklist )
301+ } )
294302 }
295303 } )
296304 }
0 commit comments