Wanikani Lesson Tab Transmutation

Change the order of lesson tabs

目前為 2016-02-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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";
      */