Greasy Fork is available in English.

EtoEto Jisho Dictionary Replacer

Replaces Jisho lookup with a few choices (in script). Defaults to Weblio. Fixes rikaichan/san display (esp Firefox). Fixes formatting when copying Japanese dialogue lines.

Mint 2017.07.25.. Lásd a legutóbbi verzió

// ==UserScript==
// @name        EtoEto Jisho Dictionary Replacer
// @namespace   etoeto_JishoReplacerKK
// @description Replaces Jisho lookup with a few choices (in script). Defaults to Weblio. Fixes rikaichan/san display (esp Firefox). Fixes formatting when copying Japanese dialogue lines.
// @author         Kai Krause (kaikrause95@gmail.com)
// @match	*etoeto.com/*books/*episodes/*
// @version     1.2
// @grant       none
// ==/UserScript==

//Choose a dictionary
// Weblio (1) | ALC (2) | Tangorin (3) | Japanese-only Goo (4)
var dictSelection = 1;

window.addEventListener('load', function() {
	var docbody = document.body;
	//Fix Rikai Display
	docbody.getElementsByClassName('off-canvas-wrap')[0].style.zIndex = "0";
	//Replace Jisho.org with Weblio
	var pos = docbody.getElementsByClassName('audio-word-text');
	var css = document.createElement("style");
	css.type = "text/css";
	css.innerHTML = 'a.highlight:hover{color: red !important;}';
	docbody.appendChild(css);
	for (var i = 0; i < pos.length; i++){
		docbody.getElementsByClassName('audio-word-text')[i].outerHTML = pos[i].outerHTML.replace(/audio-word-text/igm, 'audio-word-text highlight');
		if (dictSelection == 1){ //Weblio
			docbody.getElementsByClassName('audio-word-text')[i].outerHTML = pos[i].outerHTML.replace(/jisho.org\/search/igm, 'ejje.weblio.jp/content');
		}
		else if (dictSelection == 2){ //ALC
			docbody.getElementsByClassName('audio-word-text')[i].outerHTML = pos[i].outerHTML.replace(/jisho.org\/search\//igm, 'eow.alc.co.jp/search?q=');
		}
		else if (dictSelection == 3){ //Tangorin
			docbody.getElementsByClassName('audio-word-text')[i].outerHTML = pos[i].outerHTML.replace(/jisho.org\/search/igm, 'tangorin.com/general');
		}
		else if (dictSelection == 4){ //Goo
			docbody.getElementsByClassName('audio-word-text')[i].outerHTML = pos[i].outerHTML.replace(/jisho.org\/search/igm, 'dictionary.goo.ne.jp/srch/jn');
			docbody.getElementsByClassName('audio-word-text')[i].outerHTML = pos[i].outerHTML.replace(/" target="_blank"/igm, '/m0u/" target="_blank"');
		}
	}
	//Remove formatting errors (spaces, line breaks) when copying Japanese dialogue
	document.oncopy = function(e){
		var docbody = document.body;
		var selection = window.getSelection();
		var text = selection.toString();
		var newText = '';
		for (var i = 0; i < text.length; i++){
			var next = text[i+1];
			if (text[i].match(/[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]/) ){
				newText += text[i];
			}
			else if (text[i].match(/^[a-zA-Z]+$/) ){
				newText += '\n';
				for (var x = i; x < text.length; x++){
					newText += text[x];
				}
				i = text.length;
			}
		}
		var newSelectionContainer = document.createElement('div');
		newSelectionContainer.style.position = 'absolute';
		newSelectionContainer.style.bottom = '-99999px';
		docbody.appendChild(newSelectionContainer);
		newSelectionContainer.innerHTML = newText;
		selection.selectAllChildren(newSelectionContainer);
		window.setTimeout(function() {
			docbody.removeChild(newSelectionContainer);
		},0);
	};
}, false);