封装图标隐藏处理步骤
This commit is contained in:
parent
ad53b74725
commit
a268dca2cb
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Translate
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 5.1
|
||||
// @version 5.2
|
||||
// @description 划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典、PDF 划词翻译、Google Search、Bing Search(必应搜索)、百度搜索、Wikipedia Search(维基百科搜索)”网页翻译
|
||||
// @author https://github.com/barrer
|
||||
// @match http://*/*
|
||||
|
@ -420,8 +420,7 @@
|
|||
document.addEventListener("selectionchange", function () {
|
||||
log('selectionchange:' + window.getSelection().toString());
|
||||
if (!window.getSelection().toString().trim()) {
|
||||
icon.style.display = 'none';
|
||||
forceStopDrag();
|
||||
hideIcon();
|
||||
}
|
||||
});
|
||||
// 鼠标事件:防止选中的文本消失;显示、隐藏翻译图标
|
||||
|
@ -444,11 +443,7 @@
|
|||
icon.style.zIndex = '2147473647';
|
||||
} else if (!text) {
|
||||
log('hide icon');
|
||||
icon.style.display = 'none';
|
||||
icon.querySelectorAll('img[is-more]').forEach(function (ele) {
|
||||
ele.style.display = 'none';
|
||||
});
|
||||
forceStopDrag();
|
||||
hideIcon();
|
||||
}
|
||||
});
|
||||
/**日志输出*/
|
||||
|
@ -596,6 +591,14 @@
|
|||
iconDrag.unsetMouseMove();
|
||||
}
|
||||
}
|
||||
/**隐藏 icon*/
|
||||
function hideIcon() {
|
||||
icon.style.display = 'none';
|
||||
icon.querySelectorAll('img[is-more]').forEach(function (ele) {
|
||||
ele.style.display = 'none';
|
||||
});
|
||||
forceStopDrag();
|
||||
}
|
||||
/**设置*/
|
||||
function settings() {
|
||||
var hideConfig = gm.get(gm.HIDE, {});
|
||||
|
|
Loading…
Reference in New Issue
Block a user