From 526c52e7f9b0abb09fb08b05c6791e7dcfdd96ed Mon Sep 17 00:00:00 2001 From: example Date: Sat, 23 Feb 2019 09:18:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8B=96=E5=8A=A8=E7=82=B9?= =?UTF-8?q?=E6=8C=89=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translate/translate.js | 82 +++++------------------------------------- 1 file changed, 9 insertions(+), 73 deletions(-) diff --git a/translate/translate.js b/translate/translate.js index aa071ee..ba150dc 100644 --- a/translate/translate.js +++ b/translate/translate.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Translate // @namespace http://tampermonkey.net/ -// @version 4.4 +// @version 4.5 // @description 划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典、PDF 划词翻译”网页翻译 // @author https://github.com/barrer // @match http://*/* @@ -20,74 +20,13 @@ /**样式*/ var style = document.createElement('style'); style.textContent = ` - * { - word-wrap: break-word !important - } - - img { - cursor: pointer; - display: inline-block; - width: 22px; - height: 22px; - border: 1px solid #dfe1e5; - border-radius: 22px; - background-color: rgba(255, 255, 255, 1); - padding: 2px; - margin: 0; - margin-right: 5px; - box-sizing: content-box; - vertical-align: middle; - } - - img:last-of-type { - margin-right: auto; - } - - img:hover { - border: 1px solid #c6c6c6; - -webkit-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); - box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); - } - - tr-icon { - display: none; - position: absolute; - padding: 0; - margin: 0; - cursor: move; - background: transparent; - box-sizing: content-box; - font-size: 13px; - text-align: left; - border: 0; - color: black; - z-index: 2147473647; - } - - tr-back-forward { - display: none; - position: fixed; - top: 0; - left: 0; - padding: 0; - margin: 0; - font-size: 16px; - text-align: left; - border: 0; - cursor: move; - background: transparent; - z-index: 2147473647; - } - - tr-back-forward a { - text-decoration: none; - font-size: 16px; - cursor: pointer; - display: inline; - padding: 0; - margin: 0; - margin-right: 4px; - } + *{word-wrap:break-word!important} + img{cursor:pointer;display:inline-block;width:22px;height:22px;border:1px solid #dfe1e5;border-radius:22px;background-color:rgba(255,255,255,1);padding:2px;margin:0;margin-right:5px;box-sizing:content-box;vertical-align:middle} + img:last-of-type{margin-right:auto} + img:hover{border:1px solid #c6c6c6;-webkit-box-shadow:1px 1px 3px rgba(0,0,0,0.1);box-shadow:1px 1px 3px rgba(0,0,0,0.1)} + tr-icon{display:none;position:absolute;padding:0;margin:0;cursor:move;background:transparent;box-sizing:content-box;font-size:13px;text-align:left;border:0;color:black;z-index:2147473647} + tr-back-forward{display:none;position:fixed;top:0;left:0;padding:0;margin:0;font-size:16px;text-align:left;border:0;cursor:move;background:transparent;z-index:2147473647} + tr-back-forward a{text-decoration:none;font-size:16px;cursor:pointer;display:inline;padding:0;margin:0;margin-right:4px} `; // iframe 工具库 var iframe = document.createElement('iframe'); @@ -378,10 +317,7 @@ img.setAttribute('alt', obj.name); img.setAttribute('title', obj.name); img.addEventListener('mouseup', function () { - if (iconDrag.elementOriginalLeft == myParseInt(icon.style.left) && - iconDrag.elementOriginalTop == myParseInt(icon.style.top)) { // 没有拖动鼠标抬起的时候触发点击事件 - dataTransfer.beforePopup(obj.popup); - } + dataTransfer.beforePopup(obj.popup); }); if (isIconImgMore) { img.setAttribute('is-more', 'true');