From db4e2fd744cea0eb5e00b19d906bc46dc659baa9 Mon Sep 17 00:00:00 2001 From: example Date: Tue, 9 Apr 2019 21:02:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=BD=91=E9=A1=B5=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E6=97=B6=E9=9D=A2=E6=9D=BF=E4=BD=8D=E7=BD=AE=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translate/translate-dictionary.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/translate/translate-dictionary.js b/translate/translate-dictionary.js index 4846043..0eae4fe 100644 --- a/translate/translate-dictionary.js +++ b/translate/translate-dictionary.js @@ -1,7 +1,7 @@ // ==UserScript== // @name 划词翻译:多词典查询 // @namespace http://tampermonkey.net/ -// @version 4.1 +// @version 4.2 // @description 划词翻译调用“有道词典(有道翻译)、金山词霸、Bing 词典(必应词典)、剑桥高阶、沪江小D、谷歌翻译” // @author https://github.com/barrer // @match http://*/* @@ -631,11 +631,17 @@ }).sort(function (a, b) { return a > b ? -1 : (a == b ? 0 : 1); })[0]; // 找出最大值且小于等于 window 的高度 + if (!clientHeight) { // 网页缩放导致可能数组为空([0] 为 undefined) + clientHeight = parseInt(window.innerHeight); + } var clientWidth = [parseInt(document.documentElement.clientWidth), parseInt(document.body.clientWidth)].filter(function (x) { return x <= parseInt(window.innerWidth); }).sort(function (a, b) { return a > b ? -1 : (a == b ? 0 : 1); })[0]; // 找出最大值且小于等于 window 的宽度 + if (!clientWidth) { // 网页缩放导致可能数组为空([0] 为 undefined) + clientWidth = parseInt(window.innerWidth); + } var iconNewTop = -1; if (parseInt(icon.style.top) < scrollTop) { log('Y adjust top');