mirror of
https://gitee.com/bitdance-team/chrome-extension
synced 2025-10-08 00:45:13 +08:00
有道翻译、腾讯翻译君相关代码修改完善;一些小改动
This commit is contained in:
@@ -1,28 +1,4 @@
|
||||
$(function () {
|
||||
console.log("[BitDance extension] 学生助手插件 - 腾讯翻译君自动填入模块加载成功");
|
||||
|
||||
// refer: https://www.cnblogs.com/chen-lhx/p/5198612.html
|
||||
$.extend({
|
||||
getUrlVars: function () {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
},
|
||||
getUrlVar: function (name) {
|
||||
return $.getUrlVars()[name];
|
||||
}
|
||||
});
|
||||
|
||||
window.onload = () => {
|
||||
let transText = $.getUrlVar('__bitdance_extension__');
|
||||
if (transText == "") return
|
||||
// alert(transText)
|
||||
document.getElementsByTagName("textarea")[0].value = decodeURIComponent(transText)
|
||||
$(".language-translate-button")[0].click()
|
||||
}
|
||||
})
|
||||
console.log("[BitDance extension] 学生助手插件 - 腾讯翻译君自动点击翻译模块加载成功");
|
||||
window.onload = () => {
|
||||
$(".language-translate-button")[0].click()
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
console.log("[BitDance extension] 学生助手插件 - 有道翻译自动填入模块加载成功");
|
||||
|
||||
// refer: https://www.cnblogs.com/chen-lhx/p/5198612.html
|
||||
$.extend({
|
||||
getUrlVars: function () {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
},
|
||||
getUrlVar: function (name) {
|
||||
return $.getUrlVars()[name];
|
||||
}
|
||||
});
|
||||
|
||||
window.onload = () => {
|
||||
let transText = $.getUrlVar('__bitdance_extension__');
|
||||
if (!transText || transText.trim() == "") return
|
||||
// alert(transText)
|
||||
console.log("[BitDance extension] 学生助手插件 - 有道翻译自动填入模块 - 翻译文本为:", transText);
|
||||
document.getElementsByTagName("textarea")[0].value = decodeURIComponent(transText)
|
||||
document.getElementById("transMachine").click()
|
||||
|
||||
// 参数获取完成后,清除掉页面参数
|
||||
// History.replaceState() refer: https://developer.mozilla.org/zh-CN/docs/Web/API/History/replaceState
|
||||
history.replaceState({}, "", "/");
|
||||
}
|
Reference in New Issue
Block a user