Wanikani: Skip to Quiz

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

当前为 2022-03-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Wanikani: Skip to Quiz
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2.0
  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. // Wait until button is ready
  14. const interval = setInterval(() => {
  15. if (!$('#lesson > div:last-child ul > li:last-child button').length) return
  16. clearInterval(interval)
  17. run()
  18. }, 100)
  19.  
  20. function run() {
  21. const quizButton = $('#lesson > div:last-child ul > li:last-child button')
  22.  
  23. // Make quiz button look clickable
  24. quizButton.removeAttr('disabled').addClass('animate-pulse bg-green-400 wk-shadow')
  25.  
  26. // Go to quiz when button is clicked
  27. quizButton.on('click', go_to_quiz)
  28.  
  29. // Add hotkey
  30. $('body').on('keydown', (e) => {
  31. if (e.key === 'q' && !$.jStorage.get('l/quizActive')) {
  32. e.preventDefault()
  33. go_to_quiz()
  34. }
  35. })
  36. }
  37.  
  38. function go_to_quiz() {
  39. $.jStorage.set('l/startQuiz', true)
  40. $.jStorage.set('l/quizReady', false)
  41. }
  42. })(window.jQuery)