From ec1b51763936ba6426448bb9c29c9c756eea9961 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Mon, 6 Mar 2023 18:46:55 +0300 Subject: [PATCH] Fixed bug in RedirectType in settings --- src/pages/options/index.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/pages/options/index.js b/src/pages/options/index.js index 9fde7cd..068940f 100644 --- a/src/pages/options/index.js +++ b/src/pages/options/index.js @@ -41,19 +41,22 @@ async function changeFrontendsSettings(service) { } } } - if (config.services[service].frontends[divs[service].frontend.value].embeddable) { - document.getElementById(`${service}-redirectType`).innerHTML = ` - - - ` - document.getElementById(`${service}-redirectType`).value = options[divs[service].frontend.value].redirectType = options[service].redirectType - } else { - document.getElementById(`${service}-redirectType`).innerHTML = ` - - ` - options[service].redirectType = "main_frame" - browser.storage.local.set({ options }) + if (document.getElementById(`${service}-redirectType`)) { + const frontend = options[service].frontend ?? Object.keys(config.services[service].frontends)[0] + if (config.services[service].frontends[frontend].embeddable) { + document.getElementById(`${service}-redirectType`).innerHTML = ` + + + ` + document.getElementById(`${service}-redirectType`).value = options[frontend].redirectType = options[service].redirectType + } else { + document.getElementById(`${service}-redirectType`).innerHTML = ` + + ` + options[service].redirectType = "main_frame" + browser.storage.local.set({ options }) + } } const frontend_name_element = document.getElementById(`${service}_page`).getElementsByClassName("frontend_name")[0] if (divs[service].frontend) {