jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
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.
 
 
 
 
 

33 lines
1008 B

const isCatalog = window.location.pathname.endsWith('catalog.html');
const isThread = /\/\w+\/thread\/\d+.html/.test(window.location.pathname);
const isModView = /\/\w+\/manage\/(thread\/)?(index|\d+).html/.test(window.location.pathname);
function setLocalStorage(key, value) {
try {
localStorage.setItem(key, value);
} catch (e) {
deleteStartsWith();
} finally {
localStorage.setItem(key, value);
}
}
function appendLocalStorageArray(key, value) {
const storedArray = JSON.parse(localStorage.getItem(key));
storedArray.push(value);
setLocalStorage(key, JSON.stringify(storedArray));
}
function deleteStartsWith(startString = 'hovercache') {
//clears hover cache when localstorage gets full
const hoverCaches = Object.keys(localStorage).filter(k => k.startsWith(startString));
for(let i = 0; i < hoverCaches.length; i++) {
localStorage.removeItem(hoverCaches[i]);
}
}
function setDefaultLocalStorage(key, value) {
if (!localStorage.getItem(key)) {
setLocalStorage(key, value);
}
}