- Created storage-utils.js with safeStorage wrapper to prevent tracking prevention errors - Updated script.js to use safeStorage for theme persistence - Added conditional QZ Tray connection based on 'Enable Scan to Boxes' toggle - Fixed 404 error by removing non-existent /api/backup/path endpoint call - Enhanced fg_scan.html to disable QZ Tray and socket connections when toggle is off - Prevents console errors when browser tracking prevention blocks localStorage access
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
/**
|
|
* Safe localStorage wrapper to handle tracking prevention errors
|
|
* This prevents console errors when browser tracking prevention blocks storage access
|
|
*/
|
|
const safeStorage = {
|
|
getItem: function(key) {
|
|
try {
|
|
return localStorage.getItem(key);
|
|
} catch (e) {
|
|
console.warn('localStorage access blocked:', e.message);
|
|
return null;
|
|
}
|
|
},
|
|
setItem: function(key, value) {
|
|
try {
|
|
localStorage.setItem(key, value);
|
|
} catch (e) {
|
|
console.warn('localStorage access blocked:', e.message);
|
|
}
|
|
},
|
|
removeItem: function(key) {
|
|
try {
|
|
localStorage.removeItem(key);
|
|
} catch (e) {
|
|
console.warn('localStorage access blocked:', e.message);
|
|
}
|
|
},
|
|
clear: function() {
|
|
try {
|
|
localStorage.clear();
|
|
} catch (e) {
|
|
console.warn('localStorage access blocked:', e.message);
|
|
}
|
|
}
|
|
};
|
|
|
|
// Export for use in other scripts
|
|
if (typeof window !== 'undefined') {
|
|
window.safeStorage = safeStorage;
|
|
}
|