v1.0.0
This commit is contained in:
@@ -36,12 +36,15 @@ To test the code, you can run the index.js file located in the <b>"test"</b> fol
|
||||
<img src="./assets/popup.png" alt="Popup" height="300">
|
||||
</p>
|
||||
|
||||
- <b>Api key\*</b>: the openai api key.
|
||||
- <b>Code\*</b>: code that you will need to inject/remove the code.
|
||||
- <b>Langage</b>: the langage you want chatgpt reply (if it's not set it will take the question langage).
|
||||
- <b>Cursor indication</b>: show a pointer cursor and a hourglass to know when the request is finished.
|
||||
- <b>Title indication</b>: Show some informations into the title to know for example if the code have been injected.
|
||||
- <b>Title indication</b>: show some informations into the title to know for example if the code have been injected.
|
||||
<br/> 
|
||||
- <b>Console logs</b>: show logs into the console.
|
||||
<br/><img src="./assets/logs.png" alt="Logs" width="250">
|
||||
- <b>Typing effect</b>: create a typing effect for text.
|
||||
- <b>Typing effect</b>: 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 <b>Backspace</b> key.
|
||||
<br/> 
|
||||
- <b>Mouseover effect</b>: you will need to hover (or click for select) the question response to complete it automaticaly.
|
||||
<br/> 
|
||||
|
||||
+21
-15
@@ -6,8 +6,8 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
|
||||
//listening to the keys to inject moodleGPT
|
||||
const pressedKeys = [];
|
||||
const listeners = [];
|
||||
document.body.addEventListener("keypress", function (e) {
|
||||
pressedKeys.push(e.key);
|
||||
document.body.addEventListener("keydown", function (event) {
|
||||
pressedKeys.push(event.key);
|
||||
if (pressedKeys.length > config.code.length) pressedKeys.shift();
|
||||
if (pressedKeys.join("") === config.code) {
|
||||
pressedKeys.length = 0;
|
||||
@@ -70,8 +70,8 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
|
||||
.replace(/[ \t]+/g, " ")
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/^[a-z\d]\.\s/gi, "")
|
||||
.replace(/\n[a-z\d]\.\s/gi, "\n");
|
||||
.replace(/^[a-z\d]\.\s/gi, "") //a. text, b. text, c. text, 1. text, 2. text, 3.text
|
||||
.replace(/\n[a-z\d]\.\s/gi, "\n"); //a. text, b. text, c. text, 1. text, 2. text, 3.text
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,14 +136,19 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
|
||||
|
||||
const question = normalizeText(form.textContent);
|
||||
const inputList = form.querySelectorAll(query);
|
||||
const response = await getChatGPTResponse(
|
||||
`Give a short response as possible for this question, reply in this langage "${config.langage}" and only show the result:
|
||||
|
||||
const finalQuestion = `Give a short response as possible for this question, reply in ${
|
||||
config.langage && config.langage !== ""
|
||||
? 'this langage "' + config.langage + '"'
|
||||
: "the following question langage"
|
||||
} and only show the result:
|
||||
${question}
|
||||
(If you have to choose between multiple results only show the corrects one and do not change the initial text)`
|
||||
);
|
||||
(If you have to choose between multiple results only show the corrects one and seprate responses with new line)`;
|
||||
|
||||
const response = await getChatGPTResponse(finalQuestion);
|
||||
|
||||
if (config.logs) {
|
||||
Logs.question(question);
|
||||
Logs.question(finalQuestion);
|
||||
Logs.response(response);
|
||||
}
|
||||
|
||||
@@ -162,12 +167,13 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
|
||||
inputList[0].tagName === "TEXTAREA"
|
||||
) {
|
||||
if (config.typing) {
|
||||
for (let i = 0; i < response.length; ++i) {
|
||||
setTimeout(
|
||||
() => (inputList[0].value = response.slice(0, i + 1)),
|
||||
i * 50
|
||||
);
|
||||
}
|
||||
let index = 0;
|
||||
inputList[0].addEventListener("keydown", function (event) {
|
||||
if (event.key === "Backspace") index = response.length + 1;
|
||||
if (index > response.length) return;
|
||||
event.preventDefault();
|
||||
inputList[0].value = response.slice(0, ++index);
|
||||
});
|
||||
} else {
|
||||
inputList[0].value = response;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
/></a>
|
||||
<h1>MoodleGPT</h1>
|
||||
<div class="line">
|
||||
<label for="apiKey" class="textLabel">Api Key</label>
|
||||
<label for="apiKey" class="textLabel">Api Key*</label>
|
||||
<input id="apiKey" type="password" />
|
||||
</div>
|
||||
<div class="line">
|
||||
<label for="code" class="textLabel">Code</label>
|
||||
<label for="code" class="textLabel">Code*</label>
|
||||
<input id="code" type="text" />
|
||||
</div>
|
||||
<div class="line">
|
||||
@@ -32,7 +32,7 @@
|
||||
<input id="langage" type="text" />
|
||||
</div>
|
||||
<div class="line" style="margin-top: 1rem">
|
||||
<input id="typing" type="checkbox" checked />
|
||||
<input id="typing" type="checkbox" />
|
||||
<label for="typing">Typing effect</label>
|
||||
</div>
|
||||
<div class="line" style="margin-bottom: 1rem">
|
||||
|
||||
@@ -20,7 +20,7 @@ saveBtn.addEventListener("click", function () {
|
||||
(selector) => document.querySelector("#" + selector).checked
|
||||
);
|
||||
|
||||
if (!apiKey || !code || !langage) {
|
||||
if (!apiKey || !code) {
|
||||
showMessage("Please comple all the form");
|
||||
return;
|
||||
}
|
||||
@@ -56,8 +56,5 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
|
||||
inputsCheckbox.forEach(
|
||||
(key) => (document.querySelector("#" + key).checked = config[key] || "")
|
||||
);
|
||||
} else {
|
||||
//set default config
|
||||
document.querySelector("#langage").value = navigator.language;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user