// ==UserScript==
// @name 在 bing词典 中聚合显示 有道 的结果 添加转跳至 linggle 和 ludwig 的按钮
// @namespace http://tampermonkey.net/
// @version 6.6
// @license MIT
// @description 1. Display youdao.com results alongside the original results on bing.com/dict. 2. Provide shortcuts for linggle and ludwig.
// @author 庶民player
// @match *.bing.com/dict*
// @icon https://cn.bing.com/sa/simg/favicon-2x.ico
// @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// @run-at document-idle
// @compatible edge
// @compatible chrome
// @grant none
// @downloadURL none
// ==/UserScript==
function go_dn(elem_name){
for(
let cur_li = $(elem_name) , next_li = cur_li.next();
next_li.length > 0;
next_li = cur_li.next()
){
next_li.after(cur_li);
}
}
(function() {
'use strict';
var wd = "NONE"
var qry = window.location.search.substring(1);
var vals = qry.split('&');
for(var i in vals){
var pair = vals[i].split('=');
if(pair[0] == "q") wd = pair[1];
}
//-=-=-=-=-=-=-=-=-=-=-=-=-以下修改各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
$("#b-scopeListItem-video a").text("etymon");
$("#b-scopeListItem-video a").attr('href','https://www.etymonline.com/search?q='+ wd);
$("#b-scopeListItem-images a").text("论文例句");
$("#b-scopeListItem-images a").attr('href','http://www.esoda.org/?q='+ wd);
$("#b-scopeListItem-local a").text("Synonyms");
$("#b-scopeListItem-local a").attr('href','https://www.thesaurus.com/browse/'+ wd);
go_dn("#b-scopeListItem-images");
go_dn("#b-scopeListItem-video");
go_dn("#b-scopeListItem-local");
go_dn("#b-scopeListItem-dictionary");
//-=-=-=-=-=-=-=-=-=-=-=-=-以下显示各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
var mouse_on_effect = {"filter":"drop-shadow(0px 1px 3px #808080)", "transition":"0.1s" , "transition-timing-function": "ease-out",};
var mouse_out_effect = {"filter":"drop-shadow(0px 1px 3px #d0d0d0)", "transition":"0.1s", "transition-timing-function": "ease-out",};
const linggle_button = document.createElement('button');
linggle_button.className = 'btn btn-sm';
$(linggle_button).css({
"border":"0",
"background-color":"transparent",
"cursor": "pointer",
"position": "absolute",
"left": ($("#b_header").position().left + 57) +"px",
"top": ($("#b_header").position().top + $("#b_header").height() - 12 -3) + "px",
});
linggle_button.innerHTML = `
`;
linggle_button.onclick = function() {
location.href = "https://www.linggle.com/?q=" + wd;
}
document.body.append(linggle_button);
const ludwig_button = document.createElement('button');
ludwig_button.className = 'btn btn-sm';
$(ludwig_button).css({
"border":"0",
"background-color":"transparent",
"cursor": "pointer",
"position": "absolute",
"left": ($("#b_header").position().left + 14) +"px",
"top": ($("#b_header").position().top + $("#b_header").height() - 23 -3) + "px",
});
ludwig_button.innerHTML = `
`;
ludwig_button.onclick = function() {
location.href = "https://ludwig.guru/s/" + wd;
}
document.body.append(ludwig_button);
const gaoshan_button = document.createElement('button');
gaoshan_button.className = 'btn btn-sm';
$(gaoshan_button).css({
"border":"0",
"background-color":"transparent",
"cursor": "pointer",
"position": "absolute",
"left": parseInt(
0.5 * ($("#sb_form_q").position().left + $("#sb_form_q").width())
+ 0.5 * window.innerWidth
- 0.5 * $(".b_logo").width()
) +"px",
"top": 16 + "px",
});
$(gaoshan_button).css(mouse_out_effect);
gaoshan_button.onmouseout = function(){
$(gaoshan_button).css(mouse_out_effect);
}
gaoshan_button.onmouseover = function(){
$(gaoshan_button).css(mouse_on_effect);
}
gaoshan_button.innerHTML = `
`;
gaoshan_button.onclick = function() {
location.href = "http://www.dicts.cn/";
}
document.body.append(gaoshan_button);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-以下显示有道-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if(wd.length>50 || wd=="NONE") return;
var youdao_top_padding = 190;
var youdao_left_padding = 120;
var youdao_width = 640;
var bing_width = $(".lf_area").width(); //532
var margin = window.innerWidth -youdao_width -bing_width;
$("#b_footer").css("display", "none");
$(".sidebar").css("display", "none");
$(".lf_area").css({
"position": "absolute",
"left": parseInt(margin * 0.34)+"px",
});
let m = `