Update GoogleTranslateOption.plugin.js

This commit is contained in:
Mirco Wittrien 2020-08-05 00:36:18 +02:00 committed by GitHub
parent b43424d5de
commit b5479731d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -29,17 +29,13 @@ var GoogleTranslateOption = (_ => {
return class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";}
getVersion () {return "2.0.6";}
getVersion () {return "2.0.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a Google Translate option to your context menu, which shows a preview of the translated text and on click will open the selected text in Google Translate. Also adds a translation button to your textareas, which will automatically translate the text for you before it is being send.";}
constructor () {
this.changelog = {
"added":[["Papago","New translation engine, mostly used for asian languages, rather limited"]]
};
this.patchedModules = {
before: {
ChannelTextAreaForm: "render",
@ -204,10 +200,11 @@ var GoogleTranslateOption = (_ => {
let translating, foundTranslation, foundInput, foundOutput;
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: ["devmode-copy-id", "search-google"], group: true});
children.splice(index > -1 ? index + 1 : 0, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuPersistingItem, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
id: BDFDB.ContextMenuUtils.createItemId(this.name, "search-translation"),
disabled: isTranslating,
label: this.labels.context_googletranslateoption_text,
persisting: true,
action: event => {
let item = BDFDB.DOMUtils.getParent(BDFDB.dotCN.menuitem, event.target);
if (item) {
@ -216,6 +213,7 @@ var GoogleTranslateOption = (_ => {
};
if (foundTranslation && foundInput && foundOutput) {
if (document.querySelector(".googletranslate-tooltip")) {
BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.DiscordUtils.openLink(this.getGoogleTranslatePageURL(foundInput.id, foundOutput.id, text), settings.useChromium);
}
else createTooltip();
@ -1088,4 +1086,4 @@ var GoogleTranslateOption = (_ => {
}
})();
module.exports = GoogleTranslateOption;
module.exports = GoogleTranslateOption;