MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / writeJSON

Function writeJSON

notes.js:24–43  ·  view source on GitHub ↗
(key, value)

Source from the content-addressed store, hash-verified

22 }
23
24 function writeJSON(key, value) {
25 try {
26 localStorage.setItem(key, JSON.stringify(value));
27 } catch (e) {
28 if (e.name === 'QuotaExceededError') {
29 // 存储空间不足,尝试清理过期数据
30 console.warn('Storage quota exceeded, attempting to clean up...');
31 cleanupStorageSpace();
32 // 再次尝试保存
33 try {
34 localStorage.setItem(key, JSON.stringify(value));
35 } catch (e2) {
36 alert('存储空间不足,请清理浏览器数据或删除一些笔记');
37 console.error('Notes save failed after cleanup:', e2);
38 }
39 } else {
40 console.error('Notes save failed:', e);
41 }
42 }
43 }
44
45 function generateId(prefix) {
46 return prefix + '_' + Date.now() + '_' + Math.random().toString(36).slice(2, 8);

Callers 15

saveLastSelectedNoteFunction · 0.85
cleanupStorageSpaceFunction · 0.85
ensureInitialDataFunction · 0.85
saveColorHistoryFunction · 0.85
saveCurrentFunction · 0.85
addCategoryFunction · 0.85
editCategoryFunction · 0.85
deleteCategoryFunction · 0.85
deleteCurrentNoteFunction · 0.85
restoreToVersionFunction · 0.85
showTrashDialogFunction · 0.85
restoreNoteFromTrashFunction · 0.85

Calls 1

cleanupStorageSpaceFunction · 0.85

Tested by

no test coverage detected