Bump tesseract.js to v5.0.5

Signed-off-by: adithyagenie <adithyagenie@gmail.com>
This commit is contained in:
adithyagenie 2024-03-07 19:53:03 +05:30
parent c96bfe392e
commit c530eadda9
Signed by: adithyagenie
GPG key ID: C66E41599E458D96
2 changed files with 10 additions and 13 deletions

View file

@ -3,7 +3,7 @@
Use GreaseMonkey/TamperMonkey to run the script. Use GreaseMonkey/TamperMonkey to run the script.
> ⚠️ **Please disable the script if you are attending the test as it might lead to unintended effects.** > ⚠️ **Please disable the script if you are attending a test as it might lead to unintended effects.**
> ⚠️ **Attempting to navigate the page while the captcha solver is running may lead to unintended effects. If it gets stuck in a loop, closing and opening the tabs will fix it.** > ⚠️ **Attempting to navigate the page while the captcha solver is running may lead to unintended effects. If it gets stuck in a loop, closing and opening the tabs will fix it.**

View file

@ -11,10 +11,8 @@
// @description Solves math captcha in SkillRack using Tesseract.js // @description Solves math captcha in SkillRack using Tesseract.js
// @author adithyagenie // @author adithyagenie
// @license AGPL-3.0-or-later // @license AGPL-3.0-or-later
// @include /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogram\.xhtml/ // @include /https:\/\/(www\.)?skillrack\.com\/faces\/candidate\/(codeprogram|tutorprogram|codeprogramgroup)\.xhtml/
// @include /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/tutorprogram\.xhtml/ // @require https://cdn.jsdelivr.net/npm/tesseract.js@5.0.5/dist/tesseract.min.js
// @include /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogramgroup\.xhtml/
// @require https://cdn.jsdelivr.net/npm/tesseract.js@5.0.2/dist/tesseract.min.js
// ==/UserScript== // ==/UserScript==
const USERNAME = ""; const USERNAME = "";
@ -142,14 +140,13 @@ const USERNAME = "";
function removeText(text) { function removeText(text) {
text = text.replace(USERNAME, ""); text = text.replace(USERNAME, "");
let i = text.length - 1; let i = text.length - 1;
i = text.lastIndexOf("+");
i = text.lastIndexOf("+")
if (i == -1) { if (i == -1) {
alert("Oops! I wasn't able to parse the captcha correctly :( Please enter the captcha or try re-visitng again!");
console.error("Error parsing username."); console.error("Error parsing username.");
return; return;
} }
i--; i--;
for (i; i >= 0; i--) { for (i; i >= 0; i--) {
if (!("1234567890".includes(text[i]))) { if (!("1234567890".includes(text[i]))) {
return text.slice(i + 1); return text.slice(i + 1);
@ -171,10 +168,10 @@ const USERNAME = "";
// Image Processing with Tesseract.js // Image Processing with Tesseract.js
Tesseract.recognize(invertedimg, "eng", { Tesseract.recognize(invertedimg, "eng", {
whitelist: "1234567890+=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@ ", whitelist: "1234567890+=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@ ",
psm: 7, psm: 6,
}) })
.then(({ data: { text } }) => { .then(({ data: { text } }) => {
console.log(`OCR: ${new Date().getTime() - time} ms.`); console.log(`OCR: ${new Date().getTime() - time} ms. Result: ${text}`);
// Solve the Math Problem // Solve the Math Problem
try { try {
const mathprob = removeText(text); const mathprob = removeText(text);