Skip to content

Commit 687ed0b

Browse files
committed
ScriptVault v2.0.1: remove unused modules, multi-source script store
Removed 5 dashboard modules that were incomplete or redundant: AI Assistant, Analytics, Performance Dashboard, Onboarding Wizard, and OpenUserJS (merged into Store). Script Store upgraded to multi-source search with Greasy Fork and OpenUserJS combined results, source badges, and source filter bar. Cleaned up related background message handlers (recordAnalytics, getAnalytics, getPerfHistory, savePerfSnapshot) and quota-manager pruning for removed data. Updated lazy-loader tab mappings and What's New entries.
1 parent ae20179 commit 687ed0b

16 files changed

Lines changed: 251 additions & 5695 deletions

background.core.js

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,42 +1602,6 @@ async function handleMessage(message, sender) {
16021602
}
16031603

16041604
// v2.0: Script Analytics
1605-
case 'recordAnalytics': {
1606-
const analyticsData = await chrome.storage.local.get('analytics');
1607-
const analytics = analyticsData.analytics || {};
1608-
const today = new Date().toISOString().slice(0, 10);
1609-
if (!analytics[today]) analytics[today] = {};
1610-
const sid = data.scriptId;
1611-
if (!analytics[today][sid]) analytics[today][sid] = { runs: 0, totalTime: 0, errors: 0, urls: [] };
1612-
analytics[today][sid].runs++;
1613-
analytics[today][sid].totalTime += data.duration || 0;
1614-
if (data.error) analytics[today][sid].errors++;
1615-
if (data.url && !analytics[today][sid].urls.includes(data.url)) {
1616-
analytics[today][sid].urls.push(data.url);
1617-
if (analytics[today][sid].urls.length > 50) analytics[today][sid].urls = analytics[today][sid].urls.slice(-50);
1618-
}
1619-
// Prune data older than 90 days
1620-
const cutoffDate = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
1621-
for (const date of Object.keys(analytics)) {
1622-
if (date < cutoffDate) delete analytics[date];
1623-
}
1624-
await chrome.storage.local.set({ analytics });
1625-
return { success: true };
1626-
}
1627-
case 'getAnalytics': {
1628-
const aData = await chrome.storage.local.get('analytics');
1629-
return { analytics: aData.analytics || {} };
1630-
}
1631-
case 'getAnalyticsForScript': {
1632-
const aData2 = await chrome.storage.local.get('analytics');
1633-
const analytics2 = aData2.analytics || {};
1634-
const scriptData = {};
1635-
for (const [date, scripts] of Object.entries(analytics2)) {
1636-
if (scripts[data.scriptId]) scriptData[date] = scripts[data.scriptId];
1637-
}
1638-
return { data: scriptData };
1639-
}
1640-
16411605
// v2.0: Profiles
16421606
case 'getProfiles': {
16431607
const pData = await chrome.storage.local.get(['profiles', 'activeProfileId']);
@@ -2834,22 +2798,6 @@ async function handleMessage(message, sender) {
28342798
}
28352799

28362800
// Performance History
2837-
case 'getPerfHistory': {
2838-
const histData = await chrome.storage.local.get('perfHistory');
2839-
return { history: histData.perfHistory || [] };
2840-
}
2841-
2842-
case 'savePerfSnapshot': {
2843-
const histData2 = await chrome.storage.local.get('perfHistory');
2844-
const history = histData2.perfHistory || [];
2845-
history.push({ timestamp: Date.now(), data: data.snapshot });
2846-
// Keep last 30 days
2847-
const cutoff = Date.now() - (30 * 24 * 60 * 60 * 1000);
2848-
const trimmed = history.filter(h => h.timestamp > cutoff);
2849-
await chrome.storage.local.set({ perfHistory: trimmed });
2850-
return { success: true };
2851-
}
2852-
28532801
// Easy Cloud Sync
28542802
case 'easyCloudConnect': {
28552803
if (typeof EasyCloudSync !== 'undefined') {

background.js

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ScriptVault v2.0.0 - Background Service Worker
1+
// ScriptVault v2.0.1 - Background Service Worker
22
// Comprehensive userscript manager with cloud sync and auto-updates
33
// NOTE: This file is built from source modules. Edit the individual files in
44
// shared/, modules/, and lib/, then run build-background.sh to regenerate.
@@ -9144,23 +9144,6 @@ const Migration = (() => {
91449144
});
91459145
}
91469146

9147-
// 7. Create initial performance snapshot
9148-
try {
9149-
const perfHistory = await chrome.storage.local.get('perfHistory');
9150-
if (!perfHistory.perfHistory || perfHistory.perfHistory.length === 0) {
9151-
const allScripts = Object.values(scripts);
9152-
const snapshot = {};
9153-
for (const s of allScripts) {
9154-
if (s.stats) {
9155-
snapshot[s.id] = { avgTime: s.stats.avgTime || 0, runs: s.stats.runs || 0, errors: s.stats.errors || 0 };
9156-
}
9157-
}
9158-
await chrome.storage.local.set({
9159-
perfHistory: [{ timestamp: Date.now(), data: snapshot }]
9160-
});
9161-
}
9162-
} catch {}
9163-
91649147
console.log('[Migration] v2.0 migration complete');
91659148
}
91669149

@@ -9284,34 +9267,7 @@ const QuotaManager = (() => {
92849267
}
92859268
}
92869269

9287-
// 2. Trim analytics data to 30 days (from 90)
9288-
if (options.analytics !== false) {
9289-
const analyticsData = await chrome.storage.local.get('analytics');
9290-
if (analyticsData.analytics) {
9291-
const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
9292-
const old = Object.keys(analyticsData.analytics).filter(d => d < cutoff);
9293-
if (old.length > 0) {
9294-
for (const date of old) delete analyticsData.analytics[date];
9295-
await chrome.storage.local.set({ analytics: analyticsData.analytics });
9296-
actions.push(`Pruned ${old.length} days of old analytics`);
9297-
freedBytes += old.length * 500; // Estimate
9298-
}
9299-
}
9300-
}
9301-
9302-
// 3. Trim performance history to 14 days
9303-
if (options.perfHistory !== false) {
9304-
const perfData = await chrome.storage.local.get('perfHistory');
9305-
if (perfData.perfHistory && perfData.perfHistory.length > 14) {
9306-
const trimmed = perfData.perfHistory.slice(-14);
9307-
const removed = perfData.perfHistory.length - trimmed.length;
9308-
await chrome.storage.local.set({ perfHistory: trimmed });
9309-
actions.push(`Pruned ${removed} perf history entries`);
9310-
freedBytes += removed * 200;
9311-
}
9312-
}
9313-
9314-
// 4. Trim error log to 200 entries
9270+
// 2. Trim error log to 200 entries
93159271
if (options.errorLog !== false) {
93169272
const errData = await chrome.storage.local.get('errorLog');
93179273
if (errData.errorLog && errData.errorLog.length > 200) {
@@ -11471,42 +11427,6 @@ async function handleMessage(message, sender) {
1147111427
}
1147211428

1147311429
// v2.0: Script Analytics
11474-
case 'recordAnalytics': {
11475-
const analyticsData = await chrome.storage.local.get('analytics');
11476-
const analytics = analyticsData.analytics || {};
11477-
const today = new Date().toISOString().slice(0, 10);
11478-
if (!analytics[today]) analytics[today] = {};
11479-
const sid = data.scriptId;
11480-
if (!analytics[today][sid]) analytics[today][sid] = { runs: 0, totalTime: 0, errors: 0, urls: [] };
11481-
analytics[today][sid].runs++;
11482-
analytics[today][sid].totalTime += data.duration || 0;
11483-
if (data.error) analytics[today][sid].errors++;
11484-
if (data.url && !analytics[today][sid].urls.includes(data.url)) {
11485-
analytics[today][sid].urls.push(data.url);
11486-
if (analytics[today][sid].urls.length > 50) analytics[today][sid].urls = analytics[today][sid].urls.slice(-50);
11487-
}
11488-
// Prune data older than 90 days
11489-
const cutoffDate = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
11490-
for (const date of Object.keys(analytics)) {
11491-
if (date < cutoffDate) delete analytics[date];
11492-
}
11493-
await chrome.storage.local.set({ analytics });
11494-
return { success: true };
11495-
}
11496-
case 'getAnalytics': {
11497-
const aData = await chrome.storage.local.get('analytics');
11498-
return { analytics: aData.analytics || {} };
11499-
}
11500-
case 'getAnalyticsForScript': {
11501-
const aData2 = await chrome.storage.local.get('analytics');
11502-
const analytics2 = aData2.analytics || {};
11503-
const scriptData = {};
11504-
for (const [date, scripts] of Object.entries(analytics2)) {
11505-
if (scripts[data.scriptId]) scriptData[date] = scripts[data.scriptId];
11506-
}
11507-
return { data: scriptData };
11508-
}
11509-
1151011430
// v2.0: Profiles
1151111431
case 'getProfiles': {
1151211432
const pData = await chrome.storage.local.get(['profiles', 'activeProfileId']);
@@ -12703,22 +12623,6 @@ async function handleMessage(message, sender) {
1270312623
}
1270412624

1270512625
// Performance History
12706-
case 'getPerfHistory': {
12707-
const histData = await chrome.storage.local.get('perfHistory');
12708-
return { history: histData.perfHistory || [] };
12709-
}
12710-
12711-
case 'savePerfSnapshot': {
12712-
const histData2 = await chrome.storage.local.get('perfHistory');
12713-
const history = histData2.perfHistory || [];
12714-
history.push({ timestamp: Date.now(), data: data.snapshot });
12715-
// Keep last 30 days
12716-
const cutoff = Date.now() - (30 * 24 * 60 * 60 * 1000);
12717-
const trimmed = history.filter(h => h.timestamp > cutoff);
12718-
await chrome.storage.local.set({ perfHistory: trimmed });
12719-
return { success: true };
12720-
}
12721-
1272212626
// Easy Cloud Sync
1272312627
case 'easyCloudConnect': {
1272412628
if (typeof EasyCloudSync !== 'undefined') {

manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_extName__",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"description": "__MSG_extDescription__",
66
"default_locale": "en",
77
"homepage_url": "https://github.com/SysAdminDoc/ScriptVault",

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "__MSG_extName__",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"description": "__MSG_extDescription__",
66
"default_locale": "en",
77
"minimum_chrome_version": "120",

modules/migration.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,6 @@ const Migration = (() => {
139139
});
140140
}
141141

142-
// 7. Create initial performance snapshot
143-
try {
144-
const perfHistory = await chrome.storage.local.get('perfHistory');
145-
if (!perfHistory.perfHistory || perfHistory.perfHistory.length === 0) {
146-
const allScripts = Object.values(scripts);
147-
const snapshot = {};
148-
for (const s of allScripts) {
149-
if (s.stats) {
150-
snapshot[s.id] = { avgTime: s.stats.avgTime || 0, runs: s.stats.runs || 0, errors: s.stats.errors || 0 };
151-
}
152-
}
153-
await chrome.storage.local.set({
154-
perfHistory: [{ timestamp: Date.now(), data: snapshot }]
155-
});
156-
}
157-
} catch {}
158-
159142
console.log('[Migration] v2.0 migration complete');
160143
}
161144

modules/quota-manager.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,7 @@ const QuotaManager = (() => {
8787
}
8888
}
8989

90-
// 2. Trim analytics data to 30 days (from 90)
91-
if (options.analytics !== false) {
92-
const analyticsData = await chrome.storage.local.get('analytics');
93-
if (analyticsData.analytics) {
94-
const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
95-
const old = Object.keys(analyticsData.analytics).filter(d => d < cutoff);
96-
if (old.length > 0) {
97-
for (const date of old) delete analyticsData.analytics[date];
98-
await chrome.storage.local.set({ analytics: analyticsData.analytics });
99-
actions.push(`Pruned ${old.length} days of old analytics`);
100-
freedBytes += old.length * 500; // Estimate
101-
}
102-
}
103-
}
104-
105-
// 3. Trim performance history to 14 days
106-
if (options.perfHistory !== false) {
107-
const perfData = await chrome.storage.local.get('perfHistory');
108-
if (perfData.perfHistory && perfData.perfHistory.length > 14) {
109-
const trimmed = perfData.perfHistory.slice(-14);
110-
const removed = perfData.perfHistory.length - trimmed.length;
111-
await chrome.storage.local.set({ perfHistory: trimmed });
112-
actions.push(`Pruned ${removed} perf history entries`);
113-
freedBytes += removed * 200;
114-
}
115-
}
116-
117-
// 4. Trim error log to 200 entries
90+
// 2. Trim error log to 200 entries
11891
if (options.errorLog !== false) {
11992
const errData = await chrome.storage.local.get('errorLog');
12093
if (errData.errorLog && errData.errorLog.length > 200) {

0 commit comments

Comments
 (0)