From 37dcaa074e5c9ce4cb2eb66c3a1706fd7b945bde Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Mon, 3 Jan 2022 19:06:35 +0330 Subject: [PATCH] use updated list in autocomplete --- src/pages/options/options.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/pages/options/options.js b/src/pages/options/options.js index 4a148df..fea9411 100644 --- a/src/pages/options/options.js +++ b/src/pages/options/options.js @@ -20,20 +20,7 @@ const scribeInstances = mediumHelper.redirects; const searchEngineInstances = searchHelper.redirects; const simplyTranslateInstances = googleTranslateHelper.redirects; const wikipediaInstances = wikipediaHelper.redirects; -const autocompletes = [ - { id: "nitter-instance", instances: nitterInstances }, - { id: "invidious-instance", instances: invidiousInstances }, - { id: "bibliogram-instance", instances: bibliogramInstances }, - { id: "osm-instance", instances: osmInstances }, - { id: "reddit-instance", instances: redditInstances }, - { id: "scribe-instance", instances: scribeInstances }, - { - id: "search-engine-instance", - instances: searchEngineInstances.map((instance) => instance.link), - }, - { id: "simply-translate-instance", instances: simplyTranslateInstances }, - { id: "wikipedia-instance", instances: wikipediaInstances }, -]; +let autocompletes; const domparser = new DOMParser(); let nitterInstance = document.getElementById("nitter-instance"); @@ -189,6 +176,23 @@ browser.storage.sync.get( scribeRandomPool.value = result.scribeRandomPool || commonHelper.filterInstances(scribeInstances); + autocompletes = [ + { id: "nitter-instance", instances: nitterRandomPool.value.split(',') }, + { id: "invidious-instance", instances: invidiousRandomPool.value.split(',') }, + { id: "bibliogram-instance", instances: bibliogramRandomPool.value.split(',') }, + { id: "scribe-instance", instances: scribeRandomPool.value.split(',') }, + { id: "reddit-instance", instances: redditInstances }, + { id: "osm-instance", instances: osmInstances }, + { + id: "search-engine-instance", + instances: searchEngineInstances.map((instance) => instance.link), + }, + { id: "simply-translate-instance", instances: simplyTranslateInstances }, + { id: "wikipedia-instance", instances: wikipediaInstances }, + ]; + autocompletes.forEach((value) => { + autocomplete(document.getElementById(value.id), value.instances); + }); } ); @@ -598,10 +602,6 @@ function autocomplete(input, list) { }); } -autocompletes.forEach((value) => { - autocomplete(document.getElementById(value.id), value.instances); -}); - var coll = document.getElementsByClassName("collapsible"); var i;