Wanikani: Skip to Quiz

Enables the quiz button without having to go through any of the lessons.

  1. // ==UserScript==
  2. // @name Wanikani: Skip to Quiz
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2.1
  5. // @description Enables the quiz button without having to go through any of the lessons.
  6. // @author Kumirei
  7. // @match https://www.wanikani.com/lesson/session
  8. // @match https://preview.wanikani.com/lesson/session
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. ;(function ($) {
  13. // Run on page load
  14. run()
  15.  
  16. // Also run whenever a new batch of lessons is loaded
  17. $.jStorage.listenKeyChange('l/quizActive', run)
  18.  
  19. // Add hotkey
  20. $('body').on('keydown', (e) => {
  21. if (e.key === 'q' && !$.jStorage.get('l/quizActive')) {
  22. e.preventDefault()
  23. go_to_quiz()
  24. }
  25. })
  26.  
  27. function run() {
  28. // Wait until button is ready
  29. const interval = setInterval(() => {
  30. if ($.jStorage.get('l/quizActive', false)) return
  31. const quizButton = $('#lesson > div:last-child ul > li:last-child button')
  32. if (!quizButton.length) return
  33. clearInterval(interval)
  34. make_button_clickable(quizButton)
  35. }, 100)
  36. }
  37.  
  38. function make_button_clickable(quizButton) {
  39. // Make quiz button look clickable
  40. quizButton.removeAttr('disabled').addClass('animate-pulse bg-green-400 wk-shadow')
  41.  
  42. // Go to quiz when button is clicked
  43. quizButton.on('click', go_to_quiz)
  44. }
  45.  
  46. function go_to_quiz() {
  47. $.jStorage.set('l/startQuiz', true)
  48. $.jStorage.set('l/quizReady', false)
  49. }
  50. })(window.jQuery)