MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / clearLocalStorageIfNewSession

Function clearLocalStorageIfNewSession

userscripts.js:281–292  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

279 },
280 // 清空相关域下的 LocalStorage
281 clearLocalStorageIfNewSession() {
282 const lastSessionTimestamp = localStorage.getItem('lastSessionTimestamp');
283 const currentTime = new Date().getTime();
284
285 // 超过 24 小时清空 localStorage
286 if (!lastSessionTimestamp || currentTime - parseInt(lastSessionTimestamp) > 24 * 3600000) {
287 // if (!lastSessionTimestamp || currentTime - parseInt(lastSessionTimestamp) > 20000) {
288 localStorage.clear();
289 }
290 // 更新时间戳
291 localStorage.setItem('lastSessionTimestamp', currentTime.toString());
292 }
293}
294const util = {
295 getValue(name) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected