Wanikani Note Attention Grabber

Give extra attention to notes

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Wanikani Note Attention Grabber
// @namespace    mempo
// @version      1.0
// @description  Give extra attention to notes
// @author       Mempo
// @match        https://www.wanikani.com/review/session
// @grant        none
// ==/UserScript==

var css = ".WKNN-reading, .WKNN-meaning { "+
                 "    border: 2px solid red;"+
                 "    padding: 10px; " +
                 "}";


(function() {
    'use strict';

    addStyle(css);
    $("#option-item-info").on("click", setTimer);
    $(document).on("keydown.reviewScreen", function (event) {
        switch (event.keyCode) {
            case 70: setTimer(); //f
        }
     });
})();

function setTimer(){
    setTimeout(checkNote,300);
}

function checkNote(){
    if($.jStorage.get("questionType") === "meaning" && $(".note-meaning").html() !== "Click to add note"){
        $(".note-meaning").addClass("WKNN-meaning");
    }else if($.jStorage.get("questionType") === "reading" && $(".note-reading").html() !== "Click to add note"){
        $(".note-reading").addClass("WKNN-reading");
    }
}

function addStyle(aCss) {
  var head, style;
  head = document.getElementsByTagName('head')[0];
  if (head) {
    style = document.createElement('style');
    style.setAttribute('type', 'text/css');
    style.textContent = aCss;
    head.appendChild(style);
    return style;
  }
  return null;
}

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}