function saveToUserStorage(force = false) { const currentTime = new Date().getTime(); const lastSaveTimestamp = parseInt(localStorage.getItem('lastSaveTimestamp') || '0'); if (!force && currentTime - lastSaveTimestamp < 5000) { return; } const data = {}; document.querySelectorAll('input, textarea, select').forEach(input => { data[input.id] = input.value; }); localStorage.setItem('gemini_prompt', JSON.stringify(data)); localStorage.setItem('lastSaveTimestamp', currentTime.toString()); return true; } function loadFromUserStorage() { const data = JSON.parse(localStorage.getItem('gemini_prompt')) || {}; document.querySelectorAll('input, textarea, select').forEach(input => { let v = data[input.id] || ""; if (v) { if (input.type === "number") { v = parseInt(v); } input.value = v; } }); // エンドポイントが保存されていない場合、デフォルト値を設定 if (!data.endpointSelect) { document.getElementById('endpointSelect').value = "gemini-1.5-pro-exp-0827"; } }