Wanikani Hints

try to take over the world!

  1. // ==UserScript==
  2. // @name Wanikani Hints
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.wanikani.com/review/session
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. console.log("Wanikani Meaning / Reading Hints 2");
  15.  
  16. function addGlobalStyle(css) {
  17. var head, style;
  18. head = document.getElementsByTagName('head')[0];
  19. if (!head) { return; }
  20. style = document.createElement('style');
  21. style.type = 'text/css';
  22. style.innerHTML = css;
  23. head.appendChild(style);
  24. }
  25.  
  26. function questionTypeUpdated(){
  27. console.log("Question type updated");
  28. var questionType = $.jStorage.get('questionType');
  29. console.log(questionType);
  30. if (questionType == "reading"){
  31. //change style
  32. $("#question")[0].className = "reading";
  33. } else if (questionType == "meaning"){
  34. //change style
  35. $("#question")[0].className = "meaning";
  36. }
  37. }
  38.  
  39. addGlobalStyle('#question.meaning #answer-form { margin-right: 30% }');
  40. addGlobalStyle('#question.reading #answer-form { margin-left: 30% }');
  41. addGlobalStyle('#question.reading { background-color: #2e2e2e; }');
  42.  
  43. $.jStorage.listenKeyChange("questionType", questionTypeUpdated);
  44.  
  45. })();