LS (Local Storage)

Bu kütüphane, tarayıcının localStorage özelliğini daha akıllı ve güvenli bir şekilde kullanmanızı sağlar. Standart localStorage yalnızca düz metin (string) saklayabilirken, bu kütüphane nesne (object), dizi (array), sayı ve boolean gibi veri tiplerini otomatik olarak dönüştürerek kaydeder ve okur.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/591381/1902888/LS%20%28Local%20Storage%29.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        LS (Local Storage)
// @namespace   http://tampermonkey.net/
// @version     1
// @description Bu kütüphane, tarayıcının localStorage özelliğini daha akıllı ve güvenli bir şekilde kullanmanızı sağlar. Standart localStorage yalnızca düz metin (string) saklayabilirken, bu kütüphane nesne (object), dizi (array), sayı ve boolean gibi veri tiplerini otomatik olarak dönüştürerek kaydeder ve okur.
// @author      Atilla
// @license     MIT
// ==/UserScript==
(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD (RequireJS vb.)
    define([], factory);
  } else if (typeof module === 'object' && module.exports) {
    // CommonJS (Node.js, Webpack, require)
    module.exports = factory();
  } else {
    // Tarayıcı Doğrudan Kullanım (<script src="...">)
    // Pencere (window) nesnesine "LS" adıyla ekler
    root.LS = factory();
  }
}(typeof self !== 'undefined' ? self : this, function () {
  
  // Kütüphane mantığı burada başlar
  return {
    /**
     * Veriyi JSON formatına çevirerek kaydeder.
     * @param {string} key 
     * @param {any} value 
     */
    set: function (key, value) {
      localStorage.setItem(key, JSON.stringify(value));
    },

    /**
     * Veriyi okur ve otomatik olarak orijinal tipine çözümler.
     * @param {string} key 
     * @returns {any}
     */
    get: function (key) {
      var value = localStorage.getItem(key);
      if (value === null) return null; // Veri yoksa direkt null dön
      
      try {
        return JSON.parse(value);
      } catch (e) {
        return value; // Veri düz metin ise direkt döndür
      }
    },

    /**
     * Belirtilen anahtardaki veriyi siler.
     * @param {string} key 
     */
    remove: function (key) {
      localStorage.removeItem(key);
    },

    /**
     * Tüm depolama alanını temizler.
     */
    clear: function () {
      localStorage.clear();
    }
  };

}));