Initial release v1.2.0 — Hellion NewTab Browser Extension
Persoenlicher Bookmark-Dashboard als Browser-Extension. 8 Themes, Drag & Drop, Sticky Notes, JSON Export/Import. Chrome, Edge, Brave, Opera, Vivaldi (MV3) + Firefox (MV2). Includes GitHub Actions for security scanning, code quality validation, and automated release packaging.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/* =============================================
|
||||
HELLION NEWTAB — storage.js
|
||||
Abstraction Layer: chrome.storage.local / localStorage
|
||||
============================================= */
|
||||
|
||||
const Store = {
|
||||
QUOTA_WARNING_BYTES: 8 * 1024 * 1024, // 8 MB Warnung (Limit ist 10 MB)
|
||||
|
||||
get(key) {
|
||||
return new Promise(resolve => {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage) {
|
||||
chrome.storage.local.get([key], r => resolve(r[key] ?? null));
|
||||
} else {
|
||||
try { resolve(JSON.parse(localStorage.getItem(key))); }
|
||||
catch { resolve(null); }
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
set(key, value) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage) {
|
||||
chrome.storage.local.set({ [key]: value }, () => {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error('Storage-Fehler:', chrome.runtime.lastError.message);
|
||||
alert('Speicher voll! Bitte lösche alte Boards oder das Hintergrundbild, um Platz zu schaffen.');
|
||||
reject(new Error(chrome.runtime.lastError.message));
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
resolve();
|
||||
} catch (e) {
|
||||
console.error('Storage-Fehler:', e.message);
|
||||
alert('Speicher voll! Bitte lösche alte Boards oder das Hintergrundbild, um Platz zu schaffen.');
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async checkQuota() {
|
||||
if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local.getBytesInUse) {
|
||||
return new Promise(resolve => {
|
||||
chrome.storage.local.getBytesInUse(null, bytes => {
|
||||
if (bytes > Store.QUOTA_WARNING_BYTES) {
|
||||
const usedMB = (bytes / 1024 / 1024).toFixed(1);
|
||||
console.warn('Storage-Warnung: ' + usedMB + ' MB von 10 MB belegt.');
|
||||
}
|
||||
resolve(bytes);
|
||||
});
|
||||
});
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user