Вот UserJS контекстного яндекс-перевода для Opera, может быть кому-то пригодится. Если у кого-нибудь есть похожий, просьба выложить.
(function(){
var doc = null;
var div = null;
var g_width = 300;
var g_height = 400;
function send_request(url){
if ( document.getElementById("ajax_common")) {
document.getElementById("ajax_common").src = url;
} else {
iframe = document.createElement("iframe");
with(iframe) {
width = g_width;
height = g_height;
frameBorder = 'no';
scrolling = 'no';
id = 'ajax_common';
src = url;
}
div.appendChild(iframe);
}
}
function normalize_coord(x,y) {
var wwidth = (window.innerWidth) ? window.innerWidth: ((document.all)?document.body.offsetWidth:null);
var wheight = window.innerHeight;
if ( doc.documentElement.scrollTop == 0) {
y += doc.body.scrollTop;
wheight += doc.body.scrollTop;
} else {
y += doc.documentElement.scrollTop;
wheight += doc.documentElement.scrollTop;
}
if ( x + g_width >= wwidth) {
x -= x + g_width + 20 - wwidth;
}
if ( y + g_height >= wheight) {
y -= y + g_height + 60 - wheight;
}
return { "x": x, "y": y};
}
function create_div(x, y) {
div = document.getElementById("dictionary_answer");
if (div){
coord = normalize_coord(x,y)
with(div) {
style.top = (coord.y + 15) + "px";
style.left = (coord.x + 15) + "px";
}
} else {
div = document.createElement("div");
coord = normalize_coord(x,y)
with(div) {
id = "dictionary_answer";
style.position="absolute";
style.zIndex = "999";
style.top = (coord.y + 15) + "px";
style.left = (coord.x + 15) + "px";
style.width = g_width + "px";
style.padding = "10px";
style.height = g_height + "px";
style.background="#fff";
style.border = "2px solid #ddd";
}
doc.body.appendChild(div);
}
div.style.display="block";
}
window.addEventListener("load", function(){
doc = document;
window.addEventListener("mousemove", function() {
x = (event.clientX) ? event.clientX : ((event.pageX) ? event.pageX : event.screenX);
y = (event.clientY) ? (event.clientY) : (event.pageY);
}, false);
window.addEventListener("dblclick", function() {
event.preventDefault();
}, false);
window.addEventListener("mouseup", function() {
event.preventDefault();
selection = window.getSelection ? window.getSelection() : document.selection;
if (selection > "") {
create_div( x, y);
send_request("http://m.slovari.yandex.ru/search.xml?lang=en-ru-en&text="+ selection +"&where=3");
} else {
if (div) {
div.style.display="none";
}
}
}, false);
},false);
})();