I have the need to save favorite and deleted IDs in my database. I created two functions for this purpose:
function ADD_BLOCKED(id) {
chrome.storage.local.get("blocked", function (data) {
if (data.blocked == null)
data.blocked = [];
if (!data.blocked.includes(id)) {
data.deleted.push(id);
chrome.storage.local.set(data);
}
});
}
function ADD_FAVORITE(id) {
chrome.storage.local.get("favorite", function (data) {
if (data.favorite == null)
data.favorite = [];
if (!data.favorite.includes(id)) {
data.deleted.push(id);
chrome.storage.local.set(data);
}
});
}
Is there a way to consolidate these functions? It's challenging to pass data.blocked
as a parameter.