修复必应翻译新版页面自动填充问题

This commit is contained in:
example 2019-06-13 12:31:44 +08:00
parent cbe4fa9f00
commit 62043928a6

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name Translate
// @namespace http://tampermonkey.net/
// @version 6.0
// @version 6.1
// @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://*/*
@ -124,18 +124,22 @@
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAABgFBMVEX////////V6NV2tHZGmkYkhyQujS5ZpVmXxpep0KnT59Pn8ucCdAILeQsPew8Oew4JeAkAcwAUfhQ1kDVmrGas0qzG4Mbs9ez3+/eIvogQfBAIeAgRfRFCmEJprWmn0Kfp8+ny+PJ0s3QGdgYZgRkriytVolWx1bHi7+L6/PqlzqUEdgQOeg4HdweDvIPO5M7+/v4EdQQLegshhSGZyJn0+fTw9/ChzKExjjEPfA/5/Pnl8eU/lj+VxpUMegx+uX5cplz4+/jk8OQpiim01rQliCVNnk09lT3Y6tj2+vY6lDo4kjj+//79/v3S5tJsrmwehB7Q5dD7/ftRoFFKnEpusG78/fy52bne7d7b7NvX6dfq9Orv9u95tnnt9e2Rw5Hg7uBfqF9lq2Xa69qFvYW32LfJ4smBuoHM48wWgBbD3sMrjCtIm0iMwIy/3L8cgxySxJKfy5/w+PDQ5tD1+vWdyZ1hqWFxsXFQn1BXo1f3+vdgp2C827wHeAf2+/a417gtAEeJAAAAAXRSTlMAQObYZgAACylJREFUeAHF2mdD20jQB/ARvXi1ip1QRobDiGpuAwIMiLJU2zTTj967uRAn19KufPSnkHAaGdlWnNj3e5kA+9dodrUq4IlSUlpWXlFZVV1TC/+J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M+gVSf/nf2n3UNTg+vhR/V5JwPZ43AzrajMUZyGWmXKJNChFkQnLnohOYA2rooMv9uBLrZxZDevzHkJMyaWJWTP9wCp4MhaO0/FLbqgcPWsoZZiHWLg/Bi9G7Ds7QJuWnA/DkrWZhJrq2WNcAXuw3phhHG0tOHII30++Eiq6k+Pn3WvBi7L5dk2izegauusGrww4h3YrPylsvwIuD6kUm6UForLIXvkLtO4tJCwnOWf/iTa+ng+gKlwUFEqpYm2iArxLZ2UpZ5pdzyJlhpJLng11ehu+unQgEdRUJhrH9bfhav72erAykLKZJNTXS8dMLbxVc2L+p4BpHgono4AHkJTIzvzJ392Jlvis0DR40/Nm6NCsYUpZYK72A4khMcsYZUpIFO64boDiUHUOiA9dSr6ojUCyjf/iQkiIZu6qH4mk4IwG41FNTcwtQTH2d/3a/avpnL69DUGQf3/0lLESm8eTUi3n4DzQMB4I+MTs+cReB/8jM8P39bT6rzv8CoTxF395hjrkAAAAASUVORK5CYII=',
host: ['www.bing.com', 'cn.bing.com'],
popup: function (text) {
popupCenter('https://cn.bing.com/translator', null, 800, screen.height);
popupCenter('https://cn.bing.com/translator', null, 1024, screen.height);
},
custom: function (text) {
if (window.location.href.indexOf('bing.com/translator') != -1) {
if (hasChineseByRange(text)) {
document.querySelector('#t_tl').value = 'en';
document.querySelector('#tta_tgtsl').value = 'en';
} else {
document.querySelector('#t_tl').value = 'zh-CHS';
document.querySelector('#tta_tgtsl').value = 'zh-Hans';
}
var source = document.querySelector('#t_sv');
var source = document.querySelector('#tta_input');
source.value = text;
tiggerEvent(source, 'input');
for (var i = 0; i < 10; i++) { // 最低延迟 5 秒
setTimeout(function () {
tiggerEvent(source, 'input');
}, 500 + i * 500);
}
}
}
},
@ -492,7 +496,7 @@
function tiggerEvent(el, type) {
if ('createEvent' in document) { // modern browsers, IE9+
var e = document.createEvent('HTMLEvents');
e.initEvent(type, false, true); // event.initEvent(type, bubbles, cancelable);
e.initEvent(type, true, true); // event.initEvent(type, bubbles, cancelable);
el.dispatchEvent(e);
} else { // IE 8
var e = document.createEventObject();