Some updates for optimization and security

This commit is contained in:
Namhyeon Go 2025-03-17 11:09:00 +09:00
parent 0cbb22ac26
commit 15b2e606b1
2 changed files with 25 additions and 17 deletions

View File

@ -128,10 +128,11 @@ namespace WelsonJS.Launcher
public static void OpenWebBrowser(string url)
{
string userDataDir = Path.Combine(GetAppDataPath(), "EdgeUserProfile");
string remoteAllowOrigins = "http://localhost:3000";
string[] arguments = {
$"\"{url}\"",
"--remote-debugging-port=9222",
"--remote-allow-origins=*",
$"--remote-allow-origins={remoteAllowOrigins}", // for security reason
$"--user-data-dir=\"{userDataDir}\""
};

View File

@ -265,17 +265,15 @@
async function sendPromptMessage(wsUrl, promptMessage) {
const socket = new WebSocket(wsUrl);
socket.onopen = () => {
socket.send(JSON.stringify({
const steps = [
{
id: 1,
method: 'Input.insertText',
params: {
text: promptMessage
}
}));
socket.send(JSON.stringify({
},
{
id: 2,
method: 'Input.dispatchKeyEvent',
params: {
@ -283,17 +281,26 @@
key: 'Enter',
code: 'Enter'
}
}));
},
{
id: 3,
method: 'Runtime.evaluate',
params: {
expression: '((e)=>e[e.length-1].querySelector("code").innerText||e[e.length-1].innerText)(document.querySelectorAll("[data-content=ai-message]"))'
}
}
];
setTimeout(() => {
socket.send(JSON.stringify({
id: 3,
method: 'Runtime.evaluate',
params: {
expression: '((e)=>e[e.length-1].querySelector("code").innerText||e[e.length-1].innerText)(document.querySelectorAll("[data-content=ai-message]"))'
}
}))
}, 7000);
socket.onopen = () => {
steps.forEach((step) => {
if (step.id == 3) {
setTimeout(() => {
socket.send(JSON.stringify(step));
}, 7000);
} else {
socket.send(JSON.stringify(step));
}
});
};
socket.onmessage = (event) => {