Greasy Fork is available in English.

Wanikani Review Info Page Link

Add a link to the info page of an item

// ==UserScript==
// @name         Wanikani Review Info Page Link
// @namespace    Mempo
// @version      1.0
// @description  Add a link to the info page of an item
// @author       Mempo
// @match        https://www.wanikani.com/review/session
// @match        http://www.wanikani.com/review/session
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
    console.log('/// WKRIPL start');
    
    var style = "span.vocabulary { " +
                     "width: auto !important;" +
                     "padding-left: 0.45em;" +
                     "padding-right: 0.45em;" +
                     "background-color: #a100f1;" +
                     "background-image: -moz-linear-gradient(top, #a0f, #9300dd);" +
                     "background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#a0f), to(#9300dd));" +
                     "background-image: -webkit-linear-gradient(top, #a0f, #9300dd);" +
                     "background-image: -o-linear-gradient(top, #a0f, #9300dd);" +
                     "background-image: linear-gradient(to bottom, #a0f, #9300dd);" +
                     "background-repeat: repeat-x;" +
                     "}" ;
    
    addStyle(style);
    
    /*DISCLAIMER: full credit for the magic below goes to Thaos. I don't even know how or why it really works */
    // hook jQuery.fn.show() - for review sections of /lesson and /review
    $.fn._ripl_show = $.fn.show;
    $.fn.show = function(a,b,c){
        var res = $.fn._ripl_show.call(this,a,b,c);

        // detect when Wanikani has loaded additional item information
        // ("#all-info").show() seems to correspond with this.
        if(typeof this[0] !== 'undefined' && this[0].id === 'information'){
            // start of wanikani ajax request

        } else if(typeof this[0] !== 'undefined' && this[0].id === 'all-info'){
            // wanikani ajax request returns - does not fire with radicals
            
                insertInfoLink();
            
        } else if (typeof this[0] === 'undefined'){
            console.log(this); // i'm curious
        }

        return res;
    };
    /* end of Thaos code */
    
    function insertInfoLink() {
        //sorry
        var jisho_icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAMAAACP1l7TAAADAFBMVEVW2SZEREWRkZK276J1dHZJSUrZ2dn6+vrBwcL4+Pje3t7GxsZ44FL8/PyUlJXR0dKmpqe6ubqtra7MzMzU9ciq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AP4AtYarnjzP7d7RrFBQf25ve73dkdBnDA2BEwxuCPwiTC2j5yEUVRIFIKIf4VSZLkqb2TJAHIXPkd+eT8GTJeoDfbxEqxb5EYv+uqMKNMSyM3aM9kRV9oUcibctawbNdkri2ySnUL+HmFh5TsUhak+gcjUsO+cuoIrgHtTKchZIL2JeoXisQ6k/oI/9Y+6nHLOHtk1JGuPMbk3Ed6eL4pGG9UR+DQNHnrIrgaFjlzEICTQjGLPtKxSOEhJE3qyUGmNovGkte+jHfQcJA742z47dcueeggILQnb76OrMgHi4V5ygoBIarBcHo51WEOPgJcZXrVjD3meU4F71dpd+sDjVwHyLgnvXycZmMzyfznOZ8//HK/RjgCQUgsyu0gAr4Afg80eYrLcaoAAAAASUVORK5CYII=";
        
        var $html = ' <section id="related-items"> ' +
                    '     <h2>Link To Info Page</h2>' +
                   '      <ul class="placeholder_item_type">' +
                   '           <li>' +
                   '               <a title="View information page" target="_blank" href="placeholder_href">' +
                   '                   <span class="placeholder_item_type" lang="ja">placeholder_item_jp</span>' +
                   '                   placeholder_item_meaning' +
                   '               </a>' +
                   '            </li>' +
                   '        </ul>' +
                   '        <ul class="placeholder_item_type">' +
                   '           <li>' +
                   '               <a title="View Jisho information page" target="_blank" href="placeholder_jisho_href">' +
                   '               <img alt="Embedded Image" src="placeholder_jisho_image"/>' +
                   '               </a>' +
                   '            </li>' +
                   '        </ul>' +
                   '    </section>';
        var item = $.jStorage.get("currentItem");
        var itemType = item.kan?"kanji":"vocabulary";
        var itemJP = item.kan?item.kan:item.voc;

        //WK ITEM
        $html = $html.replace("placeholder_item_type",itemType);
        $html = $html.replace("placeholder_item_type",itemType);
        $html = $html.replace("placeholder_item_type",itemType);
        $html = $html.replace("placeholder_href","/" + itemType + "/" + itemJP);
        $html = $html.replace("placeholder_item_jp",itemJP);
        $html = $html.replace("placeholder_item_meaning",item.en[0]);
        //JISHO
        $html = $html.replace("placeholder_jisho_href","http://jisho.org/search/" + itemJP);
        $html = $html.replace("placeholder_jisho_image",jisho_icon);
        

        $("#item-info-col1").append($html);
        
        
    };
    
    
    
    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;
}
})();