您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Searches the sentence on Jisho.
当前为
// ==UserScript== // @name Bunpro: Jisho Button // @namespace http://tampermonkey.net/ // @version 0.2.0 // @description Searches the sentence on Jisho. // @author Kumirei // @include https://bunpro.jp/* // @require http://greasyfork.icu/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012 // @grant none // ==/UserScript== (function() { //Wait until we're on the study page and can add the button waitForKeyElements('.study-question-english-button', function(e) { //Add styling to button $('head').append('<style id="JishoButtonStyle">'+ '@media (max-width: 480px) {'+ '#JishoButton {'+ 'width: 10% !important;'+ 'font-size: 12px !important;'+ '}'+ '.study-question-english-button {'+ 'width: 10%;'+ '}'+ '.bunny-mode {'+ 'left: 20% !important;'+ '}'+ '}'+ '#JishoButton {'+ 'position: absolute;'+ 'left: 10%;'+ 'width: 15%;'+ 'font-size: 20px;'+ 'z-index: 100;'+ 'background: transparent;'+ 'height: 100% !important;'+ 'border: none;'+ '}'+ '#JishoButton:hover {opacity: 0.3;}</style>'); //Add button e.after('<input id="JishoButton" class="btn-primary no-padding" type="button" value="Jisho" onclick="window.open(\'https://www.jisho.org/\');">'); //Changes the target url of the button when item changes waitForKeyElements('.study-question-japanese > span', function(e) { var sentence = parseSentence(e[0]); $('#JishoButton').attr('onclick', 'window.open("https://jisho.org/search/' + sentence + '")'); }); //Bind J to the Jisho button $('#study-answer-input').on('keyup', function(e) { if (e.which == 74 && $('#submit-study-answer').attr('value') == "Next") { $('#JishoButton').click(); } }); }); //Extracts the sentence from the sentence elements function parseSentence(sentenceElem) { var sentence = ""; sentenceElem.childNodes.forEach(function(elem) { // find the text in each kind of element and append it to the sentence string var name = elem.nodeName; if (name == "#text") { sentence += elem.data; } else if (name == "STRONG" || name == "SPAN") { if (name == "STRONG" && elem.children.length) { sentence += elem.children[0].childNodes[0].data; // with kanji in url //sentence += elem.children[0].children[1].innerText; // with kana in url } else { sentence += elem.innerText; } } else if (name == "RUBY") { sentence += elem.childNodes[0].data; // with kanji in url //sentence += elem.children[1].innerText; // with kana in url } }); return sentence; } })();