storage

storage:get,set,remove,clear

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/503785/1428734/storage.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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()
	},
}