storage:get,set,remove,clear
이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greasyfork.org/scripts/503785/1428734/storage.js을(를) 사용하여 포함하는 라이브러리입니다.
const storage = {
//封装操作localstorage本地存储的方法
//存储
set(key, value) {
localStorage.setItem(key, JSON.stringify(value))
},
//取出数据
get(key) {
const value = localStorage.getItem(key)
if(value == null || value == '""' || value == undefined) {
return null
} else {
return JSON.parse(value)
}
},
// 删除数据
remove(key) {
localStorage.removeItem(key)
},
//清除所有存储
clear() {
localStorage.clear()
},
}