🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/24 02:21:01
🔄 下次更新时间:2026/01/24 03:21:01
手动刷新缓存

Temporary-Script-Storage

Sets a maximum age (minimum one day) for script storage values, after which they are deleted

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/562172/1733898/Temporary-Script-Storage.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

Author
JasonMel
Version
1.0.2
Created
2026-01-11
Updated
2026-01-11
Size
29.3 KB
License
MIT (https://mit-license.org/)

Storage set and accessed through an instance of this class will only live as long as the lifetime you set in the constructor, though it must be at least a day. The default is 30 days. After that time, it will expire and be deleted when sweepExpiredEntries() is called, which you can schedule with setInterval().

This library has no effect on script storage set directly through GM's setValue() the usual way. Such storage will behave normally.

Example usage:

const persistentStorage = new TTLStorage();
await persistentStorage.ready();
setInterval(() => persistentStorage.sweepExpiredEntries(), 1000 * 60 * 60 * 24);

await persistentStorage.set("key1", "hello");
const msg = persistentStorage.get("key1");

Additionally, any script using this library must include the following metadata:

// @grant GM.getValue
// @grant GM.setValue
// @grant GM.deleteValue
// @grant GM.listValues

This is necessary because putting what each library needs in its own metadata is not enough. The top-level script must provide the necessary @requires and @grants for all of its dependencies.