Implement handling if 'www' is missing in url

Signed-off-by: adithyagenie <adithyagenie@gmail.com>
This commit is contained in:
adithyagenie 2023-10-25 12:59:29 +05:30
parent 461186e252
commit c96bfe392e

View file

@ -7,13 +7,13 @@
// ==UserScript== // ==UserScript==
// @name Skillrack Captcha Solver // @name Skillrack Captcha Solver
// @namespace https://github.com/adithyagenie/skillrack-captcha-solver // @namespace https://github.com/adithyagenie/skillrack-captcha-solver
// @version 0.5 // @version 0.6
// @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\.xhtml/
// @include https://www.skillrack.com/faces/candidate/tutorprogram.xhtml // @include /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/tutorprogram\.xhtml/
// @include https://www.skillrack.com/faces/candidate/codeprogramgroup.xhtml // @include /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogramgroup\.xhtml/
// @require https://cdn.jsdelivr.net/npm/tesseract.js@5.0.2/dist/tesseract.min.js // @require https://cdn.jsdelivr.net/npm/tesseract.js@5.0.2/dist/tesseract.min.js
// ==/UserScript== // ==/UserScript==
@ -24,8 +24,9 @@ const USERNAME = "";
// Clear all sessionstorage data if going back out of solve. // Clear all sessionstorage data if going back out of solve.
if ( if (
window.location.href == window.location.href.match(
"https://www.skillrack.com/faces/candidate/codeprogramgroup.xhtml" /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogramgroup\.xhtml/gi
)
) { ) {
if (sessionStorage.getItem("Solvebtnid")) if (sessionStorage.getItem("Solvebtnid"))
sessionStorage.removeItem("Solvebtnid"); sessionStorage.removeItem("Solvebtnid");
@ -73,13 +74,15 @@ const USERNAME = "";
// Different image ids for tutorial and track websites // Different image ids for tutorial and track websites
let image; let image;
if ( if (
window.location.href == window.location.href.match(
"https://www.skillrack.com/faces/candidate/codeprogram.xhtml" /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogram\.xhtml/gi
)
) )
image = document.getElementById("j_id_6x"); image = document.getElementById("j_id_6x");
else if ( else if (
window.location.href == window.location.href.match(
"https://www.skillrack.com/faces/candidate/tutorprogram.xhtml" /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/tutorprogram\.xhtml/gi
)
) )
image = document.getElementById("j_id_5o"); image = document.getElementById("j_id_5o");
@ -95,8 +98,9 @@ const USERNAME = "";
if (errors.length > 0) { if (errors.length > 0) {
if (errors[0].textContent.includes("Incorrect Captcha")) { if (errors[0].textContent.includes("Incorrect Captcha")) {
if ( if (
window.location.href == window.location.href.match(
"https://www.skillrack.com/faces/candidate/tutorprogram.xhtml" /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/tutorprogram\.xhtml/gi
)
) { ) {
alert("Unable to solve captcha :("); alert("Unable to solve captcha :(");
return; return;