From 661875ceb8fba4e58b5bea2b7e6420413fe91467 Mon Sep 17 00:00:00 2001 From: Kevin Payravi Date: Mon, 27 Nov 2023 03:19:14 -0500 Subject: [PATCH] Changelog opening no longer active tab + default to off --- background.js | 4 ++-- popup.html | 7 +++++++ popup.js | 28 ++++++++++++++++++++++++++++ settings.js | 4 ++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/background.js b/background.js index ad54b9c..4a20b87 100644 --- a/background.js +++ b/background.js @@ -40,9 +40,9 @@ chrome.runtime.onInstalled.addListener(async function (detail) { } // If update, open changelog if setting is enabled - chrome.storage.sync.get({ 'openChangelog': 'on' }, function (item) { + chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) { if (item.openChangelog === 'on' && detail.reason === 'update') { - chrome.tabs.create({ url: 'https://getindie.wiki/changelog/?updated=true' }); + chrome.tabs.create({ url: 'https://getindie.wiki/changelog/?updated=true', active: false }); } }); diff --git a/popup.html b/popup.html index b275611..65ce15e 100644 --- a/popup.html +++ b/popup.html @@ -357,6 +357,13 @@ independent English wikis when no same-language wiki exists +
+ +
diff --git a/popup.js b/popup.js index 65c8d3d..d802d52 100644 --- a/popup.js +++ b/popup.js @@ -250,6 +250,22 @@ function setCrossLanguage(setting, storeSetting = true) { } } +// Set open changelog setting +function setOpenChangelog(setting, storeSetting = true) { + if (storeSetting) { + chrome.storage.sync.set({ 'openChangelog': setting }); + } + + const openChangelogIcon = document.getElementById('openChangelogIcon'); + if (setting === 'on') { + document.getElementById('openChangelogCheckbox').checked = true; + openChangelogIcon.innerText = '📂'; + } else { + document.getElementById('openChangelogCheckbox').checked = false; + openChangelogIcon.innerText = '📁'; + } +} + // Set default action setting chrome.storage.sync.get(['defaultWikiAction'], function (item) { if (item.defaultWikiAction === 'disabled') { @@ -380,6 +396,9 @@ document.addEventListener('DOMContentLoaded', function () { chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) { setCrossLanguage(item.crossLanguage, false); }); + chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) { + setOpenChangelog(item.openChangelog, false); + }); chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) { setBreezeWiki(item.breezewiki, false); @@ -417,6 +436,15 @@ document.addEventListener('DOMContentLoaded', function () { } }); }); + document.getElementById('openChangelogCheckbox').addEventListener('change', function () { + chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) { + if (item.openChangelog === 'on') { + setOpenChangelog('off'); + } else { + setOpenChangelog('on'); + } + }); + }); // Add event listeners for BreezeWiki settings document.getElementById('breezewikiCheckbox').addEventListener('change', function () { diff --git a/settings.js b/settings.js index 3b8726c..28426da 100644 --- a/settings.js +++ b/settings.js @@ -777,7 +777,7 @@ document.addEventListener('DOMContentLoaded', function () { chrome.storage.sync.get({ 'crossLanguage': 'off' }, function (item) { setCrossLanguage(item.crossLanguage, false); }); - chrome.storage.sync.get({ 'openChangelog': 'on' }, function (item) { + chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) { setOpenChangelog(item.openChangelog, false); }); chrome.storage.sync.get({ 'breezewiki': 'off' }, function (item) { @@ -818,7 +818,7 @@ document.addEventListener('DOMContentLoaded', function () { }); }); document.getElementById('openChangelogCheckbox').addEventListener('change', function () { - chrome.storage.sync.get({ 'openChangelog': 'on' }, function (item) { + chrome.storage.sync.get({ 'openChangelog': 'off' }, function (item) { if (item.openChangelog === 'on') { setOpenChangelog('off'); } else {