From baeed582fd180c7cbfc8d1d89ae98dbb9a1c458f Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Sun, 3 Feb 2019 18:03:02 +0100 Subject: [PATCH] stuff --- .../CompleteTimestamps.plugin.js | 18 +++++++++--------- Plugins/PersonalPins/PersonalPins.plugin.js | 4 +++- PluginsV2/CompleteTimestamps/index.js | 4 ++-- PluginsV2/EditUsers/index.js | 2 +- PluginsV2/GoogleTranslateOption/index.js | 2 +- PluginsV2/PersonalPins/index.js | 16 +++++++++------- PluginsV2/PinDMs/index.js | 4 ++-- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Plugins/CompleteTimestamps/CompleteTimestamps.plugin.js b/Plugins/CompleteTimestamps/CompleteTimestamps.plugin.js index 5ec9bf13c1..a079aef2e4 100644 --- a/Plugins/CompleteTimestamps/CompleteTimestamps.plugin.js +++ b/Plugins/CompleteTimestamps/CompleteTimestamps.plugin.js @@ -3,13 +3,17 @@ class CompleteTimestamps { getName () {return "CompleteTimestamps";} - getVersion () {return "1.2.9";} + getVersion () {return "1.3.0";} getAuthor () {return "DevilBro";} getDescription () {return "Replace all timestamps with complete timestamps.";} initConstructor () { + this.changelog = { + "fixed":[["Chat Timestamps","The plugin now properly checking the option whether chat timestamps should be changed or not"]] + }; + this.patchModules = { "MessageGroup":["componentDidMount","componentDidUpdate"], "StandardSidebarView":"componentWillUnmount" @@ -53,7 +57,7 @@ class CompleteTimestamps { settingshtml += `

${this.defaults.formats[key].description}

`; } let infoHidden = BDFDB.loadData("hideInfo", this, "hideInfo"); - settingshtml += `
Information
`; + settingshtml += `
Information
`; settingshtml += `
`; settingshtml += `
$hour will be replaced with the current hour
$minute will be replaced with the current minutes
$second will be replaced with the current seconds
$msecond will be replaced with the current milliseconds
$timemode will change $hour to a 12h format and will be replaced with AM/PM
$year will be replaced with the current year
$month will be replaced with the current month
$day will be replaced with the current day
$monthnameL will be replaced with the monthname in long format based on the Discord Language
$monthnameS will be replaced with the monthname in short format based on the Discord Language
$weekdayL will be replaced with the weekday in long format based on the Discord Language
$weekdayS will be replaced with the weekday in short format based on the Discord Language
`; settingshtml += `
`; @@ -112,15 +116,11 @@ class CompleteTimestamps { let time = marker.getAttribute("datetime"); if (!time) return; let choice = BDFDB.getData("creationDateLang", this, "choices"); - let customTooltipCSS = ` - body ${BDFDB.dotCN.tooltip}:not(.completetimestampedit-tooltip) { - display: none !important; - }`; - BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, time), marker, {type:"top",selector:"completetimestampedit-tooltip",css:customTooltipCSS}); + BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, time), marker, {type:"top",selector:"completetimestampedit-tooltip",css:`body ${BDFDB.dotCN.tooltip}:not(.completetimestampedit-tooltip) {display: none !important;}`}); } }); - BDFDB.WebModules.forceAllUpdates(); + BDFDB.WebModules.forceAllUpdates(this); } else { console.error(`%c[${this.name}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!'); @@ -215,7 +215,7 @@ class CompleteTimestamps { } processMessageGroup (instance, wrapper) { - for (let stamp of wrapper.querySelectorAll("time[datetime]")) this.changeTimestamp(stamp); + if (BDFDB.getData("showInChat", this, "settings")) for (let stamp of wrapper.querySelectorAll("time[datetime]")) this.changeTimestamp(stamp); } processStandardSidebarView (instance, wrapper) { diff --git a/Plugins/PersonalPins/PersonalPins.plugin.js b/Plugins/PersonalPins/PersonalPins.plugin.js index 004d08f825..866aeef0bb 100644 --- a/Plugins/PersonalPins/PersonalPins.plugin.js +++ b/Plugins/PersonalPins/PersonalPins.plugin.js @@ -416,7 +416,9 @@ class PersonalPins { let timestamp = message.querySelector(BDFDB.dotCN.messagetimestampcozy); timestamp.innerText = date.toLocaleString(BDFDB.getDiscordLanguage().id); timestamp.setAttribute("datetime", date); - if (BDFDB.isPluginEnabled("CompleteTimestamps")) bdplugins.CompleteTimestamps.plugin.changeTimestamp(timestamp); + if (BDFDB.isPluginEnabled("CompleteTimestamps") && BDFDB.loadData("showInChat", "CompleteTimestamps", "settings")) { + bdplugins.CompleteTimestamps.plugin.changeTimestamp(timestamp); + } message.querySelector(BDFDB.dotCN.messagemarkup).innerHTML = noteData.markup.replace(``,``); message.querySelector(BDFDB.dotCN.messageaccessory).innerHTML = noteData.accessory; if (noteData.accessory) { diff --git a/PluginsV2/CompleteTimestamps/index.js b/PluginsV2/CompleteTimestamps/index.js index 2b840705ca..7c8d3b626c 100644 --- a/PluginsV2/CompleteTimestamps/index.js +++ b/PluginsV2/CompleteTimestamps/index.js @@ -76,7 +76,7 @@ module.exports = (Plugin, Api, Vendor) => { } }); - BDFDB.WebModules.forceAllUpdates(); + BDFDB.WebModules.forceAllUpdates(this); return true; } @@ -178,7 +178,7 @@ module.exports = (Plugin, Api, Vendor) => { } processMessageGroup (instance, wrapper) { - for (let stamp of wrapper.querySelectorAll("time[datetime]")) this.changeTimestamp(stamp); + if (BDFDB.getData("showInChat", this, "settings")) for (let stamp of wrapper.querySelectorAll("time[datetime]")) this.changeTimestamp(stamp); } changeTimestamp (stamp) { diff --git a/PluginsV2/EditUsers/index.js b/PluginsV2/EditUsers/index.js index 7388dcf58c..5f18d98a7d 100644 --- a/PluginsV2/EditUsers/index.js +++ b/PluginsV2/EditUsers/index.js @@ -800,7 +800,7 @@ module.exports = (Plugin, Api, Vendor) => { let data = this.getUserData(info.id, mention); let member = this.MemberUtils.getMember(this.LastGuildStore.getGuildId(), info.id) || {}; let color1 = BDFDB.colorCONVERT(data.color1 || (BDFDB.isPluginEnabled("BetterRoleColors") ? member.colorString : null), "RGBCOMP"); - let name = data.name ? data.name : (BDFDB.isPluginEnabled("RemoveNicknames") ? bdplugins.RemoveNicknames.plugin.getNewName(info) : member.nick || info.username); + let name = data.name ? data.name : (BDFDB.isPluginEnabled("RemoveNicknames") ? BDFDB.Plugins["removenicknames"].getNewName(info) : member.nick || info.username); BDFDB.setInnerText(mention, "@" + name); if (mention.EditUsersHovered) colorHover(); else colorDefault(); diff --git a/PluginsV2/GoogleTranslateOption/index.js b/PluginsV2/GoogleTranslateOption/index.js index add8d33f95..89961fe010 100644 --- a/PluginsV2/GoogleTranslateOption/index.js +++ b/PluginsV2/GoogleTranslateOption/index.js @@ -475,7 +475,7 @@ module.exports = (Plugin, Api, Vendor) => { this.translateMessage(instance.props.message, instance.props.target, instance.props.channel); }); if (BDFDB.isPluginEnabled("MessageUtilities")) { - BDFDB.setContextHint(translateitem, bdplugins.MessageUtilities.plugin.getActiveShortcutString("__Translate_Message")); + BDFDB.setContextHint(translateitem, BDFDB.Plugins["messageutilities"].getActiveShortcutString("__Translate_Message")); } let text = document.getSelection().toString(); if (text) { diff --git a/PluginsV2/PersonalPins/index.js b/PluginsV2/PersonalPins/index.js index e2fa4d6913..6520952690 100644 --- a/PluginsV2/PersonalPins/index.js +++ b/PluginsV2/PersonalPins/index.js @@ -237,7 +237,7 @@ module.exports = (Plugin, Api, Vendor) => { this.addMessageToNotes(instance.props.message, instance.props.target, instance.props.channel); }); if (BDFDB.isPluginEnabled("MessageUtilities")) { - BDFDB.setContextHint(pinitem, bdplugins.MessageUtilities.plugin.getActiveShortcutString("__Note_Message")); + BDFDB.setContextHint(pinitem, BDFDB.Plugins["messageutilities"].getActiveShortcutString("__Note_Message")); } } } @@ -372,12 +372,12 @@ module.exports = (Plugin, Api, Vendor) => { let channelname = messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname); channelname.innerText = (noteData.guild_id == "@me" ? " @" : " #") + (channel.name || noteData.channel_name); if (noteData.guild_id != "@me" && BDFDB.isPluginEnabled("EditChannels")) { - bdplugins.EditChannels.plugin.changeChannel2({id:noteData.channel_id,name:noteData.channel_name}, channelname); + BDFDB.Plugins["editchannels"].changeChannel2({id:noteData.channel_id,name:noteData.channel_name}, channelname); } else if (noteData.guild_id == "@me" && BDFDB.isPluginEnabled("EditUsers")) { let dmuser_id = channel && channel.type == 1 ? channel.recipients[0] : noteData.dmuser_id; if (dmuser_id) { - bdplugins.EditUsers.plugin.changeName2({id:dmuser_id,username:noteData.channel_name}, channelname); + BDFDB.Plugins["editusers"].changeName2({id:dmuser_id,username:noteData.channel_name}, channelname); if (channelname.innerText.indexOf("@") != 0) channelname.innerText = "@" + channelname.innerText; } } @@ -389,14 +389,16 @@ module.exports = (Plugin, Api, Vendor) => { username.innerText = user.username || noteData.author_name; username.style.setProperty("color", member.colorString || noteData.color); if (BDFDB.isPluginEnabled("EditUsers")) { - bdplugins.EditUsers.plugin.changeName({id:noteData.author_id,username:noteData.author_name}, username, noteData.guild_id); - if (user.id) bdplugins.EditUsers.plugin.changeAvatar({id:noteData.author_id,username:noteData.author_name}, avatar); - bdplugins.EditUsers.plugin.addTag({id:noteData.author_id,username:noteData.author_name}, username.parentElement, " " + BDFDB.disCN.bottagnametag); + BDFDB.Plugins["editusers"].changeName({id:noteData.author_id,username:noteData.author_name}, username, noteData.guild_id); + if (user.id) BDFDB.Plugins["editusers"].changeAvatar({id:noteData.author_id,username:noteData.author_name}, avatar); + BDFDB.Plugins["editusers"].addTag({id:noteData.author_id,username:noteData.author_name}, username.parentElement, " " + BDFDB.disCN.bottagnametag); } let timestamp = message.querySelector(BDFDB.dotCN.messagetimestampcozy); timestamp.innerText = date.toLocaleString(BDFDB.getDiscordLanguage().id); timestamp.setAttribute("datetime", date); - if (BDFDB.isPluginEnabled("CompleteTimestamps")) bdplugins.CompleteTimestamps.plugin.changeTimestamp(timestamp); + if (BDFDB.isPluginEnabled("CompleteTimestamps") && BDFDB.loadData("showInChat", "CompleteTimestamps", "settings")) { + BDFDB.Plugins["completetimestamps"].changeTimestamp(timestamp); + } message.querySelector(BDFDB.dotCN.messagemarkup).innerHTML = noteData.markup.replace(``,``); message.querySelector(BDFDB.dotCN.messageaccessory).innerHTML = noteData.accessory; if (noteData.accessory) { diff --git a/PluginsV2/PinDMs/index.js b/PluginsV2/PinDMs/index.js index 68c2f881cf..427c2e4c41 100644 --- a/PluginsV2/PinDMs/index.js +++ b/PluginsV2/PinDMs/index.js @@ -427,12 +427,12 @@ module.exports = (Plugin, Api, Vendor) => { dmname = dmname + this.UserUtils.getUser(dmuser_id).username; } } - let EditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? bdplugins.EditUsers.plugin.getUserData(user.id, dmdiv) : {}; + let EditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? BDFDB.Plugins["editusers"].getUserData(user.id, dmdiv) : {}; if (!EditUsersData.removeIcon) avatar.style.setProperty("background-image", `url(${EditUsersData.url || BDFDB.getChannelIcon(id)})`); avatar.setAttribute("channel", dmname); if (user) avatar.setAttribute("user", user.username); dmdiv.addEventListener("mouseenter", () => { - let FreshEditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? bdplugins.EditUsers.plugin.getUserData(user.id, dmdiv) : {}; + let FreshEditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? BDFDB.Plugins["editusers"].getUserData(user.id, dmdiv) : {}; BDFDB.createTooltip(FreshEditUsersData.name || dmname, dmdiv, {selector:(BDFDB.isObjectEmpty(FreshEditUsersData) ? "" : "EditUsers-tooltip"),type:"right"}); }); dmdiv.addEventListener("click", () => {