Advertisement
Guest User

Cleverflow by Thenn42

a guest
Jul 3rd, 2013
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       WaniKani Flash Forward
  3. // @namespace thenn42.eu/userscripts
  4. // @description Automatically moves to the next item, and replaces the back button with previous item.
  5. // @include    http://www.wanikani.com/review/*
  6. // @version    0.2
  7. // @run-at document-end
  8. // @require http://code.jquery.com/jquery-1.9.1.min.js
  9. // @grant GM_log
  10. // ==/UserScript==
  11. var timer = 200;
  12. var lastItem = "";
  13. var currentItem = "";
  14. var lastType = "";
  15. var currentType = "";
  16. var url = "";
  17. setTimeout(WhenNewQuestion1, timer);
  18. $("#option-end-session a").replaceWith("<i class=\"icon-arrow-left\"></i>");
  19. WhenNewQuestion();
  20.  
  21. function WhenNewQuestion1() {
  22.     if ($('fieldset').attr("class") == "correct") {
  23.         $('#option-submit').click();
  24.     }
  25.     setTimeout(WhenNewQuestion1, timer);
  26. }
  27.  
  28. function WhenNewQuestion() {
  29.     currentType = $("#item-box").find("h1").attr("class");
  30.     if (currentType == "vocabulary") {
  31.         currentItem = $("#item-box").find("h1 small").text();
  32.     } else if (currentType == "kanji") {
  33.         currentItem = $("#item-box").find("h1").text();
  34.     } else {
  35.         currentItem = $("#meanings p").text().toLowerCase();
  36.         currentItem = currentItem.replace(" ","-");
  37.     }
  38.     if (currentItem != lastItem) {
  39.         url = "http://www.wanikani.com/quickview/";
  40.         if (lastType == "kanji") {
  41.             url += "kanji\/"+lastItem;
  42.         } else if (lastType=="vocabulary") {
  43.             url += "vocabulary\/" + lastItem;
  44.         } else {
  45.             url += "radicals\/" + lastItem;
  46.         }
  47.         $("#option-end-session").replaceWith("<li id=\"option-end-session\"><a target=\"_blank\" href=\""+url+"\"><i class=\"icon-arrow-left\"></i></a></li>");
  48.     }
  49.     lastType = currentType;
  50.     lastItem = currentItem;
  51. }
  52.  
  53. $('#item-info-sub').bind('DOMNodeInserted', WhenNewQuestion);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement