mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
387 B
13 lines
387 B
function setLocalStorage(key, value) {
|
|
try {
|
|
localStorage.setItem(key, value);
|
|
} catch (e) {
|
|
//clears hover cache when storage gets too large
|
|
const hoverCaches = Object.keys(localStorage).filter(k => k.startsWith('hovercache'));
|
|
for(let i = 0; i < hoverCaches.length; i++) {
|
|
localStorage.removeItem(hoverCaches[i]);
|
|
}
|
|
} finally {
|
|
localStorage.setItem(key, value);
|
|
}
|
|
}
|
|
|