From c96bfe392ea976d2678ebc50a8567e56960aba82 Mon Sep 17 00:00:00 2001 From: adithyagenie Date: Wed, 25 Oct 2023 12:59:29 +0530 Subject: [PATCH] Implement handling if 'www' is missing in url Signed-off-by: adithyagenie --- userscript.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/userscript.js b/userscript.js index 288b0e7..17f28e8 100644 --- a/userscript.js +++ b/userscript.js @@ -7,13 +7,13 @@ // ==UserScript== // @name 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 // @author adithyagenie // @license AGPL-3.0-or-later -// @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/codeprogramgroup.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\/codeprogramgroup\.xhtml/ // @require https://cdn.jsdelivr.net/npm/tesseract.js@5.0.2/dist/tesseract.min.js // ==/UserScript== @@ -24,8 +24,9 @@ const USERNAME = ""; // Clear all sessionstorage data if going back out of solve. if ( - window.location.href == - "https://www.skillrack.com/faces/candidate/codeprogramgroup.xhtml" + window.location.href.match( + /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogramgroup\.xhtml/gi + ) ) { if (sessionStorage.getItem("Solvebtnid")) sessionStorage.removeItem("Solvebtnid"); @@ -73,13 +74,15 @@ const USERNAME = ""; // Different image ids for tutorial and track websites let image; if ( - window.location.href == - "https://www.skillrack.com/faces/candidate/codeprogram.xhtml" + window.location.href.match( + /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/codeprogram\.xhtml/gi + ) ) image = document.getElementById("j_id_6x"); else if ( - window.location.href == - "https://www.skillrack.com/faces/candidate/tutorprogram.xhtml" + window.location.href.match( + /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/tutorprogram\.xhtml/gi + ) ) image = document.getElementById("j_id_5o"); @@ -95,8 +98,9 @@ const USERNAME = ""; if (errors.length > 0) { if (errors[0].textContent.includes("Incorrect Captcha")) { if ( - window.location.href == - "https://www.skillrack.com/faces/candidate/tutorprogram.xhtml" + window.location.href.match( + /https:\/\/(www.)?skillrack\.com\/faces\/candidate\/tutorprogram\.xhtml/gi + ) ) { alert("Unable to solve captcha :("); return;