Skip to content

Commit c0193e5

Browse files
committed
Condensed processKey() ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
1 parent 9780fa0 commit c0193e5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

starters/chrome/extension/lib/settings.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@ window.settings = {
5151
config[key] = processKey(key, (await chrome.storage.local.get(key))[key])))
5252
function processKey(key, val) {
5353
const ctrl = settings.controls?.[key]
54-
if (val != undefined) {
55-
if (ctrl?.type == 'toggle' // ensure toggle vals are booleans
56-
&& typeof val != 'boolean') val = undefined
57-
else if (ctrl?.type == 'slider') { // ensure slider vals are nums
58-
val = parseFloat(val) ; if (isNaN(val)) val = undefined }
59-
}
54+
if (val != undefined && ( // validate stored val
55+
(ctrl?.type == 'toggle' && typeof val != 'boolean')
56+
|| (ctrl?.type == 'slider' && isNaN(parseFloat(val)))
57+
)) val = undefined
6058
return val ?? (ctrl?.defaultVal ?? (ctrl?.type == 'slider' ? 100 : false))
6159
}
6260
},

starters/chrome/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "ChatGPT Extension",
44
"short_name": "ChatGPT 🧩",
55
"description": "A Chromium extension template to start using chatgpt.js like a boss!",
6-
"version": "2025.8.19",
6+
"version": "2025.8.19.1",
77
"author": "KudoAI",
88
"homepage_url": "https://github.com/KudoAI/chatgpt.js-chrome-starter",
99
"icons": { "16": "icons/icon16.png", "32": "icons/icon32.png", "64": "icons/icon64.png", "128": "icons/icon128.png" },

0 commit comments

Comments
 (0)