Skip to content

Commit

Permalink
Added support for Chromium Sync #838
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Oct 25, 2023
1 parent 8c3c716 commit e21da3e
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions src/pages/options/widgets/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,29 @@ importSettingsElement.addEventListener("change", () => {
const exportSettingsSync = document.getElementById("export-settings-sync")
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()
options.version = browser.runtime.getManifest().version
browser.storage.sync.set({ options }, () => location.reload())
})

importSettingsSync.addEventListener("click", () => {
function importError() {
importSettingsSyncText.innerHTML = '<span style="color:red;">Error!</span>'
setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000)
exportSettingsSync.addEventListener("click", async () => {
let options = await utils.getOptions()
options.version = browser.runtime.getManifest().version
browser.storage.sync.set({ options }, () => location.reload())
})

importSettingsSync.addEventListener("click", () => {
function importError() {
importSettingsSyncText.innerHTML = '<span style="color:red;">Error!</span>'
setTimeout(() => (importSettingsSyncText.innerHTML = oldHTML), 1000)
}
const oldHTML = importSettingsSyncText.innerHTML
importSettingsSyncText.innerHTML = "..."
browser.storage.sync.get({ options }, r => {
const options = r.options
if (options.version == browser.runtime.getManifest().version) {
browser.storage.local.set({ options }, () => location.reload())
} else {
importError()
}
const oldHTML = importSettingsSyncText.innerHTML
importSettingsSyncText.innerHTML = "..."
browser.storage.sync.get({ options }, r => {
const options = r.options
if (options.version == browser.runtime.getManifest().version) {
browser.storage.local.set({ options }, () => location.reload())
} else {
importError()
}
})
})
} else {
exportSettingsSync.style.display = 'none'
importSettingsSync.style.display = 'none'
}

})

const resetSettings = document.getElementById("reset-settings")
resetSettings.addEventListener("click", async () => {
Expand Down

0 comments on commit e21da3e

Please sign in to comment.