This commit is contained in:
yoannchb-pro
2023-03-21 18:02:07 -04:00
committed by GitHub
parent 2547c4b974
commit 669119f11c
8 changed files with 108 additions and 53 deletions
+6 -4
View File
@@ -26,10 +26,6 @@ You just need to enter on the keyboard the <b>code</b> you have set into the ext
Type back the <b>code</b> on the keyboard and the code will be removed from the current page.
## Test
To test the code, you can run the index.js file located in the <b>"test"</b> folder.
## Options
<p align="center">
@@ -39,9 +35,11 @@ To test the code, you can run the index.js file located in the <b>"test"</b> fol
- <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>GPT Model</b>: the gpt model you want to use (by default it's "gpt-3.5-turbo").
- <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.
<br/> ![Injected](./assets/title-injected.png)
- <b>Infinite try</b>: click as much as you want on the question (don't forget to reset the question).
- <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. Type any text and it will be replaced by the correct one. If you want to stop it press <b>Backspace</b> key.
@@ -85,3 +83,7 @@ To test the code, you can run the index.js file located in the <b>"test"</b> fol
To know if the answer has been copied to the clipboard, you can look at the title of the page which will become <b>"Copied to clipboard"</b> for 3 seconds.
![Clipboard](./assets/clipboard.gif)
## Test
To test the code, you can run the index.js file located in the <b>"test"</b> folder.
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 25 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 44 KiB

+8 -6
View File
@@ -34,7 +34,7 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
for (const listener of listeners) {
if (config.cursor) listener.element.style.cursor = "initial";
listener.element.removeEventListener("click", listener.fn, {
once: true,
once: !config.infinite,
});
}
if (config.title) titleIndications("Removed");
@@ -54,7 +54,7 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
if (config.cursor) hiddenButton.style.cursor = "pointer";
const fn = reply.bind(null, hiddenButton, form, query);
listeners.push({ element: hiddenButton, fn });
hiddenButton.addEventListener("click", fn, { once: true });
hiddenButton.addEventListener("click", fn, { once: !config.infinite });
}
if (config.title) titleIndications("Injected");
@@ -87,7 +87,8 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
Authorization: `Bearer ${config.apiKey}`,
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
model:
config.model && config.model !== "" ? config.model : "gpt-3.5-turbo",
messages: [{ role: "user", content: question }],
temperature: 0.8,
top_p: 1.0,
@@ -105,7 +106,7 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
*/
class Logs {
static question(text) {
const css = "color: blue";
const css = "color: cyan";
console.log("%c[QUESTION]: %s", css, text);
}
@@ -143,7 +144,7 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
: "the following question langage"
} and only show the result:
${question}
(If you have to choose between multiple results only show the corrects one and seprate responses with new line)`;
(If you have to choose between multiple results only show the corrects one and separate them with new line)`;
const response = await getChatGPTResponse(finalQuestion);
@@ -152,7 +153,8 @@ chrome.storage.sync.get(["moodleGPT"]).then(function (storage) {
Logs.response(response);
}
if (config.cursor) hiddenButton.style.cursor = "initial";
if (config.cursor)
hiddenButton.style.cursor = config.infinite ? "pointer" : "initial";
//if we dont find the input we copy into the clipboard
if (inputList.length === 0) {
+44 -23
View File
@@ -19,42 +19,63 @@
><img src="../icon.png" alt="icon"
/></a>
<h1>MoodleGPT</h1>
<div class="line">
<div class="line center">
<label for="apiKey" class="textLabel">Api Key*</label>
<input id="apiKey" type="password" />
</div>
<div class="line">
<div class="line center">
<label for="code" class="textLabel">Code*</label>
<input id="code" type="text" />
</div>
<div class="line">
<div class="line center">
<label for="langage" class="textLabel">Langage</label>
<input id="langage" type="text" />
</div>
<div class="line" style="margin-top: 1rem">
<input id="typing" type="checkbox" />
<label for="typing">Typing effect</label>
<div class="line center">
<label for="model" class="textLabel">GPT Model</label>
<input id="model" type="text" />
</div>
<div class="line" style="margin-bottom: 1rem">
<input id="mouseover" type="checkbox" />
<label for="mouseover">Mouseover effect</label>
<div class="line center" style="margin-top: 1rem">
<div class="col">
<div class="line">
<input id="typing" type="checkbox" />
<label for="typing">Typing effect</label>
</div>
<div class="line">
<input id="mouseover" type="checkbox" />
<label for="mouseover">Mouseover effect</label>
</div>
<div class="line">
<input id="infinite" type="checkbox" />
<label for="infinite">Infinite try</label>
</div>
</div>
<div class="col">
<div class="line">
<input id="logs" type="checkbox" />
<label for="logs">Console logs</label>
</div>
<div class="line">
<input id="title" type="checkbox" />
<label for="title">Title indication</label>
</div>
<div class="line">
<input id="cursor" type="checkbox" checked />
<label for="cursor">Cursor indication</label>
</div>
</div>
</div>
<div class="line">
<input id="logs" type="checkbox" />
<label for="logs">Console logs</label>
</div>
<div class="line">
<input id="title" type="checkbox" checked />
<label for="title">Title indication</label>
</div>
<div class="line">
<input id="cursor" type="checkbox" checked />
<label for="cursor">Cursor indication</label>
</div>
<p id="message"></p>
<div class="line">
<p id="message">Message</p>
<div class="line center">
<button class="save">Save</button>
</div>
<a
href="https://github.com/yoannchb-pro/MoodleGPT"
target="_blank"
rel="noopener noreferrer"
>
See the documentation
</a>
</main>
</body>
</html>
+13 -4
View File
@@ -1,8 +1,15 @@
const saveBtn = document.querySelector(".save");
const message = document.querySelector("#message");
const inputsText = ["apiKey", "code", "langage"];
const inputsCheckbox = ["logs", "title", "cursor", "typing", "mouseover"];
const inputsText = ["apiKey", "code", "langage", "model"];
const inputsCheckbox = [
"logs",
"title",
"cursor",
"typing",
"mouseover",
"infinite",
];
function showMessage(messageTxt, valide) {
message.style.color = valide ? "limegreen" : "red";
@@ -13,10 +20,10 @@ function showMessage(messageTxt, valide) {
//save the configuration
saveBtn.addEventListener("click", function () {
const [apiKey, code, langage] = inputsText.map((selector) =>
const [apiKey, code, langage, model] = inputsText.map((selector) =>
document.querySelector("#" + selector).value.trim()
);
const [logs, title, cursor, typing, mouseover] = inputsCheckbox.map(
const [logs, title, cursor, typing, mouseover, infinite] = inputsCheckbox.map(
(selector) => document.querySelector("#" + selector).checked
);
@@ -35,11 +42,13 @@ saveBtn.addEventListener("click", function () {
apiKey,
code,
langage,
model,
logs,
title,
cursor,
typing,
mouseover,
infinite,
},
});
+25 -9
View File
@@ -32,28 +32,37 @@ main {
padding: 0.75rem;
gap: 0.4rem;
text-align: center;
width: 20rem;
width: 22rem;
}
img {
width: 5rem;
margin-top: 1rem;
margin-top: 0.75rem;
}
h1 {
margin-top: 1rem;
margin-bottom: 1rem;
margin-top: 0.75rem;
margin-bottom: 0.75rem;
}
a {
color: var(--btn-color);
margin: 0;
}
.line {
display: flex;
width: 100%;
gap: 0.5rem;
}
.center {
justify-content: center;
align-items: center;
width: 100%;
}
.line .textLabel {
width: 5rem;
width: 6rem;
text-transform: uppercase;
}
@@ -72,18 +81,25 @@ h1 {
margin-right: 0.3rem;
}
.col {
display: flex;
flex-direction: column;
text-align: left;
}
.save {
border: none;
background-color: var(--btn-color);
margin-top: 1.5rem;
padding: 0.5rem 2rem;
margin-top: 1rem;
cursor: pointer;
border-radius: 0.2rem;
font-size: 1.5rem;
margin-bottom: 1rem;
margin-bottom: 0.75rem;
}
#message {
display: none;
margin-top: 1rem;
margin-top: 0.75rem;
margin-bottom: -0.25rem;
}
+12 -7
View File
@@ -121,14 +121,17 @@
<!-- Select Number -->
<section class="formulation">
<div class="qtext">
<p>Put the following tags in the order of creation of a html file:</p>
<p>
Put the three steps needed in a general sense for a computer program
to solve the problem in the correct order
</p>
</div>
<div>
<div class="inp">
<table>
<tr>
<td class="text">
<p>html</p>
<p>Understand the problem</p>
</td>
<td>
<select>
@@ -141,7 +144,7 @@
</tr>
<tr>
<td class="text">
<p>body</p>
<p>Carry out the plan and write the actual code</p>
</td>
<td>
<select>
@@ -154,7 +157,9 @@
</tr>
<tr>
<td class="text"><p>head</p></td>
<td class="text">
<p>Create a step-by-step plan for how you'll solve it</p>
</td>
<td>
<select>
<option>Choose...</option>
@@ -179,7 +184,7 @@
<table>
<tr>
<td class="text">
<p>5*5</p>
<p>1. 5*5</p>
</td>
<td>
<select>
@@ -192,7 +197,7 @@
</tr>
<tr>
<td class="text">
<p>20 - 10</p>
<p>2. 20 - 10</p>
</td>
<td>
<select>
@@ -205,7 +210,7 @@
</tr>
<tr>
<td class="text"><p>10+10</p></td>
<td class="text"><p>3. 10+10</p></td>
<td>
<select>
<option>Choose...</option>