Skip to content

Commit

Permalink
feat(options): Updates the save_options helper to avoid overriding th…
Browse files Browse the repository at this point in the history
…e storage
  • Loading branch information
ERosendo committed Apr 2, 2024
1 parent 59d0df3 commit c048e13
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,25 @@ function load_options() {
}

function save_options() {
let options = {};
for (let i = 0; i < inputs.length; i++) {
if (inputs[i].type === 'checkbox' || inputs[i].type === 'radio') {
options[inputs[i].id] = inputs[i].checked;
} else if (inputs[i].type === 'text') {
options[inputs[i].id] = inputs[i].value;
chrome.storage.local.get('options', function (items) {
let options = items.options;
for (let i = 0; i < inputs.length; i++) {
if (inputs[i].type === 'checkbox' || inputs[i].type === 'radio') {
options[inputs[i].id] = inputs[i].checked;
} else if (inputs[i].type === 'text') {
options[inputs[i].id] = inputs[i].value;
}
}
}

let banner = document.getElementById('header-banner');
if (!banner) {
options['dismiss_class_action_info'] = true;
}
let banner = document.getElementById('header-banner');
if (!banner) {
options['dismiss_class_action_info'] = true;
}

chrome.storage.local.set({ options: options }, function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
updateToolbarButton(tabs[0]);
chrome.storage.local.set({ options: options }, function () {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
updateToolbarButton(tabs[0]);
});
});
});
}
Expand Down

0 comments on commit c048e13

Please sign in to comment.