This commit is contained in:
Mirco Wittrien 2019-12-21 11:25:13 +01:00
parent f782b233a1
commit 25b4686859
5 changed files with 58 additions and 40 deletions

View File

@ -1056,6 +1056,7 @@
SearchResults: "searchresultswrap", SearchResults: "searchresultswrap",
TypingUsers: "typing", TypingUsers: "typing",
UnreadDMs: "guildsscroller", UnreadDMs: "guildsscroller",
Upload: "uploadmodal",
UserPopout: "userpopout", UserPopout: "userpopout",
V2C_ContentColumn: "contentcolumn", V2C_ContentColumn: "contentcolumn",
V2C_List: "_repolist", V2C_List: "_repolist",
@ -4629,6 +4630,7 @@
DiscordClassModules.TooltipGuild = BDFDB.ModuleUtils.findByProperties("rowIcon", "rowGuildName"); DiscordClassModules.TooltipGuild = BDFDB.ModuleUtils.findByProperties("rowIcon", "rowGuildName");
DiscordClassModules.Typing = BDFDB.ModuleUtils.findByProperties("cooldownWrapper", "typing"); DiscordClassModules.Typing = BDFDB.ModuleUtils.findByProperties("cooldownWrapper", "typing");
DiscordClassModules.UnreadBar = BDFDB.ModuleUtils.findByProperties("active", "bar", "unread"); DiscordClassModules.UnreadBar = BDFDB.ModuleUtils.findByProperties("active", "bar", "unread");
DiscordClassModules.UploadModal = BDFDB.ModuleUtils.findByProperties("uploadModal", "bgScale");
DiscordClassModules.UserPopout = BDFDB.ModuleUtils.findByProperties("userPopout", "headerPlaying"); DiscordClassModules.UserPopout = BDFDB.ModuleUtils.findByProperties("userPopout", "headerPlaying");
DiscordClassModules.UserProfile = BDFDB.ModuleUtils.findByProperties("topSectionNormal", "tabBarContainer"); DiscordClassModules.UserProfile = BDFDB.ModuleUtils.findByProperties("topSectionNormal", "tabBarContainer");
DiscordClassModules.Video = BDFDB.ModuleUtils.findByProperties("video", "fullScreen"); DiscordClassModules.Video = BDFDB.ModuleUtils.findByProperties("video", "fullScreen");
@ -5935,6 +5937,7 @@
unreadbarmention: ["UnreadBar", "mention"], unreadbarmention: ["UnreadBar", "mention"],
unreadbartext: ["UnreadBar", "text"], unreadbartext: ["UnreadBar", "text"],
unreadbarunread: ["UnreadBar", "unread"], unreadbarunread: ["UnreadBar", "unread"],
uploadmodal: ["UploadModal", "uploadModal"],
userpopout: ["UserPopout", "userPopout"], userpopout: ["UserPopout", "userPopout"],
userpopoutavatarhint: ["UserPopout", "avatarHint"], userpopoutavatarhint: ["UserPopout", "avatarHint"],
userpopoutavatarhintinner: ["UserPopout", "avatarHintInner"], userpopoutavatarhintinner: ["UserPopout", "avatarHintInner"],

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
class GoogleTranslateOption { class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";} getName () {return "GoogleTranslateOption";}
getVersion () {return "1.8.9";} getVersion () {return "1.9.0";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -17,7 +17,8 @@ class GoogleTranslateOption {
this.patchedModules = { this.patchedModules = {
before: { before: {
ChannelTextArea: "render" ChannelTextAreaForm: "render",
ChannelEditorContainer: "render"
}, },
after: { after: {
ChannelTextAreaContainer: "render", ChannelTextAreaContainer: "render",
@ -144,7 +145,7 @@ class GoogleTranslateOption {
if (instances.Message) for (let ins of instances.Message) ins.props.message = new BDFDB.DiscordObjects.Message(ins.props.message); 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.ReactUtils.forceUpdate(instances.Message, instances.Embeds);
BDFDB.ModuleUtils.forceAllUpdates(this, ["ChannelTextArea", "ChannelTextAreaContainer"]); BDFDB.ModuleUtils.forceAllUpdates(this, ["ChannelTextAreaForm", "ChannelTextAreaContainer"]);
BDFDB.PluginUtils.clear(this); BDFDB.PluginUtils.clear(this);
} }
@ -157,7 +158,7 @@ class GoogleTranslateOption {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
this.setLanguages(); this.setLanguages();
BDFDB.ModuleUtils.forceAllUpdates(this, ["ChannelTextArea", "ChannelTextAreaContainer"]); BDFDB.ModuleUtils.forceAllUpdates(this, ["ChannelTextAreaForm", "ChannelTextAreaContainer"]);
} }
} }
@ -228,28 +229,36 @@ 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) { processChannelTextAreaForm (e) {
if (e.instance.props.type != "normal" || e.instance.props.disabled) return; if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSendMessage", {instead: e2 => {
if (this.translating && this.isTranslating) e.instance.props.disabled = true;
if (!BDFDB.ModuleUtils.isPatched(this, e.instance.props, "onSubmit")) BDFDB.ModuleUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => {
if (this.translating) { if (this.translating) {
BDFDB.ReactUtils.forceUpdate(e.instance);
e2.stopOriginalMethodCall(); e2.stopOriginalMethodCall();
this.translateText(e2.methodArguments[0], "message", (translation, input, output) => { 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); translation = !translation ? e2.methodArguments[0] : (BDFDB.DataUtils.get(this, "settings", "sendOriginalMessage") ? e2.methodArguments[0] + "\n\n" + translation : translation);
e2.originalMethod(translation); e2.originalMethod(translation);
}); });
return Promise.resolve({
shouldClear: true,
shouldRefocus: true
});
} }
else e2.callOriginalMethodAfterwards(); else return e2.callOriginalMethodAfterwards();
}}, true); }}, true);
} }
processChannelEditorContainer (e) {
if (this.translating && this.isTranslating) e.instance.props.disabled = true;
}
processChannelTextAreaContainer (e) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "ChannelEditorContainer"});
if (index > -1 && children[index].props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) {
let [children2, index2] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.textareapickerbuttons]]});
if (index2 > -1 && children2[index2].props && children2[index2].props.children) children2[index2].props.children.unshift(this.createTranslateButton());
}
}
processMessageContent (e) { processMessageContent (e) {
if (typeof e.returnvalue.props.children == "function") { if (typeof e.returnvalue.props.children == "function") {
let renderChildren = e.returnvalue.props.children; let renderChildren = e.returnvalue.props.children;

View File

@ -3,7 +3,7 @@
class SendLargeMessages { class SendLargeMessages {
getName () {return "SendLargeMessages";} getName () {return "SendLargeMessages";}
getVersion () {return "1.5.8";} getVersion () {return "1.5.9";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -17,7 +17,8 @@ class SendLargeMessages {
this.patchedModules = { this.patchedModules = {
before: { before: {
ChannelTextArea: "render" ChannelTextAreaForm: "render",
ChannelEditorContainer: "render"
} }
}; };
} }
@ -79,24 +80,29 @@ class SendLargeMessages {
// begin of own functions // begin of own functions
processChannelTextArea (e) { processChannelTextAreaForm (e) {
if (e.instance.props && e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) { if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSendMessage", {instead: e2 => {
e.instance.props.shouldUploadLongMessages = false; let parsedLength = BDFDB.StringUtils.getParsedLength(e2.methodArguments[0]);
if (!BDFDB.ModuleUtils.isPatched(this, e.instance.props, "onSubmit")) BDFDB.ModuleUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => { if (parsedLength > 2000) {
let parsedLength = BDFDB.StringUtils.getParsedLength(e2.methodArguments[0]); e2.stopOriginalMethodCall();
if (parsedLength > 2000) { 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);
e2.stopOriginalMethodCall(); messages.filter(n => n).forEach((message, i) => {
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); BDFDB.TimeUtils.timeout(_ => {
messages.filter(n => n).forEach((message, i) => { e2.originalMethod(message);
BDFDB.TimeUtils.timeout(_ => { if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
e2.originalMethod(message); }, this.messageDelay * i);
if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"}); });
}, this.messageDelay * i); return Promise.resolve({
}); shouldClear: true,
} shouldRefocus: true
else e2.callOriginalMethodAfterwards(); });
}}, true); }
} else return e2.callOriginalMethodAfterwards();
}}, true);
}
processChannelEditorContainer (e) {
if (e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) e.instance.props.shouldUploadLongMessages = false;
} }
formatText (text, parse) { formatText (text, parse) {

View File

@ -3,7 +3,7 @@
class WriteUpperCase { class WriteUpperCase {
getName () {return "WriteUpperCase";} getName () {return "WriteUpperCase";}
getVersion () {return "1.2.3";} getVersion () {return "1.2.4";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -17,7 +17,7 @@ class WriteUpperCase {
this.patchedModules = { this.patchedModules = {
before: { before: {
ChannelTextArea: "render" ChannelEditorContainer: "render"
} }
}; };
} }
@ -66,8 +66,8 @@ class WriteUpperCase {
// begin of own functions // begin of own functions
processChannelTextArea (e) { processChannelEditorContainer (e) {
if (e.instance.props.type && e.instance.props.textValue && e.instance.state.focused) { if (e.instance.props.textValue && e.instance.state.focused) {
let string = e.instance.props.textValue; let string = e.instance.props.textValue;
if (string.length > 0) { if (string.length > 0) {
let newstring = string; let newstring = string;