This commit is contained in:
ManeraKai 2023-07-23 21:48:22 +03:00
parent 19b6a25150
commit cc0df130a2
1 changed files with 30 additions and 21 deletions

View File

@ -4,6 +4,8 @@ window.browser = window.browser || window.chrome
import utils from "../../../assets/javascripts/utils.js" import utils from "../../../assets/javascripts/utils.js"
import servicesHelper from "../../../assets/javascripts/services.js" import servicesHelper from "../../../assets/javascripts/services.js"
const isChrome = browser.runtime.getBrowserInfo === undefined
async function setOption(option, type, event) { async function setOption(option, type, event) {
let options = await utils.getOptions() let options = await utils.getOptions()
if (type == "select") { if (type == "select") {
@ -62,16 +64,18 @@ importSettingsElement.addEventListener("change", () => {
} }
}) })
const exportSettingsSync = document.getElementById("export-settings-sync") const exportSettingsSync = document.getElementById("export-settings-sync")
exportSettingsSync.addEventListener("click", async () => { const importSettingsSync = document.getElementById("import-settings-sync")
const importSettingsSyncText = document.getElementById("import_settings_sync_text")
if (!isChrome) {
exportSettingsSync.addEventListener("click", async () => {
let options = await utils.getOptions() let options = await utils.getOptions()
options.version = browser.runtime.getManifest().version options.version = browser.runtime.getManifest().version
browser.storage.sync.set({ options }, () => location.reload()) browser.storage.sync.set({ options }, () => location.reload())
}) })
const importSettingsSync = document.getElementById("import-settings-sync") importSettingsSync.addEventListener("click", () => {
const importSettingsSyncText = document.getElementById("import_settings_sync_text")
importSettingsSync.addEventListener("click", () => {
function importError() { function importError() {
importSettingsSyncText.innerHTML = '<span style="color:red;">Error!</span>' importSettingsSyncText.innerHTML = '<span style="color:red;">Error!</span>'
setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000) setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000)
@ -86,7 +90,12 @@ importSettingsSync.addEventListener("click", () => {
importError() importError()
} }
}) })
}) })
} else {
exportSettingsSync.style.display = 'none'
importSettingsSync.style.display = 'none'
}
const resetSettings = document.getElementById("reset-settings") const resetSettings = document.getElementById("reset-settings")
resetSettings.addEventListener("click", async () => { resetSettings.addEventListener("click", async () => {