This commit is contained in:
Mirco Wittrien 2019-12-21 02:24:30 +01:00
parent 949d66d2c7
commit 5f9883cbb9
5 changed files with 43 additions and 46 deletions

View File

@ -6652,7 +6652,7 @@
getCounterString() {
let input = this.refElement || {}, string = "";
if (BDFDB.DOMUtils.containsClass(this.refElement, BDFDB.disCN.textarea)) {
let instance = BDFDB.ReactUtils.findOwner(input, {name:"ChannelTextArea", up:true});
let instance = BDFDB.ReactUtils.findOwner(input, {name:"ChannelTextAreaForm", up:true});
if (instance) string = instance.props.textValue;
else string = input.value || input.textContent || "";
}

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
class CharCounter {
getName () {return "CharCounter";}
getVersion () {return "1.4.3";}
getVersion () {return "1.4.4";}
getAuthor () {return "DevilBro";}
@ -17,7 +17,7 @@ class CharCounter {
this.patchedModules = {
after: {
ChannelTextArea: "render",
ChannelTextAreaContainer: "render",
Note: "render",
ChangeNickname: "render"
}
@ -127,10 +127,11 @@ class CharCounter {
// begin of own functions
processChannelTextArea (e) {
if (e.instance.props.type && this.maxLenghts[e.instance.props.type]) {
processChannelTextAreaContainer (e) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "ChannelEditorContainer"});
if (index > -1 && children[index].props.type && this.maxLenghts[children[index].props.type]) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectCounter(e.returnvalue, e.returnvalue.props.children, e.instance.props.type, BDFDB.dotCN.textarea, true);
this.injectCounter(e.returnvalue, e.returnvalue.props.children, children[index].props.type, BDFDB.dotCN.textarea, true);
}
}

View File

@ -3,7 +3,7 @@
class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";}
getVersion () {return "1.8.8";}
getVersion () {return "1.8.9";}
getAuthor () {return "DevilBro";}
@ -20,7 +20,7 @@ class GoogleTranslateOption {
ChannelTextArea: "render"
},
after: {
ChannelTextArea: "render",
ChannelTextAreaContainer: "render",
MessageContent: "render"
}
};
@ -144,7 +144,7 @@ class GoogleTranslateOption {
if (instances.Message) for (let ins of instances.Message) ins.props.message = new BDFDB.DiscordObjects.Message(ins.props.message);
BDFDB.ReactUtils.forceUpdate(instances.Message, instances.Embeds);
BDFDB.ModuleUtils.forceAllUpdates(this, "ChannelTextArea");
BDFDB.ModuleUtils.forceAllUpdates(this, ["ChannelTextArea", "ChannelTextAreaContainer"]);
BDFDB.PluginUtils.clear(this);
}
@ -157,7 +157,7 @@ class GoogleTranslateOption {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.setLanguages();
BDFDB.ModuleUtils.forceAllUpdates(this, "ChannelTextArea");
BDFDB.ModuleUtils.forceAllUpdates(this, ["ChannelTextArea", "ChannelTextAreaContainer"]);
}
}
@ -229,24 +229,25 @@ class GoogleTranslateOption {
}
}
processChannelTextAreaContainer (e) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.textareapickerbuttons]]});
if (index > -1 && children[index].props && children[index].props.children) children[index].props.children.unshift(this.createTranslateButton());
}
processChannelTextArea (e) {
if (e.instance.props.type != "normal" || e.instance.props.disabled) return;
if (this.translating && this.isTranslating) e.instance.props.disabled = true;
if (e.returnvalue) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.textareapickerbuttons]]});
if (index > -1 && children[index].props && children[index].props.children) children[index].props.children.unshift(this.createTranslateButton());
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSubmit")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSubmit", {instead: e2 => {
if (this.translating) {
BDFDB.ReactUtils.forceUpdate(e.instance);
e2.stopOriginalMethodCall();
this.translateText(e2.methodArguments[0], "message", (translation, input, output) => {
translation = !translation ? e2.methodArguments[0] : (BDFDB.DataUtils.get(this, "settings", "sendOriginalMessage") ? e2.methodArguments[0] + "\n\n" + translation : translation);
e2.originalMethod(translation);
});
}
else e2.callOriginalMethodAfterwards();
}}, true);
}
if (!BDFDB.ModuleUtils.isPatched(this, e.instance.props, "onSubmit")) BDFDB.ModuleUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => {
if (this.translating) {
BDFDB.ReactUtils.forceUpdate(e.instance);
e2.stopOriginalMethodCall();
this.translateText(e2.methodArguments[0], "message", (translation, input, output) => {
translation = !translation ? e2.methodArguments[0] : (BDFDB.DataUtils.get(this, "settings", "sendOriginalMessage") ? e2.methodArguments[0] + "\n\n" + translation : translation);
e2.originalMethod(translation);
});
}
else e2.callOriginalMethodAfterwards();
}}, true);
}
processMessageContent (e) {

View File

@ -3,7 +3,7 @@
class SendLargeMessages {
getName () {return "SendLargeMessages";}
getVersion () {return "1.5.7";}
getVersion () {return "1.5.8";}
getAuthor () {return "DevilBro";}
@ -18,9 +18,6 @@ class SendLargeMessages {
this.patchedModules = {
before: {
ChannelTextArea: "render"
},
after: {
ChannelTextArea: "render"
}
};
}
@ -85,22 +82,20 @@ class SendLargeMessages {
processChannelTextArea (e) {
if (e.instance.props && e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) {
e.instance.props.shouldUploadLongMessages = false;
if (e.returnvalue) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSubmit")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSubmit", {instead: e2 => {
let parsedLength = BDFDB.StringUtils.getParsedLength(e2.methodArguments[0]);
if (parsedLength > 2000) {
e2.stopOriginalMethodCall();
let messages = this.formatText(e2.methodArguments[0], Math.sqrt(Math.pow(parsedLength - e2.methodArguments[0].length, 2)) > Math.max(parsedLength, e2.methodArguments[0].length) / 20);
messages.filter(n => n).forEach((message, i) => {
BDFDB.TimeUtils.timeout(_ => {
e2.originalMethod(message);
if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
}, this.messageDelay * i);
});
}
else e2.callOriginalMethodAfterwards();
}}, true);
}
if (!BDFDB.ModuleUtils.isPatched(this, e.instance.props, "onSubmit")) BDFDB.ModuleUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => {
let parsedLength = BDFDB.StringUtils.getParsedLength(e2.methodArguments[0]);
if (parsedLength > 2000) {
e2.stopOriginalMethodCall();
let messages = this.formatText(e2.methodArguments[0], Math.sqrt(Math.pow(parsedLength - e2.methodArguments[0].length, 2)) > Math.max(parsedLength, e2.methodArguments[0].length) / 20);
messages.filter(n => n).forEach((message, i) => {
BDFDB.TimeUtils.timeout(_ => {
e2.originalMethod(message);
if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
}, this.messageDelay * i);
});
}
else e2.callOriginalMethodAfterwards();
}}, true);
}
}