This commit is contained in:
informaticker 2024-10-24 22:50:14 +02:00
parent 464a17008e
commit 501fdaa4a1
3 changed files with 29 additions and 11 deletions

View File

@ -4,6 +4,7 @@ const DEFAULT_SETTINGS = {
apiKey: "sk-TvFhtxHAPXEcmRtyva-ctA", apiKey: "sk-TvFhtxHAPXEcmRtyva-ctA",
textOpacity: 10, textOpacity: 10,
model: "llama3.2-90b", model: "llama3.2-90b",
background: false,
}; };
const MAX_CONTEXT_LENGTH = 6000; const MAX_CONTEXT_LENGTH = 6000;
@ -49,7 +50,7 @@ const queryLLM = async (text) => {
messages: [ messages: [
{ {
role: "user", role: "user",
content: `You are tasked to solve an exam. Exam's page context: ${pageContext}\n\Answer this question of said exam in very short but accurate manner (Utilize context to figure out the exam's topic. ONLY REPLY WITH ANSWER TO THE QUESTION): ${text}`, content: `You are tasked to solve an exam. It is a website. Exam's page context: ${pageContext}\n\Answer this question of said exam in a very short but accurate manner (Utilize context to figure out the exam's topic. ONLY REPLY WITH ANSWER TO THE QUESTION. If you do not know, reply with "I do not know."): ${text}`,
}, },
], ],
temperature: 0.1, temperature: 0.1,
@ -80,10 +81,19 @@ const createOverlay = (text) => {
padding: 5px; padding: 5px;
z-index: 2147483647; z-index: 2147483647;
color: rgba(0, 0, 0, ${settings.textOpacity / 100}); color: rgba(0, 0, 0, ${settings.textOpacity / 100});
font-size: 16px; font-size: 12px;
max-width: 600px; max-width: 600px;
white-space: pre-wrap; white-space: pre-wrap;
pointer-events: none; pointer-events: none;
${
settings.background
? `
background-color: rgba(255, 255, 255, ${settings.textOpacity / 100});
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
`
: ""
}
`; `;
document.body.appendChild(overlay); document.body.appendChild(overlay);

View File

@ -224,7 +224,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">Answer Text Style</label> <label class="form-label">Overlay opacity</label>
<div class="slider-container"> <div class="slider-container">
<input <input
type="range" type="range"
@ -239,21 +239,26 @@
</div> </div>
</div> </div>
<div class="form-group">
<label class="form-label">
<input type="checkbox" id="background" /> Overlay background
</label>
</div>
<div class="shortcuts-panel"> <div class="shortcuts-panel">
<div class="shortcut"> <div class="shortcut">
<span>Solve Question</span> <span>Process Question</span>
<div class="shortcut-keys"> <div class="shortcut-keys">
<span class="key"></span> <span class="key">Ctrl</span>
<span class="key"></span> <span class="key">Space</span>
<span class="key">U</span>
</div> </div>
</div> </div>
<div class="shortcut"> <div class="shortcut">
<span>Fill Answer</span> <span>Process to text field</span>
<div class="shortcut-keys"> <div class="shortcut-keys">
<span class="key"></span> <span class="key">Ctrl</span>
<span class="key"></span> <span class="key">Shift</span>
<span class="key">7</span> <span class="key">Space</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@ const DEFAULT_SETTINGS = {
apiKey: "sk-TvFhtxHAPXEcmRtyva-ctA", apiKey: "sk-TvFhtxHAPXEcmRtyva-ctA",
textOpacity: 10, textOpacity: 10,
model: "llama3.2-90b", model: "llama3.2-90b",
background: false,
}; };
// Load settings when the popup opens // Load settings when the popup opens
@ -17,6 +18,7 @@ document.addEventListener("DOMContentLoaded", async () => {
document.getElementById("textOpacity").value = settings.textOpacity; document.getElementById("textOpacity").value = settings.textOpacity;
document.getElementById("opacityValue").textContent = document.getElementById("opacityValue").textContent =
`${settings.textOpacity}%`; `${settings.textOpacity}%`;
document.getElementById("background").checked = settings.background;
} catch (error) { } catch (error) {
console.error("Error loading settings:", error); console.error("Error loading settings:", error);
showStatus("Error loading settings", "error"); showStatus("Error loading settings", "error");
@ -39,6 +41,7 @@ document
apiKey: document.getElementById("apiKey").value, apiKey: document.getElementById("apiKey").value,
model: document.getElementById("model").value, model: document.getElementById("model").value,
textOpacity: parseInt(document.getElementById("textOpacity").value), textOpacity: parseInt(document.getElementById("textOpacity").value),
background: document.getElementById("background").checked,
}; };
try { try {