Skip to content

Commit 2ebddeb

Browse files
OsaSoftclaude
andauthored
Add setting to disable auto-changelog and manual view button (#231)
* Add setting to disable auto-changelog and manual view button (#230) Users reported the extension forcefully opening a changelog tab on every update, interrupting active tasks. This adds a toggle to disable the automatic changelog and a button to view it manually from settings. - First install always shows changelog regardless of setting - Default is ON to preserve existing behavior for current users - Fallback to opening changelog if storage read fails (safe default) * Fix computed property access for LAST_SHOWN_CHANGELOG_KEY and sync test defaults Use bracket notation [LAST_SHOWN_CHANGELOG_KEY] so the constant's value ("changelog.lastShown") is used as the storage key, not the literal identifier. Also add missing settings to tests/setup.js DEFAULT_SETTINGS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 386732d commit 2ebddeb

File tree

5 files changed

+53
-9
lines changed

5 files changed

+53
-9
lines changed

common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const DEFAULT_SETTINGS = {
1717
"settings.hide.lives": false,
1818
"settings.hide.members.only": false,
1919
"settings.hide.mark.watched.button": false,
20+
"settings.changelog.auto.open": true,
2021
};
2122

2223
const SETTINGS_KEY = "settings";

pages/background.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,35 @@ brwsr.runtime.onMessage.addListener(function (message) {
2121
}
2222
});
2323

24-
brwsr.runtime.onInstalled.addListener(() => {
25-
brwsr.storage.local.get({LAST_SHOWN_CHANGELOG_KEY}, showChangelog);
24+
brwsr.runtime.onInstalled.addListener((details) => {
25+
brwsr.storage.local.get({[LAST_SHOWN_CHANGELOG_KEY]: null}, (data) => {
26+
showChangelog(data, details);
27+
});
2628
});
2729

28-
function showChangelog(data) {
29-
let lastShownChangelog = data.LAST_SHOWN_CHANGELOG_KEY;
30-
if (currentVersion !== lastShownChangelog) {
31-
brwsr.tabs.create({
32-
url: "pages/changelog.html"
33-
});
34-
brwsr.storage.local.set({LAST_SHOWN_CHANGELOG_KEY: currentVersion});
30+
function showChangelog(data, details) {
31+
let lastShownChangelog = data[LAST_SHOWN_CHANGELOG_KEY];
32+
if (currentVersion === lastShownChangelog) {
33+
return;
3534
}
35+
36+
// Always update the last shown version, even if we don't open the tab
37+
brwsr.storage.local.set({[LAST_SHOWN_CHANGELOG_KEY]: currentVersion});
38+
39+
// Always show changelog on first install
40+
if (details && details.reason === "install") {
41+
brwsr.tabs.create({ url: "pages/changelog.html" });
42+
return;
43+
}
44+
45+
// On update, check the user's setting
46+
brwsr.storage.sync.get("settings", (result) => {
47+
let autoOpen = true; // default: open changelog
48+
if (result && result.settings && typeof result.settings["settings.changelog.auto.open"] === "boolean") {
49+
autoOpen = result.settings["settings.changelog.auto.open"];
50+
}
51+
if (autoOpen) {
52+
brwsr.tabs.create({ url: "pages/changelog.html" });
53+
}
54+
});
3655
}

pages/settings/settings.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,25 @@ <h2 class="settings-card__title">General</h2>
272272
</label>
273273
</div>
274274

275+
<div class="setting-item">
276+
<div class="setting-info">
277+
<span class="setting-title" id="setting-changelog-auto-open-title">Show changelog on update</span>
278+
<span class="setting-description" id="setting-changelog-auto-open-desc">Automatically open the changelog page when the extension is updated</span>
279+
</div>
280+
<label class="toggle">
281+
<input type="checkbox" id="settings.changelog.auto.open" aria-labelledby="setting-changelog-auto-open-title" aria-describedby="setting-changelog-auto-open-desc">
282+
<span class="toggle-slider"></span>
283+
</label>
284+
</div>
285+
286+
<div class="data-action">
287+
<div class="data-action__info">
288+
<span class="data-action__title">View changelog</span>
289+
<span class="data-action__description">Open the changelog page to see what's new</span>
290+
</div>
291+
<button id="view-changelog" class="btn btn-secondary">View Changelog</button>
292+
</div>
293+
275294
<div class="setting-item">
276295
<div class="setting-info">
277296
<span class="setting-title">Log level</span>

pages/settings/settings.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ function setupButtons() {
8686
document.getElementById("force-sync").addEventListener("click", forceSyncAll);
8787
document.getElementById("force-pull").addEventListener("click", forcePullFromSync);
8888
document.getElementById("clear-oldest").addEventListener("click", clearOldestVideosHandler);
89+
document.getElementById("view-changelog").addEventListener("click", () => {
90+
brwsr.tabs.create({ url: "../changelog.html" });
91+
});
8992

9093
// Modal event listeners
9194
document.getElementById("modal-cancel").addEventListener("click", hideConfirmModal);

tests/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const DEFAULT_SETTINGS = {
2222
"settings.hide.shorts": false,
2323
"settings.hide.lives": false,
2424
"settings.hide.members.only": false,
25+
"settings.hide.mark.watched.button": false,
26+
"settings.changelog.auto.open": true,
2527
};
2628

2729
// Constants matching the codebase

0 commit comments

Comments
 (0)