Skip to content

Commit 6afc6e0

Browse files
committed
main: only trigger autoRestart when changing preferences
prevents the new preference-set-on-read logic from triggering autoRestart unnecessarily
1 parent 20263ee commit 6afc6e0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/content_scripts/main.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
const runScript = async function (name) {
1212
const { main, clean, stylesheet, autoRestart } = await fakeImport(`/scripts/${name}.js`);
1313

14-
main()
15-
.catch(console.error);
14+
main().catch(console.error);
1615

1716
if (stylesheet) {
1817
const link = Object.assign(document.createElement('link'), {
@@ -24,11 +23,9 @@
2423

2524
if (autoRestart) {
2625
restartListeners[name] = function (changes, areaName) {
27-
if (areaName !== 'local') {
28-
return;
29-
}
26+
if (areaName !== 'local') { return; }
3027

31-
if (Object.keys(changes).some(key => key.startsWith(`${name}.preferences`))) {
28+
if (Object.keys(changes).some(key => key.startsWith(`${name}.preferences`) && changes[key].oldValue !== undefined)) {
3229
clean().then(main);
3330
}
3431
};
@@ -40,8 +37,7 @@
4037
const destroyScript = async function (name) {
4138
const { clean, stylesheet, autoRestart } = await fakeImport(`/scripts/${name}.js`);
4239

43-
clean()
44-
.catch(console.error);
40+
clean().catch(console.error);
4541

4642
if (stylesheet) {
4743
const link = document.querySelector(`link[href="${getURL(`/scripts/${name}.css`)}"]`);

0 commit comments

Comments
 (0)