🏠 Home 

JEE Mains Marks after capturing the answers

This script calculates the marks after you give the captured answers.


Install this script?
  1. // ==UserScript==
  2. // @license MIT
  3. // @name JEE Mains Marks after capturing the answers
  4. // @match https://examinationservices.nic.in/*/KeyChallange/AnswerKey.aspx
  5. // @description This script calculates the marks after you give the captured answers.
  6. // @version 0.0.1.20220804185237
  7. // @namespace https://greasyfork.org/users/941655
  8. // ==/UserScript==
  9. function parseAnswerKey() {
  10. let table = document.querySelector('#ctl00_LoginContent_grAnswerKey.table.table-bordered.table-condensed tbody')
  11. const content = table = table.querySelectorAll('tr:not(tr:nth-child(1))')
  12. correct_answers = {}
  13. for (let row of content) {
  14. let question_id = row.querySelector('span[id$=QuestionNo]').textContent
  15. let answer = row.querySelector('span[id$=Answer]').textContent
  16. correct_answers[question_id] = answer
  17. }
  18. return correct_answers;
  19. }
  20. /**
  21. * @param {{id: string; subject: "Chemistry" | "Physics" | "Maths"; section: "A" | "B"; givenAnswer: string}[]} givenAnswers Description
  22. */
  23. function calculateMarks(givenAnswers) {
  24. const correctAnswers = parseAnswerKey();
  25. let total = 0;
  26. for (const givenAnswer of givenAnswers) {
  27. if (!givenAnswer.givenAnswer.includes("Not Attempted")) {
  28. if (correctAnswers[givenAnswer.id] === givenAnswer.givenAnswer) total += 4;
  29. else total--;
  30. }
  31. }
  32. alert(`The total marks are ${total}`)
  33. }
  34. const main = () => {
  35. const mapForm = document.createElement("form");
  36. const mapInput = document.createElement("input");
  37. mapInput.type = "text";
  38. mapInput.name = "answers";
  39. mapInput.placeholder = 'Paste captured answers';
  40. const submitBtn = document.createElement("button");
  41. submitBtn.type = 'submit'
  42. submitBtn.innerText = "Get marks"
  43. mapForm.appendChild(mapInput);
  44. mapForm.appendChild(submitBtn);
  45. document.body.prepend(mapForm);
  46. mapForm.onsubmit = e => {
  47. e.preventDefault();
  48. try {
  49. calculateMarks(JSON.parse(mapInput.value));
  50. } catch (e) {
  51. alert(e)
  52. }
  53. }
  54. }
  55. main()