Temporary-Script-Storage

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

Acest script nu ar trebui instalat direct. Aceasta este o bibliotecă pentru alte scripturi care este inclusă prin directiva meta a // @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!)

Autor
JasonMel
Versiune
1.0.4
Creat
11-01-2026
Actualizat
21-07-2026
Size
31,2 KB
Licență
MIT (https://mit-license.org/)

Stocarea setată și accesată printr-o instanță a acestei clase va trăi doar cât timp durează pe care o setați în constructor, deși trebuie să fie cel puțin o zi. Implicit este 30 de zile. După aceea, va expira și va fi ștearsă când se apelează sweepExpiredEntries(), pe care o puteți programa cu setInterval().

Această bibliotecă nu are niciun efect asupra stocării scriptului setată direct prin setValue() a GM în mod obișnuit. O asemenea stocare se va comporta normal.

Exemplu de utilizare:

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 {}

În plus, orice script care utilizează această bibliotecă trebuie să includă următoarele metadate:

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

Acest lucru este necesar deoarece punerea a ceea ce fiecare bibliotecă are nevoie în propriile sale metadate nu este suficientă. Scriptul de nivel superior trebuie să furnizeze @requireurile și @granturile necesare pentru toate dependențele sale.