Skip to content

Instantly share code, notes, and snippets.

@smrq
Last active November 16, 2017 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smrq/e5f65010e3818df5f810d66cbb078956 to your computer and use it in GitHub Desktop.
Save smrq/e5f65010e3818df5f810d66cbb078956 to your computer and use it in GitHub Desktop.
WaniKani Lesson Study Quiz
// ==UserScript==
// @name Wanikani Lesson Study Quiz
// @namespace smrq
// @description Hides the meaning of items while re-reviewing lessons
// @include https://www.wanikani.com/lesson/session
// @version 1.0.0
// @author Greg Smith
// @license MIT
// @run-at document-end
// @grant none
// @homepageURL https://gist.github.com/smrq/e5f65010e3818df5f810d66cbb078956
// ==/UserScript==
(function() {
'use strict';
const style = document.createElement('style');
style.innerHTML = `
.self-study #main-info #meaning {
opacity: 0;
transition: opacity 150ms linear;
}
.self-study #main-info:hover #meaning {
opacity: 1;
}
`;
document.head.appendChild(style);
(function tryObserve() {
const quizElement = document.querySelector('#batch-items li[data-index="quiz"]');
if (!quizElement) {
setTimeout(tryObserve, 100);
return;
}
const observer = new MutationObserver(function (mutations) {
if (quizElement.classList.contains('active-quiz')) {
document.querySelector('#lessons').classList.add('self-study');
} else {
document.querySelector('#lessons').classList.remove('self-study');
}
});
observer.observe(quizElement, {
attributes: true,
attributeFilter: ['class']
});
})();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment