diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..2f4fec9
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,18 @@
+module.exports = {
+ root: true,
+ parser: '@typescript-eslint/parser',
+ plugins: ['@typescript-eslint'],
+ extends: [
+ 'eslint:recommended',
+ 'plugin:@typescript-eslint/eslint-recommended',
+ 'plugin:@typescript-eslint/recommended',
+ 'prettier'
+ ],
+ ignorePatterns: ['node_modules/'],
+ overrides: [
+ {
+ files: ['extension/popup/*.js', 'src/**/*.ts'],
+ rules: {}
+ }
+ ]
+};
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100644
index 0000000..3e0eb2c
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,3 @@
+#!/bin/bash
+npm run prettier
+npm run lint
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md
new file mode 100644
index 0000000..bda7baf
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md
@@ -0,0 +1,28 @@
+## Bug Report
+
+**Description of the Bug**
+A clear and concise description of the bug.
+
+**Steps to Reproduce**
+
+1. Step 1
+2. Step 2
+3. ...
+
+**Expected Behavior**
+A clear and concise description of what you expected to happen.
+
+**Actual Behavior**
+A clear and concise description of what actually happens.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Tried Solutions**
+Have you tried anything to solve the problem? If yes, what?
+
+**Additional Context**
+Add any other context about the problem here.
+
+**Additional Information**
+Add any other information you think is relevant.
diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
new file mode 100644
index 0000000..3a24437
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
@@ -0,0 +1,16 @@
+## Feature Request
+
+**Description of the Feature**
+A clear and concise description of the feature you'd like to see added.
+
+**Motivation**
+An explanation of the motivation behind this feature. How would it improve the user experience or utility of the software?
+
+**Screenshot (Optional)**
+If possible, add a screenshot or illustration of the feature you're proposing.
+
+**Additional Context**
+Add any other context or information about the feature that you think is relevant.
+
+**Additional Information**
+Add any other information you think is relevant.
diff --git a/.github/ISSUE_TEMPLATE/HELP_REQUEST.md b/.github/ISSUE_TEMPLATE/HELP_REQUEST.md
new file mode 100644
index 0000000..66eddb6
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/HELP_REQUEST.md
@@ -0,0 +1,24 @@
+## Help Request
+
+**Issue Summary**
+
+[Summarize the issue you are facing concisely.]
+
+**Describe the problem**
+
+[Describe what is the problem]
+
+**Environment**
+
+- Operating System: [Your OS]
+- Browser: [Your Browser]
+- Version: [Version Number]
+- Any other relevant information
+
+### Screenshots
+
+[Include any relevant screenshots if they can help illustrate the issue.]
+
+### Additional Information
+
+[Any additional information that may be helpful in diagnosing the issue.]
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000..1849f5e
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,28 @@
+## Pull Request
+
+**Description**
+A brief description of the changes in this pull request.
+
+**Related Issue**
+
+- Fixes # (issue number)
+- Addresses # (issue number)
+
+**Changes Made**
+Describe the changes you've made. Provide a high-level overview of what has been done in this pull request.
+
+**Screenshots (if applicable)**
+Add screenshots or GIFs to demonstrate the changes, if applicable.
+
+**Checklist**
+
+- [ ] I have tested the changes locally.
+- [ ] I have updated the documentation accordingly.
+- [ ] I have added necessary comments to the code.
+- [ ] All tests pass successfully.
+
+**Additional Notes**
+Add any additional notes or comments about the pull request here.
+
+**Reviewer(s)**
+@username1, @username2
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..24b36d7
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,10 @@
+{
+ "semi": true,
+ "singleQuote": true,
+ "tabWidth": 2,
+ "useTabs": false,
+ "printWidth": 100,
+ "trailingComma": "none",
+ "arrowParens": "avoid",
+ "endOfLine": "auto"
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2581e32..d78c3d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,24 +1,37 @@
-# CHANGELOG
-
-## v1.0.3
-
-- Removed the option `table formating` because it will now set to true by default
-- Adjusted the abort timeout to 15seconds
-- If an error occur the user can now click back on the question
-- `Textbox, question to answser mode and clipboard mode` is not formatted anymore
-- Fixed many bugs
-- Write AI system instructions
-
-## v1.0.2
-
-- Added `mode`
-
-## v1.0.1
-
-- Removed langage
-- Added a button next to model to get the last ChatGPT version
-- Added update message
-
-## v1.0.0
-
-- Initial commit
+# CHANGELOG
+
+## v1.1.0
+
+- Bugs correction
+- Adjusted the abort timeout to 20seconds
+- `code` is not required anymore
+- Issue [#9](https://github.com/yoannchb-pro/MoodleGPT/issues/9) resolved
+- GPT model autocompletation
+- Better algorithm to find the correct answer (levenshtein distance)
+- Better ChatGPT prompt
+- Added `history` to the options/configuration
+- Added `include images` to the option/configuration
+- `gpt-4` support
+
+## v1.0.3
+
+- Removed the option `table formating` because it will now set to true by default
+- Adjusted the abort timeout to 15seconds
+- If an error occur the user can now click back on the question
+- `Textbox, question to answser mode and clipboard mode` is not formatted anymore
+- Fixed many bugs
+- Write AI system instructions
+
+## v1.0.2
+
+- Added `mode`
+
+## v1.0.1
+
+- Removed langage
+- Added a button next to model to get the last ChatGPT version
+- Added update message
+
+## v1.0.0
+
+- Initial commit
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..b16e98b
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,76 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, sex characteristics, gender identity and expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+- Using welcoming and inclusive language
+- Being respectful of differing viewpoints and experiences
+- Gracefully accepting constructive criticism
+- Focusing on what is best for the community
+- Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+- The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+- Trolling, insulting/derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+
+[homepage]: https://www.contributor-covenant.org
+
+For answers to common questions about this code of conduct, see
+https://www.contributor-covenant.org/faq
diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md
new file mode 100644
index 0000000..3f2738b
--- /dev/null
+++ b/CONTRIBUTE.md
@@ -0,0 +1,43 @@
+# CONTRIBUTE
+
+When contributing to this repository, please first discuss the change you wish to make via issue,
+email, or any other method with the owners of this repository before making a change.
+
+Please note we have a code of conduct, please follow it in all your interactions with the project.
+
+## Code of Conduct
+
+See the code of conduct [here](./CODE_OF_CONDUCT.md)
+
+## Pull Request Process
+
+1. Update the README.md with details of changes to the extension and update the screens.
+2. Build the project.
+3. Select `dev` as the target branch to prepare the futur version.
+4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
+ do not have permission to do that, you may request the second reviewer to merge it for you.
+
+## Setup the project
+
+```
+node: 18.13.0
+npm: 8.19.2
+```
+
+### 1. Install dependencies
+
+```
+$ npm install
+```
+
+### 2. Setup Git hooks
+
+```
+$ git config --local core.hooksPath .githooks/
+```
+
+### 3. Build project
+
+```
+$ npm run build
+```
diff --git a/README.md b/README.md
index d27055c..1a5318d 100644
--- a/README.md
+++ b/README.md
@@ -1,166 +1,161 @@
-
-
-# MoodleGPT v1.0.3
-
-This extension allows you to hide CHAT-GPT in a Moodle quiz. You just need to enter the code configured in the extension on the keyboard and then click on the question you want to solve, and CHAT-GPT will automatically provide the answer. However, one needs to be careful because as we know, CHAT-GPT can make errors especially in calculations.
-
-## Chrome Webstore
-
-Find the extension on the Chrome Webstore right [here](https://chrome.google.com/webstore/detail/moodlegpt/fgiepdkoifhpcgdhbiikpgdapjdoemko)
-
-## Summary
-
-- [MoodleGPT v1.0.3](#moodlegpt-v103)
- - [Chrome Webstore](#chrome-webstore)
- - [Summary](#summary)
- - [Disclaimer !](#disclaimer-)
- - [Donate](#donate)
- - [Update](#update)
- - [MoodleGPT don't complete my quiz ?](#moodlegpt-dont-complete-my-quiz-)
- - [Set up](#set-up)
- - [Inject the code into the moodle](#inject-the-code-into-the-moodle)
- - [Remove injection](#remove-injection)
- - [Mode](#mode)
- - [Settings](#settings)
- - [Internal Features](#internal-features)
- - [Support table](#support-table)
- - [Supported questions type](#supported-questions-type)
- - [Select](#select)
- - [Put in order question](#put-in-order-question)
- - [Resolve equation](#resolve-equation)
- - [One response (radio button)](#one-response-radio-button)
- - [Multiples responses (checkbox)](#multiples-responses-checkbox)
- - [True or false](#true-or-false)
- - [Number](#number)
- - [Text](#text)
- - [What about if the question can't be completed ?](#what-about-if-the-question-cant-be-completed-)
- - [Test](#test)
-
-## Disclaimer !
-
-I hereby declare that I am not responsible for any misuse or illegal activities carried out using my program. The code is provided for educational and research purposes only, and any use of it outside of these purposes is at the user's own risk.
-
-## Donate
-
-Will be a pleasure if you want to support this project :)
-
-
-
-## Update
-
-See [changelog](./CHANGELOG.md)
-
-## MoodleGPT don't complete my quiz ?
-
-If MoodleGPT cannot complete one of your moodle quiz please provide the html code of the page. It will help us to add it in the futur version of MoodleGPT ! Check the [TODO](./TODO.md) to see what is comming in the futur version.
-
-## Set up
-
-> NOTE: This extension only works on Chromium-based browsers like Edge, Chrome, etc. Unfortunately, Firefox requires a click on the extension, which is not very discreet.
-
-
-
-
-
-Go to "Manage my extensions" on your browser, then click on "Load unpacked extension" and select the "extension" folder. Afterwards, click on the extension icon and enter the apiKey obtained from [openai](https://platform.openai.com/) and enter a code that will activate the extension on your moodle page. Finally, click on the reload button next to model (it should give you the last ChatGPT version, otherwise enter it by your self) and click on the save button (The extension need to be configured before entering the moodle quiz).
-
-## Inject the code into the moodle
-
-You just need to enter on the keyboard the code you have set into the extension and click on the question you want to solve.
-
-## Remove injection
-
-Type back the code on the keyboard and the code will be removed from the current page.
-
-## Mode
-
-
-
-
-
-- Autocomplete: The extension will complete the question for you.
-- Clipboard: The response is copied into the clipboard.
-- Question to answer: The question is converted to the answer and you can click on it to show back the question (or show back the answer).
-
-
-## Settings
-
-
-
-
-
-- Api key: the openai api key.
-- Code: code that you will need to inject/remove the code.
-- GPT Model: the gpt model you want to use. You can click on the reload button to get the latest version of available gpt model for your account but you need to enter the api key first.
-- Cursor indication: show a pointer cursor and a hourglass to know when the request is finished.
-- Title indication: show some informations into the title to know for example if the code have been injected.
- 
-- Console logs: show logs into the console.
-
-- Request timeout: if the request is too long it will be abort after 15seconds.
-- Typing effect: create a typing effect for text. Type any text and it will be replaced by the correct one. If you want to stop it press Backspace key.
- 
-- Mouseover effect: you will need to hover (or click for select) the question response to complete it automaticaly.
- 
- 
-
-- Infinite try: click as much as you want on the question (don't forget to reset the question).
-
-## Internal Features
-
-### Support table
-
-Table are formated from the question to make it more readable for CHAT-GPT. Example of formatted table output:
-
-```
-| id | name | birthDate | cars |
-----------------------------------------
-| Person 1 | Yvick | 15/08/1999 | yes |
-| Person 2 | Yann | 19/01/2000 | no |
-```
-
-## Supported questions type
-
-### Select
-
-
-
-### Put in order question
-
-
-
-### Resolve equation
-
-
-
-### One response (radio button)
-
-
-
-### Multiples responses (checkbox)
-
-
-
-### True or false
-
-
-
-### Number
-
-
-
-### Text
-
-
-
-## What about if the question can't be completed ?
-
-To know if the answer has been copied to the clipboard, you can look at the title of the page which will become "Copied to clipboard" for 3 seconds.
-
-
-
-## Test
-
-To test the code, you can run the index.html file located in the "test/fake-moodle" folder. Or a better solution is to install moodle locally.
+
+
+# MoodleGPT 1.1.0
+
+This extension allows you to hide CHAT-GPT in a Moodle quiz. You just need to click on the question you want to solve, and CHAT-GPT will automatically provide the answer. However, one needs to be careful because as we know, CHAT-GPT can make errors especially in calculations.
+
+## Chrome Webstore
+
+Find the extension on the Chrome Webstore right [here](https://chrome.google.com/webstore/detail/moodlegpt/fgiepdkoifhpcgdhbiikpgdapjdoemko)
+
+## Summary
+
+- [MoodleGPT 1.1.0](#moodlegpt-110)
+ - [Chrome Webstore](#chrome-webstore)
+ - [Summary](#summary)
+ - [Disclaimer !](#disclaimer-)
+ - [Donate](#donate)
+ - [Update](#update)
+ - [Set up](#set-up)
+ - [Mode](#mode)
+ - [Settings](#settings)
+ - [Internal other features](#internal-other-features)
+ - [Support table](#support-table)
+ - [Supported questions type](#supported-questions-type)
+ - [Select](#select)
+ - [Put in order question](#put-in-order-question)
+ - [Resolve equation](#resolve-equation)
+ - [One response (radio button)](#one-response-radio-button)
+ - [Multiples responses (checkbox)](#multiples-responses-checkbox)
+ - [True or false](#true-or-false)
+ - [Number](#number)
+ - [Text](#text)
+ - [What about if the question can't be autocompleted ?](#what-about-if-the-question-cant-be-autocompleted-)
+ - [Test](#test)
+ - [Beta version with advanced features](#beta-version-with-advanced-features)
+
+## Disclaimer !
+
+I hereby declare that I am not responsible for any misuse or illegal activities carried out using my program. The code is provided for educational and research purposes only, and any use of it outside of these purposes is at the user's own risk.
+
+## Donate
+
+Will be a pleasure if you want to support this project :). I'm alone working on this project and I'm still a student.
+
+
+
+## Update
+
+See the [changelog](./CHANGELOG.md) to see every updates !
+
+## Set up
+
+> NOTE: This extension only works on Chromium-based browsers like Edge, Chrome, etc.
+
+
+
+
+
+Go to "Manage my extensions" on your browser, then click on "Load unpacked extension" and select the "extension" folder. Afterwards, click on the extension icon and enter the ApiKey obtained from [openai api](https://platform.openai.com/api-keys). Finally, select a [gpt model](https://platform.openai.com/docs/models) (ensure it work with completion api).
+
+## Mode
+
+
+
+
+
+- Autocomplete: The extension will complete the question for you by selecting the correct(s) answer(s).
+- Clipboard: The response is copied into the clipboard.
+- Question to answer: The question is converted to the answer and you can click on it to show back the question (or show back the answer).
+
+
+## Settings
+
+
+
+
+
+- Api key\*: the [openai api key](https://platform.openai.com/api-keys) from your account (Note you have to put credits by entering a credit card onto your account).
+- GPT Model\*: the [gpt model](https://platform.openai.com/docs/models) you want to use.
+- Code: a code to be more discret for injecting/removing the extension from the page. Simply type your code you entered into the configuration on the keyboard when you are on your moodle quiz and the extension will be inject. If you want to remove the injection just simply type back the code on your keyboard.
+- Cursor indication: show a pointer cursor and a hourglass to know when the request is finished.
+- Title indication: show some informations into the title to know for example if the code have been injected.
+ 
+- Console logs: show logs into the console for the question, chatgpt answer and which response has been chosen.
+
+- Request timeout: if the request is too long it will be abort after 20 seconds.
+- Typing effect: create a typing effect for text. Type any text and it will be replaced by the correct one. If you want to stop it press Backspace key.
+ 
+- Mouseover effect: you will need to hover (or click for select) the question response to complete it automaticaly.
+ 
+ 
+- Infinite try: click as much as you want on the question (don't forget to reset the question).
+- Save history: allows you to create a conversation with ChatGPT by saving the previous question with its answer. However, note that it can consume a significant number of tokens.
+- Include images (only work with gpt-4): allows you to include the images from the question to be send to the chatgpt api. The quality is reduced to 75% to use less tokens. However, note that it can consume a significant number of tokens.
+ 
+
+## Internal other features
+
+### Support table
+
+Table are formated from the question to make it more readable for CHAT-GPT. Example of formatted table output:
+
+```
+id | name | birthDate | cars
+------------------------------------
+Person 1 | Yvick | 15/08/1999 | yes
+Person 2 | Yann | 19/01/2000 | no
+```
+
+
+
+## Supported questions type
+
+### Select
+
+
+
+### Put in order question
+
+
+
+### Resolve equation
+
+
+
+### One response (radio button)
+
+
+
+### Multiples responses (checkbox)
+
+
+
+### True or false
+
+
+
+### Number
+
+
+
+### Text
+
+
+
+## What about if the question can't be autocompleted ?
+
+To know if the answer has been copied to the clipboard, you can look at the title of the page which will become "Copied to clipboard" for 3 seconds if `Title indication` is on.
+
+
+
+## Test
+
+- Solution 1: Go on [this moodle test page](https://school.moodledemo.net/login/index.php) (username: `student`, password: `moodle`) and choose any quiz.
+- Solution 2: Run the `index.html` file located in the `test/fake-moodle` folder.
+
+## Beta version with advanced features
+
+If you're interested in accessing advanced features ahead of their official release, please consider downloading the extension from the [dev branch](https://github.com/yoannchb-pro/MoodleGPT/tree/dev). However, please be aware that this branch is under development and may contain bugs. If you encounter any issues, don't hesitate to contact me or create an issue on GitHub. Your feedback is invaluable in helping us improve the extension.
diff --git a/TODO.md b/TODO.md
index 0ba115e..4640904 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,16 +1 @@
-# TODO
-
-## Priority: 1
-
-- [ ] Fixe put in order
-- [ ] Make some tests
-
-## Priority: 2
-
-## Priority: 3 (because hard to make)
-
-- [ ] Increment question when there is statement (hard because it is often on another page)
-- [ ] Support math equation from image stocked in the `data-mathml` attribute
-- [ ] Try something to understand images like (image -> ascii or may be using other AI ?)
-- [ ] Support multiple input type in a question
-- [ ] Support drag and drop quiz
+# TODO
diff --git a/assets/images.gif b/assets/images.gif
new file mode 100644
index 0000000..84fc686
Binary files /dev/null and b/assets/images.gif differ
diff --git a/assets/logs.png b/assets/logs.png
index 612d7f7..918914d 100644
Binary files a/assets/logs.png and b/assets/logs.png differ
diff --git a/assets/popup.png b/assets/popup.png
index 673dcab..601e817 100644
Binary files a/assets/popup.png and b/assets/popup.png differ
diff --git a/assets/settings.png b/assets/settings.png
index d85e836..568e261 100644
Binary files a/assets/settings.png and b/assets/settings.png differ
diff --git a/assets/setup.png b/assets/setup.png
index d326e0e..6e68157 100644
Binary files a/assets/setup.png and b/assets/setup.png differ
diff --git a/assets/table.gif b/assets/table.gif
new file mode 100644
index 0000000..f26bf2d
Binary files /dev/null and b/assets/table.gif differ
diff --git a/extension/MoodleGPT.js b/extension/MoodleGPT.js
index a44c165..cd2a9d2 100644
--- a/extension/MoodleGPT.js
+++ b/extension/MoodleGPT.js
@@ -1,2 +1,2 @@
-!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e){const t=document.title;document.title=e,setTimeout((()=>document.title=t),3e3)}function t(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function l(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,l)}c((o=o.apply(e,t||[])).next())}))}class n{static question(e){console.log("%c[QUESTION]: %s","color: cyan",e)}static responseTry(e,t){const n="color: "+(t?"green":"red");console.log("%c[CHECKING]: %s",n,e)}static array(e){console.log("[CORRECTS] ",e)}static response(e){console.log("Original:\n"+e.response),console.log("Normalized:\n"+e.normalizedResponse)}}function o(e,t=!0){let n=e.replace(/\n+/gi,"\n").replace(/(\n\s*\n)+/g,"\n").replace(/[ \t]+/gi," ");return t&&(n=n.toLowerCase()),n.trim().replace(/^[a-z\d]\.\s/gi,"").replace(/\n[a-z\d]\.\s/gi,"\n")}function r(e){const t=[],n=Array.from(e.querySelectorAll("tr")),o=[];n.map((e=>{const n=Array.from(e.querySelectorAll("td, th")).map(((e,t)=>{var n;const r=null===(n=e.textContent)||void 0===n?void 0:n.trim();return o[t]=Math.max(o[t]||0,r.length||0),r}));t.push(n)}));const r=o.reduce(((e,t)=>e+t))+3*t[0].length+1,s="\n"+Array(r).fill("-").join("")+"\n",i=t.map((e=>"| "+e.map(((e,t)=>e.padEnd(o[t]," "))).join(" | ")+" |"));return i.shift()+s+i.join("\n")}function s(e,t,r){const s=null==t?void 0:t[0];if(!s||"checkbox"!==s.type&&"radio"!==s.type)return!1;for(const s of t){const t=o(s.parentNode.textContent),i=r.normalizedResponse.includes(t);e.logs&&n.responseTry(t,i),i&&(e.mouseover?s.addEventListener("mouseover",(()=>s.checked=!0),{once:!0}):s.checked=!0)}return!0}function i(e,t,r){if(0===t.length||"SELECT"!==t[0].tagName)return!1;let s=r.normalizedResponse.split("\n");e.logs&&n.array(s),s.length===2*t.length&&(s=s.filter(((e,t)=>t%2==1)));for(let r=0;r{const o=t.includes(r);return e.logs&&n.responseTry(r,o),o}));if(-1!==l){e.mouseover?i[l+1].closest("select").addEventListener("click",(function(){i[l+1].selected="selected"}),{once:!0}):i[l+1].selected="selected";break}}if(e.logs&&n.responseTry(l,c),c){e.mouseover?t.closest("select").addEventListener("click",(()=>t.selected=!0),{once:!0}):t.selected=!0;break}}}return!0}function l(e,t,n){const o=t[0];if(1!==t.length||"TEXTAREA"!==o.tagName&&"text"!==o.type)return!1;if(e.typing){let e=0;o.addEventListener("keydown",(function(t){"Backspace"===t.key&&(e=n.response.length+1),e>n.response.length||(t.preventDefault(),o.value=n.response.slice(0,++e))}))}else o.value=n.response;return!0}function c(t,n){t.title&&e("Copied to clipboard"),navigator.clipboard.writeText(n.response)}function a(e,t,n){var o,r;const s=t[0];if(1!==t.length||"number"!==s.type)return!1;const i=null===(r=null===(o=n.normalizedResponse.match(/\d+([,\.]\d+)?/gi))||void 0===o?void 0:o[0])||void 0===r?void 0:r.replace(",",".");if(!i)return!1;if(e.typing){let e=0;s.addEventListener("keydown",(function(t){"Backspace"===t.key&&(e=i.length+1),e>i.length||(t.preventDefault(),"."===i.slice(e,e+1)&&++e,s.value=i.slice(0,++e))}))}else s.value=i;return!0}function u(e,t,n){const o=t[0];if(1!==t.length||"true"!==o.getAttribute("contenteditable"))return!1;if(e.typing){let e=0;o.addEventListener("keydown",(function(t){if("Backspace"===t.key&&(e=n.response.length+1),e>n.response.length)return;t.preventDefault(),o.textContent=n.response.slice(0,++e),o.focus();const r=document.createRange();r.selectNodeContents(o),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}))}else o.textContent=n.response;return!0}function d(e,d,f,p){return t(this,void 0,void 0,(function*(){e.cursor&&(d.style.cursor="wait");const h=function(e,t){let n=t.innerText;const s=t.querySelectorAll(".accesshide");for(const e of s)n=n.replace(e.innerText,"");const i=t.querySelectorAll(".qtext table");for(const e of i)n=n.replace(e.innerText,"\n"+r(e)+"\n");return o(n,!1)}(0,f),g=f.querySelectorAll(p),y=yield function(e,n){return t(this,void 0,void 0,(function*(){const t=new AbortController,r=setTimeout((()=>t.abort()),15e3),s=yield fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},signal:e.timeout?t.signal:null,body:JSON.stringify({model:e.model,messages:[{role:"system",content:"\nFollow those rules:\n- Sometimes there won't be a question, so just answer the statement as you normally would without following the other rules and give the most detailled and complete answer with explication.\n- For put in order question just give the good order separate by new line\n- Your goal is to understand the statement and to reply to each question by giving only the answer.\n- You will keep the same order for the answers like in the text. \n- You will separate all the answer with new lines and only show the correctes one.\n- You will only give the answers for each question and omit the questions, statement, title or other informations from the response.\n- You will only give answer with exactly the same text as the gived answers.\n- The question always have the good answer so you should always give an answer to the question.\n- You will always respond in the same langage as the user question."},{role:"user",content:n}],temperature:.8,top_p:1,presence_penalty:1,stop:null})});clearTimeout(r);const i=(yield s.json()).choices[0].message.content;return{response:i,normalizedResponse:o(i)}}))}(e,h).catch((e=>({error:e}))),v="object"==typeof y&&"error"in y;if(e.cursor&&(d.style.cursor=e.infinite||v?"pointer":"initial"),v)return void console.error(y.error);if(e.logs&&(n.question(h),n.response(y)),"clipboard"===e.mode)return e.infinite||m(d),c(e,y);if("question-to-answer"===e.mode){m(d);const e=f.querySelector(".qtext"),t=e.textContent;return e.textContent=y.response,e.style.whiteSpace="pre-wrap",void e.addEventListener("click",(function(){const n=e.textContent===t;e.style.whiteSpace=n?"pre-wrap":null,e.textContent=n?y.response:t}))}e.infinite||m(d);const w=[u,l,a,i,s];for(const t of w)if(t(e,g,y))return;c(e,y)}))}const f=[],p=[];function h(t){document.body.addEventListener("keydown",(function(n){f.push(n.key),f.length>t.code.length&&f.shift(),f.join("")===t.code&&(f.length=0,function(t){if(p.length>0){for(const e of p)t.cursor&&(e.element.style.cursor="initial"),e.element.removeEventListener("click",e.fn);return t.title&&e("Removed"),void(p.length=0)}const n=["checkbox","radio","text","number"].map((e=>`input[type="${e}"]`)).join(",")+", textarea, select, [contenteditable]",o=document.querySelectorAll(".formulation");for(const e of o){const o=e.querySelector(".qtext");t.cursor&&(o.style.cursor="pointer");const r=d.bind(null,t,o,e,n);p.push({element:o,fn:r}),o.addEventListener("click",r)}t.title&&e("Injected")}(t))}))}function m(e){const t=p.findIndex((t=>t.element===e));if(-1!==t){const e=p.splice(t,1)[0];e.element.removeEventListener("click",e.fn)}}chrome.storage.sync.get(["moodleGPT"]).then((function(e){const t=e.moodleGPT;if(!t)throw new Error("Please configure MoodleGPT into the extension");h(t)}))}));
+!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e){const n=document.title;document.title=e,setTimeout((()=>document.title=n),3e3)}function n(e,n,t,o){return new(t||(t=Promise))((function(r,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function l(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(s,l)}c((o=o.apply(e,n||[])).next())}))}function t(e,n){const t=e.length>n.length?e.length:n.length;return 0===t?1:(t-function(e,n){if(0===e.length)return n.length;if(0===n.length)return e.length;const t=[],o=e.replace(/\s+/,""),r=n.replace(/\s+/,"");for(let e=0;e<=o.length;++e){t.push([e]);for(let n=1;n<=r.length;++n)t[e][n]=0===e?n:Math.min(t[e-1][n]+1,t[e][n-1]+1,t[e-1][n-1]+(o[e-1]===r[n-1]?0:1))}return t[o.length][r.length]}(e,n))/t}function o(e,n){let o={element:null,similarity:0,value:null};for(const r of n){const n=t(r.value,e);if(1===n)return{element:r.element,value:r.value,similarity:n};n>o.similarity&&(o={element:r.element,value:r.value,similarity:n})}return o}"function"==typeof SuppressedError&&SuppressedError;class r{static question(e){console.log("%c[QUESTION]: %s","color: cyan",e)}static bestAnswer(e,n){console.log("%c[BEST ANSWER]: %s","color: green",`"${e}" with a similarity of ${function(e){return Math.round(100*e*100)/100+"%"}(n)}`)}static array(e){console.log("[CORRECTS] ",e)}static response(e){console.log("Original:\n"+e.response),console.log("Normalized:\n"+e.normalizedResponse)}}function i(e,n=!0){n&&(e=e.toLowerCase());return e.replace(/\n+/gi,"\n").replace(/(\n\s*\n)+/g,"\n").replace(/[ \t]+/gi," ").trim().replace(/^[a-z\d]\.\s/gi,"").replace(/\n[a-z\d]\.\s/gi,"\n")}var s,l;!function(e){e.SYSTEM="system",e.USER="user",e.ASSISTANT="assistant"}(s||(s={})),function(e){e.TEXT="text",e.IMAGE="image_url"}(l||(l={}));const c="\nAct as a quiz solver for the best notation with the following rules:\n- If no answer(s) are given, answer the statement as usual without following the other rules, providing the most detailed, complete and precise explanation. \n- But for the calculation provide this format 'result: '\n- For 'put in order' questions, maintain the answer in the order as presented in the question but assocy the correct order to it by usin this format ':\n:', ignore other rules.\n- Always reply in the format: '\n\n...'.\n- Retain only the correct answer(s).\n- Maintain the same order for the answers as in the text.\n- Retain all text from the answer with its description, content or definition.\n- Only provide answers that exactly match the given answer in the text.\n- The question always has the correct answer(s), so you should always provide an answer.\n- Always respond in the same language as the user's question.\n".trim(),a={role:s.SYSTEM,content:c};function u(e,t,o){return n(this,void 0,void 0,(function*(){const n=t.querySelectorAll("img");if(!e.includeImages||!function(e){const n=e.match(/gpt-(\d+)/);return!!(null==n?void 0:n[1])&&Number(n[1])>=4}(e.model)||0===n.length)return o;const r=[],i=Array.from(n).map((e=>function(e,n=.75){return new Promise(((t,o)=>{const r=document.createElement("canvas"),i=r.getContext("2d");if(!i)return o("Can't get the canvas context, ensure your navigator support canvas"),void r.remove();const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{r.width=s.width,r.height=s.height,i.drawImage(s,0,0);const e=r.toDataURL("image/png",n);t(e),r.remove()},s.onerror=e=>{o(e),r.remove()},s.src=e.src}))}(e))),s=yield Promise.allSettled(i);for(const n of s)"fulfilled"===n.status?r.push({type:l.IMAGE,image_url:{url:n.value}}):e.logs&&console.error(n.reason);return r.push({type:l.TEXT,text:o}),r}))}function f(e,t,o){return n(this,void 0,void 0,(function*(){const n=yield u(e,t,o),r={role:s.USER,content:n};if(!e.history)return{messages:[a,r]};let i;const l=JSON.parse(null!==(c=sessionStorage.moodleGPTHistory)&&void 0!==c?c:"null");var c;const f=function(){var e,n;const t=new URLSearchParams(document.location.search);return{host:document.location.host,cmid:null!==(e=t.get("cmid"))&&void 0!==e?e:"",attempt:null!==(n=t.get("attempt"))&&void 0!==n?n:"",history:[]}}();return i=null!==l&&function(e,n){const t=["host","cmid","attempt"];for(const o of t)if(e[o]!==n[o])return!1;return!0}(l,f)?l:f,{messages:[a,...i.history,r],saveResponse(n){e.history&&(i.history.push(r),i.history.push({role:s.ASSISTANT,content:n}),sessionStorage.moodleGPTHistory=JSON.stringify(i))}}}))}function m(e){const n=[],t=Array.from(e.querySelectorAll("tr")),o=[];t.map((e=>{const t=Array.from(e.querySelectorAll("td, th")).map(((e,n)=>{var t;const r=null===(t=e.textContent)||void 0===t?void 0:t.trim();return o[n]=Math.max(o[n]||0,(null==r?void 0:r.length)||0),null!=r?r:""}));n.push(t)}));const r=n[0].length,i=o.reduce(((e,n)=>e+n),0)+3*(r-1),s="\n"+Array(i).fill("-").join("")+"\n",l=n.map((e=>e.map(((e,n)=>e.padEnd(o[n]," "))).join(" | ")));return l.shift()+s+l.join("\n")}function d(n,t){n.title&&e("Copied to clipboard"),navigator.clipboard.writeText(t.response)}function p(e,n,t){const o=n[0];if(1!==n.length||"true"!==o.getAttribute("contenteditable"))return!1;if(e.typing){let e=0;o.addEventListener("keydown",(function(n){if("Backspace"===n.key&&(e=t.response.length+1),e>t.response.length)return;n.preventDefault(),o.textContent=t.response.slice(0,++e),o.focus();const r=document.createRange();r.selectNodeContents(o),r.collapse(!1);const i=window.getSelection();null!==i&&(i.removeAllRanges(),i.addRange(r))}))}else o.textContent=t.response;return!0}function h(e,n,t){var o,r;const i=n[0];if(1!==n.length||"number"!==i.type)return!1;const s=null===(r=null===(o=t.normalizedResponse.match(/\d+([,.]\d+)?/gi))||void 0===o?void 0:o[0])||void 0===r?void 0:r.replace(",",".");if(void 0===s)return!1;if(e.typing){let e=0;i.addEventListener("keydown",(function(n){n.preventDefault(),"Backspace"===n.key&&(e=s.length+1),e>s.length||("."===s.slice(e,e+1)&&++e,i.value=s.slice(0,++e))}))}else i.value=s;return!0}function g(e,n,t){const s=null==n?void 0:n[0];if(!s||"radio"!==s.type)return!1;const l=Array.from(n).map((e=>{var n,t;return{element:e,value:i(null!==(t=null===(n=null==e?void 0:e.parentElement)||void 0===n?void 0:n.textContent)&&void 0!==t?t:"")}})).filter((e=>""!==e.value)),c=o(t.normalizedResponse,l);e.logs&&c.value&&r.bestAnswer(c.value,c.similarity);const a=c.element;return e.mouseover?a.addEventListener("mouseover",(()=>a.click()),{once:!0}):a.click(),!0}function v(e,n,t){const s=null==n?void 0:n[0];if(!s||"checkbox"!==s.type)return!1;const l=t.normalizedResponse.split("\n"),c=Array.from(n).map((e=>{var n,t;return{element:e,value:i(null!==(t=null===(n=null==e?void 0:e.parentElement)||void 0===n?void 0:n.textContent)&&void 0!==t?t:"")}})).filter((e=>""!==e.value));for(const n of l){const t=o(n,c);e.logs&&t.value&&r.bestAnswer(t.value,t.similarity);const i=t.element;e.mouseover?i.addEventListener("mouseover",(()=>i.click()),{once:!0}):i.click()}return!0}function y(e,n,t){if(0===n.length||"SELECT"!==n[0].tagName)return!1;const s=t.normalizedResponse.split("\n");e.logs&&r.array(s);for(let t=0;t{var n;return{element:e,value:i(null!==(n=e.textContent)&&void 0!==n?n:"")}})).filter((e=>""!==e.value)),a=o(s[t],c);e.logs&&a.value&&r.bestAnswer(a.value,a.similarity);const u=a.element,f=u.closest("select");null!==f&&(e.mouseover?f.addEventListener("click",(()=>u.selected=!0),{once:!0}):u.selected=!0)}return!0}function w(e,n,t){const o=n[0];if(1!==n.length||"TEXTAREA"!==o.tagName&&"text"!==o.type)return!1;if(e.typing){let e=0;o.addEventListener("keydown",(function(n){n.preventDefault(),"Backspace"===n.key&&(e=t.response.length+1),e>t.response.length||(o.value=t.response.slice(0,++e))}))}else o.value=t.response;return!0}function A(e){return n(this,void 0,void 0,(function*(){e.config.cursor&&(e.questionElement.style.cursor="wait");const t=function(e){let n=e.innerText;const t=e.querySelectorAll(".accesshide");for(const e of t)n=n.replace(e.innerText,"");const o=e.querySelectorAll(".qtext table");for(const e of o)n=n.replace(e.innerText,"\n"+m(e)+"\n");return i(n,!1)}(e.form),o=e.form.querySelectorAll(e.inputQuery),s=yield function(e,t,o){return n(this,void 0,void 0,(function*(){const n=new AbortController,r=setTimeout((()=>n.abort()),2e4),s=yield f(e,t,o),l=yield fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},signal:e.timeout?n.signal:null,body:JSON.stringify({model:e.model,messages:s.messages,temperature:.1,top_p:.6,presence_penalty:0,max_tokens:2e3})});clearTimeout(r);const c=(yield l.json()).choices[0].message.content;return"function"==typeof s.saveResponse&&s.saveResponse(c),{question:o,response:c,normalizedResponse:i(c)}}))}(e.config,e.questionElement,t).catch((e=>({error:e}))),l="object"==typeof s&&"error"in s;if(e.config.cursor&&(e.questionElement.style.cursor=e.config.infinite||l?"pointer":"initial"),l)console.error(s.error);else switch(e.config.logs&&(r.question(t),r.response(s)),e.config.mode){case"clipboard":!function(e){e.config.infinite||e.removeListener(),d(e.config,e.gptAnswer)}({config:e.config,questionElement:e.questionElement,gptAnswer:s,removeListener:e.removeListener});break;case"question-to-answer":!function(e){var n;const t=e.questionElement;e.removeListener();const o=null!==(n=t.innerHTML)&&void 0!==n?n:"";t.innerHTML=e.gptAnswer.response,t.style.whiteSpace="pre-wrap",t.addEventListener("click",(function(){const n=t.innerHTML===e.gptAnswer.response;t.style.whiteSpace=n?"initial":"pre-wrap",t.innerHTML=n?o:e.gptAnswer.response}))}({gptAnswer:s,questionElement:e.questionElement,removeListener:e.removeListener});break;case"autocomplete":!function(e){e.config.infinite||e.removeListener();const n=[p,w,h,y,g,v];for(const t of n)if(t(e.config,e.inputList,e.gptAnswer))return;d(e.config,e.gptAnswer)}({config:e.config,gptAnswer:s,inputList:o,questionElement:e.questionElement,removeListener:e.removeListener})}}))}const E=[],S=[];function T(e){const n=S.findIndex((n=>n.element===e));if(-1!==n){const e=S.splice(n,1)[0];e.element.removeEventListener("click",e.fn)}}function q(n){if(S.length>0){for(const e of S)n.cursor&&(e.element.style.cursor="initial"),e.element.removeEventListener("click",e.fn);return n.title&&e("Removed"),void(S.length=0)}const t=["checkbox","radio","text","number"].map((e=>`input[type="${e}"]`)).join(",")+", textarea, select, [contenteditable]",o=document.querySelectorAll(".formulation");for(const e of o){const o=e.querySelector(".qtext");if(null===o)continue;n.cursor&&(o.style.cursor="pointer");const r=A.bind(null,{config:n,questionElement:o,form:e,inputQuery:t,removeListener:()=>T(o)});S.push({element:o,fn:r}),o.addEventListener("click",r)}n.title&&e("Injected")}chrome.storage.sync.get(["moodleGPT"]).then((function(e){const n=e.moodleGPT;if(!n)throw new Error("Please configure MoodleGPT into the extension");n.code?function(e){document.body.addEventListener("keydown",(function(n){E.push(n.key),E.length>e.code.length&&E.shift(),E.join("")===e.code&&(E.length=0,q(e))}))}(n):q(n)}))}));
//# sourceMappingURL=MoodleGPT.js.map
diff --git a/extension/MoodleGPT.js.map b/extension/MoodleGPT.js.map
index e43d28b..655f9fe 100644
--- a/extension/MoodleGPT.js.map
+++ b/extension/MoodleGPT.js.map
@@ -1 +1 @@
-{"version":3,"file":"MoodleGPT.js","sources":["../src/utils/title-indications.ts","../node_modules/tslib/tslib.es6.js","../src/utils/logs.ts","../src/utils/normalize-text.ts","../src/utils/html-table-to-string.ts","../src/core/questions/radio-checkbox.ts","../src/core/questions/select.ts","../src/core/questions/textbox.ts","../src/core/questions/clipboard.ts","../src/core/questions/number.ts","../src/core/questions/contenteditable.ts","../src/core/reply.ts","../src/core/create-question.ts","../src/core/get-response.ts","../src/core/code-listener.ts","../src/index.ts"],"sourcesContent":["/**\r\n * Show some informations into the document title and remove it after 3000ms\r\n * @param text\r\n */\r\nfunction titleIndications(text: string) {\r\n const backTitle = document.title;\r\n document.title = text;\r\n setTimeout(() => (document.title = backTitle), 3000);\r\n}\r\n\r\nexport default titleIndications;\r\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.push(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.push(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import GPTAnswer from \"../types/gptAnswer\";\r\nclass Logs {\r\n static question(text: string) {\r\n const css = \"color: cyan\";\r\n console.log(\"%c[QUESTION]: %s\", css, text);\r\n }\r\n\r\n static responseTry(text: string, valide: boolean) {\r\n const css = \"color: \" + (valide ? \"green\" : \"red\");\r\n console.log(\"%c[CHECKING]: %s\", css, text);\r\n }\r\n\r\n static array(arr: unknown[]) {\r\n console.log(\"[CORRECTS] \", arr);\r\n }\r\n\r\n static response(gptAnswer: GPTAnswer) {\r\n console.log(\"Original:\\n\" + gptAnswer.response);\r\n console.log(\"Normalized:\\n\" + gptAnswer.normalizedResponse);\r\n }\r\n}\r\n\r\nexport default Logs;\r\n","/**\r\n * Normlize text\r\n * @param text\r\n */\r\nfunction normalizeText(text: string, toLowerCase: boolean = true) {\r\n let normalizedText = text\r\n .replace(/\\n+/gi, \"\\n\") //remove duplicate new lines\r\n .replace(/(\\n\\s*\\n)+/g, \"\\n\") //remove useless white sapce from textcontent\r\n .replace(/[ \\t]+/gi, \" \"); //replace multiples space or tabs by a space\r\n\r\n if (toLowerCase) normalizedText = normalizedText.toLowerCase();\r\n\r\n return (\r\n normalizedText\r\n .trim()\r\n /* We remove that because sometimes ChatGPT will reply: \"answer d\" */\r\n .replace(/^[a-z\\d]\\.\\s/gi, \"\") //a. text, b. text, c. text, 1. text, 2. text, 3.text\r\n .replace(/\\n[a-z\\d]\\.\\s/gi, \"\\n\") //same but with new line\r\n );\r\n}\r\n\r\nexport default normalizeText;\r\n","/**\r\n * Convert table to representating string table\r\n * @param table\r\n * @returns\r\n */\r\nfunction htmlTableToString(table: HTMLTableElement) {\r\n const tab: string[][] = [];\r\n const lines = Array.from(table.querySelectorAll(\"tr\"));\r\n const maxColumnsLength: number[] = [];\r\n lines.map((line) => {\r\n const cells = Array.from(line.querySelectorAll(\"td, th\"));\r\n const cellsContent = cells.map((cell, index) => {\r\n const content = cell.textContent?.trim();\r\n maxColumnsLength[index] = Math.max(\r\n maxColumnsLength[index] || 0,\r\n content.length || 0\r\n );\r\n return content;\r\n });\r\n tab.push(cellsContent);\r\n });\r\n\r\n const lineSeparationSize =\r\n maxColumnsLength.reduce((a, b) => a + b) + tab[0].length * 3 + 1;\r\n const lineSeparation =\r\n \"\\n\" + Array(lineSeparationSize).fill(\"-\").join(\"\") + \"\\n\";\r\n\r\n const mappedTab = tab.map((line) => {\r\n const mappedLine = line.map((content, index) =>\r\n content.padEnd(\r\n maxColumnsLength[index],\r\n \"\\u00A0\" /* For no matching with \\s */\r\n )\r\n );\r\n return \"| \" + mappedLine.join(\" | \") + \" |\";\r\n });\r\n const head = mappedTab.shift();\r\n return head + lineSeparation + mappedTab.join(\"\\n\");\r\n}\r\n\r\nexport default htmlTableToString;\r\n","import Config from \"../../types/config\";\r\nimport GPTAnswer from \"../../types/gptAnswer\";\r\nimport Logs from \"../../utils/logs\";\r\nimport normalizeText from \"../../utils/normalize-text\";\r\n\r\n/**\r\n * Handle checkbox and input elements\r\n * @param config\r\n * @param inputList\r\n * @param gptAnswer\r\n */\r\nfunction handleRadioAndCheckbox(\r\n config: Config,\r\n inputList: NodeListOf,\r\n gptAnswer: GPTAnswer\r\n): boolean {\r\n const input = inputList?.[0] as HTMLInputElement;\r\n\r\n if (!input || (input.type !== \"checkbox\" && input.type !== \"radio\"))\r\n return false;\r\n\r\n for (const input of inputList as NodeListOf) {\r\n const content = normalizeText(input.parentNode.textContent);\r\n const valide = gptAnswer.normalizedResponse.includes(content);\r\n if (config.logs) Logs.responseTry(content, valide);\r\n if (valide) {\r\n if (config.mouseover) {\r\n input.addEventListener(\"mouseover\", () => (input.checked = true), {\r\n once: true,\r\n });\r\n } else {\r\n input.checked = true;\r\n }\r\n }\r\n }\r\n return true;\r\n}\r\n\r\nexport default handleRadioAndCheckbox;\r\n","import Config from \"../../types/config\";\r\nimport GPTAnswer from \"../../types/gptAnswer\";\r\nimport Logs from \"../../utils/logs\";\r\nimport normalizeText from \"../../utils/normalize-text\";\r\n\r\n/**\r\n * Handle select elements (and put in order select)\r\n * @param config\r\n * @param inputList\r\n * @param gptAnswer\r\n * @returns\r\n */\r\nfunction handleSelect(\r\n config: Config,\r\n inputList: NodeListOf,\r\n gptAnswer: GPTAnswer\r\n): boolean {\r\n if (inputList.length === 0 || inputList[0].tagName !== \"SELECT\") return false;\r\n\r\n let correct = gptAnswer.normalizedResponse.split(\"\\n\");\r\n\r\n if (config.logs) Logs.array(correct);\r\n\r\n /**\r\n * Sometimes ChatGPT give the question so we should remove them\r\n * Example:\r\n * 5*5\r\n * 25\r\n * 10+10\r\n * 20\r\n * 20-10\r\n * 10\r\n *\r\n * And we only want to keep answers\r\n * 25\r\n * 20\r\n * 10\r\n */\r\n if (correct.length === inputList.length * 2) {\r\n correct = correct.filter((answer, index) => index % 2 === 1);\r\n }\r\n\r\n for (let j = 0; j < inputList.length; ++j) {\r\n const options = inputList[j].querySelectorAll(\"option\");\r\n\r\n for (const option of options) {\r\n const content = normalizeText(option.textContent);\r\n const valide = correct[j].includes(content);\r\n\r\n /* Handle put in order question */\r\n if (!/[^\\d]+/gi.test(content)) {\r\n const elementTitle = (option.parentNode as HTMLElement)\r\n .closest(\"tr\")\r\n .querySelector(\".text\");\r\n const content = normalizeText(elementTitle.textContent);\r\n\r\n const indexCorrectAnswer = correct.findIndex((answer) => {\r\n const valide = answer.includes(content);\r\n if (config.logs) Logs.responseTry(content, valide);\r\n return valide;\r\n });\r\n\r\n if (indexCorrectAnswer !== -1) {\r\n //we do + 1 because we skip the first option: Choose...\r\n if (config.mouseover) {\r\n options[indexCorrectAnswer + 1].closest(\"select\").addEventListener(\r\n \"click\",\r\n function () {\r\n options[indexCorrectAnswer + 1].selected = \"selected\" as any;\r\n },\r\n { once: true }\r\n );\r\n } else {\r\n options[indexCorrectAnswer + 1].selected = \"selected\" as any;\r\n }\r\n break;\r\n }\r\n }\r\n /* End */\r\n\r\n if (config.logs) Logs.responseTry(content, valide);\r\n\r\n if (valide) {\r\n if (config.mouseover) {\r\n option\r\n .closest(\"select\")\r\n .addEventListener(\"click\", () => (option.selected = true), {\r\n once: true,\r\n });\r\n } else {\r\n option.selected = true;\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport default handleSelect;\r\n","import Config from \"../../types/config\";\r\nimport GPTAnswer from \"../../types/gptAnswer\";\r\n\r\n/**\r\n * Handle textbox\r\n * @param config\r\n * @param inputList\r\n * @param gptAnswer\r\n * @returns\r\n */\r\nfunction handleTextbox(\r\n config: Config,\r\n inputList: NodeListOf,\r\n gptAnswer: GPTAnswer\r\n): boolean {\r\n const input = inputList[0] as HTMLInputElement | HTMLTextAreaElement;\r\n\r\n if (\r\n inputList.length !== 1 ||\r\n (input.tagName !== \"TEXTAREA\" && input.type !== \"text\")\r\n )\r\n return false;\r\n\r\n if (config.typing) {\r\n let index = 0;\r\n input.addEventListener(\"keydown\", function (event: KeyboardEvent) {\r\n if (event.key === \"Backspace\") index = gptAnswer.response.length + 1;\r\n if (index > gptAnswer.response.length) return;\r\n event.preventDefault();\r\n input.value = gptAnswer.response.slice(0, ++index);\r\n });\r\n } else {\r\n input.value = gptAnswer.response;\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport default handleTextbox;\r\n","import Config from \"../../types/config\";\r\nimport GPTAnswer from \"../../types/gptAnswer\";\r\nimport titleIndications from \"../../utils/title-indications\";\r\n\r\n/**\r\n * Copy the response in the clipboard if we can automaticaly fill the question\r\n * @param config\r\n * @param gptAnswer\r\n */\r\nfunction handleClipboard(config: Config, gptAnswer: GPTAnswer) {\r\n if (config.title) titleIndications(\"Copied to clipboard\");\r\n navigator.clipboard.writeText(gptAnswer.response);\r\n}\r\n\r\nexport default handleClipboard;\r\n","import Config from \"../../types/config\";\r\nimport GPTAnswer from \"../../types/gptAnswer\";\r\n\r\n/**\r\n * Handle number input\r\n * @param config\r\n * @param inputList\r\n * @param gptAnswer\r\n * @returns\r\n */\r\nfunction handleNumber(\r\n config: Config,\r\n inputList: NodeListOf,\r\n gptAnswer: GPTAnswer\r\n): boolean {\r\n const input = inputList[0] as HTMLInputElement | HTMLTextAreaElement;\r\n\r\n if (inputList.length !== 1 || input.type !== \"number\") return false;\r\n\r\n const number = gptAnswer.normalizedResponse\r\n .match(/\\d+([,\\.]\\d+)?/gi)?.[0]\r\n ?.replace(\",\", \".\");\r\n\r\n if (!number) return false;\r\n\r\n if (config.typing) {\r\n let index = 0;\r\n input.addEventListener(\"keydown\", function (event: KeyboardEvent) {\r\n if (event.key === \"Backspace\") index = number.length + 1;\r\n if (index > number.length) return;\r\n event.preventDefault();\r\n if (number.slice(index, index + 1) === \".\") ++index;\r\n input.value = number.slice(0, ++index);\r\n });\r\n } else {\r\n input.value = number;\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport default handleNumber;\r\n","import Config from \"../../types/config\";\r\nimport GPTAnswer from \"../../types/gptAnswer\";\r\n\r\n/**\r\n * Hanlde contenteditable elements\r\n * @param config\r\n * @param inputList\r\n * @param gptAnswer\r\n * @returns\r\n */\r\nfunction handleContentEditable(\r\n config: Config,\r\n inputList: NodeListOf,\r\n gptAnswer: GPTAnswer\r\n): boolean {\r\n const input = inputList[0];\r\n\r\n if (\r\n inputList.length !== 1 ||\r\n input.getAttribute(\"contenteditable\") !== \"true\"\r\n )\r\n return false;\r\n\r\n if (config.typing) {\r\n let index = 0;\r\n input.addEventListener(\"keydown\", function (event: KeyboardEvent) {\r\n if (event.key === \"Backspace\") index = gptAnswer.response.length + 1;\r\n if (index > gptAnswer.response.length) return;\r\n event.preventDefault();\r\n input.textContent = gptAnswer.response.slice(0, ++index);\r\n\r\n /* Put the cursor at the end of the typed text */\r\n input.focus();\r\n const range = document.createRange();\r\n range.selectNodeContents(input);\r\n range.collapse(false);\r\n const selection = window.getSelection();\r\n selection.removeAllRanges();\r\n selection.addRange(range);\r\n });\r\n } else {\r\n input.textContent = gptAnswer.response;\r\n }\r\n\r\n return true;\r\n}\r\n\r\nexport default handleContentEditable;\r\n","import Config from \"../types/config\";\r\nimport Logs from \"../utils/logs\";\r\nimport getChatGPTResponse from \"./get-response\";\r\nimport createQuestion from \"./create-question\";\r\nimport handleRadioAndCheckbox from \"./questions/radio-checkbox\";\r\nimport handleSelect from \"./questions/select\";\r\nimport handleTextbox from \"./questions/textbox\";\r\nimport handleClipboard from \"./questions/clipboard\";\r\nimport handleNumber from \"./questions/number\";\r\nimport handleContentEditable from \"./questions/contenteditable\";\r\nimport { removeListener } from \"./code-listener\";\r\n\r\n/**\r\n * Reply to the question\r\n * @param config\r\n * @param hiddenButton\r\n * @param form\r\n * @param query\r\n * @returns\r\n */\r\nasync function reply(\r\n config: Config,\r\n hiddenButton: HTMLElement,\r\n form: HTMLElement,\r\n query: string\r\n) {\r\n if (config.cursor) hiddenButton.style.cursor = \"wait\";\r\n\r\n const question = createQuestion(config, form);\r\n const inputList: NodeListOf = form.querySelectorAll(query);\r\n\r\n const gptAnswer = await getChatGPTResponse(config, question).catch(\r\n (error) => ({\r\n error,\r\n })\r\n );\r\n\r\n const haveError = typeof gptAnswer === \"object\" && \"error\" in gptAnswer;\r\n\r\n if (config.cursor)\r\n hiddenButton.style.cursor =\r\n config.infinite || haveError ? \"pointer\" : \"initial\";\r\n\r\n if (haveError) {\r\n console.error(gptAnswer.error);\r\n return;\r\n }\r\n\r\n if (config.logs) {\r\n Logs.question(question);\r\n Logs.response(gptAnswer);\r\n }\r\n\r\n /* Handle clipboard mode */\r\n if (config.mode === \"clipboard\") {\r\n if (!config.infinite) removeListener(hiddenButton);\r\n return handleClipboard(config, gptAnswer);\r\n }\r\n\r\n /* Handle question to answer mode */\r\n if (config.mode === \"question-to-answer\") {\r\n removeListener(hiddenButton);\r\n\r\n const questionContainer = form.querySelector(\".qtext\");\r\n const questionBackup = questionContainer.textContent;\r\n\r\n questionContainer.textContent = gptAnswer.response;\r\n questionContainer.style.whiteSpace = \"pre-wrap\";\r\n\r\n questionContainer.addEventListener(\"click\", function () {\r\n const isNotResponse = questionContainer.textContent === questionBackup;\r\n questionContainer.style.whiteSpace = isNotResponse ? \"pre-wrap\" : null;\r\n questionContainer.textContent = isNotResponse\r\n ? gptAnswer.response\r\n : questionBackup;\r\n });\r\n return;\r\n }\r\n\r\n /* Better then set once on the event because if there is an error the user can click an other time on the question */\r\n if (!config.infinite) removeListener(hiddenButton);\r\n\r\n const handlers = [\r\n handleContentEditable,\r\n handleTextbox,\r\n handleNumber,\r\n handleSelect,\r\n handleRadioAndCheckbox,\r\n ];\r\n\r\n for (const handler of handlers) {\r\n if (handler(config, inputList, gptAnswer)) return;\r\n }\r\n\r\n /* In the case we can't auto complete the question */\r\n handleClipboard(config, gptAnswer);\r\n}\r\n\r\nexport default reply;\r\n","import Config from \"../types/config\";\r\nimport normalizeText from \"../utils/normalize-text\";\r\nimport htmlTableToString from \"../utils/html-table-to-string\";\r\n\r\n/**\r\n * Normalize the question and add sub informations\r\n * @param langage\r\n * @param question\r\n * @returns\r\n */\r\nfunction createQuestion(config: Config, questionContainer: HTMLElement) {\r\n let question = questionContainer.innerText;\r\n\r\n /* We remove unnecessary information */\r\n const accesshideElements: NodeListOf =\r\n questionContainer.querySelectorAll(\".accesshide\");\r\n for (const useless of accesshideElements) {\r\n question = question.replace(useless.innerText, \"\");\r\n }\r\n\r\n /* Make tables more readable for chat-gpt */\r\n const tables: NodeListOf =\r\n questionContainer.querySelectorAll(\".qtext table\");\r\n for (const table of tables) {\r\n question = question.replace(\r\n table.innerText,\r\n \"\\n\" + htmlTableToString(table) + \"\\n\"\r\n );\r\n }\r\n\r\n return normalizeText(question, false);\r\n}\r\n\r\nexport default createQuestion;\r\n","import Config from \"../types/config\";\r\nimport GPTAnswer from \"../types/gptAnswer\";\r\nimport normalizeText from \"../utils/normalize-text\";\r\n\r\n/**\r\n * Get the response from chatGPT api\r\n * @param config\r\n * @param question\r\n * @returns\r\n */\r\nasync function getChatGPTResponse(\r\n config: Config,\r\n question: string\r\n): Promise {\r\n const controller = new AbortController();\r\n const timeoutControler = setTimeout(() => controller.abort(), 15000);\r\n const req = await fetch(\"https://api.openai.com/v1/chat/completions\", {\r\n method: \"POST\",\r\n headers: {\r\n \"Content-Type\": \"application/json\",\r\n Authorization: `Bearer ${config.apiKey}`,\r\n },\r\n signal: config.timeout ? controller.signal : null,\r\n body: JSON.stringify({\r\n model: config.model,\r\n messages: [\r\n {\r\n role: \"system\",\r\n content: `\r\nFollow those rules:\r\n- Sometimes there won't be a question, so just answer the statement as you normally would without following the other rules and give the most detailled and complete answer with explication.\r\n- For put in order question just give the good order separate by new line\r\n- Your goal is to understand the statement and to reply to each question by giving only the answer.\r\n- You will keep the same order for the answers like in the text. \r\n- You will separate all the answer with new lines and only show the correctes one.\r\n- You will only give the answers for each question and omit the questions, statement, title or other informations from the response.\r\n- You will only give answer with exactly the same text as the gived answers.\r\n- The question always have the good answer so you should always give an answer to the question.\r\n- You will always respond in the same langage as the user question.`,\r\n },\r\n { role: \"user\", content: question },\r\n ],\r\n temperature: 0.8,\r\n top_p: 1.0,\r\n presence_penalty: 1.0,\r\n stop: null,\r\n }),\r\n });\r\n clearTimeout(timeoutControler);\r\n const rep = await req.json();\r\n const response = rep.choices[0].message.content;\r\n return {\r\n response,\r\n normalizedResponse: normalizeText(response),\r\n };\r\n}\r\n\r\nexport default getChatGPTResponse;\r\n","import Config from \"../types/config\";\r\nimport titleIndications from \"../utils/title-indications\";\r\nimport reply from \"./reply\";\r\n\r\nconst pressedKeys: string[] = [];\r\nconst listeners: {\r\n element: HTMLElement;\r\n fn: (this: HTMLElement, ev: MouseEvent) => any;\r\n}[] = [];\r\n\r\n/**\r\n * Create a listener on the keyboard to inject the code\r\n * @param config\r\n */\r\nfunction codeListener(config: Config) {\r\n document.body.addEventListener(\"keydown\", function (event) {\r\n pressedKeys.push(event.key);\r\n if (pressedKeys.length > config.code.length) pressedKeys.shift();\r\n if (pressedKeys.join(\"\") === config.code) {\r\n pressedKeys.length = 0;\r\n setUpMoodleGpt(config);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Setup moodleGPT into the page (remove/injection)\r\n * @param config\r\n * @returns\r\n */\r\nfunction setUpMoodleGpt(config: Config) {\r\n /* Removing events */\r\n if (listeners.length > 0) {\r\n for (const listener of listeners) {\r\n if (config.cursor) listener.element.style.cursor = \"initial\";\r\n listener.element.removeEventListener(\"click\", listener.fn);\r\n }\r\n if (config.title) titleIndications(\"Removed\");\r\n listeners.length = 0;\r\n return;\r\n }\r\n\r\n /* Code injection */\r\n const inputQuery = [\"checkbox\", \"radio\", \"text\", \"number\"]\r\n .map((e) => `input[type=\"${e}\"]`)\r\n .join(\",\");\r\n const query = inputQuery + \", textarea, select, [contenteditable]\";\r\n const forms = document.querySelectorAll(\".formulation\");\r\n\r\n for (const form of forms) {\r\n const hiddenButton: HTMLElement = form.querySelector(\".qtext\");\r\n\r\n if (config.cursor) hiddenButton.style.cursor = \"pointer\";\r\n\r\n const injectionFunction = reply.bind(\r\n null,\r\n config,\r\n hiddenButton,\r\n form,\r\n query\r\n );\r\n listeners.push({ element: hiddenButton, fn: injectionFunction });\r\n hiddenButton.addEventListener(\"click\", injectionFunction);\r\n }\r\n\r\n if (config.title) titleIndications(\"Injected\");\r\n}\r\n\r\n/**\r\n * Remove the event listener on a specific question\r\n * @param element\r\n */\r\nfunction removeListener(element: HTMLElement) {\r\n const index = listeners.findIndex((listener) => listener.element === element);\r\n if (index !== -1) {\r\n const listener = listeners.splice(index, 1)[0];\r\n listener.element.removeEventListener(\"click\", listener.fn);\r\n }\r\n}\r\n\r\nexport { codeListener, removeListener };\r\n","import { codeListener } from \"./core/code-listener\";\r\n\r\nchrome.storage.sync.get([\"moodleGPT\"]).then(function (storage) {\r\n const config = storage.moodleGPT;\r\n\r\n if (!config) throw new Error(\"Please configure MoodleGPT into the extension\");\r\n\r\n codeListener(config);\r\n});\r\n"],"names":["titleIndications","text","backTitle","document","title","setTimeout","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","Logs","static","console","log","valide","css","arr","gptAnswer","response","normalizedResponse","normalizeText","toLowerCase","normalizedText","replace","trim","htmlTableToString","table","tab","lines","Array","from","querySelectorAll","maxColumnsLength","map","line","cellsContent","cell","index","content","_a","textContent","Math","max","length","push","lineSeparationSize","reduce","a","b","lineSeparation","fill","join","mappedTab","padEnd","shift","handleRadioAndCheckbox","config","inputList","input","type","parentNode","includes","logs","responseTry","mouseover","addEventListener","checked","once","handleSelect","tagName","correct","split","array","filter","answer","j","options","option","test","closest","querySelector","indexCorrectAnswer","findIndex","selected","handleTextbox","typing","event","key","preventDefault","slice","handleClipboard","navigator","clipboard","writeText","handleNumber","number","_b","match","handleContentEditable","getAttribute","focus","range","createRange","selectNodeContents","collapse","selection","window","getSelection","removeAllRanges","addRange","reply","hiddenButton","form","query","cursor","style","question","questionContainer","innerText","accesshideElements","useless","tables","createQuestion","controller","AbortController","timeoutControler","abort","req","fetch","method","headers","Authorization","apiKey","signal","timeout","body","JSON","stringify","model","messages","role","temperature","top_p","presence_penalty","stop","clearTimeout","json","choices","message","getChatGPTResponse","catch","error","haveError","infinite","mode","removeListener","questionBackup","whiteSpace","isNotResponse","handlers","handler","pressedKeys","listeners","codeListener","code","listener","element","removeEventListener","fn","forms","injectionFunction","bind","setUpMoodleGpt","splice","chrome","storage","sync","get","moodleGPT","Error"],"mappings":"2FAIA,SAASA,EAAiBC,GACxB,MAAMC,EAAYC,SAASC,MAC3BD,SAASC,MAAQH,EACjBI,YAAW,IAAOF,SAASC,MAAQF,GAAY,IACjD,CC0GO,SAASI,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,KAAKR,EAAWK,EAAY,CAC9GH,GAAMN,EAAYA,EAAUa,MAAMhB,EAASC,GAAc,KAAKS,OACtE,GACA,CCzHA,MAAMO,EACJC,gBAAgBxB,GAEdyB,QAAQC,IAAI,mBADA,cACyB1B,EACtC,CAEDwB,mBAAmBxB,EAAc2B,GAC/B,MAAMC,EAAM,WAAaD,EAAS,QAAU,OAC5CF,QAAQC,IAAI,mBAAoBE,EAAK5B,EACtC,CAEDwB,aAAaK,GACXJ,QAAQC,IAAI,cAAeG,EAC5B,CAEDL,gBAAgBM,GACdL,QAAQC,IAAI,cAAgBI,EAAUC,UACtCN,QAAQC,IAAI,gBAAkBI,EAAUE,mBACzC,ECfH,SAAS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L,CAAepH,GAEnB,GACF,CAiDA,SAASmG,EAAeW,GACtB,MAAMjI,EAAQ6H,EAAUhF,WAAWmF,GAAaA,EAASC,UAAYA,IACrE,IAAe,IAAXjI,EAAc,CAChB,MAAMgI,EAAWH,EAAUW,OAAOxI,EAAO,GAAG,GAC5CgI,EAASC,QAAQC,oBAAoB,QAASF,EAASG,GACxD,CACH,CC5EAM,OAAOC,QAAQC,KAAKC,IAAI,CAAC,cAAczK,MAAK,SAAUuK,GACpD,MAAMvH,EAASuH,EAAQG,UAEvB,IAAK1H,EAAQ,MAAM,IAAI2H,MAAM,iDAE7BhB,EAAa3G,EACf","x_google_ignoreList":[1]}
\ No newline at end of file
+{"version":3,"file":"MoodleGPT.js","sources":["../src/utils/title-indications.ts","../node_modules/tslib/tslib.es6.js","../src/utils/pick-best-response.ts","../src/utils/logs.ts","../src/utils/normalize-text.ts","../src/types/message.ts","../src/core/get-content-with-history.ts","../src/utils/version-support-images.ts","../src/utils/image-to-base64.ts","../src/utils/html-table-to-string.ts","../src/core/questions/clipboard.ts","../src/core/questions/contenteditable.ts","../src/core/questions/number.ts","../src/core/questions/radio.ts","../src/core/questions/checkbox.ts","../src/core/questions/select.ts","../src/core/questions/textbox.ts","../src/core/reply.ts","../src/core/create-question.ts","../src/core/get-response.ts","../src/core/modes/clipboard.ts","../src/core/modes/question-to-answer.ts","../src/core/modes/autocomplete.ts","../src/core/code-listener.ts","../src/index.ts"],"sourcesContent":["/**\n * Show some informations into the document title and remove it after 3000ms\n * @param text\n */\nfunction titleIndications(text: string) {\n const backTitle = document.title;\n document.title = text;\n setTimeout(() => (document.title = backTitle), 3000);\n}\n\nexport default titleIndications;\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n","type BestResponse = {\n similarity: number;\n value: string | null;\n element: HTMLElement | null;\n};\n\ntype ResponsesBySimilarity = {\n similarity: number;\n value: string;\n element: HTMLElement;\n};\n\n/**\n * Calculate the levenshtein distance between two sentence\n * @param str1\n * @param str2\n * @returns\n */\nfunction levenshteinDistance(str1: string, str2: string) {\n if (str1.length === 0) return str2.length;\n if (str2.length === 0) return str1.length;\n\n const matrix: number[][] = [];\n const str1WithoutSpaces = str1.replace(/\\s+/, '');\n const str2WithoutSpaces = str2.replace(/\\s+/, '');\n\n for (let i = 0; i <= str1WithoutSpaces.length; ++i) {\n matrix.push([i]);\n for (let j = 1; j <= str2WithoutSpaces.length; ++j) {\n matrix[i][j] =\n i === 0\n ? j\n : Math.min(\n matrix[i - 1][j] + 1,\n matrix[i][j - 1] + 1,\n matrix[i - 1][j - 1] + (str1WithoutSpaces[i - 1] === str2WithoutSpaces[j - 1] ? 0 : 1)\n );\n }\n }\n\n return matrix[str1WithoutSpaces.length][str2WithoutSpaces.length];\n}\n\n/**\n * Calculate the similarity between two sentences from 0 to 1 (best)\n * @param str1\n * @param str2\n * @returns\n */\nfunction sentenceSimilarity(str1: string, str2: string) {\n const longerLength = str1.length > str2.length ? str1.length : str2.length;\n if (longerLength === 0) return 1;\n return (longerLength - levenshteinDistance(str1, str2)) / longerLength;\n}\n\n/**\n * Pick the best sentence that correspond to the answer\n * @param arr\n * @param answer\n * @returns\n */\nexport function pickBestReponse(\n answer: string,\n arr: { element: HTMLElement; value: string }[]\n): BestResponse {\n let bestResponse: BestResponse = {\n element: null,\n similarity: 0,\n value: null\n };\n for (const obj of arr) {\n const similarity = sentenceSimilarity(obj.value, answer);\n if (similarity === 1) {\n return { element: obj.element, value: obj.value, similarity };\n }\n if (similarity > bestResponse.similarity) {\n bestResponse = { element: obj.element, value: obj.value, similarity };\n }\n }\n return bestResponse;\n}\n\n/**\n * Return the sentences sorted by score with a score superior or equal to what is asked\n * @param answer\n * @param arr\n * @param score\n * @returns\n */\nexport function pickResponsesWithSimilarityGreaterThan(\n answer: string,\n arr: { element: HTMLElement; value: string }[],\n score: number\n): ResponsesBySimilarity[] {\n const responses: ResponsesBySimilarity[] = [];\n for (const obj of arr) {\n const similarity = sentenceSimilarity(obj.value, answer);\n if (similarity >= score)\n responses.push({\n similarity,\n value: obj.value,\n element: obj.element\n });\n }\n return responses.sort((a, b) => a.similarity - b.similarity);\n}\n\n/**\n * Convert a number to a readable string pourcentage\n * @param similarity\n */\nexport function toPourcentage(similarity: number): string {\n return Math.round(similarity * 100 * 100) / 100 + '%';\n}\n","import GPTAnswer from '@typing/gpt-answer';\nimport { toPourcentage } from './pick-best-response';\n\nclass Logs {\n static question(text: string) {\n const css = 'color: cyan';\n console.log('%c[QUESTION]: %s', css, text);\n }\n\n static bestAnswer(answer: string, similarity: number) {\n const css = 'color: green';\n console.log(\n '%c[BEST ANSWER]: %s',\n css,\n `\"${answer}\" with a similarity of ${toPourcentage(similarity)}`\n );\n }\n\n static array(arr: unknown[]) {\n console.log('[CORRECTS] ', arr);\n }\n\n static response(gptAnswer: GPTAnswer) {\n console.log('Original:\\n' + gptAnswer.response);\n console.log('Normalized:\\n' + gptAnswer.normalizedResponse);\n }\n}\n\nexport default Logs;\n","/**\n * Normlize text\n * @param text\n */\nfunction normalizeText(text: string, toLowerCase: boolean = true) {\n if (toLowerCase) text = text.toLowerCase();\n\n const normalizedText = text\n .replace(/\\n+/gi, '\\n') //remove duplicate new lines\n .replace(/(\\n\\s*\\n)+/g, '\\n') //remove useless white space from textcontent\n .replace(/[ \\t]+/gi, ' ') //replace multiples space or tabs by a space\n .trim()\n // We remove the following content because sometimes ChatGPT will reply: \"answer d\"\n .replace(/^[a-z\\d]\\.\\s/gi, '') //a. text, b. text, c. text, 1. text, 2. text, 3.text\n .replace(/\\n[a-z\\d]\\.\\s/gi, '\\n'); //same but with new line\n\n return normalizedText;\n}\n\nexport default normalizeText;\n","export enum ROLE {\r\n SYSTEM = 'system',\r\n USER = 'user',\r\n ASSISTANT = 'assistant'\r\n}\r\n\r\nexport enum CONTENT_TYPE {\r\n TEXT = 'text',\r\n IMAGE = 'image_url'\r\n}\r\n\r\nexport type MessageContent =\r\n | string\r\n | Array<\r\n | {\r\n type: CONTENT_TYPE.TEXT;\r\n text: string;\r\n }\r\n | {\r\n type: CONTENT_TYPE.IMAGE;\r\n image_url: { url: string };\r\n }\r\n >;\r\n\r\nexport type Message = {\r\n role: ROLE;\r\n content: MessageContent;\r\n};\r\n","import type Config from '@typing/config';\r\nimport { ROLE, CONTENT_TYPE, type MessageContent, type Message } from '@typing/message';\r\nimport imageToBase64 from '@utils/image-to-base64';\r\nimport isGPTModelGreaterOrEqualTo4 from '@utils/version-support-images';\r\n\r\n// The attempt and the cmid allow us to identify a quiz\r\ntype History = {\r\n host: string;\r\n cmid: string; // The id of the quiz\r\n attempt: string; // The attempt of the current quiz\r\n history: { role: ROLE; content: MessageContent }[];\r\n};\r\n\r\nconst INSTRUCTION: string = `\r\nAct as a quiz solver for the best notation with the following rules:\r\n- If no answer(s) are given, answer the statement as usual without following the other rules, providing the most detailed, complete and precise explanation. \r\n- But for the calculation provide this format 'result: '\r\n- For 'put in order' questions, maintain the answer in the order as presented in the question but assocy the correct order to it by usin this format ':\\n:', ignore other rules.\r\n- Always reply in the format: '\\n\\n...'.\r\n- Retain only the correct answer(s).\r\n- Maintain the same order for the answers as in the text.\r\n- Retain all text from the answer with its description, content or definition.\r\n- Only provide answers that exactly match the given answer in the text.\r\n- The question always has the correct answer(s), so you should always provide an answer.\r\n- Always respond in the same language as the user's question.\r\n`.trim();\r\n\r\nconst SYSTEM_INSTRUCTION_MESSAGE = {\r\n role: ROLE.SYSTEM,\r\n content: INSTRUCTION\r\n} as const satisfies Message;\r\n\r\n/**\r\n * Get the content to send to ChatGPT API (it allows to includes images if supported)\r\n * @param config\r\n */\r\nasync function getContent(\r\n config: Config,\r\n questionElement: HTMLElement,\r\n question: string\r\n): Promise {\r\n const imagesElements = questionElement.querySelectorAll('img');\r\n\r\n if (\r\n !config.includeImages ||\r\n !isGPTModelGreaterOrEqualTo4(config.model) ||\r\n imagesElements.length === 0\r\n ) {\r\n return question;\r\n }\r\n\r\n const contentWithImages: MessageContent = [];\r\n\r\n const base64Images = Array.from(imagesElements).map(imgEl => imageToBase64(imgEl));\r\n const base64ImagesResolved = await Promise.allSettled(base64Images);\r\n\r\n for (const result of base64ImagesResolved) {\r\n if (result.status === 'fulfilled') {\r\n contentWithImages.push({\r\n type: CONTENT_TYPE.IMAGE,\r\n image_url: { url: result.value }\r\n });\r\n } else if (config.logs) {\r\n console.error(result.reason);\r\n }\r\n }\r\n\r\n contentWithImages.push({\r\n type: CONTENT_TYPE.TEXT,\r\n text: question\r\n });\r\n\r\n return contentWithImages;\r\n}\r\n\r\n/**\r\n * Create a new history object from the current page\r\n * @returns\r\n */\r\nfunction createNewHistory(): History {\r\n const urlParams = new URLSearchParams(document.location.search);\r\n\r\n return {\r\n host: document.location.host,\r\n cmid: urlParams.get('cmid') ?? '',\r\n attempt: urlParams.get('attempt') ?? '',\r\n history: []\r\n };\r\n}\r\n\r\n/**\r\n * Load the past history from the session storage otherwise return the default history object\r\n * @returns\r\n */\r\nfunction loadPastHistory(): History | null {\r\n return JSON.parse(sessionStorage.moodleGPTHistory ?? 'null');\r\n}\r\n\r\n/**\r\n * Check if two history are from the same origin\r\n * @param a\r\n * @param b\r\n * @returns\r\n */\r\nfunction areHistoryFromSameQuiz(a: History, b: History): boolean {\r\n const KEYS_TO_COMPARE: (keyof History)[] = ['host', 'cmid', 'attempt'];\r\n\r\n for (const key of KEYS_TO_COMPARE) {\r\n if (a[key] !== b[key]) return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Return the content to send to chatgpt api with history if needed\r\n * @param config\r\n * @param questionElement\r\n * @param question\r\n * @returns\r\n */\r\nasync function getContentWithHistory(\r\n config: Config,\r\n questionElement: HTMLElement,\r\n question: string\r\n): Promise<{\r\n messages: [typeof SYSTEM_INSTRUCTION_MESSAGE, ...Message[]];\r\n saveResponse?: (response: string) => void;\r\n}> {\r\n const content = await getContent(config, questionElement, question);\r\n const message = { role: ROLE.USER, content };\r\n\r\n if (!config.history) return { messages: [SYSTEM_INSTRUCTION_MESSAGE, message] };\r\n\r\n let history: History;\r\n\r\n const pastHistory: History | null = loadPastHistory();\r\n const newHistory: History = createNewHistory();\r\n\r\n if (pastHistory === null || !areHistoryFromSameQuiz(pastHistory, newHistory)) {\r\n history = newHistory;\r\n } else {\r\n history = pastHistory;\r\n }\r\n\r\n return {\r\n messages: [SYSTEM_INSTRUCTION_MESSAGE, ...history.history, message],\r\n saveResponse(response: string) {\r\n // Register the conversation\r\n if (config.history) {\r\n history.history.push(message);\r\n history.history.push({ role: ROLE.ASSISTANT, content: response });\r\n sessionStorage.moodleGPTHistory = JSON.stringify(history);\r\n }\r\n }\r\n };\r\n}\r\n\r\nexport default getContentWithHistory;\r\n","/**\r\n * Check if the current ChatGPT version is greater or equal to 4\r\n * @param version\r\n * @returns\r\n */\r\nfunction isGPTModelGreaterOrEqualTo4(version: string): boolean {\r\n const versionNumber = version.match(/gpt-(\\d+)/);\r\n if (!versionNumber?.[1]) {\r\n return false;\r\n }\r\n return Number(versionNumber[1]) >= 4;\r\n}\r\n\r\nexport default isGPTModelGreaterOrEqualTo4;\r\n","/**\r\n * Convert an image html element into a base64 image string\r\n * @param imageElement\r\n * @param quality (default: 0.75 -> 75%)\r\n * @returns\r\n */\r\nfunction imageToBase64(imageElement: HTMLImageElement, quality = 0.75): Promise {\r\n return new Promise((resolve, reject) => {\r\n const canvas = document.createElement('canvas');\r\n const ctx = canvas.getContext('2d');\r\n\r\n if (!ctx) {\r\n reject(\"Can't get the canvas context, ensure your navigator support canvas\");\r\n canvas.remove();\r\n return;\r\n }\r\n\r\n const img = new Image();\r\n img.crossOrigin = 'Anonymous';\r\n img.onload = () => {\r\n canvas.width = img.width;\r\n canvas.height = img.height;\r\n ctx.drawImage(img, 0, 0);\r\n\r\n const base64 = canvas.toDataURL('image/png', quality);\r\n resolve(base64);\r\n\r\n canvas.remove();\r\n };\r\n\r\n img.onerror = err => {\r\n reject(err);\r\n canvas.remove();\r\n };\r\n\r\n img.src = imageElement.src;\r\n });\r\n}\r\n\r\nexport default imageToBase64;\r\n","/**\n * Convert table to representating string table\n * @param table\n * @returns\n */\nfunction htmlTableToString(table: HTMLTableElement) {\n const tab: string[][] = [];\n const lines = Array.from(table.querySelectorAll('tr'));\n const maxColumnsLength: number[] = [];\n\n lines.map(line => {\n const cells = Array.from(line.querySelectorAll('td, th'));\n const cellsContent = cells.map((cell, index) => {\n const content = cell.textContent?.trim();\n maxColumnsLength[index] = Math.max(maxColumnsLength[index] || 0, content?.length || 0);\n return content ?? '';\n });\n tab.push(cellsContent);\n });\n\n const jointure = ' | ';\n const headerLineLength = tab[0].length;\n const lineSeparationSize =\n maxColumnsLength.reduce((a, b) => a + b, 0) + (headerLineLength - 1) * jointure.length;\n const lineSeparation = '\\n' + Array(lineSeparationSize).fill('-').join('') + '\\n';\n\n const mappedTab = tab.map(line => {\n const mappedLine = line.map((content, index) =>\n content.padEnd(\n maxColumnsLength[index],\n '\\u00A0' // For no matching with \\s\n )\n );\n return mappedLine.join(jointure);\n });\n\n const head = mappedTab.shift();\n\n return head + lineSeparation + mappedTab.join('\\n');\n}\n\nexport default htmlTableToString;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\nimport titleIndications from '@utils/title-indications';\n\n/**\n * Copy the response in the clipboard if we can automaticaly fill the question\n * @param config\n * @param gptAnswer\n */\nfunction handleClipboard(config: Config, gptAnswer: GPTAnswer) {\n if (config.title) titleIndications('Copied to clipboard');\n navigator.clipboard.writeText(gptAnswer.response);\n}\n\nexport default handleClipboard;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\n\n/**\n * Hanlde contenteditable elements\n * @param config\n * @param inputList\n * @param gptAnswer\n * @returns\n */\nfunction handleContentEditable(\n config: Config,\n inputList: NodeListOf,\n gptAnswer: GPTAnswer\n): boolean {\n const input = inputList[0];\n\n if (\n inputList.length !== 1 || // for now we don't handle many input for editable textcontent\n input.getAttribute('contenteditable') !== 'true'\n ) {\n return false;\n }\n\n if (config.typing) {\n let index = 0;\n input.addEventListener('keydown', function (event: KeyboardEvent) {\n if (event.key === 'Backspace') index = gptAnswer.response.length + 1;\n if (index > gptAnswer.response.length) return;\n event.preventDefault();\n input.textContent = gptAnswer.response.slice(0, ++index);\n\n // Put the cursor at the end of the typed text\n input.focus();\n const range = document.createRange();\n range.selectNodeContents(input);\n range.collapse(false);\n const selection = window.getSelection();\n if (selection !== null) {\n selection.removeAllRanges();\n selection.addRange(range);\n }\n });\n } else {\n input.textContent = gptAnswer.response;\n }\n\n return true;\n}\n\nexport default handleContentEditable;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\n\n/**\n * Handle number input\n * @param config\n * @param inputList\n * @param gptAnswer\n * @returns\n */\nfunction handleNumber(\n config: Config,\n inputList: NodeListOf,\n gptAnswer: GPTAnswer\n): boolean {\n const input = inputList[0] as HTMLInputElement | HTMLTextAreaElement;\n\n if (\n inputList.length !== 1 || // for now we don't handle many input number\n input.type !== 'number'\n ) {\n return false;\n }\n\n const number = gptAnswer.normalizedResponse.match(/\\d+([,.]\\d+)?/gi)?.[0]?.replace(',', '.');\n\n if (number === undefined) return false;\n\n if (config.typing) {\n let index = 0;\n input.addEventListener('keydown', function (event: Event) {\n event.preventDefault();\n if ((event).key === 'Backspace') index = number.length + 1;\n if (index > number.length) return;\n if (number.slice(index, index + 1) === '.') ++index;\n input.value = number.slice(0, ++index);\n });\n } else {\n input.value = number;\n }\n\n return true;\n}\n\nexport default handleNumber;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\nimport Logs from '@utils/logs';\nimport normalizeText from '@utils/normalize-text';\nimport { pickBestReponse } from '@utils/pick-best-response';\n\n/**\n * Handle input radio elements\n * @param config\n * @param inputList\n * @param gptAnswer\n */\nfunction handleRadio(\n config: Config,\n inputList: NodeListOf,\n gptAnswer: GPTAnswer\n): boolean {\n const firstInput = inputList?.[0] as HTMLInputElement;\n\n // Handle the case the input is not a radio\n if (!firstInput || firstInput.type !== 'radio') {\n return false;\n }\n\n const possibleAnswers = Array.from(inputList)\n .map(inp => ({\n element: inp,\n value: normalizeText(inp?.parentElement?.textContent ?? '')\n }))\n .filter(obj => obj.value !== '');\n\n const bestAnswer = pickBestReponse(gptAnswer.normalizedResponse, possibleAnswers);\n\n if (config.logs && bestAnswer.value) {\n Logs.bestAnswer(bestAnswer.value, bestAnswer.similarity);\n }\n\n const correctInput = bestAnswer.element as HTMLInputElement;\n if (config.mouseover) {\n correctInput.addEventListener('mouseover', () => correctInput.click(), {\n once: true\n });\n } else {\n correctInput.click();\n }\n\n return true;\n}\n\nexport default handleRadio;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\nimport Logs from '@utils/logs';\nimport normalizeText from '@utils/normalize-text';\nimport { pickBestReponse } from '@utils/pick-best-response';\n\n/**\n * Handle input checkbox elements\n * @param config\n * @param inputList\n * @param gptAnswer\n */\nfunction handleCheckbox(\n config: Config,\n inputList: NodeListOf,\n gptAnswer: GPTAnswer\n): boolean {\n const firstInput = inputList?.[0] as HTMLInputElement;\n\n // Handle the case the input is not a checkbox\n if (!firstInput || firstInput.type !== 'checkbox') {\n return false;\n }\n\n const corrects = gptAnswer.normalizedResponse.split('\\n');\n\n const possibleAnswers = Array.from(inputList)\n .map(inp => ({\n element: inp,\n value: normalizeText(inp?.parentElement?.textContent ?? '')\n }))\n .filter(obj => obj.value !== '');\n\n for (const correct of corrects) {\n const bestAnswer = pickBestReponse(correct, possibleAnswers);\n\n if (config.logs && bestAnswer.value) {\n Logs.bestAnswer(bestAnswer.value, bestAnswer.similarity);\n }\n\n const correctInput = bestAnswer.element as HTMLInputElement;\n if (config.mouseover) {\n correctInput.addEventListener('mouseover', () => correctInput.click(), {\n once: true\n });\n } else {\n correctInput.click();\n }\n }\n\n return true;\n}\n\nexport default handleCheckbox;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\nimport Logs from '@utils/logs';\nimport normalizeText from '@utils/normalize-text';\nimport { pickBestReponse } from '@utils/pick-best-response';\n\n/**\n * Handle select elements (and put in order select)\n * @param config\n * @param inputList\n * @param gptAnswer\n * @returns\n */\nfunction handleSelect(\n config: Config,\n inputList: NodeListOf,\n gptAnswer: GPTAnswer\n): boolean {\n if (inputList.length === 0 || inputList[0].tagName !== 'SELECT') return false;\n\n const corrects = gptAnswer.normalizedResponse.split('\\n');\n\n if (config.logs) Logs.array(corrects);\n\n for (let i = 0; i < inputList.length; ++i) {\n if (!corrects[i]) break;\n\n const options = inputList[i].querySelectorAll('option');\n\n const possibleAnswers = Array.from(options)\n .slice(1) // We remove the first option which correspond to \"Choose...\"\n .map(opt => ({\n element: opt,\n value: normalizeText(opt.textContent ?? '')\n }))\n .filter(obj => obj.value !== '');\n\n const bestAnswer = pickBestReponse(corrects[i], possibleAnswers);\n\n if (config.logs && bestAnswer.value) {\n Logs.bestAnswer(bestAnswer.value, bestAnswer.similarity);\n }\n\n const correctOption = bestAnswer.element as HTMLOptionElement;\n const currentSelect = correctOption.closest('select');\n\n if (currentSelect === null) continue;\n\n if (config.mouseover) {\n currentSelect.addEventListener('click', () => (correctOption.selected = true), {\n once: true\n });\n } else {\n correctOption.selected = true;\n }\n }\n\n return true;\n}\n\nexport default handleSelect;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\n\n/**\n * Handle textbox\n * @param config\n * @param inputList\n * @param gptAnswer\n * @returns\n */\nfunction handleTextbox(\n config: Config,\n inputList: NodeListOf,\n gptAnswer: GPTAnswer\n): boolean {\n const input = inputList[0] as HTMLInputElement | HTMLTextAreaElement;\n\n if (\n inputList.length !== 1 || // for now we don't handle many input text\n (input.tagName !== 'TEXTAREA' && input.type !== 'text')\n ) {\n return false;\n }\n\n if (config.typing) {\n let index = 0;\n input.addEventListener('keydown', function (event: Event) {\n event.preventDefault();\n if ((event).key === 'Backspace') {\n index = gptAnswer.response.length + 1;\n }\n if (index > gptAnswer.response.length) return;\n input.value = gptAnswer.response.slice(0, ++index);\n });\n } else {\n input.value = gptAnswer.response;\n }\n\n return true;\n}\n\nexport default handleTextbox;\n","import type Config from '@typing/config';\nimport Logs from '@utils/logs';\nimport getChatGPTResponse from './get-response';\nimport createAndNormalizeQuestion from './create-question';\nimport clipboardMode from './modes/clipboard';\nimport questionToAnswerMode from './modes/question-to-answer';\nimport autoCompleteMode from './modes/autocomplete';\n\ntype Props = {\n config: Config;\n questionElement: HTMLElement;\n form: HTMLElement;\n inputQuery: string;\n removeListener: () => void;\n};\n\n/**\n * Reply to the question\n * @param props\n * @returns\n */\nasync function reply(props: Props): Promise {\n if (props.config.cursor) props.questionElement.style.cursor = 'wait';\n\n const question = createAndNormalizeQuestion(props.form);\n const inputList: NodeListOf = props.form.querySelectorAll(props.inputQuery);\n\n const gptAnswer = await getChatGPTResponse(props.config, props.questionElement, question).catch(\n error => ({\n error\n })\n );\n\n const haveError = typeof gptAnswer === 'object' && 'error' in gptAnswer;\n\n if (props.config.cursor) {\n props.questionElement.style.cursor = props.config.infinite || haveError ? 'pointer' : 'initial';\n }\n\n if (haveError) {\n console.error(gptAnswer.error);\n return;\n }\n\n if (props.config.logs) {\n Logs.question(question);\n Logs.response(gptAnswer);\n }\n\n switch (props.config.mode) {\n case 'clipboard':\n clipboardMode({\n config: props.config,\n questionElement: props.questionElement,\n gptAnswer,\n removeListener: props.removeListener\n });\n break;\n case 'question-to-answer':\n questionToAnswerMode({\n gptAnswer,\n questionElement: props.questionElement,\n removeListener: props.removeListener\n });\n break;\n case 'autocomplete':\n autoCompleteMode({\n config: props.config,\n gptAnswer,\n inputList,\n questionElement: props.questionElement,\n removeListener: props.removeListener\n });\n break;\n }\n}\n\nexport default reply;\n","import normalizeText from '@utils/normalize-text';\nimport htmlTableToString from '@utils/html-table-to-string';\n\n/**\n * Normalize the question as text and add sub informations\n * @param langage\n * @param question\n * @returns\n */\nfunction createAndNormalizeQuestion(questionContainer: HTMLElement) {\n let question = questionContainer.innerText;\n\n // We remove unnecessary information\n const accesshideElements: NodeListOf =\n questionContainer.querySelectorAll('.accesshide');\n for (const useless of accesshideElements) {\n question = question.replace(useless.innerText, '');\n }\n\n // Make tables more readable for chat-gpt\n const tables: NodeListOf = questionContainer.querySelectorAll('.qtext table');\n for (const table of tables) {\n question = question.replace(table.innerText, '\\n' + htmlTableToString(table) + '\\n');\n }\n\n return normalizeText(question, false);\n}\n\nexport default createAndNormalizeQuestion;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\nimport normalizeText from '@utils/normalize-text';\nimport getContentWithHistory from './get-content-with-history';\n\n/**\n * Get the response from chatGPT api\n * @param config\n * @param question\n * @returns\n */\nasync function getChatGPTResponse(\n config: Config,\n questionElement: HTMLElement,\n question: string\n): Promise {\n const controller = new AbortController();\n const timeoutControler = setTimeout(() => controller.abort(), 20 * 1000);\n\n // Get the content to send to chatgpt\n // Including the instructions to the AI, the images as base64 if needed, the question and the past conversation if history is set to true\n const contentHandler = await getContentWithHistory(config, questionElement, question);\n\n const req = await fetch('https://api.openai.com/v1/chat/completions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${config.apiKey}`\n },\n signal: config.timeout ? controller.signal : null,\n body: JSON.stringify({\n model: config.model,\n messages: contentHandler.messages,\n\n temperature: 0.1, // Controls the randomness of the generated responses, with lower values producing more deterministic and predictable outputs. With set to 0.1 instead of 0 for more creativity.\n top_p: 0.6, // Determines the diversity of the generated responses\n presence_penalty: 0, // Encourages the model to introduce new concepts by penalizing words that have already appeared in the text.\n max_tokens: 2000 // Maximum length of the response\n })\n });\n\n clearTimeout(timeoutControler);\n\n const rep = await req.json();\n const response = rep.choices[0].message.content;\n\n // Save the response into the history\n if (typeof contentHandler.saveResponse === 'function') contentHandler.saveResponse(response);\n\n return {\n question,\n response,\n normalizedResponse: normalizeText(response)\n };\n}\n\nexport default getChatGPTResponse;\n","import type Config from '@typing/config';\nimport type GPTAnswer from '@typing/gpt-answer';\nimport handleClipboard from '@core/questions/clipboard';\n\ntype Props = {\n config: Config;\n questionElement: HTMLElement;\n gptAnswer: GPTAnswer;\n removeListener: () => void;\n};\n\n/**\n * Clipboard mode:\n * Simply copy the answer into the clipboard\n * @param props\n */\nfunction clipboardMode(props: Props) {\n if (!props.config.infinite) props.removeListener();\n handleClipboard(props.config, props.gptAnswer);\n}\n\nexport default clipboardMode;\n","import type GPTAnswer from '@typing/gpt-answer';\n\ntype Props = {\n questionElement: HTMLElement;\n gptAnswer: GPTAnswer;\n removeListener: () => void;\n};\n\n/**\n * Question to answer mode:\n * Simply turn the question into the answer by clicking on it\n * @param props\n */\nfunction questionToAnswerMode(props: Props) {\n const questionElement = props.questionElement;\n\n props.removeListener();\n\n const questionBackup = questionElement.innerHTML ?? '';\n questionElement.innerHTML = props.gptAnswer.response;\n questionElement.style.whiteSpace = 'pre-wrap';\n\n // To go back to the question / answer\n questionElement.addEventListener('click', function () {\n const contentIsResponse = questionElement.innerHTML === props.gptAnswer.response;\n\n questionElement.style.whiteSpace = contentIsResponse ? 'initial' : 'pre-wrap';\n questionElement.innerHTML = contentIsResponse ? questionBackup : props.gptAnswer.response;\n });\n}\n\nexport default questionToAnswerMode;\n","import type GPTAnswer from '@typing/gpt-answer';\nimport type Config from '@typing/config';\nimport handleClipboard from '@core/questions/clipboard';\nimport handleContentEditable from '@core/questions/contenteditable';\nimport handleNumber from '@core/questions/number';\nimport handleRadio from '@core/questions/radio';\nimport handleCheckbox from '@core/questions/checkbox';\nimport handleSelect from '@core/questions/select';\nimport handleTextbox from '@core/questions/textbox';\n\ntype Props = {\n config: Config;\n questionElement: HTMLElement;\n inputList: NodeListOf;\n gptAnswer: GPTAnswer;\n removeListener: () => void;\n};\n\n/**\n * Autocomplete mode:\n * Autocomplete the question by checking the good answer\n * @param props\n * @returns\n */\nfunction autoCompleteMode(props: Props) {\n if (!props.config.infinite) props.removeListener();\n\n const handlers = [\n handleContentEditable,\n handleTextbox,\n handleNumber,\n handleSelect,\n handleRadio,\n handleCheckbox\n ];\n\n for (const handler of handlers) {\n if (handler(props.config, props.inputList, props.gptAnswer)) return;\n }\n\n // In the case we can't auto complete the question\n handleClipboard(props.config, props.gptAnswer);\n}\n\nexport default autoCompleteMode;\n","import type Config from '@typing/config';\nimport titleIndications from '@utils/title-indications';\nimport reply from './reply';\n\ntype Listener = {\n element: HTMLElement;\n fn: (this: HTMLElement, ev: MouseEvent) => void;\n};\n\nconst pressedKeys: string[] = [];\nconst listeners: Listener[] = [];\n\n/**\n * Create a listener on the keyboard to inject the code\n * @param config\n */\nfunction codeListener(config: Config) {\n document.body.addEventListener('keydown', function (event) {\n pressedKeys.push(event.key);\n if (pressedKeys.length > config.code!.length) pressedKeys.shift();\n if (pressedKeys.join('') === config.code) {\n pressedKeys.length = 0;\n setUpMoodleGpt(config);\n }\n });\n}\n\n/**\n * Remove the event listener on a specific question\n * @param element\n */\nfunction removeListener(element: HTMLElement) {\n const index = listeners.findIndex(listener => listener.element === element);\n if (index !== -1) {\n const listener = listeners.splice(index, 1)[0];\n listener.element.removeEventListener('click', listener.fn);\n }\n}\n\n/**\n * Setup moodleGPT into the page (remove/injection)\n * @param config\n * @returns\n */\nfunction setUpMoodleGpt(config: Config) {\n // Removing events if there are already declared\n if (listeners.length > 0) {\n for (const listener of listeners) {\n if (config.cursor) listener.element.style.cursor = 'initial';\n listener.element.removeEventListener('click', listener.fn);\n }\n if (config.title) titleIndications('Removed');\n listeners.length = 0;\n return;\n }\n\n // Query to find inputs and forms\n const inputTypeQuery = ['checkbox', 'radio', 'text', 'number']\n .map(e => `input[type=\"${e}\"]`)\n .join(',');\n const inputQuery = inputTypeQuery + ', textarea, select, [contenteditable]';\n const forms = document.querySelectorAll('.formulation');\n\n // For each form we inject a function on the queqtion\n for (const form of forms) {\n const questionElement: HTMLElement | null = form.querySelector('.qtext');\n\n if (questionElement === null) continue;\n\n if (config.cursor) questionElement.style.cursor = 'pointer';\n\n const injectionFunction = reply.bind(null, {\n config,\n questionElement,\n form: form as HTMLElement,\n inputQuery,\n removeListener: () => removeListener(questionElement)\n });\n\n listeners.push({ element: questionElement, fn: injectionFunction });\n questionElement.addEventListener('click', injectionFunction);\n }\n\n if (config.title) titleIndications('Injected');\n}\n\nexport { codeListener, removeListener, setUpMoodleGpt };\n","import type Config from '@typing/config';\nimport { codeListener, setUpMoodleGpt } from './core/code-listener';\n\nchrome.storage.sync.get(['moodleGPT']).then(function (storage) {\n const config: Config = storage.moodleGPT;\n\n if (!config) throw new Error('Please configure MoodleGPT into the extension');\n\n if (config.code) {\n codeListener(config);\n } else {\n setUpMoodleGpt(config);\n }\n});\n"],"names":["titleIndications","text","backTitle","document","title","setTimeout","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","sentenceSimilarity","str1","str2","longerLength","length","matrix","str1WithoutSpaces","replace","str2WithoutSpaces","i","push","j","Math","min","levenshteinDistance","pickBestReponse","answer","arr","bestResponse","element","similarity","obj","SuppressedError","Logs","question","console","log","bestAnswer","round","toPourcentage","array","response","gptAnswer","normalizedResponse","normalizeText","toLowerCase","trim","ROLE","CONTENT_TYPE","INSTRUCTION","SYSTEM_INSTRUCTION_MESSAGE","role","SYSTEM","content","getContent","config","questionElement","imagesElements","querySelectorAll","includeImages","version","versionNumber","match","Number","isGPTModelGreaterOrEqualTo4","model","contentWithImages","base64Images","Array","from","map","imgEl","imageElement","quality","canvas","createElement","ctx","getContext","remove","img","Image","crossOrigin","onload","width","height","drawImage","base64","toDataURL","onerror","err","src","imageToBase64","base64ImagesResolved","allSettled","status","type","IMAGE","image_url","url","logs","error","reason","TEXT","getContentWithHistory","message","USER","history","messages","pastHistory","JSON","parse","_a","sessionStorage","moodleGPTHistory","newHistory","urlParams","URLSearchParams","location","search","host","cmid","get","attempt","_b","createNewHistory","a","b","KEYS_TO_COMPARE","key","areHistoryFromSameQuiz","saveResponse","ASSISTANT","stringify","htmlTableToString","table","tab","lines","maxColumnsLength","line","cellsContent","cell","index","textContent","max","headerLineLength","lineSeparationSize","reduce","jointure","lineSeparation","fill","join","mappedTab","padEnd","shift","handleClipboard","navigator","clipboard","writeText","handleContentEditable","inputList","input","getAttribute","typing","addEventListener","event","preventDefault","slice","focus","range","createRange","selectNodeContents","collapse","selection","window","getSelection","removeAllRanges","addRange","handleNumber","number","undefined","handleRadio","firstInput","possibleAnswers","inp","parentElement","filter","correctInput","mouseover","click","once","handleCheckbox","corrects","split","correct","handleSelect","tagName","options","opt","correctOption","currentSelect","closest","selected","handleTextbox","reply","props","cursor","style","questionContainer","innerText","accesshideElements","useless","tables","createAndNormalizeQuestion","form","inputQuery","controller","AbortController","timeoutControler","abort","contentHandler","req","fetch","method","headers","Authorization","apiKey","signal","timeout","body","temperature","top_p","presence_penalty","max_tokens","clearTimeout","json","choices","getChatGPTResponse","catch","haveError","infinite","mode","removeListener","clipboardMode","questionBackup","innerHTML","whiteSpace","contentIsResponse","questionToAnswerMode","handlers","handler","autoCompleteMode","pressedKeys","listeners","findIndex","listener","splice","removeEventListener","fn","setUpMoodleGpt","forms","querySelector","injectionFunction","bind","chrome","storage","sync","moodleGPT","Error","code","codeListener"],"mappings":"2FAIA,SAASA,EAAiBC,GACxB,MAAMC,EAAYC,SAASC,MAC3BD,SAASC,MAAQH,EACjBI,YAAW,IAAOF,SAASC,MAAQF,GAAY,IACjD,CC0GO,SAASI,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,Q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AAQ6O,EAAYlG,QACtDkG,EAAYrG,KAAK,MAAQ/F,EAAOqN,OAClCjB,EAAY7O,OAAS,EACrBoP,EAAe3M,GAEnB,GACF,CChBIsN,CAAatN,GAEb2M,EAAe3M,EAEnB","x_google_ignoreList":[1]}
\ No newline at end of file
diff --git a/extension/manifest.json b/extension/manifest.json
index 511db99..cd82460 100644
--- a/extension/manifest.json
+++ b/extension/manifest.json
@@ -1,26 +1,26 @@
-{
- "manifest_version": 3,
- "name": "MoodleGPT",
- "version": "1.0.3",
- "description": "Hidden chat-gpt for your moodle quiz",
- "permissions": ["storage"],
- "action": {
- "default_icon": "icon.png",
- "default_popup": "./popup/index.html"
- },
-
- "icons": {
- "16": "icon.png",
- "32": "icon.png",
- "48": "icon.png",
- "128": "icon.png"
- },
-
- "content_scripts": [
- {
- "matches": ["*://*/**/mod/quiz/*", "*://*/mod/quiz/*", "file:///*"],
- "js": ["MoodleGPT.js"],
- "run_at": "document_end"
- }
- ]
-}
+{
+ "manifest_version": 3,
+ "name": "MoodleGPT",
+ "version": "1.1.0",
+ "description": "Hidden chat-gpt for your moodle quiz",
+ "permissions": ["storage"],
+ "action": {
+ "default_icon": "icon.png",
+ "default_popup": "./popup/index.html"
+ },
+
+ "icons": {
+ "16": "icon.png",
+ "32": "icon.png",
+ "48": "icon.png",
+ "128": "icon.png"
+ },
+
+ "content_scripts": [
+ {
+ "matches": ["*://*/**/mod/quiz/attempt.php*", "*://*/mod/quiz/attempt.php*", "file:///*"],
+ "js": ["MoodleGPT.js"],
+ "run_at": "document_end"
+ }
+ ]
+}
diff --git a/extension/popup/index.html b/extension/popup/index.html
index caa943c..3871c91 100644
--- a/extension/popup/index.html
+++ b/extension/popup/index.html
@@ -1,138 +1,149 @@
-
-
-
-
-
-
- MoodleGPT
-
-
-
-
-
-
-
-
-
- Gives a "reverseWorld" function in javascript which takes as a
- parameter a word and flips it in the opposite direction
+ Gives a "reverseWorld" function in javascript which takes as a parameter a word and flips
+ it in the opposite direction
+
+
+
+
+ Warning ! Only work with gpt-4 and if "includes images" is activate
+
+
+
What is the race of those cats:
+
+
+
+
+
+
+
diff --git a/test/reset-moodle-inputs/reset.js b/test/reset-moodle-inputs/reset.js
index 2ba4d86..9675c46 100644
--- a/test/reset-moodle-inputs/reset.js
+++ b/test/reset-moodle-inputs/reset.js
@@ -1,21 +1,19 @@
/* Reset real moodle inputs to try in real env */
-for (const option of document.querySelectorAll("option")) {
+for (const option of document.querySelectorAll('option')) {
option.selected = false;
option.disabled = false;
- option.closest("select").disabled = false;
+ option.closest('select').disabled = false;
}
-for (const input of document.querySelectorAll(
- 'input[type="radio"], input[type="checkbox"]'
-)) {
+for (const input of document.querySelectorAll('input[type="radio"], input[type="checkbox"]')) {
input.checked = false;
input.disabled = false;
}
-for (const icon of document.querySelectorAll(".text-danger, .text-success")) {
+for (const icon of document.querySelectorAll('.text-danger, .text-success')) {
icon.remove();
}
-for (const feedback of document.querySelectorAll(".specificfeedback")) {
+for (const feedback of document.querySelectorAll('.specificfeedback')) {
feedback.remove();
}
diff --git a/tsconfig.json b/tsconfig.json
index c7d476b..e6bdc50 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,16 +1,25 @@
-{
- "compilerOptions": {
- "module": "CommonJS",
- "esModuleInterop": true,
- "allowSyntheticDefaultImports": true,
- "target": "ES6",
- "noImplicitAny": true,
- "moduleResolution": "node",
- "sourceMap": true,
- "outDir": "extension",
- "resolveJsonModule": true,
- "types": ["node", "chrome"],
- "typeRoots": ["node_modules/@types"]
- },
- "include": ["src/**/*"]
-}
+{
+ "compilerOptions": {
+ "strict": true,
+ "baseUrl": "src",
+ "module": "CommonJS",
+ "esModuleInterop": true,
+ "allowSyntheticDefaultImports": true,
+ "target": "ES6",
+ "noImplicitAny": true,
+ "moduleResolution": "node",
+ "sourceMap": true,
+ "outDir": "extension",
+ "resolveJsonModule": true,
+ "types": ["node", "chrome"],
+ "typeRoots": ["node_modules/@types"],
+ "strictBindCallApply": true,
+ "paths": {
+ "@typing/*": ["types/*"],
+ "@utils/*": ["utils/*"],
+ "@core/*": ["core/*"],
+ "@questions/*": ["core/question/*"]
+ }
+ },
+ "include": ["src/**/*"]
+}
diff --git a/webstore-assets/banner1.jpg b/webstore-assets/v1/banner1.jpg
similarity index 100%
rename from webstore-assets/banner1.jpg
rename to webstore-assets/v1/banner1.jpg
diff --git a/webstore-assets/banner2.png b/webstore-assets/v1/banner2.png
similarity index 100%
rename from webstore-assets/banner2.png
rename to webstore-assets/v1/banner2.png
diff --git a/webstore-assets/banner3.jpg b/webstore-assets/v1/banner3.jpg
similarity index 100%
rename from webstore-assets/banner3.jpg
rename to webstore-assets/v1/banner3.jpg
diff --git a/webstore-assets/banner4.png b/webstore-assets/v1/banner4.png
similarity index 100%
rename from webstore-assets/banner4.png
rename to webstore-assets/v1/banner4.png
diff --git a/webstore-assets/description.txt b/webstore-assets/v1/description.txt
similarity index 100%
rename from webstore-assets/description.txt
rename to webstore-assets/v1/description.txt
diff --git a/webstore-assets/icon-128x128.jpg b/webstore-assets/v1/icon-128x128.jpg
similarity index 100%
rename from webstore-assets/icon-128x128.jpg
rename to webstore-assets/v1/icon-128x128.jpg
diff --git a/webstore-assets/v2/banner1.jpg b/webstore-assets/v2/banner1.jpg
new file mode 100644
index 0000000..69990f0
Binary files /dev/null and b/webstore-assets/v2/banner1.jpg differ
diff --git a/webstore-assets/v2/banner2.png b/webstore-assets/v2/banner2.png
new file mode 100644
index 0000000..b160a72
Binary files /dev/null and b/webstore-assets/v2/banner2.png differ
diff --git a/webstore-assets/v2/banner3.jpg b/webstore-assets/v2/banner3.jpg
new file mode 100644
index 0000000..b04c130
Binary files /dev/null and b/webstore-assets/v2/banner3.jpg differ
diff --git a/webstore-assets/v2/banner4.jpg b/webstore-assets/v2/banner4.jpg
new file mode 100644
index 0000000..571649d
Binary files /dev/null and b/webstore-assets/v2/banner4.jpg differ
diff --git a/webstore-assets/v2/description.txt b/webstore-assets/v2/description.txt
new file mode 100644
index 0000000..628275c
--- /dev/null
+++ b/webstore-assets/v2/description.txt
@@ -0,0 +1,22 @@
+MoodleGPT: Transform Your Moodle Quiz Experience
+
+MoodleGPT is a revolutionary Chrome extension designed to elevate your Moodle quiz-taking experience to new heights. By seamlessly integrating the power of CHAT-GPT, MoodleGPT provides you with an invisible assistant that effortlessly guides you through quiz questions, delivering answers with precision and speed.
+
+Key Features:
+---
+- Versatile Question Support: Whether it's Select, Put in Order, Resolve Equation, One Response, Multiple Responses, True or False, Number, or Text questions, MoodleGPT has you covered.
+- Dynamic Modes: Choose from Autocomplete, Clipboard, or Question to Answer modes to interact with answers in a way that suits your style.
+- Simple Setup: Load the extension, enter your OpenAI API key, choose a model, and you're ready to conquer your Moodle quizzes.
+- Customizable Settings: Tailor the extension to your preferences, including the choice of GPT model, cursor indication, title indication, typing/mouseover effect, include images, create conversation and more.
+
+Enhance Your Quiz-Taking Experience:
+---
+MoodleGPT streamlines the quiz-taking process, providing you with accurate answers and saving you valuable time. It's the perfect tool for students and educators looking to optimize their Moodle experience.
+
+Support Us:
+---
+If you find MoodleGPT helpful, consider supporting the project with a donation. Your support helps us continue improving and adding new features.
+
+Github: https://github.com/yoannchb-pro/MoodleGPT
+Donation: https://www.buymeacoffee.com/yoannchbpro
+Icon credits: Mortarboard icons created by itim2101 - Flaticon
\ No newline at end of file
diff --git a/webstore-assets/v2/icon-128x128-black.jpg b/webstore-assets/v2/icon-128x128-black.jpg
new file mode 100644
index 0000000..e3d431d
Binary files /dev/null and b/webstore-assets/v2/icon-128x128-black.jpg differ
diff --git a/webstore-assets/v2/little_promotion.jpg b/webstore-assets/v2/little_promotion.jpg
new file mode 100644
index 0000000..37e0ae6
Binary files /dev/null and b/webstore-assets/v2/little_promotion.jpg differ