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/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.

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

Аўтар
JasonMel
Версія
1.0.4
Створаны
11.01.2026
Абноўлены
21.07.2026
Памер
31.2 КБ
Ліцэнзія
MIT (https://mit-license.org/)

Сховішча, установленае і атрыманае праз экзэмпляр гэтага класа, будзе існаваць толькі столькі, колькі зададзена ў канструктары, хаця яно павінна быць прынамсі адзін дзень. По змаўчанні — 30 дзён. Пасля гэтага часу яно стане непрыдатным і будзе выдалена пры выкліку sweepExpiredEntries(), што вы можаце запланаваць з дапамогай setInterval().

Гэтая бібліятэка не мае эфекту на сховішча, установленае безпасрэдна праз setValue() GM звычайным спосабам. Такое сховішча будзе павoдзіцца нармальна.

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

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 для ўсіх яго залежнасцей.