Enhance custom.js to prompt for API key if missing and inject script tag
This commit is contained in:
1 parent
632328db88
commit
e56624d943
2 files changed
+14
-4
No files matched your search
+11
-2
@@ -1,6 +1,15 @@
|
||||
// Auto‑load saved image generation API key into the MCP input field
|
||||
// Auto‑load saved image‑generation API key into the MCP input field.
|
||||
// If no key is stored, prompt the user once and persist it in localStorage.
|
||||
window.addEventListener('load', () => {
|
||||
const savedKey = localStorage.getItem('image_api_key');
|
||||
const storageKey = 'image_api_key';
|
||||
let savedKey = localStorage.getItem(storageKey);
|
||||
if (!savedKey) {
|
||||
// Prompt user only once per browser session
|
||||
savedKey = prompt('Enter your Inference Co‑op image‑generation API key (will be saved locally):');
|
||||
if (savedKey) {
|
||||
localStorage.setItem(storageKey, savedKey);
|
||||
}
|
||||
}
|
||||
if (savedKey) {
|
||||
const icInput = document.querySelector('input[name="IC_API_KEY"]');
|
||||
if (icInput) icInput.value = savedKey;
|
||||
|
||||
Reference in new issue
Block a user