Wanikani Lesson Tab Transmutation

Change the order of lesson tabs

当前为 2016-02-13 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Wanikani Lesson Tab Transmutation
// @namespace   mempo
// @description Change the order of lesson tabs
// @include     https://www.wanikani.com/lesson/session
// @version     1
// @grant       none
// @run-at      document-end
// ==/UserScript==

var vocReorderReadingOption = false;

//ATTENTION: It's only possible to choose one of the options below.
//If you select multiple, only the last one will work
var kanReorderExamplesOption = true;
var kanReorderReadingOption  = false;

console.log('START OF WLTT');

var intervalFunction  = setInterval(function(){
  if($('#loading-screen').css('display') !== 'none'){
    console.log('WLTT loading...');
  }else{
    console.log("WLTT LOADED");
    clearInterval(intervalFunction);
  
    WLTTreorder();
    $.jStorage.listenKeyChange('l/currentLesson', WLTTreorder);
  } 
},250);

var WLTTreorder = function(){
  
    if($.jStorage.get('l/currentLesson').kan){ //kanji
      //console.log('/// the current lesson is kanji');

      //radical examples meaning reading
      if(kanReorderExamplesOption){
         kanReorderExamples();
      }
      
      //radical reading meaning examples
      if(kanReorderReadingOption){
         kanReorderReading();
      }

    }else{//vocab
      //console.log('/// the current lesson is vocab');
      
      //breakdown reading meaning
      if(vocReorderReadingOption){
         vocReorderReading();
      }

    }
}



var kanReorderExamples = function(){
        $('#supplement-nav li:nth-child(2)')[0].innerHTML = "Examples";
        $('#supplement-nav li:nth-child(3)')[0].innerHTML = "Meaning";
        $('#supplement-nav li:nth-child(4)')[0].innerHTML = "Reading";
        $('#supplement-kan-meaning').appendTo('#supplement-kan');
        $('#supplement-kan-reading').appendTo('#supplement-kan');
}

var kanReorderReading = function(){
        $('#supplement-nav li:nth-child(2)')[0].innerHTML = "Reading";
        $('#supplement-nav li:nth-child(3)')[0].innerHTML = "Meaning";
        $('#supplement-kan-meaning').appendTo('#supplement-kan');
        $('#supplement-kan-related-vocabulary').appendTo('#supplement-kan');
}

var vocReorderReading = function(){
        $('#supplement-nav li:nth-child(2)')[0].innerHTML = "Reading";
        $('#supplement-nav li:nth-child(3)')[0].innerHTML = "Meaning";
        $('#supplement-voc-meaning').appendTo('#supplement-voc');
}




// RESEARCH CODE - for educational purposes

//////////////// ATTEMPT #1
      //Moves content, but internal counter li.active.data(index) jumps to 2
      //Therefore, meaning is skipped altogether dispite index===1
      //Manually selecting tabs really fucks shit up.
      //$('#supplement-nav li:nth-child(3)').data("index",1);
      //$('#supplement-nav li:nth-child(2)').data("index",2);
//////////////// ATTEMPT #2
      /*
      //moves needle out of order
      //completes cycle
      //shows meaning -> reading
      $('#supplement-nav li:nth-child(3)').attr('data-index', 1); 
      $('#supplement-nav li:nth-child(2)').attr('data-index', 2);
      */
//////////////// ATTEMPT #3
      /* 
      //Works, but fucks up page content every other item
      //Cause unknown
      var meaning = $('#supplement-voc-meaning').html();
      var reading = $('#supplement-voc-reading').html();

      $('#supplement-voc-reading').html(meaning);
      $('#supplement-voc-meaning').html(reading);

      $('#supplement-nav li:nth-child(2)')[0].innerHTML = "Reading";
      $('#supplement-nav li:nth-child(3)')[0].innerHTML = "Meaning";
      */