diff --git a/public/index.html b/public/index.html
index 477365a..3c02947 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2113,6 +2113,23 @@
return sources;
}
+ function getPreferredSourceForTab(opt, tabId = activeTab) {
+ const sources = getAvailableSourcesForTab(opt, tabId);
+ if (!sources.length) return null;
+
+ return [...sources].sort((a, b) => {
+ const aPoints = a.pointCount || 0;
+ const bPoints = b.pointCount || 0;
+ if (aPoints !== bPoints) return bPoints - aPoints;
+
+ const aChecked = Date.parse(a.latestCheckedAt || '') || 0;
+ const bChecked = Date.parse(b.latestCheckedAt || '') || 0;
+ if (aChecked !== bChecked) return bChecked - aChecked;
+
+ return String(a.sourceLabel || '').localeCompare(String(b.sourceLabel || ''));
+ })[0] || null;
+ }
+
function getVisibleOptionsForTab(tabId = activeTab) {
const sourcesForTab = (opt) => getAvailableSourcesForTab(opt, tabId).length > 0;
if (tabId === BUNDLE_TAB_ID) {
@@ -2169,7 +2186,8 @@
return normalizedStored;
}
- const defaultKey = normalizeSourceKey(opt.currentSourceKey || opt.defaultSourceKey || availableSources[0]?.sourceKey);
+ const preferredKey = getPreferredSourceForTab(opt, tabId)?.sourceKey;
+ const defaultKey = normalizeSourceKey(preferredKey || opt.currentSourceKey || opt.defaultSourceKey || availableSources[0]?.sourceKey);
return availableSources.some(source => source.sourceKey === defaultKey)
? defaultKey
: availableSources[0]?.sourceKey || 'unknown-source';