Adds links to info pages during reviews. Jisho and WaniKani. Click the review item for a popup.
当前为
// ==UserScript==
// @name WaniKani Links
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Adds links to info pages during reviews. Jisho and WaniKani. Click the review item for a popup.
// @author You
// @match https://www.wanikani.com/review/session
// @grant none
// ==/UserScript==
(function () {
'use strict';
addStyle('#divLinks {' +
' display: none;' +
' position: absolute;' +
' z-index: 10;' +
' background: #c7c2c2;' +
' border: black 1px solid;' +
'}' +
'#divLinks a {' +
' padding: 5px;' +
' display: inline;' +
'}' +
'#divLinks a:after {' +
' content:"\\a";' +
' white-space: pre;' +
' padding: 5px;' +
'}');
$.jStorage.listenKeyChange('currentItem', function (key, action) {
choiceBox($.jStorage.get('currentItem'));
$('.radicals [lang="ja"]').click(
function(event){
showLinks(event);
}
).css('cursor','pointer');
$('.kanji [lang="ja"]').click(
function(event){
showLinks(event);
}
).css('cursor','pointer');
$('.vocabulary [lang="ja"]').click(
function(event){
showLinks(event);
}
).css('cursor','pointer');
});
}());
function choiceBox(data){
$('#divLinks').remove();
var divLinks = $("<div>", {
id: 'divLinks',
title: 'Links',
});
if (data.voc !== undefined) {
$("<a>", {
text: "WaniKani",
title: "WaniKani",
href: "https://www.wanikani.com/vocabulary/" + data.voc,
target: "_blank",
click: function(){hideLinks();}
}).appendTo(divLinks);
$("<a>", {
text: "Jisho",
title: "Jisho",
href: "http://jisho.org/search/" + data.voc,
target: "_blank",
click: function(){hideLinks();}
}).appendTo(divLinks);
} else if (data.kan !== undefined) {
$("<a>", {
text: "WaniKani",
title: "WaniKani",
href: "https://www.wanikani.com/kanji/" + data.kan,
target: "_blank",
click: function(){hideLinks();}
}).appendTo(divLinks);
$("<a>", {
text: "Jisho",
title: "Jisho",
href: "http://jisho.org/search/" + data.kan,
target: "_blank",
click: function(){hideLinks();}
}).appendTo(divLinks);
} else if (data.rad !== undefined) {
$("<a>", {
text: "WaniKani",
title: "WaniKani",
href: "https://www.wanikani.com/radicals/" + data.rad,
target: "_blank",
click: function(){hideLinks();}
}).appendTo(divLinks);
}
$('body').append(divLinks);
}
function showLinks(event){
$('#divLinks').css('display','block').css('left',event.pageX).css('top',event.pageY);
}
function hideLinks(){
$('#divLinks').css('display','none');
}
//-------------------------------------------------------------------
// Add a <style> section to the document.
//-------------------------------------------------------------------
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;
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址