Temporary-Script-Storage

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

Skrip ini tidak untuk dipasang secara langsung. Ini adalah pustaka skrip lain untuk disertakan dengan direktif meta // @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!)

Penulis
JasonMel
Versi
1.0.4
Dibuat
11 Januari 2026
Diperbarui
21 Juli 2026
ukuran
31,2 KB
Lisensi
MIT (https://mit-license.org/)

Penyimpanan yang ditetapkan dan diakses melalui instance kelas ini hanya akan bertahan selama masa hidup yang Anda tetapkan di konstruktor, meskipun harus setidaknya satu hari. Defaultnya adalah 30 hari. Setelah itu, penyimpanan akan kedaluwarsa dan dihapus ketika sweepExpiredEntries() dipanggil, yang dapat Anda jadwalkan dengan setInterval().

Perpustakaan ini tidak berpengaruh pada penyimpanan skrip yang ditetapkan langsung melalui setValue() GM dengan cara biasa. Penyimpanan seperti itu akan berperilaku secara normal.

Contoh penggunaan:

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

Selain itu, setiap skrip yang menggunakan perpustakaan ini harus menyertakan metadata berikut:

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

Ini diperlukan karena menempatkan apa yang dibutuhkan setiap perpustakaan dalam metadata-nya sendiri tidaklah cukup. Skrip tingkat atas harus menyediakan @requires dan @grants yang diperlukan untuk semua dependensinya.