()
| 1622 | } |
| 1623 | } |
| 1624 | async function saveCurrentOptions() { |
| 1625 | if ( |
| 1626 | !UI.targetTab1 || |
| 1627 | !UI.listTab1 || |
| 1628 | !UI.selectModTab1 || |
| 1629 | !UI.searchengineSelect |
| 1630 | ) |
| 1631 | return; |
| 1632 | const listKeyValueToSave = UI.listTab1.value; |
| 1633 | const options = { |
| 1634 | Target: UI.targetTab1.value, |
| 1635 | ModeV: UI.selectModTab1.value, |
| 1636 | SearchEngine: UI.searchengineSelect.value, |
| 1637 | }; |
| 1638 | try { |
| 1639 | const itemsToSave = { [CONSTANTS.STORAGE_KEYS.SAVE_OPTION]: options }; |
| 1640 | if (listKeyValueToSave !== "0") { |
| 1641 | itemsToSave[CONSTANTS.STORAGE_KEYS.LIST_SAVE_TAB1] = listKeyValueToSave; |
| 1642 | await setStorageData(itemsToSave); |
| 1643 | } else { |
| 1644 | await setStorageData({ [CONSTANTS.STORAGE_KEYS.SAVE_OPTION]: options }); |
| 1645 | await removeStorageData(CONSTANTS.STORAGE_KEYS.LIST_SAVE_TAB1); |
| 1646 | } |
| 1647 | } catch (error) { |
| 1648 | console.error("Error saving options:", error); |
| 1649 | showModal(`Error saving settings: ${error.message}`); |
| 1650 | } |
| 1651 | } |
| 1652 | async function loadSavedOptions() { |
| 1653 | try { |
| 1654 | const data = await getStorageData([ |
no test coverage detected