Files
reddit-tweaks-ffe/content/main.js
cottongin 37c142f6e6 fix: prevent page reload on color/preset saves
saveSettings() writes all keys including 'enabled', which triggered
the storage.onChanged reload check even when enabled didn't actually
change. Compare oldValue vs newValue so the reload only fires when
the enabled state genuinely toggles.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-26 18:17:33 -04:00

25 lines
637 B
JavaScript

(function () {
"use strict";
async function init() {
const settings = await window.RedditTweaks.loadSettings();
if (!settings.enabled) return;
document.documentElement.classList.add("rt-enabled");
window.RedditTweaks.badgeTweak.apply(settings);
browser.storage.onChanged.addListener(function (changes) {
if (changes.enabled && changes.enabled.newValue !== changes.enabled.oldValue) {
location.reload();
return;
}
window.RedditTweaks.loadSettings().then(function (updated) {
window.RedditTweaks.badgeTweak.updateColors(updated);
});
});
}
init();
})();