This commit is contained in:
Mirco Wittrien 2020-03-28 07:41:31 +01:00
parent 60ae0456f1
commit 945355220d
5 changed files with 249 additions and 258 deletions

View File

@ -1135,6 +1135,9 @@
QuickSwitchUserResult: "LibraryComponents.QuickSwitchItems.User",
};
WebModulesData.SpecialFilter = {
V2C_ContentColumn: ins => ins && ins.return && ins.return.stateNode && ins.return.stateNode.props && typeof ins.return.stateNode.props.title == "string" && (ins.return.stateNode.props.title.toUpperCase().indexOf("PLUGINS") == 0 || ins.return.stateNode.props.title.toUpperCase().indexOf("THEMES") == 0) && ins.return.type,
V2C_PluginCard: ins => ins && ins.return && ins.return.stateNode && ins.return.stateNode.props && ins.return.stateNode.props.addon && ins.return.stateNode.props.addon.plugin && ins.return.type,
V2C_ThemeCard: ins => ins && ins.return && ins.return.stateNode && ins.return.stateNode.props && ins.return.stateNode.props.addon && ins.return.stateNode.props.addon.theme && ins.return.type
};
WebModulesData.PatchFinder = {
Account: "accountinfo",
@ -1183,9 +1186,8 @@
UserPopout: "userpopout",
UserProfile: "userprofile",
V2C_ContentColumn: "contentcolumn",
V2C_List: "_repolist",
V2C_PluginCard: "_repolist",
V2C_ThemeCard: "_repolist"
V2C_PluginCard: "_repocard",
V2C_ThemeCard: "_repocard"
};
WebModulesData.CodeFinder = {
};

File diff suppressed because one or more lines are too long

View File

@ -4,18 +4,13 @@ var ChatAliases = (_ => {
return class ChatAliases {
getName () {return "ChatAliases";}
getVersion () {return "2.0.9";}
getVersion () {return "2.1.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows the user to configure their own chat-aliases which will automatically be replaced before the message is being sent.";}
constructor () {
this.changelog = {
"fixed":[["Aliases Autocomplete","Fixed menu not showing up"]],
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
};
this.patchedModules = {
before: {
ChannelAutoComplete: "render",
@ -364,19 +359,19 @@ var ChatAliases = (_ => {
processChannelTextAreaForm (e) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSendMessage", {before: e2 => {
this.handleSubmit(e, e2, 0);
}}, {force: true});
}}, {force: true, noCache: true});
}
processMessageEditor (e) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "onSubmit")) BDFDB.ModuleUtils.patch(this, e.instance, "onSubmit", {before: e2 => {
this.handleSubmit(e, e2, 0);
}}, {force: true});
}}, {force: true, noCache: true});
}
processUpload (e) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "submitUpload")) BDFDB.ModuleUtils.patch(this, e.instance, "submitUpload", {before: e2 => {
this.handleSubmit(e, e2, 1);
}}, {force: true});
}}, {force: true, noCache: true});
}
handleSubmit (e, e2, textIndex) {

View File

@ -27,17 +27,13 @@ var GoogleTranslateOption = (_ => {
return class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";}
getVersion () {return "1.9.8";}
getVersion () {return "1.9.9";}
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 = {
"fixed":[["Emojis","Emojis are now properly inserted when a message is translated, really now"]]
};
this.patchedModules = {
before: {
ChannelTextAreaForm: "render",
@ -286,7 +282,7 @@ var GoogleTranslateOption = (_ => {
});
}
else return e2.callOriginalMethodAfterwards();
}}, {force: true});
}}, {force: true, noCache: true});
}
processChannelEditorContainer (e) {

View File

@ -1,261 +1,259 @@
//META{"name":"SendLargeMessages","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SendLargeMessages","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SendLargeMessages/SendLargeMessages.plugin.js"}*//
class SendLargeMessages {
getName () {return "SendLargeMessages";}
var SendLargeMessages = (_ => {
return class SendLargeMessages {
getName () {return "SendLargeMessages";}
getVersion () {return "1.6.3";}
getVersion () {return "1.6.4";}
getAuthor () {return "DevilBro";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to enter larger messages in the chattextarea, which allows you to automatically send the message in several smaller messages.";}
getDescription () {return "Opens a popout when your message is too large, which allows you to automatically send the message in several smaller messages.";}
constructor () {
this.changelog = {
"fixed":[["New WYSIWYG Textarea","Fixed for the new WYSIWYG Textarea that is hidden by experiments"]]
};
constructor () {
this.patchedModules = {
before: {
ChannelTextAreaForm: "render",
ChannelEditorContainer: "render"
},
after: {
ChannelTextAreaContainer: "render",
}
};
}
this.patchedModules = {
before: {
ChannelTextAreaForm: "render",
ChannelEditorContainer: "render"
},
after: {
ChannelTextAreaContainer: "render",
initConstructor () {
this.messageDelay = 1000; //changing at own risk, might result in bans or mutes
this.css = `
.${this.name}-modal textarea {
height: 50vh;
}`;
}
//legacy
load () {}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
};
}
initConstructor () {
this.messageDelay = 1000; //changing at own risk, might result in bans or mutes
this.css = `
.${this.name}-modal textarea {
height: 50vh;
}`;
}
//legacy
load () {}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.ModuleUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.ModuleUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// begin of own functions
processChannelTextAreaForm (e) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSendMessage", {instead: e2 => {
if (e2.methodArguments[0].length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) {
e2.stopOriginalMethodCall();
let messages = this.formatText(e2.methodArguments[0]);
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);
});
return Promise.resolve({
shouldClear: true,
shouldRefocus: true
});
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.ModuleUtils.forceAllUpdates(this);
}
else return e2.callOriginalMethodAfterwards();
}}, {force: true});
}
processChannelTextAreaContainer (e) {
if (e.returnvalue.ref && e.returnvalue.ref.current && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, e.returnvalue.ref.current)) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "SlateCharacterCount"});
if (index > -1) {
let text = BDFDB.LibraryModules.SlateSelectionUtils.serialize(children[index].props.document, "raw");
if (text.length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) children[index] = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.textareacharcounter + BDFDB.disCN.textareacharcountererror,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: Math.ceil(text.length / BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) + " " + BDFDB.LanguageUtils.LanguageStrings.MESSAGES,
children: BDFDB.ReactUtils.createElement("span", {
children: BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH - text.length
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.ModuleUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// begin of own functions
processChannelTextAreaForm (e) {
if (!BDFDB.ModuleUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.ModuleUtils.patch(this, e.instance, "handleSendMessage", {instead: e2 => {
if (e2.methodArguments[0].length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) {
e2.stopOriginalMethodCall();
let messages = this.formatText(e2.methodArguments[0]);
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);
});
return Promise.resolve({
shouldClear: true,
shouldRefocus: true
});
}
else return e2.callOriginalMethodAfterwards();
}}, {force: true, noCache: true});
}
processChannelTextAreaContainer (e) {
if (e.returnvalue.ref && e.returnvalue.ref.current && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, e.returnvalue.ref.current)) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "SlateCharacterCount"});
if (index > -1) {
let text = BDFDB.LibraryModules.SlateSelectionUtils.serialize(children[index].props.document, "raw");
if (text.length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) children[index] = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.textareacharcounter + BDFDB.disCN.textareacharcountererror,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: Math.ceil(text.length / BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) + " " + BDFDB.LanguageUtils.LanguageStrings.MESSAGES,
children: BDFDB.ReactUtils.createElement("span", {
children: BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH - text.length
})
})
})
});
}
}
}
processChannelEditorContainer (e) {
if (e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) e.instance.props.shouldUploadLongMessages = false;
}
formatText (text) {
text = text.replace(/\t/g, " ");
let longwords = text.match(/[\S]{1800,}/gm);
if (longwords) for (let longword of longwords) {
let count1 = 0;
let shortwords = [];
longword.split("").forEach(c => {
if (shortwords[count1] && shortwords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20)) count1++;
shortwords[count1] = shortwords[count1] ? shortwords[count1] + c : c;
});
text = text.replace(longword, shortwords.join(" "));
}
}
}
processChannelEditorContainer (e) {
if (e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) e.instance.props.shouldUploadLongMessages = false;
}
formatText (text) {
text = text.replace(/\t/g, " ");
let longwords = text.match(/[\S]{1800,}/gm);
if (longwords) for (let longword of longwords) {
let count1 = 0;
let shortwords = [];
longword.split("").forEach(c => {
if (shortwords[count1] && shortwords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20)) count1++;
shortwords[count1] = shortwords[count1] ? shortwords[count1] + c : c;
let messages = [];
let count2 = 0;
text.split(" ").forEach((word) => {
if (messages[count2] && (messages[count2] + "" + word).length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) count2++;
messages[count2] = messages[count2] ? messages[count2] + " " + word : word;
});
text = text.replace(longword, shortwords.join(" "));
}
let messages = [];
let count2 = 0;
text.split(" ").forEach((word) => {
if (messages[count2] && (messages[count2] + "" + word).length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) count2++;
messages[count2] = messages[count2] ? messages[count2] + " " + word : word;
});
let insertCodeBlock = null, insertCodeLine = null;
for (let j = 0; j < messages.length; j++) {
if (insertCodeBlock) {
messages[j] = insertCodeBlock + messages[j];
insertCodeBlock = null;
}
else if (insertCodeLine) {
messages[j] = insertCodeLine + messages[j];
insertCodeLine = null;
let insertCodeBlock = null, insertCodeLine = null;
for (let j = 0; j < messages.length; j++) {
if (insertCodeBlock) {
messages[j] = insertCodeBlock + messages[j];
insertCodeBlock = null;
}
else if (insertCodeLine) {
messages[j] = insertCodeLine + messages[j];
insertCodeLine = null;
}
let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
if (codeBlocks && codeBlocks.length % 2 == 1) {
messages[j] = messages[j] + "```";
insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n";
}
else if (codeLines && codeLines.length % 2 == 1) {
insertCodeLine = codeLines[codeLines.length-1].replace(/[^`]/g, "");
messages[j] = messages[j] + insertCodeLine;
}
}
let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
if (codeBlocks && codeBlocks.length % 2 == 1) {
messages[j] = messages[j] + "```";
insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n";
}
else if (codeLines && codeLines.length % 2 == 1) {
insertCodeLine = codeLines[codeLines.length-1].replace(/[^`]/g, "");
messages[j] = messages[j] + insertCodeLine;
}
return messages;
}
return messages;
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
toast_allsent_text: "Sve veliku poslane."
};
case "da": //danish
return {
toast_allsent_text: "Alle beskeder sendes."
};
case "de": //german
return {
toast_allsent_text: "Alle Nachrichten versendet."
};
case "es": //spanish
return {
toast_allsent_text: "Todos los mensajes enviados."
};
case "fr": //french
return {
toast_allsent_text: "Tous les messages envoyés"
};
case "it": //italian
return {
toast_allsent_text: "Tutti i messaggi inviati."
};
case "nl": //dutch
return {
toast_allsent_text: "Alle berichten verzonden."
};
case "no": //norwegian
return {
toast_allsent_text: "Alle meldinger sendt."
};
case "pl": //polish
return {
toast_allsent_text: "Wszystkie wiadomości zostały wysłane."
};
case "pt-BR": //portuguese (brazil)
return {
toast_allsent_text: "Todas as mensagens enviadas."
};
case "fi": //finnish
return {
toast_allsent_text: "Kaikki lähetetyt viestit."
};
case "sv": //swedish
return {
toast_allsent_text: "Alla meddelanden skickade."
};
case "tr": //turkish
return {
toast_allsent_text: "Tüm mesajlar gönderildi."
};
case "cs": //czech
return {
toast_allsent_text: "Všechny zprávy byly odeslány."
};
case "bg": //bulgarian
return {
toast_allsent_text: "Всички изпратени съобщения."
};
case "ru": //russian
return {
toast_allsent_text: "Все отправленные сообщения."
};
case "uk": //ukrainian
return {
toast_allsent_text: "Всі повідомлення надіслано."
};
case "ja": //japanese
return {
toast_allsent_text: "すべてのメッセージが送信されました。"
};
case "zh-TW": //chinese (traditional)
return {
toast_allsent_text: "發送的所有消息。"
};
case "ko": //korean
return {
toast_allsent_text: "모든 메시지가 전송되었습니다."
};
default: //default: english
return {
toast_allsent_text: "All messages sent."
};
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
toast_allsent_text: "Sve veliku poslane."
};
case "da": //danish
return {
toast_allsent_text: "Alle beskeder sendes."
};
case "de": //german
return {
toast_allsent_text: "Alle Nachrichten versendet."
};
case "es": //spanish
return {
toast_allsent_text: "Todos los mensajes enviados."
};
case "fr": //french
return {
toast_allsent_text: "Tous les messages envoyés"
};
case "it": //italian
return {
toast_allsent_text: "Tutti i messaggi inviati."
};
case "nl": //dutch
return {
toast_allsent_text: "Alle berichten verzonden."
};
case "no": //norwegian
return {
toast_allsent_text: "Alle meldinger sendt."
};
case "pl": //polish
return {
toast_allsent_text: "Wszystkie wiadomości zostały wysłane."
};
case "pt-BR": //portuguese (brazil)
return {
toast_allsent_text: "Todas as mensagens enviadas."
};
case "fi": //finnish
return {
toast_allsent_text: "Kaikki lähetetyt viestit."
};
case "sv": //swedish
return {
toast_allsent_text: "Alla meddelanden skickade."
};
case "tr": //turkish
return {
toast_allsent_text: "Tüm mesajlar gönderildi."
};
case "cs": //czech
return {
toast_allsent_text: "Všechny zprávy byly odeslány."
};
case "bg": //bulgarian
return {
toast_allsent_text: "Всички изпратени съобщения."
};
case "ru": //russian
return {
toast_allsent_text: "Все отправленные сообщения."
};
case "uk": //ukrainian
return {
toast_allsent_text: "Всі повідомлення надіслано."
};
case "ja": //japanese
return {
toast_allsent_text: "すべてのメッセージが送信されました。"
};
case "zh-TW": //chinese (traditional)
return {
toast_allsent_text: "發送的所有消息。"
};
case "ko": //korean
return {
toast_allsent_text: "모든 메시지가 전송되었습니다."
};
default: //default: english
return {
toast_allsent_text: "All messages sent."
};
}
}
}
}
})();