Yo saveData, getData.
이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greatest.deepsurf.us/scripts/489971/1343998/Save%20and%20Get.js을(를) 사용하여 포함하는 라이브러리입니다.
// ==UserScript==
// @name Save and Get
// @namespace none
// @version 0.1
// @description Yo saveData, getData.
// @author no
// @match *://*/*
// @grant unsafeWindow
// ==/UserScript==
(() => {
'use strict';
unsafeWindow.saveData = (key, value) => {
localStorage.setItem(key, JSON.stringify(value));
};
unsafeWindow.getData = (keysArray) => {
const data = {};
keysArray.forEach(key => {
try {
const value = localStorage.getItem(key);
if (value !== null) {
data[key] = JSON.parse(value);
}
} catch (error) {
console.error('Ошибка при загрузке данных:', error);
}
});
return data;
};
})();