Last active
November 16, 2017 02:00
-
-
Save smrq/e5f65010e3818df5f810d66cbb078956 to your computer and use it in GitHub Desktop.
WaniKani Lesson Study Quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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