Toggle button to hide/show answers on Academy
s
s1
Hi guys,
Recently I was re-doing some of the modules and it was fraustrating seeing the answers that I've already given to some of the questions. So, I made this simple JS script which helps to show/hide answers on Academy. It was useful to me, so I posted on Reddit so other people can also use it.
It actually got some positive feedback and somebody recommended me posting it here, so maybe it can get enough votes to become a feature in the near future.
The original Reddit post: https://www.reddit.com/r/hackthebox/comments/1pmcnvk/hiding_answers_on_academy
The script:
// ==UserScript==
// HTB Academy – Hide/Show Answers
// https://academy.hackthebox.com/module/*
// u/run-at document-idle
// ==/UserScript==
(function () {
const MASK = "********";
const processInputs = () => {
document
.querySelectorAll("input.form-control.text-success")
.forEach(input => {
if (input.dataset.processed) return;
input.dataset.realValue = input.value;
input.value = MASK;
const btn = document.createElement("button");
btn.type = "button";
btn.textContent = "Show";
btn.className = "btn btn-outline-success";
let visible = false;
btn.addEventListener("click", () => {
visible = !visible;
input.value = visible ? input.dataset.realValue : MASK;
btn.textContent = visible ? "Hide" : "Show";
input.dispatchEvent(new Event("input", { bubbles: true }));
});
input.after(btn);
input.dataset.processed = "true";
});
};
processInputs();
const observer = new MutationObserver(processInputs);
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
You need to have violentmonkey extension enabled in order to automatic applies on refreshes.