Greasy Fork

Greasy Fork is available in English.

Bunpro Toolbox

Adds various search options from Japanese resources

当前为 2021-02-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bunpro Toolbox
// @version      1.1.0
// @description  Adds various search options from Japanese resources
// @author       Ambo100
// @match        *bunpro.jp/grammar_points/*
// @grant        none
// @namespace    http://greasyfork.icu/users/230700
// ==/UserScript==

(function() {
    'use strict';

    var grammarPoint = document.getElementsByClassName("meaning__japanese")[0].innerText;
    var toolboxDiv;

    AddToolbox();

    //TOOKBOX LINKS START//

    //Dictionaries, References
    AddLink("Jisho", "https://jisho.org/search/");
    AddLink("Wikitionary", "https://en.wiktionary.org/wiki/","#Japanese");
    AddLink("Eijirou", "https://eow.alc.co.jp/search?q=","");

    AddDivider();

    //YouTube
    AddLink("YouGlish", "https://youglish.com/pronounce/","/japanese?");
    AddLink("YouTube", "https://www.youtube.com/results?search_query=","+Japanese");

    AddDivider();

    //Q&A, Communities
    AddLink("Stack Exchange", "https://japanese.stackexchange.com/search?q=","");
    AddLink("WK Forum", "https://community.wanikani.com/search?q=","%20category%3A17");
    AddLink("Reddit", "https://www.reddit.com/r/LearnJapanese/search?q=");

    //TOOLBOX LINKS END//

    function AddToolbox()
    {
        var grammarDiv = document.getElementsByClassName("section")[0];
        toolboxDiv = document.createElement("div");
        grammarDiv.append(toolboxDiv);

        //Toolbox styling
        toolboxDiv.classList.add('related-grammar__holder');
        toolboxDiv.style.marginBottom = "0px";
        toolboxDiv.style.paddingBottom = "25px";
    }

    function AddLink(linkName, urlPrefix = '', urlSuffix = '')
    {
        toolboxDiv.innerHTML += '<a class="related-grammar-tile__link--japanese" style="padding: 30px" href="' + urlPrefix + grammarPoint + urlSuffix + '" target="_blank" >' + linkName + '</a>';
    }

    function AddDivider(padding = '10')
    {
        toolboxDiv.innerHTML += '<span class="related-grammar-tile__link--japanese" style="padding: ' + padding + 'px">|</span>';
    }

}
)();