Temporary-Script-Storage

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

Цей скрипт не слід встановлювати безпосередньо. Це - бібліотека для інших скриптів для включення в мета директиву // @require https://update.greasyfork.org/scripts/562172/1881822/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 or Violentmonkey 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.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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!)

Автор
JasonMel
Версія
1.0.4
Створено
11.01.2026
Оновлено
21.07.2026
Size
31,2 кБ
Ліцензія
MIT (https://mit-license.org/)

Сховище, встановлене та доступне через екземпляр цього класу, буде існувати лише так довго, як час життя, який ви встановили в конструкторі, однак воно повинно бути принаймні одним днем. За замовчуванням це 30 днів. По закінченні цього часу воно закінчиться дійсності та буде видалено при виклику sweepExpiredEntries(), яку ви можете планувати за допомогою setInterval().

Ця бібліотека не впливає на сховище, встановлене безпосередньо через GM's setValue() звичайним способом. Таке сховище працюватиме нормально.

Приклад використання:

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

try { 
  await persistentStorage.set("key1", "hello"); // throws
  const msg = persistentStorage.get("key1");    // fast memory read
  await persistentStorage.delete("key1");       // throws
} catch {}

Крім того, будь-який скрипт, що використовує цю бібліотеку, повинен включати наступні метадані:

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

Це необхідно, оскільки розміщення того, що потрібно кожній бібліотеці у своїх власних метаданих, недостатньо. Скрипт верхнього рівня повинен надати необхідні @requires та @grants для всіх своїх залежностей.