From a4ee455c4d9d15ba49ad3549ad0e6c73f28d0a7e Mon Sep 17 00:00:00 2001
From: yuri-kiss <135030944+yuri-kiss@users.noreply.github.com>
Date: Fri, 4 Apr 2025 22:35:51 -0400
Subject: [PATCH 1/5] implement a password input
---
src/addons/settings/settings.jsx | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/addons/settings/settings.jsx b/src/addons/settings/settings.jsx
index 47591877924..79fe97e905b 100644
--- a/src/addons/settings/settings.jsx
+++ b/src/addons/settings/settings.jsx
@@ -428,23 +428,23 @@ const Setting = ({
/>
)}
- {(setting.type === 'string' || setting.type === 'long_string' || setting.type === 'untranslated') && (
+ {(setting.type === 'string' || setting.type === 'long_string' || setting.type === 'untranslated' || setting.type === 'password') && (
{label}
SettingsStore.setAddonSetting(addonId, settingId, newValue)}
/>
{setting.type !== 'long_string' && (
-
- )}
+
+ )}
)}
{setting.type === 'color' && (
From 712e779ad8862a2087db89f534809555bf8405a0 Mon Sep 17 00:00:00 2001
From: yuri-kiss <135030944+yuri-kiss@users.noreply.github.com>
Date: Fri, 4 Apr 2025 22:37:20 -0400
Subject: [PATCH 2/5] Switch to long password
---
src/addons/addons/ai-integration/_manifest_entry.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/addons/addons/ai-integration/_manifest_entry.js b/src/addons/addons/ai-integration/_manifest_entry.js
index 1f2349c386f..f8eda04b4b0 100644
--- a/src/addons/addons/ai-integration/_manifest_entry.js
+++ b/src/addons/addons/ai-integration/_manifest_entry.js
@@ -19,13 +19,13 @@ const manifest = {
{
"id": "GeminiAPIKey",
"name": "Gemini API Key",
- "type": "long_string",
+ "type": "long_password",
"default": "",
},
{
"id": "OpenRouterAPIKey",
"name": "OpenRouter API Key",
- "type": "long_string",
+ "type": "long_password",
"default": "",
}
],
From 25a76208953645be759f2093b2c55302e4465674 Mon Sep 17 00:00:00 2001
From: yuri-kiss <135030944+yuri-kiss@users.noreply.github.com>
Date: Fri, 4 Apr 2025 22:43:03 -0400
Subject: [PATCH 3/5] make code more... legible
---
.../addons/ai-integration/userscript.js | 32 +++++++++++--------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/addons/addons/ai-integration/userscript.js b/src/addons/addons/ai-integration/userscript.js
index 7e8ea146f3d..a0b81b05665 100644
--- a/src/addons/addons/ai-integration/userscript.js
+++ b/src/addons/addons/ai-integration/userscript.js
@@ -4,16 +4,7 @@ import Attachment from "./helpers/attachment.js";
import main from "./main.js";
const {API_HOST} = require('../../../lib/brand.js');
-let authToken = {};
-
-var mainWorkspace;
-
-
-window.addEventListener('blockError', (event) => {
- document.AI_INTEGRATION.errorsDetected.push(event.detail);
-});
-
-document.AI_INTEGRATION = { //probably the dumbest way to possibly do this, it just make debugging alot easier (will do it properly later)
+const AI_INTEGRATION = {
AI_currently_blabbering: false,
CodeChunks: [],
AllCodeChunksEverAdded: [],
@@ -24,7 +15,18 @@ document.AI_INTEGRATION = { //probably the dumbest way to possibly do this, it j
errorsDetected: [],
AIModels: [],
};
+// TODO: possibly push this into the addons api?
+document.AI_INTEGRATION = AI_INTEGRATION;
+
+let authToken = {};
+let mainWorkspace;
+
+// TODO: dont use global events
+window.addEventListener('blockError', (event) => {
+ AI_INTEGRATION.errorsDetected.push(event.detail);
+});
+// TODO: find a better way to do this, this may break other monkey-patching and it eats RAM...
function workspaceOverride() {
if (typeof Blockly !== 'undefined') {
Blockly.getMainWorkspace = function () { // I have to do this as the getmainworkspace gets linked to the getSVG parsing one
@@ -38,9 +40,10 @@ function workspaceOverride() {
}
workspaceOverride();
+// TODO: this should use a global hook
document.addEventListener("mousemove", (event) => {
- document.AI_INTEGRATION.X_COORDINATE = event.clientX;
- document.AI_INTEGRATION.Y_COORDINATE = event.clientY;
+ AI_INTEGRATION.X_COORDINATE = event.clientX;
+ AI_INTEGRATION.Y_COORDINATE = event.clientY;
});
export default async function ({ addon, console }) {
@@ -62,7 +65,7 @@ export default async function ({ addon, console }) {
document.head.appendChild(style);
if (authToken.gemini == "" && authToken.openrouter == "") {
- document.AI_INTEGRATION.canUse = false;
+ AI_INTEGRATION.canUse = false;
window.addEventListener('ai-button-clicked', function () {
main.createBasePopup(2, "");
});
@@ -84,7 +87,7 @@ export default async function ({ addon, console }) {
}
})
.then(data => {
- document.AI_INTEGRATION.AIModels = data;
+ AI_INTEGRATION.AIModels = data;
helpers.updateAIModels(authToken.gemini, authToken.openrouter);
})
.catch(error => {
@@ -166,6 +169,7 @@ export default async function ({ addon, console }) {
}
});
+ // TODO: dont use global events
window.addEventListener('ai-button-clicked', function () {
main.createBasePopup(2, "");
});
From 4aec7e0baee96acaba801bb945bcff85ebd484d4 Mon Sep 17 00:00:00 2001
From: yuri-kiss <135030944+yuri-kiss@users.noreply.github.com>
Date: Fri, 4 Apr 2025 22:45:22 -0400
Subject: [PATCH 4/5] Implement long password
---
src/addons/settings/settings.jsx | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/addons/settings/settings.jsx b/src/addons/settings/settings.jsx
index 79fe97e905b..ac7d501428b 100644
--- a/src/addons/settings/settings.jsx
+++ b/src/addons/settings/settings.jsx
@@ -428,17 +428,18 @@ const Setting = ({
/>
)}
- {(setting.type === 'string' || setting.type === 'long_string' || setting.type === 'untranslated' || setting.type === 'password') && (
+ {(setting.type === 'string' || setting.type === 'long_string' || setting.type === 'untranslated' ||
+ setting.type === 'password' || setting.type === 'long_password') && (
{label}
SettingsStore.setAddonSetting(addonId, settingId, newValue)}
/>
- {setting.type !== 'long_string' && (
+ {setting.type !== 'long_string' && setting.type !== 'long_password' && (
Date: Fri, 4 Apr 2025 22:45:40 -0400
Subject: [PATCH 5/5] Update copyright
---
src/addons/settings/settings.jsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/addons/settings/settings.jsx b/src/addons/settings/settings.jsx
index ac7d501428b..c70c4bddd82 100644
--- a/src/addons/settings/settings.jsx
+++ b/src/addons/settings/settings.jsx
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2021-2023 Thomas Weber
+ * Copyright (C) 2021-2025 Thomas Weber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as