Study.com Quiz Answers

Highlights correct answers with a green background on Study.com quizzes and exams

2021-04-07 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Study.com Quiz Answers
// @namespace   Violentmonkey Scripts
// @match       *://*.study.com/*
// @include     https://study.com/*
// @grant       none
// @version     1.1.0
// @author      Jonah Lawrence
// @description Highlights correct answers with a green background on Study.com quizzes and exams
// ==/UserScript==

/* jshint esversion: 6 */

(function () {
    const interval = setInterval(function () {
        const container = document.querySelector("#practice-exam-container");
        // check if practice-exam-container element exists (only on exam pages)
        if (container) {
            const controller = angular.element(container).controller();
            if (controller) {
                // get questions
                const questions = controller.questionByQuestionInstanceId;
                // highlight the answer to each question
                Object.values(questions).forEach(function (x) {
                    const correctAnswer = document.querySelector(`li[ng-class*="${x.correctQuizQuestionOptionId}"]`);
                    if (correctAnswer) {
                        correctAnswer.style.background = "#c5ff81";
                        correctAnswer.style.borderRadius = "2px";
                        correctAnswer.style.boxShadow = "0 0 0 6px #c5ff81";
                        // no need to keep checking
                        clearInterval(interval);
                    }
                });
            }
        }
        else {
            // add styling for showing quiz answers
            const style = document.createElement('style');
            style.innerText = `
                            label[data-correct="true"] {
                                    background: #c5ff81;
                                    box-shadow: 0 0 0 14px #c5ff81;
                            }`;
            document.head.appendChild(style);
            // disable interval since this is not an exam
            clearInterval(interval);
        }
    }, 500);
})();