在 bing词典 中聚合显示 有道 的结果 添加转跳至各种在线工具的按钮

1. Display youdao.com results alongside the original results on bing.com/dict. 2. Provide shortcuts for many online tools.

  1. // ==UserScript==
  2. // @name 在 bing词典 中聚合显示 有道 的结果 添加转跳至各种在线工具的按钮
  3. // @namespace http://tampermonkey.net/
  4. // @version 10.6.7
  5. // @license MIT
  6. // @description 1. Display youdao.com results alongside the original results on bing.com/dict. 2. Provide shortcuts for many online tools.
  7. // @author 庶民player
  8. // @match *.bing.com/dict*
  9. // @icon https://cn.bing.com/sa/simg/favicon-2x.ico
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js
  11. // @run-at document-idle
  12. // @compatible edge
  13. // @compatible chrome
  14. // @compatible safari
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. function clone_a(name){
  19. var tmp = $('#b-scopeListItem-images').clone(true).attr('id', name);
  20. $('#b-scopeListItem-images').after(tmp);
  21. }
  22. function clone_b(name){
  23. var tmp = $('#b-scopeListItem-flights').clone(true).attr('id', name);
  24. $('#b-scopeListItem-flights').after(tmp);
  25. }
  26. function check_emp(x) {
  27. return x.length > 0;
  28. }
  29. function go_dn(elem_name){
  30. for(
  31. let cur_li = $(elem_name) , next_li = cur_li.next();
  32. next_li.length > 0;
  33. next_li = cur_li.next()
  34. ){
  35. next_li.after(cur_li);
  36. }
  37. }
  38.  
  39. (function() {
  40. 'use strict';
  41.  
  42. var wd = "NONE";
  43.  
  44. var path = window.location.pathname.split('/').filter(check_emp);
  45. if(path.length > 1)
  46. wd = path[path.length -1];
  47.  
  48. var vals = window.location.search.substring(1).split('&');
  49. for(var i in vals){
  50. var pair = vals[i].split('=');
  51. if(pair[0] == "q") wd = pair[1];
  52. }
  53.  
  54. wd = wd.replace(/%20/g,'+');
  55. wd = wd.split('+').filter(check_emp).join('+');
  56.  
  57. try{
  58. if(vals.length > 2) window.history.replaceState(null, null, 'https://' + window.location.hostname + '/dict/search?mkt=zh-CN&q=' + wd);
  59. }catch(error){}
  60.  
  61. //-=-=-=-=-=-=-=-=-=-=-=-=-以下修改各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  62. $("#b-scopeListItem-local").hide();
  63.  
  64. clone_b('oxford');clone_b('cambridge');clone_b('mw');clone_b('pwr');
  65.  
  66. $("#mw a").text("webster");
  67. $("#mw a").attr('href',"https://www.merriam-webster.com/dictionary/" + wd);
  68.  
  69. $("#oxford a").text("oxford");
  70. $("#oxford a").attr('href','https://www.oxfordlearnersdictionaries.com/definition/english/'+wd);
  71.  
  72. $("#cambridge a").text("cambridge");
  73. $("#cambridge a").attr('href','https://dictionary.cambridge.org/zhs/dictionary/english/'+wd);
  74.  
  75. $("#pwr a").text("pwr thesaurus");
  76. $("#pwr a").attr('href','https://www.powerthesaurus.org/'+wd);
  77.  
  78. $("#b-scopeListItem-flights a").text("urban dict");
  79. $("#b-scopeListItem-flights a").attr('href','https://www.urbandictionary.com/define.php?term='+wd);
  80.  
  81. go_dn("#b-scopeListItem-flights");
  82.  
  83.  
  84.  
  85. clone_a('acronyms');clone_a('jtw');clone_a('anti');clone_a('full_write');clone_a('rhyme');clone_a('wenku');
  86.  
  87. $("#wenku a").text("论文例句 & 替词");
  88. $("#wenku a").attr('href','http://www.esoda.org/?q='+ wd);
  89.  
  90. $("#anti a").text("反义词");
  91. $("#anti a").attr('href','https://zh.powerthesaurus.org/' + wd +'/antonyms');
  92.  
  93. $("#rhyme a").text("押韵");
  94. $("#rhyme a").attr('href','https://www.wordhippo.com/what-is/words-that-rhyme-with/'+ wd + '.html');
  95.  
  96. $("#full_write a").text("全写");
  97. $("#full_write a").attr('href','https://www.allacronyms.com/'+ wd);
  98.  
  99. $("#acronyms a").text("缩写");
  100. $("#acronyms a").attr('href','https://acronymify.com/search?q='+ wd);
  101.  
  102. $("#jtw a").text("搭配");
  103. $("#jtw a").attr('href','http://www.just-the-word.com/main.pl?word='+ wd);
  104.  
  105. $("#b-scopeListItem-video a").text("源流");
  106. $("#b-scopeListItem-video a").attr('href','https://www.etymonline.com/search?q='+ wd);
  107.  
  108. $("#b-scopeListItem-images a").text("同义词");
  109. $("#b-scopeListItem-images a").attr('href','https://www.thesaurus.com/browse/'+ wd);
  110.  
  111.  
  112.  
  113.  
  114. go_dn("#jtw");
  115. go_dn("#wenku");
  116. go_dn("#b-scopeListItem-images");
  117. go_dn("#anti");
  118. go_dn("#acronyms");
  119. go_dn("#full_write");
  120. go_dn("#b-scopeListItem-dictionary");
  121. go_dn("#b-scopeListItem-video");
  122. go_dn("#rhyme");
  123. go_dn("#b-scopeListItem-menu");
  124.  
  125. //-=-=-=-=-=-=-=-=-=-=-=-=-以下显示各种按钮-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  126.  
  127. var mouse_on_effect = {"filter":"drop-shadow(0px 1px 3px #808080)", "transition":"0.1s" , "transition-timing-function": "ease-out",};
  128. var mouse_out_effect = {"filter":"drop-shadow(0px 1px 3px #d0d0d0)", "transition":"0.1s", "transition-timing-function": "ease-out",};
  129.  
  130. const linggle_button = document.createElement('button');
  131. linggle_button.className = 'btn btn-sm';
  132. $(linggle_button).css({
  133. "border":"0",
  134. "background-color":"transparent",
  135. "cursor": "pointer",
  136. "position": "absolute",
  137. "left": ($("#b_header").position().left + 57) +"px",
  138. "top": ($("#b_header").position().top + $("#b_header").height() - 12 -3) + "px",
  139. });
  140. linggle_button.innerHTML = `
  141. <img
  142. src="https://search.linggle.com/linggle-logo.png"
  143. alt="linggle-logo"
  144. width=`+ parseInt($(".b_logo").width()*0.6) +`px
  145. />
  146. `;
  147. linggle_button.onclick = function() {
  148. location.href = "https://search.linggle.com/?q=" + wd;
  149. }
  150. document.body.append(linggle_button);
  151.  
  152.  
  153. const ludwig_button = document.createElement('button');
  154. ludwig_button.className = 'btn btn-sm';
  155. $(ludwig_button).css({
  156. "border":"0",
  157. "background-color":"transparent",
  158. "cursor": "pointer",
  159. "position": "absolute",
  160. "left": ($("#b_header").position().left + 14) +"px",
  161. "top": ($("#b_header").position().top + $("#b_header").height() - 23 -3) + "px",
  162. });
  163. ludwig_button.innerHTML = `
  164. <img
  165. src="https://ludwig.guru/icons/icon_144x144.png"
  166. alt="ludwig-logo"
  167. height=`+ parseInt($(".b_logo").height()*2.0) +`px
  168. />
  169. `;
  170. ludwig_button.onclick = function() {
  171. location.href = "https://ludwig.guru/s/" + wd;
  172. }
  173. document.body.append(ludwig_button);
  174.  
  175. var gaoshan_height = parseInt($("#sb_form_q").height() * 1.25);
  176. const gaoshan_button = document.createElement('button');
  177. gaoshan_button.className = 'btn btn-sm';
  178. $(gaoshan_button).css({
  179. "border":"0",
  180. "background-color":"transparent",
  181. "cursor": "pointer",
  182. "position": "absolute",
  183. "left": parseInt(
  184. $("#sb_search").position().left + $("#sb_search").width()
  185. + 1.6*gaoshan_height //**********+ $(".b_logo").width()+1.45
  186. ) +"px",
  187. "top": parseInt(
  188. $("#sb_form_q").position().top
  189. + $("#sb_form_q").height()
  190. - gaoshan_height
  191. + 6
  192. ) + "px",
  193. });
  194. $(gaoshan_button).css(mouse_out_effect);
  195. gaoshan_button.onmouseout = function(){
  196. $(gaoshan_button).css(mouse_out_effect);
  197. }
  198. gaoshan_button.onmouseover = function(){
  199. $(gaoshan_button).css(mouse_on_effect);
  200. }
  201. gaoshan_button.innerHTML = `
  202. <img
  203. src= "https://picx.zhimg.com/v2-23056dfc4cb2193ea32e50a5679cbfce_1440w.png"
  204. alt="gaoshan-logo"
  205. height=`+ gaoshan_height +`px
  206. />
  207. `;
  208. gaoshan_button.onclick = function() {
  209. location.href = "http://www.dicts.cn/";
  210. }
  211. document.body.append(gaoshan_button);
  212.  
  213. const deepl_button = document.createElement('button');
  214. deepl_button.className = 'btn btn-sm';
  215. $(deepl_button).css({
  216. "border":"0",
  217. "background-color":"transparent",
  218. "cursor": "pointer",
  219. "position": "absolute",
  220. "left": parseInt(
  221. $("#sb_search").position().left + $("#sb_search").width()
  222. + 0.45*gaoshan_height //**********+ $(".b_logo").width()+0.1
  223. ) +"px",
  224. "top": parseInt(
  225. $("#sb_form_q").position().top
  226. + $("#sb_form_q").height()
  227. - gaoshan_height
  228. + 10
  229. ) + "px",
  230. });
  231. $(deepl_button).css(mouse_out_effect);
  232. deepl_button.onmouseout = function(){
  233. $(deepl_button).css(mouse_out_effect);
  234. }
  235. deepl_button.onmouseover = function(){
  236. $(deepl_button).css(mouse_on_effect);
  237. }
  238. deepl_button.innerHTML = `
  239. <img
  240. src= "https://static.deepl.com/img/logo/DeepL_Logo_darkBlue_v2.svg"
  241. alt="deepl-logo"
  242. height=`+ gaoshan_height +`px
  243. />
  244. `;
  245. deepl_button.onclick = function() {
  246. location.href = "https://www.deepl.com/translator#auto/auto/" + wd.replace(/\+/g,' ');
  247. }
  248. document.body.append(deepl_button);
  249.  
  250. //-=-=-=-=-=-=-=-=-=-=-=-=-=-以下显示有道-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  251. $(".sidebar").css("display", "none");
  252. $("#id_rh").css("display", "none");
  253.  
  254. if( wd=="NONE" ) return;
  255.  
  256. var youdao_top_padding = 190;
  257. var youdao_left_padding = 120;
  258. var youdao_width = 640;
  259. var bing_width = $(".lf_area").width(); //532
  260. var margin = window.innerWidth -youdao_width -bing_width;
  261.  
  262. $("#b_footer").css("display", "none");
  263.  
  264. $(".lf_area").css({
  265. "position": "absolute",
  266. "left": parseInt(margin * 0.34)+"px",
  267. });
  268.  
  269. //$('#ex_id').click()//trigger("click");
  270. $('.pos_close').click()//trigger("click");
  271.  
  272. if( !($(".no_results").is(":visible")) ){
  273. let m = `
  274. <div
  275. style="
  276. overflow: hidden;
  277. position: absolute;
  278. right:`+ parseInt(margin * 0.16) +`px;
  279. top: `+ $(".contentPadding").position().top +`px;
  280. width:`+ youdao_width +`px;
  281. "
  282. >
  283. <iframe
  284. style="
  285. position:relative;
  286. top: `+ (-youdao_top_padding) +`px;
  287. left:`+ (-youdao_left_padding)+`px
  288. "
  289. src="https://dict.youdao.com/w/` + wd.replace(/\+/g,' ') + `"
  290. frameborder=0
  291. scrolling="no"
  292. width="` + (youdao_left_padding + youdao_width) + `px"
  293. height="` + $(document).height()*1.02 + `px"
  294. >
  295. </iframe>
  296. </div>
  297. `
  298. $(m).appendTo(document.body);
  299. }else{
  300. let m = `
  301. <div
  302. style="
  303. overflow: hidden;
  304. position: absolute;
  305. left:`+ 0 +`px;
  306. top: `+ ($("#b_header").height() + 25) +`px;
  307. width:` + $("#b_header").width() +`px;
  308. "
  309. >
  310. <iframe
  311. width="`+ $("#b_header").width() +`px"
  312. style="
  313. position:relative;
  314. top: `+ (-youdao_top_padding) +`px
  315. "
  316. src="https://www.youdao.com/w/` + wd.replace(/\+/g,' ')+ `"
  317. frameborder=0
  318. scrolling="no"
  319. height=` + ($(document).height()) + `"px"
  320. >
  321. </iframe>
  322. </div>
  323.  
  324. <div
  325. style="
  326. overflow: hidden;
  327. position: absolute;
  328. background-color: #fcfcfe;
  329. left:`+ 810 +`px;
  330. top: `+ ($("#b_header").height() + 50) +`px;
  331. width:` + ($("#b_header").width() -850) +`px;
  332. height:` + ($(document).height() -200) + `px
  333. "
  334. >
  335. </div>
  336. `
  337. $(m).appendTo(document.body);
  338. }
  339. })();