This commit is contained in:
Mirco Wittrien 2019-02-03 18:03:02 +01:00
parent c8739a851e
commit baeed582fd
7 changed files with 27 additions and 23 deletions

View File

@ -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 += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${this.defaults.formats[key].description}</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" option="${key}" value="${formats[key]}" placeholder="${this.defaults.formats[key].value}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16}"></div></div>`;
}
let infoHidden = BDFDB.loadData("hideInfo", this, "hideInfo");
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.cursorpointer + (infoHidden ? BDFDB.disCN.categorywrappercollapsed : BDFDB.disCN.categorywrapperdefault)} toggle-info" style="flex: 1 1 auto;"><svg class="${BDFDB.disCNS.categoryicontransition + BDFDB.disCNS.directionright + (infoHidden ? BDFDB.disCN.categoryiconcollapsed : BDFDB.disCN.categoryicondefault)}" width="12" height="12" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10"></path></svg><div class="${BDFDB.disCNS.categorycolortransition + BDFDB.disCNS.overflowellipsis + BDFDB.disCN.categorynamecollapsed}" style="flex: 1 1 auto;">Information</div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.cursorpointer + (infoHidden ? BDFDB.disCN.categorywrappercollapsed : BDFDB.disCN.categorywrapperdefault)} toggle-info" style="flex: 1 1 auto;"><svg class="${BDFDB.disCNS.categoryicontransition + BDFDB.disCNS.directionright + (infoHidden ? BDFDB.disCN.categoryiconcollapsed : BDFDB.disCN.categoryicondefault)}" width="12" height="12" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10"></path></svg><div class="${BDFDB.disCNS.categorycolortransition + BDFDB.disCNS.categoryoverflowellipsis + BDFDB.disCN.categorynamecollapsed}" style="flex: 1 1 auto;">Information</div></div>`;
settingshtml += `<div class="DevilBro-settings-inner-list info-container" ${infoHidden ? "style='display:none;'" : ""}>`;
settingshtml += `<div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$hour will be replaced with the current hour</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$minute will be replaced with the current minutes</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$second will be replaced with the current seconds</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$msecond will be replaced with the current milliseconds</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$timemode will change $hour to a 12h format and will be replaced with AM/PM</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$year will be replaced with the current year</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$month will be replaced with the current month</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$day will be replaced with the current day</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$monthnameL will be replaced with the monthname in long format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$monthnameS will be replaced with the monthname in short format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$weekdayL will be replaced with the weekday in long format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$weekdayS will be replaced with the weekday in short format based on the Discord Language</div>`;
settingshtml += `</div></div>`;
@ -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) {

View File

@ -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(`<span class="edited">`,`<span class="${BDFDB.disCN.messageedited}">`);
message.querySelector(BDFDB.dotCN.messageaccessory).innerHTML = noteData.accessory;
if (noteData.accessory) {

View File

@ -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) {

View File

@ -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();

View File

@ -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) {

View File

@ -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(`<span class="edited">`,`<span class="${BDFDB.disCN.messageedited}">`);
message.querySelector(BDFDB.dotCN.messageaccessory).innerHTML = noteData.accessory;
if (noteData.accessory) {

View File

@ -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", () => {