diff --git a/src/core/code-listener.ts b/src/core/code-listener.ts index 896dab3..76284ba 100644 --- a/src/core/code-listener.ts +++ b/src/core/code-listener.ts @@ -4,7 +4,7 @@ import reply from "./reply"; type Listener = { element: HTMLElement; - fn: (this: HTMLElement, ev: MouseEvent) => any; + fn: (this: HTMLElement, ev: MouseEvent) => void; }; const pressedKeys: string[] = []; diff --git a/src/core/modes/question-to-answer.ts b/src/core/modes/question-to-answer.ts index 21bb904..1e4a33d 100644 --- a/src/core/modes/question-to-answer.ts +++ b/src/core/modes/question-to-answer.ts @@ -30,6 +30,8 @@ function questionToAnswerMode(props: Props) { questionElement.textContent = contentIsResponse ? questionBackup : props.gptAnswer.response; + + contentIsResponse = !contentIsResponse; }); } diff --git a/src/core/questions/checkbox.ts b/src/core/questions/checkbox.ts index ac2e152..3c3150b 100644 --- a/src/core/questions/checkbox.ts +++ b/src/core/questions/checkbox.ts @@ -2,7 +2,7 @@ import type Config from "@typing/config"; import type GPTAnswer from "@typing/gptAnswer"; import Logs from "@utils/logs"; import normalizeText from "@utils/normalize-text"; -import { pickBestReponse, toPourcentage } from "@utils/pick-best-response"; +import { pickBestReponse } from "@utils/pick-best-response"; /** * Handle input checkbox elements diff --git a/src/core/questions/number.ts b/src/core/questions/number.ts index d86d153..2134904 100644 --- a/src/core/questions/number.ts +++ b/src/core/questions/number.ts @@ -23,7 +23,7 @@ function handleNumber( } const number = gptAnswer.normalizedResponse - .match(/\d+([,\.]\d+)?/gi)?.[0] + .match(/\d+([,.]\d+)?/gi)?.[0] ?.replace(",", "."); if (number === undefined) return false; diff --git a/src/core/questions/radio.ts b/src/core/questions/radio.ts index ad8ab4f..67b5d8d 100644 --- a/src/core/questions/radio.ts +++ b/src/core/questions/radio.ts @@ -2,7 +2,7 @@ import type Config from "@typing/config"; import type GPTAnswer from "@typing/gptAnswer"; import Logs from "@utils/logs"; import normalizeText from "@utils/normalize-text"; -import { pickBestReponse, toPourcentage } from "@utils/pick-best-response"; +import { pickBestReponse } from "@utils/pick-best-response"; /** * Handle input radio elements diff --git a/src/core/questions/select.ts b/src/core/questions/select.ts index 6c5c3b3..f0e3e58 100644 --- a/src/core/questions/select.ts +++ b/src/core/questions/select.ts @@ -2,7 +2,7 @@ import type Config from "@typing/config"; import type GPTAnswer from "@typing/gptAnswer"; import Logs from "@utils/logs"; import normalizeText from "@utils/normalize-text"; -import { pickBestReponse, toPourcentage } from "@utils/pick-best-response"; +import { pickBestReponse } from "@utils/pick-best-response"; /** * Handle select elements (and put in order select) diff --git a/src/utils/normalize-text.ts b/src/utils/normalize-text.ts index 40d0a83..a5321a4 100644 --- a/src/utils/normalize-text.ts +++ b/src/utils/normalize-text.ts @@ -5,7 +5,7 @@ function normalizeText(text: string, toLowerCase: boolean = true) { if (toLowerCase) text = text.toLowerCase(); - let normalizedText = text + const normalizedText = text .replace(/\n+/gi, "\n") //remove duplicate new lines .replace(/(\n\s*\n)+/g, "\n") //remove useless white space from textcontent .replace(/[ \t]+/gi, " ") //replace multiples space or tabs by a space