This commit is contained in:
Mirco Wittrien 2019-11-03 19:21:41 +01:00
parent 7ca490bc32
commit 47544d9f05
3 changed files with 85 additions and 75 deletions

View File

@ -5597,6 +5597,8 @@ var BDFDB = {
NativeSubComponents.TooltipContainer = BDFDB.ModuleUtils.findByName("Tooltip");
LibraryComponents.Anchor = BDFDB.ModuleUtils.findByName("Anchor");
LibraryComponents.BotTag = reactInitialized ? class BDFDB_BotTag extends LibraryModules.React.Component {
render() {
return BDFDB.ReactUtils.createElement("span", {
@ -7754,8 +7756,8 @@ var BDFDB = {
BDFDB.patchModules = {
V2C_ContentColumn: "render",
V2C_PluginCard: ["componentDidMount","componentDidUpdate"],
V2C_ThemeCard: ["componentDidMount","componentDidUpdate"],
V2C_PluginCard: "render",
V2C_ThemeCard: "render",
UserPopout: "componentDidMount",
UserProfile: "componentDidMount",
Message: ["componentDidMount","componentDidUpdate"],
@ -7789,47 +7791,64 @@ var BDFDB = {
};
BDFDBprocessFunctions._processCard = function (e, data) {
var author, description = null;
if (BDFDB.DOMUtils.containsClass(e.node, BDFDB.disCN._reposettingsclosed) && (author = e.node.querySelector(BDFDB.dotCN._repoauthor)) != null && (description = e.node.querySelector(BDFDB.dotCN._repodescription)) != null && (!BDFDB.ObjectUtils.is(data) || typeof data.getRawUrl != "function")) {
if (!author.firstElementChild && !description.firstElementChild && (author.innerText == "DevilBro" || author.innerText.indexOf("DevilBro,") == 0)) {
description.style.setProperty("display", "block", "important");
author.innerHTML = `<a class="${BDFDB.disCNS.anchor + BDFDB.disCN.anchorunderlineonhover}">DevilBro</a>${author.innerText.split("DevilBro").slice(1).join("DevilBro")}`;
author.addEventListener("click", _ => {
if (BDFDB.UserUtils.me.id == "278543574059057154") return;
let DMid = LibraryModules.ChannelStore.getDMFromUserId("278543574059057154")
if (DMid) LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid);
else LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.UserUtils.me.id, "278543574059057154");
let close = document.querySelector(BDFDB.dotCNS.settingsclosebuttoncontainer + BDFDB.dotCN.settingsclosebutton);
if (close) close.click();
});
let version = e.node.querySelector(BDFDB.dotCN._repoversion);
if (version && data.changelog) {
BDFDB.DOMUtils.remove(version.querySelectorAll(".BDFDB-versionchangelog"));
let changelogicon = BDFDB.DOMUtils.create(`<span class="BDFDB-versionchangelog" style="white-space: pre !important;"> </span>`);
version.appendChild(changelogicon);
changelogicon.addEventListener("click", _ => {BDFDB.PluginUtils.openChangeLog(data);});
changelogicon.addEventListener("mouseenter", _ => {
BDFDB.TooltipUtils.create(changelogicon, BDFDB.LanguageUtils.LanguageStrings.CHANGE_LOG, {type:"top", selector:"changelogicon-tooltip"});
});
}
let links = e.node.querySelector(BDFDB.dotCN._repolinks);
if (links) {
if (links.firstElementChild) links.appendChild(document.createTextNode(" | "));
let supportlink = BDFDB.DOMUtils.create(`<a class="${BDFDB.disCNS._repolink + BDFDB.disCN._repolink}-support" target="_blank">Support Server</a>`);
supportlink.addEventListener("click", e => {
BDFDB.ListenerUtils.stopEvent(e);
let switchguild = _ => {
LibraryModules.GuildUtils.transitionToGuildSync("410787888507256842");
if (e.instance.state && !e.instance.state.settings) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN._repoauthor]]});
if (index > -1) {
let author = children[index].props.children;
if (author && (author == "DevilBro" || author.indexOf("DevilBro,") == 0)) {
children.splice(index, 1, BDFDB.ReactUtils.createElement(LibraryComponents.Anchor, {
className: BDFDB.disCN._repoauthor,
children: "DevilBro",
onClick: e => {
BDFDB.ListenerUtils.stopEvent(e);
if (BDFDB.UserUtils.me.id == "278543574059057154") return;
let DMid = LibraryModules.ChannelStore.getDMFromUserId("278543574059057154")
if (DMid) LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid);
else LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.UserUtils.me.id, "278543574059057154");
let close = document.querySelector(BDFDB.dotCNS.settingsclosebuttoncontainer + BDFDB.dotCN.settingsclosebutton);
if (close) close.click();
};
if (LibraryModules.GuildStore.getGuild("410787888507256842")) switchguild();
else LibraryModules.InviteUtils.acceptInvite("Jx3TjNS").then(_ => {switchguild();});
});
links.appendChild(supportlink);
if (BDFDB.UserUtils.me.id != "98003542823944192" && BDFDB.UserUtils.me.id != "116242787980017679" && BDFDB.UserUtils.me.id != "81388395867156480") {
links.appendChild(document.createTextNode(" | "));
links.appendChild(BDFDB.DOMUtils.create(`<a class="${BDFDB.disCNS._repolink + BDFDB.disCN._repolink}-donations" href="https://www.paypal.me/MircoWittrien" target="_blank">Donations</a>`));
}
}));
if (author != "DevilBro") children.splice(index + 1, author.split("DevilBro").slice(1).join("DevilBro"));
if (data.changelog) {
[children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN._repoversion]]});
if (index > -1) children[index].props.children = [children[index].props.children, BDFDB.ReactUtils.createElement(LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.CHANGE_LOG,
children: BDFDB.ReactUtils.createElement("span", {
className: "BDFDB-versionchangelog",
children: " ",
style: {whiteSpace: "pre"},
onClick: _ => {BDFDB.PluginUtils.openChangeLog(data);}
})
})];
}
[children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN._repolinks]]});
if (index > -1) {
if (!children[index].props.children.filter(n => n).length) children[index].props.children.push(" | ");
children[index].props.children.push(BDFDB.ReactUtils.createElement("a", {
className: `${BDFDB.disCNS._repolink + BDFDB.disCN._repolink}-support`,
target: "_blank",
children: "Support Server",
onClick: e => {
BDFDB.ListenerUtils.stopEvent(e);
let switchguild = _ => {
LibraryModules.GuildUtils.transitionToGuildSync("410787888507256842");
let close = document.querySelector(BDFDB.dotCNS.settingsclosebuttoncontainer + BDFDB.dotCN.settingsclosebutton);
if (close) close.click();
};
if (LibraryModules.GuildStore.getGuild("410787888507256842")) switchguild();
else LibraryModules.InviteUtils.acceptInvite("Jx3TjNS").then(_ => {switchguild();});
}
}));
children[index].props.children.push(" | ");
children[index].props.children.push(BDFDB.ReactUtils.createElement("a", {
className: `${BDFDB.disCNS._repolink + BDFDB.disCN._repolink}-donations`,
target: "_blank",
href: "https://www.paypal.me/MircoWittrien",
children: "Donations"
}));
}
}
}
@ -7865,18 +7884,18 @@ var BDFDB = {
let [children, index] = BDFDB.ReactUtils.findChildren(renderedChildren, {name:"MessageOptionButton"});
if (index > -1) {
let props = children[index].props;
if (!(props.message.author.isLocalBot() || props.message.author.id === props.currentUserId || props.canDelete || props.canPin || BDFDB.LibraryModules.CopyLinkUtils.SUPPORTS_COPY && props.developerMode)) children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.PopoutContainer, {
if (!(props.message.author.isLocalBot() || props.message.author.id === props.currentUserId || props.canDelete || props.canPin || BDFDB.LibraryModules.CopyLinkUtils.SUPPORTS_COPY && props.developerMode)) children.push(BDFDB.ReactUtils.createElement(LibraryComponents.PopoutContainer, {
native: true,
position: BDFDB.LibraryComponents.PopoutContainer.Positions.BOTTOM,
align: BDFDB.LibraryComponents.PopoutContainer.Align.CENTER,
position: LibraryComponents.PopoutContainer.Positions.BOTTOM,
align: LibraryComponents.PopoutContainer.Align.CENTER,
renderPopout: event => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessageOptionPopout, Object.assign({}, props, {onClose: event.closePopout}));
return BDFDB.ReactUtils.createElement(LibraryComponents.MessageOptionPopout, Object.assign({}, props, {onClose: event.closePopout}));
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
children: BDFDB.ReactUtils.createElement(LibraryComponents.Clickable, {
className: BDFDB.disCN.optionpopoutbutton,
"aria-label": BDFDB.LanguageUtils.LanguageStrings.MESSAGE_OPTIONS,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
name: BDFDB.LibraryComponents.SvgIcon.Names.OVERFLOW_MENU,
children: BDFDB.ReactUtils.createElement(LibraryComponents.SvgIcon, {
name: LibraryComponents.SvgIcon.Names.OVERFLOW_MENU,
className: BDFDB.disCN.optionpopoutbuttonicon
})
})

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
class CopyRawMessage {
getName () {return "CopyRawMessage";}
getVersion () {return "1.0.2";}
getVersion () {return "1.0.3";}
getAuthor () {return "DevilBro";}
@ -11,11 +11,11 @@ class CopyRawMessage {
constructor () {
this.changelog = {
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]]
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
};
this.patchModules = {
"Message":"componentDidMount"
MessageContent: "render"
};
}
@ -47,6 +47,8 @@ class CopyRawMessage {
if (global.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!");
}
@ -62,9 +64,9 @@ class CopyRawMessage {
// begin of own functions
onMessageContextMenu (instance, menu, returnvalue) {
if (instance.props && instance.props.message && instance.props.message.content && instance.props.target && !menu.querySelector(`${this.name}-contextMenuItem`)) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
onMessageContextMenu (e) {
if (e.instance.props && e.instance.props.message && e.instance.props.message.content) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [
@ -72,9 +74,9 @@ class CopyRawMessage {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
hint: BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-copyraw-contextMenuItem`,
action: e => {
BDFDB.ContextMenuUtils.close(menu);
BDFDB.LibraryRequires.electron.clipboard.write({text:instance.props.message.content});
action: _ => {
BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.content});
}
})
]
@ -84,29 +86,18 @@ class CopyRawMessage {
}
}
onMessageOptionPopout (instance, popout, returnvalue) {
if (instance.props.message && instance.props.channel && instance._reactInternalFiber.memoizedProps.target && !popout.querySelector(".copyrawmessage-itembtn")) {
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {props:[["label", BDFDB.LanguageUtils.LanguageStrings.DELETE]]});
onMessageOptionPopout (e) {
if (e.instance.props && e.instance.props.message) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["label", BDFDB.LanguageUtils.LanguageStrings.DELETE]]});
const copyItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-copyraw-popoutMenuItem`,
action: e => {
BDFDB.LibraryRequires.electron.clipboard.write({text:instance.props.message.content});
instance.props.onClose();
action: _ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.content});
e.instance.props.onClose();
}
});
children.splice(index, 0, copyItem);
}
}
processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) {
let optionPopoutButton = BDFDB.DOMUtils.create(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);
optionPopoutButton.addEventListener("click", () => {BDFDB.createMessageOptionPopout(optionPopoutButton);});
buttonwrap.appendChild(optionPopoutButton);
}
}
}
}