- // ==UserScript==
- // @name 在 bing词典 中聚合显示 有道 的结果 添加转跳至各种在线工具的按钮
- // @namespace http://tampermonkey.net/
- // @version 10.6.7
- // @license MIT
- // @description 1. Display youdao.com results alongside the original results on bing.com/dict. 2. Provide shortcuts for many online tools.
- // @author 庶民player
- // @match *.bing.com/dict*
- // @icon https://cn.bing.com/sa/simg/favicon-2x.ico
- // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js
- // @run-at document-idle
- // @compatible edge
- // @compatible chrome
- // @compatible safari
- // @grant none
- // ==/UserScript==
-
- function clone_a(name){
- var tmp = $('#b-scopeListItem-images').clone(true).attr('id', name);
- $('#b-scopeListItem-images').after(tmp);
- }
- function clone_b(name){
- var tmp = $('#b-scopeListItem-flights').clone(true).attr('id', name);
- $('#b-scopeListItem-flights').after(tmp);
- }
- function check_emp(x) {
- return x.length > 0;
- }
- 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 path = window.location.pathname.split('/').filter(check_emp);
- if(path.length > 1)
- wd = path[path.length -1];
-
- var vals = window.location.search.substring(1).split('&');
- for(var i in vals){
- var pair = vals[i].split('=');
- if(pair[0] == "q") wd = pair[1];
- }
-
- wd = wd.replace(/%20/g,'+');
- wd = wd.split('+').filter(check_emp).join('+');
-
- try{
- if(vals.length > 2) window.history.replaceState(null, null, 'https://' + window.location.hostname + '/dict/search?mkt=zh-CN&q=' + wd);
- }catch(error){}
-
- //-=-=-=-=-=-=-=-=-=-=-=-=-以下修改各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- $("#b-scopeListItem-local").hide();
-
- clone_b('oxford');clone_b('cambridge');clone_b('mw');clone_b('pwr');
-
- $("#mw a").text("webster");
- $("#mw a").attr('href',"https://www.merriam-webster.com/dictionary/" + wd);
-
- $("#oxford a").text("oxford");
- $("#oxford a").attr('href','https://www.oxfordlearnersdictionaries.com/definition/english/'+wd);
-
- $("#cambridge a").text("cambridge");
- $("#cambridge a").attr('href','https://dictionary.cambridge.org/zhs/dictionary/english/'+wd);
-
- $("#pwr a").text("pwr thesaurus");
- $("#pwr a").attr('href','https://www.powerthesaurus.org/'+wd);
-
- $("#b-scopeListItem-flights a").text("urban dict");
- $("#b-scopeListItem-flights a").attr('href','https://www.urbandictionary.com/define.php?term='+wd);
-
- go_dn("#b-scopeListItem-flights");
-
-
-
- clone_a('acronyms');clone_a('jtw');clone_a('anti');clone_a('full_write');clone_a('rhyme');clone_a('wenku');
-
- $("#wenku a").text("论文例句 & 替词");
- $("#wenku a").attr('href','http://www.esoda.org/?q='+ wd);
-
- $("#anti a").text("反义词");
- $("#anti a").attr('href','https://zh.powerthesaurus.org/' + wd +'/antonyms');
-
- $("#rhyme a").text("押韵");
- $("#rhyme a").attr('href','https://www.wordhippo.com/what-is/words-that-rhyme-with/'+ wd + '.html');
-
- $("#full_write a").text("全写");
- $("#full_write a").attr('href','https://www.allacronyms.com/'+ wd);
-
- $("#acronyms a").text("缩写");
- $("#acronyms a").attr('href','https://acronymify.com/search?q='+ wd);
-
- $("#jtw a").text("搭配");
- $("#jtw a").attr('href','http://www.just-the-word.com/main.pl?word='+ wd);
-
- $("#b-scopeListItem-video a").text("源流");
- $("#b-scopeListItem-video a").attr('href','https://www.etymonline.com/search?q='+ wd);
-
- $("#b-scopeListItem-images a").text("同义词");
- $("#b-scopeListItem-images a").attr('href','https://www.thesaurus.com/browse/'+ wd);
-
-
-
-
- go_dn("#jtw");
- go_dn("#wenku");
- go_dn("#b-scopeListItem-images");
- go_dn("#anti");
- go_dn("#acronyms");
- go_dn("#full_write");
- go_dn("#b-scopeListItem-dictionary");
- go_dn("#b-scopeListItem-video");
- go_dn("#rhyme");
- go_dn("#b-scopeListItem-menu");
-
- //-=-=-=-=-=-=-=-=-=-=-=-=-以下显示各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- 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 = `
- <img
- src="https://search.linggle.com/linggle-logo.png"
- alt="linggle-logo"
- width=`+ parseInt($(".b_logo").width()*0.6) +`px
- />
- `;
- linggle_button.onclick = function() {
- location.href = "https://search.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 = `
- <img
- src="https://ludwig.guru/icons/icon_144x144.png"
- alt="ludwig-logo"
- height=`+ parseInt($(".b_logo").height()*2.0) +`px
- />
- `;
- ludwig_button.onclick = function() {
- location.href = "https://ludwig.guru/s/" + wd;
- }
- document.body.append(ludwig_button);
-
- var gaoshan_height = parseInt($("#sb_form_q").height() * 1.25);
- 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(
- $("#sb_search").position().left + $("#sb_search").width()
- + 1.6*gaoshan_height //**********+ $(".b_logo").width()+1.45
- ) +"px",
- "top": parseInt(
- $("#sb_form_q").position().top
- + $("#sb_form_q").height()
- - gaoshan_height
- + 6
- ) + "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 = `
- <img
- src= "https://picx.zhimg.com/v2-23056dfc4cb2193ea32e50a5679cbfce_1440w.png"
- alt="gaoshan-logo"
- height=`+ gaoshan_height +`px
- />
- `;
- gaoshan_button.onclick = function() {
- location.href = "http://www.dicts.cn/";
- }
- document.body.append(gaoshan_button);
-
- const deepl_button = document.createElement('button');
- deepl_button.className = 'btn btn-sm';
- $(deepl_button).css({
- "border":"0",
- "background-color":"transparent",
- "cursor": "pointer",
- "position": "absolute",
- "left": parseInt(
- $("#sb_search").position().left + $("#sb_search").width()
- + 0.45*gaoshan_height //**********+ $(".b_logo").width()+0.1
- ) +"px",
- "top": parseInt(
- $("#sb_form_q").position().top
- + $("#sb_form_q").height()
- - gaoshan_height
- + 10
- ) + "px",
- });
- $(deepl_button).css(mouse_out_effect);
- deepl_button.onmouseout = function(){
- $(deepl_button).css(mouse_out_effect);
- }
- deepl_button.onmouseover = function(){
- $(deepl_button).css(mouse_on_effect);
- }
- deepl_button.innerHTML = `
- <img
- src= "https://static.deepl.com/img/logo/DeepL_Logo_darkBlue_v2.svg"
- alt="deepl-logo"
- height=`+ gaoshan_height +`px
- />
- `;
- deepl_button.onclick = function() {
- location.href = "https://www.deepl.com/translator#auto/auto/" + wd.replace(/\+/g,' ');
- }
- document.body.append(deepl_button);
-
- //-=-=-=-=-=-=-=-=-=-=-=-=-=-以下显示有道-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- $(".sidebar").css("display", "none");
- $("#id_rh").css("display", "none");
-
- if( 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");
-
- $(".lf_area").css({
- "position": "absolute",
- "left": parseInt(margin * 0.34)+"px",
- });
-
- //$('#ex_id').click()//trigger("click");
- $('.pos_close').click()//trigger("click");
-
- if( !($(".no_results").is(":visible")) ){
- let m = `
- <div
- style="
- overflow: hidden;
- position: absolute;
- right:`+ parseInt(margin * 0.16) +`px;
- top: `+ $(".contentPadding").position().top +`px;
- width:`+ youdao_width +`px;
- "
- >
- <iframe
- style="
- position:relative;
- top: `+ (-youdao_top_padding) +`px;
- left:`+ (-youdao_left_padding)+`px
- "
- src="https://dict.youdao.com/w/` + wd.replace(/\+/g,' ') + `"
- frameborder=0
- scrolling="no"
- width="` + (youdao_left_padding + youdao_width) + `px"
- height="` + $(document).height()*1.02 + `px"
- >
- </iframe>
- </div>
- `
- $(m).appendTo(document.body);
- }else{
- let m = `
- <div
- style="
- overflow: hidden;
- position: absolute;
- left:`+ 0 +`px;
- top: `+ ($("#b_header").height() + 25) +`px;
- width:` + $("#b_header").width() +`px;
- "
- >
- <iframe
- width="`+ $("#b_header").width() +`px"
- style="
- position:relative;
- top: `+ (-youdao_top_padding) +`px
- "
- src="https://www.youdao.com/w/` + wd.replace(/\+/g,' ')+ `"
- frameborder=0
- scrolling="no"
- height=` + ($(document).height()) + `"px"
- >
- </iframe>
- </div>
-
- <div
- style="
- overflow: hidden;
- position: absolute;
- background-color: #fcfcfe;
- left:`+ 810 +`px;
- top: `+ ($("#b_header").height() + 50) +`px;
- width:` + ($("#b_header").width() -850) +`px;
- height:` + ($(document).height() -200) + `px
- "
- >
- </div>
- `
- $(m).appendTo(document.body);
- }
- })();