-
Notifications
You must be signed in to change notification settings - Fork 0
/
uworld-reveal-answers.user.js
77 lines (68 loc) · 2.71 KB
/
uworld-reveal-answers.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// ==UserScript==
// @name UWorld Review Answers
// @namespace mailto:[email protected]
// @version 1.1
// @description Hides and Reveals Answers
// @author John Ciubuc
// @match https://www.uworld.com/ClientApp/v*/apps/qbanktestinterface/index.html
// @grant none
// ==/UserScript==
(function() {
'use strict';
var timer;
function pageLoader() {
// Get the answer container
var unansweredBtn = document.getElementById("answerContainer");
// If we got it, the page is loaded and we're ready for injection
if (unansweredBtn) {
clearTimeout(timer);
// Create CSS 'hide the answer' stylesheet
var style = document.createElement('style');
style.innerHTML = `
[ng-if="(launchTestOptions.canShowAnswer || testInfo.testModeId == constants.testMode.search) && (currentQuestion.formatTypeId == constants.questionFormatType.singleBestResponse)"],
.iradio_square-grey,
[class="fal fa-lg fa-check"],
[class="fal fa-lg fa-times"],
.explanation,
.pace pace-active,
[class="answerStatsBarInsideDiv"],
a[class="textHighlight"].a[class^="selection"]{
visibility: hidden;
display: none;
}
strike {
text-decoration:none;
}
`;
// Add it to page so that previous answers and explanations are hidden
document.head.appendChild(style);
// Generate button, place it after answers
var el = document.createElement("span");
el.innerHTML = "<button id=\"revealAnswers\">Reveal Answers</a>";
unansweredBtn.parentNode.insertBefore(el, unansweredBtn.nextSibling)
// Connect button to removing the stylesheet
el.onclick= ( function () {
document.head.removeChild(style)
} );
// Connect Forward/Back buttons to activating the Style sheet
// This is so that when you reveal answers, they hide on the next Q
var btnPrev = document.getElementById("btnPrev");
var btnNext = document.getElementById("btnNext");
btnPrev.onclick = (function(){
document.head.appendChild(style);
});
btnNext.onclick = (function(){
document.head.appendChild(style);
});
// Get all the Q numbers on the side bar and hide answers when clicked
var allNums = document.querySelectorAll("div[ng-click=\"selectQuestion(q.sequenceId)\"]");
var i;
for (i = 0; i < allNums.length; i++) {
allNums[i].onclick = (function(){
document.head.appendChild(style);
});
}
}
}
timer = setInterval(pageLoader, 250);
})();