From 20fa28e568c3b776823562b77b3783aabd41ef34 Mon Sep 17 00:00:00 2001 From: example Date: Tue, 16 Apr 2019 14:16:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A4=A7=E5=B0=8F=E5=86=99?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=E6=AF=94=E8=BE=83=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translate/translate-dictionary.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/translate/translate-dictionary.js b/translate/translate-dictionary.js index 017429c..db002b1 100644 --- a/translate/translate-dictionary.js +++ b/translate/translate-dictionary.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 划词翻译:多词典查询 // @namespace http://tampermonkey.net/ -// @version 4.5 +// @version 4.6 // @description 划词翻译调用“有道词典(有道翻译)、金山词霸、Bing 词典(必应词典)、剑桥高阶、沪江小D、谷歌翻译” // @author https://github.com/barrer // @match http://*/* @@ -720,19 +720,9 @@ } /**内容面板填充数据*/ function showContent() { - // 比较大小写内容 - var needDel = {}; - for (var key in idsExtension.lowerCaseMap) { - if (engineResult[key] && - engineResult[idsExtension.lowerCaseMap[key]] && - (engineResult[key].innerHTML == engineResult[idsExtension.lowerCaseMap[key]].innerHTML || - engineResult[key].innerHTML.toLowerCase() == engineResult[idsExtension.lowerCaseMap[key]].innerHTML.toLowerCase())) { - needDel[key] = key; - } - } - // 填充指定引擎内容 + // 填充已有结果集引擎内容 idsType.forEach(function (id) { - if (engineResult[id] && !(id in needDel)) { + if (engineResult[id]) { var engine = contentList.querySelector('tr-engine[data-id="' + id + '"]'); if (engine) { engine.appendChild(engineResult[id]); @@ -740,6 +730,18 @@ } } }); + // 比较大小写内容 + for (var id in idsExtension.lowerCaseMap) { + if (engineResult[id] && + engineResult[idsExtension.lowerCaseMap[id]] && + (engineResult[id].innerHTML == engineResult[idsExtension.lowerCaseMap[id]].innerHTML || + engineResult[id].innerHTML.toLowerCase() == engineResult[idsExtension.lowerCaseMap[id]].innerHTML.toLowerCase())) { + var engine = contentList.querySelector('tr-engine[data-id="' + id + '"]'); + if (engine) { + engine.style.display = 'none'; // 隐藏小写内容 + } + } + } } /**隐藏翻译引擎指示器*/ function engineActivateHide() {