diff --git a/README.md b/README.md index 858706d..84381d2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ![translate.jpg](translate/translate.jpg) 特色: -* 划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典”网页翻译 +* 划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典、PDF 划词翻译”网页翻译 * 支持顺序自定义 * 支持隐藏图标 * 支持显示更多图标 @@ -27,6 +27,8 @@ ![translate-bundle.jpg](translate/translate-bundle.jpg) +![translate-pdf.jpg](translate/translate-pdf.jpg) + 同时安装: ① 划词翻译:多词典查询 @@ -52,5 +54,5 @@ Tampermonkey 是一款免费的浏览器扩展和最为流行的用户脚本管 脚本名 | 用途 -|- -translate.js|划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典”网页翻译 +translate.js|划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典、PDF 划词翻译”网页翻译 translate-dictionary.js|划词翻译调用“有道词典(有道翻译)、金山词霸、Bing 词典(必应词典)、沪江小D、谷歌翻译” diff --git a/translate/translate-pdf.jpg b/translate/translate-pdf.jpg new file mode 100644 index 0000000..ef4fb8d Binary files /dev/null and b/translate/translate-pdf.jpg differ diff --git a/translate/translate.js b/translate/translate.js index ad67bc7..94744ef 100644 --- a/translate/translate.js +++ b/translate/translate.js @@ -1,8 +1,8 @@ // ==UserScript== // @name Translate // @namespace http://tampermonkey.net/ -// @version 3.8 -// @description 划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典”网页翻译 +// @version 3.9 +// @description 划词翻译调用“金山词霸、有道词典(有道翻译)、Google Translate(谷歌翻译)、沪江小D、搜狗翻译、必应词典(必应翻译)、Microsoft Translator(必应在线翻译)、海词词典、百度翻译、Oxford Learner's Dictionaries、Oxford Dictionaries、Merriam-Webster、汉典、PDF 划词翻译”网页翻译 // @author https://github.com/barrer // @match http://*/* // @include https://*/* @@ -332,6 +332,16 @@ }, custom: function (text) {} }, + { + name: 'PDF 划词翻译', + id: 'pdf', + image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAABBVBMVEX////v7+/MzMzPz8/Z2dnf39/l5eX19fXs7Ozy8vLS0tLi4uLp6en5+fnR0dHf4OHZ2trX2NjS09PPz9DW1tbc3Nz8/Pzl5+jg4uPd39/V1tfOzs7j5ebc3d7U1NXa29zi5OXn6ens7e7w8vLq7Ozt7+/y8/T////19vb6+/vv8PH9/v7o6uv3+Pj09fX/5N//yb/jrKLZo5nnsqnst67/zsP/08bswbXZraD/6eL/kn//JgD/Ow3/UBr/p4z/XED/QSD/TzD/fFP/cUX/Zjf/8e//NBD/k4D/knD/9PH/1s//spv/nX7/qI3/h2L/Wyj/3tT/van1v7XdqJ76z8HnvK/csKN0GMq7AAAAAXRSTlMAQObYZgAABJZJREFUeAG00mEORTAAA+CpvQFsAAD3P+XLBJaAgO8n0LQjEw06/THNIB8zNPajOszVDQsjmzqu5ZHXeZbLqI2RtRHA5yIII4zihJlWSt5gmSyhGEV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BMe8UaFIvIK0IsIydOK8JYMhR8MgBcZpWCWjQHAPIKQJsyFGgB2A+EkCZigzAIFIDYHdiRBGgpxmAYVjSCeB3YjxFoQCw2mUAIeYxX77eseq1AGQ5duJZNQC+nB8FyBw1xgCY76+s4QAeEG4c8uUyk5RSBeDL+VEAQDkogC9Hyj4ARSKangzwj+i3fHFymoiyLMBI5clKaWqp6g/gp7xRr9D/yaeMmI8Y2dTsAFFrsgD/5Vm+XWY+XrhHzJRr3N7MlyfmgpRLRC6dJCuVemMxRHkxEwuRXHouYSPwnxllOZIp2gh7ebD/mc0Q5cx/Jr88mrXyjIpyiSgMlke51oy2nFkeKKckyhXHuTxkeToXizJYHurLmeURtvw/zIHlkE48ciYAAAAASUVORK5CYII=', + host: ['pdf.example.com'], + popup: function (text) { + openInNewTab('https://barrer.github.io/tools/pdfjs/web/viewer.html'); + }, + custom: function (text) {} + }, { name: 'Settings', id: 'settings', @@ -535,6 +545,16 @@ } return win; } + /**打开新的标签页*/ + function openInNewTab(url) { + gm.set(gm.REDIRECT_URL, url); + var a = document.createElement('a'); + a.setAttribute('target', '_blank'); + a.setAttribute('href', 'https://example.com'); + a.style.display = 'none'; + shadow.appendChild(a); + a.click(); + } /**鼠标拖动*/ function Drag(element) { this.dragging = false;