This displays dictionary iframes in the Memrise presentation screen. I used a different script as a base. It works but anyone familiar with Javascript(?) will know the original script writer knew what they were doing and I don’t, and this could have been done so much easier.
Anyone feel like looking at it and deleting the extra stuff? @cooljingle or @DrewSSP or @neoncube perhaps?
// ==UserScript==
// @name Dictionary pages in Memrise presentation screen. Can be changed to work with other languages.
// @description your description here
// @match http://www.memrise.com/course/*/learn/*
// @match http://www.memrise.com/garden/review/*
// @match http://www.mdbg.net/chindict/chindict_ajax.php*
// @version 0.1
// @updateURL none
// @downloadURL none
// @grant none
// ==/UserScript==
var onLoad = function($) {
$("#central-area").on("DOMSubtreeModified", function() { //trigger many times
if ($("#otherRefs").size()==0 && MEMRISE.garden.session.category.name=="Chinese (Simplified)") { //only triggered once
var hanzi = MEMRISE.garden.box.thing.columns[1].val;
// Change "Chinese (Simplified)" above to the language you are studying
// Append the HTML
$(".columns").append('<div class="row column on-show-more"><div class="row-label">Other References</div><div id="otherRefs" class="row-value"><div id="strokeIcons"></div><div id="decompIcons"></div></div>'+
// Begin edits by Arete_Hime
'<style>'+
// Width of the wrapper div. You may want to increase this.
'div.mywrapper{position: relative;left: -2%; overflow: hidden; margin: 0%; width: 104%; background-color:ivory;}'+
// styling for: iframe for the dictionary, half width
'.half-width-iframe {width: 49.4%;}'+
// styling for: iframe for the dictionary, whole width
'.whole-width-iframe {width: 99.4%;}'+
// styling for: both half width and whole width iframes
'.half-width-iframe, .whole-width-iframe{background: rgba(255,255,255,0.8) !important;height:700px; margin:0%;}'+
// hide stuff that the rest of this script tries to show...
'#otherRefs, #strokeIcons, #decompIcons{display:none;}'+
'</style>'+
'<div class="mywrapper">'+
//your dictionary sites here
'<iframe class="half-width-iframe" src="http://dj.iciba.com/'+ hanzi +'-1.html"></iframe>'+
'<iframe class="half-width-iframe" src="http://www.mdbg.net/chindict/chindict.php?wdqb=c:*'+ hanzi +'*"></iframe>'+
'</div>'+
'</div>'+
'</div>'+
//End edits by Arete_Hime
'</div></div></div>');
//Arete_Hime: I have zero knowledge of the below, so I don't know how to touch this
if (hanzi.length<=3) for (var i=0; i<hanzi.length; i++){
$("#strokeIcons").append('<div id="icon4stroke'+hanzi.substring(i,i+1)+'" class="tile" title="Stroke Order">' +hanzi.substring(i,i+1)+'</div>');
$("#decompIcons").append('<div id="icon4decomp'+hanzi.substring(i,i+1)+'" class="tile" title="Character Decomposition">'+hanzi.substring(i,i+1)+'</div>');
$("#otherRefs" ).append('<img id="stroke' +hanzi.substring(i,i+1)+'" class="mdbg" src="http://www.mdbg.net/chindict/rsc/img/stroke_anim/' + hanzi.substring(i,i+1).charCodeAt(0) +'.gif"/>'+
'<iframe id="decomp' +hanzi.substring(i,i+1)+'" class="mdbg" src="http://www.mdbg.net/chindict/chindict_ajax.php?c=cdcd&i='+ hanzi.substring(i,i+1)+'"></iframe>');
}
//Add styles & mouse events
$("#strokeIcons .tile").css({background:"white url(\'https://openclipart.org/people/warszawianka/tango-style-paintbrush.svg\') no-repeat right top"});
$("#decompIcons .tile").css({background:"white url(\'http://repurposed.files.wordpress.com/2009/08/scissors.jpg\' ) no-repeat right top",textAlign:"center"});
$(" .tile").css({float:"left",width:"50px",height:"50px",color:"red"})
.mouseover(function(){$( "#"+$(this).attr("id").substring(5) ).show().offset( $(this).offset() )});
$(".mdbg" ).css({display:"none",position:"absolute",top:"200px",left:"200px","z-index":1000,width:"250px",height:"250px"})
.mouseleave(function(){console.log(this);$(this).hide()});
}
});
};
if (location.hostname=="www.mdbg.net") {
// Handle the inline frame
document.body.style.backgroundColor = "white";
document.getElementsByClassName("characterdecomposition")[0].style.fontSize = "1.8em";
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
anchors[i].target = "_blank";
anchors[i].style.color = "#008";
anchors[i].style.textDecoration = "none";
}
}else{
// Handle the main page at Memrise.com
var injectWithJQ = function(f) {
var script = document.createElement('script');
script.textContent = '$(' + f.toString() + '($));';
document.body.appendChild(script);
};
injectWithJQ(onLoad);
}