Storing power setting in local instead of sync
parent
09fad7c8df
commit
78aa7bf98e
|
@ -127,7 +127,9 @@ async function main(eventInfo, eventName) {
|
|||
|
||||
sites = await getData();
|
||||
|
||||
chrome.storage.sync.get(function (storage) {
|
||||
chrome.storage.local.get(function (localStorage) {
|
||||
chrome.storage.sync.get(function (syncStorage) {
|
||||
const storage = {...syncStorage, ...localStorage};
|
||||
if ((storage.power ?? 'on') === 'on') {
|
||||
// Check if site is in our list of wikis:
|
||||
let matchingSites = sites.filter(el => url.href.replace(/^https?:\/\//, '').startsWith(el.origin_base_url));
|
||||
|
@ -204,6 +206,7 @@ async function main(eventInfo, eventName) {
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -204,7 +204,9 @@ function main(mutations = null, observer = null) {
|
|||
if (observer) {
|
||||
observer.disconnect();
|
||||
}
|
||||
chrome.storage.sync.get(function (storage) {
|
||||
chrome.storage.local.get(function (localStorage) {
|
||||
chrome.storage.sync.get(function (syncStorage) {
|
||||
const storage = {...syncStorage, ...localStorage};
|
||||
// Check if extension is on:
|
||||
if ((storage.power ?? 'on') === 'on') {
|
||||
// Check if on Fandom, Fextralife, or BreezeWiki
|
||||
|
@ -323,6 +325,7 @@ function main(mutations = null, observer = null) {
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (checkSite()) {
|
||||
|
|
8
popup.js
8
popup.js
|
@ -1,6 +1,6 @@
|
|||
// Set power setting
|
||||
function setPower(setting) {
|
||||
chrome.storage.sync.set({ 'power': setting });
|
||||
chrome.storage.local.set({ 'power': setting });
|
||||
var powerImage = document.getElementById('powerImage');
|
||||
powerImage.src = 'images/power-' + setting + '.png';
|
||||
powerImage.alt = 'Indie Wiki Buddy is ' + setting;
|
||||
|
@ -86,7 +86,7 @@ async function loadBreezeWikiOptions() {
|
|||
// Set power setting
|
||||
function setPower(setting, storeSetting = true) {
|
||||
if (storeSetting) {
|
||||
chrome.storage.sync.set({ 'power': setting });
|
||||
chrome.storage.local.set({ 'power': setting });
|
||||
}
|
||||
var powerImage = document.getElementById('powerImage');
|
||||
powerImage.src = 'images/power-' + setting + '.png';
|
||||
|
@ -178,7 +178,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
});
|
||||
|
||||
// Set setting toggle values:
|
||||
chrome.storage.sync.get({ 'power': 'on' }, function (item) {
|
||||
chrome.storage.local.get({ 'power': 'on' }, function (item) {
|
||||
setPower(item.power, false);
|
||||
});
|
||||
chrome.storage.sync.get({ 'notifications': 'on' }, function (item) {
|
||||
|
@ -193,7 +193,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
|
||||
// Add event listeners for setting toggles
|
||||
document.getElementById('powerCheckbox').addEventListener('change', function () {
|
||||
chrome.storage.sync.get({ 'power': 'on' }, function (item) {
|
||||
chrome.storage.local.get({ 'power': 'on' }, function (item) {
|
||||
if (item.power === 'on') {
|
||||
setPower('off');
|
||||
} else {
|
||||
|
|
11
settings.js
11
settings.js
|
@ -44,7 +44,9 @@ async function getData() {
|
|||
async function loadOptions(lang) {
|
||||
sites = await getData();
|
||||
|
||||
chrome.storage.sync.get(function (storage) {
|
||||
chrome.storage.local.get(function (localStorage) {
|
||||
chrome.storage.sync.get(function (syncStorage) {
|
||||
const storage = {...syncStorage, ...localStorage};
|
||||
let siteSettings = storage.siteSettings || {};
|
||||
let defaultActionSettings = storage.defaultActionSettings || {};
|
||||
let defaultSearchFilterSettings = storage.defaultSearchFilterSettings || {};
|
||||
|
@ -355,12 +357,13 @@ async function loadOptions(lang) {
|
|||
chrome.storage.sync.set({ 'defaultSearchFilterSettings': defaultSearchFilterSettings });
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Set power setting
|
||||
function setPower(setting, storeSetting = true) {
|
||||
if (storeSetting) {
|
||||
chrome.storage.sync.set({ 'power': setting });
|
||||
chrome.storage.local.set({ 'power': setting });
|
||||
}
|
||||
var powerImage = document.getElementById('powerImage');
|
||||
powerImage.src = 'images/power-' + setting + '.png';
|
||||
|
@ -489,7 +492,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
});
|
||||
|
||||
// Set setting toggle values:
|
||||
chrome.storage.sync.get({ 'power': 'on' }, function (item) {
|
||||
chrome.storage.local.get({ 'power': 'on' }, function (item) {
|
||||
setPower(item.power, false);
|
||||
});
|
||||
chrome.storage.sync.get({ 'notifications': 'on' }, function (item) {
|
||||
|
@ -504,7 +507,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
|
||||
// Add event listeners for setting toggles
|
||||
document.getElementById('powerCheckbox').addEventListener('change', function () {
|
||||
chrome.storage.sync.get({ 'power': 'on' }, function (item) {
|
||||
chrome.storage.local.get({ 'power': 'on' }, function (item) {
|
||||
if (item.power === 'on') {
|
||||
setPower('off');
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue