stuff
This commit is contained in:
parent
30e5f9c7fb
commit
fdb6219fdf
|
@ -1774,7 +1774,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.GuildUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.GuildUtils.getAll()) if (info && info.id == id) return info;
|
||||
return null;
|
||||
|
@ -1802,7 +1802,7 @@ var BDFDB = {
|
|||
var found = [];
|
||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
if (id && (LibraryModules.UnreadGuildUtils.hasUnread(id) || LibraryModules.MentionUtils.getMentionCount(id) > 0)) found.push(eleOrInfoOrId);
|
||||
}
|
||||
|
@ -1812,7 +1812,7 @@ var BDFDB = {
|
|||
var found = [];
|
||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
if (id && LibraryModules.MentionUtils.getMentionCount(id) > 0) found.push(eleOrInfoOrId);
|
||||
}
|
||||
|
@ -1822,7 +1822,7 @@ var BDFDB = {
|
|||
var found = [];
|
||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
if (id && LibraryModules.MutedUtils.isGuildOrCategoryOrChannelMuted(id)) found.push(eleOrInfoOrId);
|
||||
}
|
||||
|
@ -1925,7 +1925,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.GuildUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.mousePosition) {
|
||||
if (!eleOrInfoOrId) return;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.GuildUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
let guild = LibraryModules.GuildStore.getGuild(id);
|
||||
if (guild) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("GuildContextMenu"), Object.assign({}, e, {
|
||||
|
@ -1941,8 +1941,8 @@ var BDFDB = {
|
|||
if (!guilds) return;
|
||||
var unreadchannels = [];
|
||||
for (let guild of BDFDB.ArrayUtils.is(guilds) ? guilds : (typeof guilds == "string" || typeof guilds == "number" ? Array.of(guilds) : Array.from(guilds))) {
|
||||
let id = Node.prototype.isPrototypeOf(guild) ? BDFDB.GuildUtils.getId(guild) : guild && typeof guild == "object" ? guild.id : guild;
|
||||
let channels = id ? LibraryModules.GuildChannelStore.getChannels(id) : null;
|
||||
let id = Node.prototype.isPrototypeOf(guild) ? BDFDB.GuildUtils.getId(guild) : (guild && typeof guild == "object" ? guild.id : guild);
|
||||
let channels = id && LibraryModules.GuildChannelStore.getChannels(id);
|
||||
if (channels) for (let type in channels) if (BDFDB.ArrayUtils.is(channels[type])) for (let channelobj of channels[type]) unreadchannels.push(channelobj.channel.id);
|
||||
}
|
||||
if (unreadchannels.length) LibraryModules.AckUtils.bulkAck(unreadchannels);
|
||||
|
@ -1962,7 +1962,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.FolderUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.FolderUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.FolderUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.FolderUtils.getAll()) if (info && info.folderId == id) return info;
|
||||
return null;
|
||||
|
@ -1990,7 +1990,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.ChannelUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.ChannelUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.ChannelUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.ChannelUtils.getAll()) if (info && info.id == id) return info;
|
||||
return null;
|
||||
|
@ -2011,7 +2011,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.ChannelUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.mousePosition) {
|
||||
if (!eleOrInfoOrId) return;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.ChannelUtils.getId(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.ChannelUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
let channel = LibraryModules.ChannelStore.getChannel(id);
|
||||
if (channel) {
|
||||
let type = null;
|
||||
|
@ -2029,6 +2029,15 @@ var BDFDB = {
|
|||
});
|
||||
}
|
||||
};
|
||||
BDFDB.ChannelUtils.markAsRead = function (channels) {
|
||||
if (!channels) return;
|
||||
var unreadchannels = [];
|
||||
for (let channel of channels = BDFDB.ArrayUtils.is(channels) ? channels : (typeof channels == "string" || typeof channels == "number" ? Array.of(channels) : Array.from(channels))) {
|
||||
let id = Node.prototype.isPrototypeOf(channel) ? BDFDB.ChannelUtils.getId(channel) : (channel && typeof channel == "object" ? channel.id : channel);
|
||||
if (id) unreadchannels.push(id);
|
||||
}
|
||||
if (unreadchannels.length) LibraryModules.AckUtils.bulkAck(unreadchannels);
|
||||
};
|
||||
|
||||
BDFDB.DMUtils = {};
|
||||
BDFDB.DMUtils.getIcon = function (id) {
|
||||
|
@ -2062,7 +2071,7 @@ var BDFDB = {
|
|||
};
|
||||
BDFDB.DMUtils.getData = function (eleOrInfoOrId) {
|
||||
if (!eleOrInfoOrId) return null;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.getDmID(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
|
||||
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.BDFDB.DMUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
|
||||
id = typeof id == "number" ? id.toFixed() : id;
|
||||
for (let info of BDFDB.DMUtils.getAll()) if (info && info.id == id) return info;
|
||||
return null;
|
||||
|
@ -2074,14 +2083,14 @@ var BDFDB = {
|
|||
}
|
||||
return found;
|
||||
};
|
||||
BDFDB.DMUtils.markAsRead = BDFDB.ChannelUtils.markAsRead = function (channels) {
|
||||
if (!channels) return;
|
||||
BDFDB.DMUtils.markAsRead = function (dms) {
|
||||
if (!dms) return;
|
||||
var unreadchannels = [];
|
||||
for (let cha of channels = BDFDB.ArrayUtils.is(channels) ? channels : (typeof channels == "string" || typeof channels == "number" ? Array.of(channels) : Array.from(channels))) {
|
||||
let id = Node.prototype.isPrototypeOf(cha) ? (BDFDB.ChannelUtils.getId(cha) || BDFDB.getDmID(cha)) : cha && typeof cha == "object" ? cha.id : cha;
|
||||
for (let dm of dms = BDFDB.ArrayUtils.is(dms) ? dms : (typeof dms == "string" || typeof dms == "number" ? Array.of(dms) : Array.from(dms))) {
|
||||
let id = Node.prototype.isPrototypeOf(dm) ? BDFDB.BDFDB.DMUtils.getId(dm) : (dm && typeof dm == "object" ? dm.id : dm);
|
||||
if (id) unreadchannels.push(id);
|
||||
}
|
||||
if (unreadchannels.length) LibraryModules.AckUtils.bulkAck(unreadchannels);
|
||||
for (let i in unreadchannels) BDFDB.TimeUtils.timeout(_ => {LibraryModules.AckUtils.ack(unreadchannels[i]);}, i * 1000);
|
||||
};
|
||||
|
||||
BDFDB.DataUtils = {};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
|||
class ReadAllNotificationsButton {
|
||||
getName () {return "ReadAllNotificationsButton";}
|
||||
|
||||
getVersion () {return "1.5.1";}
|
||||
getVersion () {return "1.5.2";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,29 +11,16 @@ class ReadAllNotificationsButton {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"added":[["Pinged servers","Added the contextmenu item to only clear unread notifications on pinged servers"]]
|
||||
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||
};
|
||||
|
||||
this.patchModules = {
|
||||
"Guilds":["componentDidMount","componentDidUpdate"],
|
||||
"RecentMentions":"componentDidMount",
|
||||
"DirectMessage":"componentDidMount"
|
||||
Guilds: "render",
|
||||
RecentMentions: "render"
|
||||
};
|
||||
}
|
||||
|
||||
initConstructor () {
|
||||
this.RANbuttonMarkup =
|
||||
`<div class="${BDFDB.disCN.guildouter} RANbutton-frame" style="height: 20px;">
|
||||
<div class="${BDFDB.disCN.guildiconwrapper} RANbutton-inner" style="height: 20px;">
|
||||
<div class="${BDFDB.disCNS.guildiconchildwrapper + BDFDB.disCN.guildiconacronym} RANbutton" style="height: 20px;">read all</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.RAMbuttonMarkup =
|
||||
`<button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow} RAMbutton" style="flex: 0 0 auto; margin-left: 25px; height: 25px;">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">Clear Mentions</div>
|
||||
</button>`;
|
||||
|
||||
this.css = `
|
||||
.RANbutton-frame {
|
||||
margin-bottom: 10px;
|
||||
|
@ -126,8 +113,8 @@ class ReadAllNotificationsButton {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
BDFDB.DOMUtils.remove(".RANbutton-frame", ".RAMbutton");
|
||||
BDFDB.DOMUtils.removeClassFromDOM("RAN-added", "RAM-added");
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
}
|
||||
|
@ -135,86 +122,103 @@ class ReadAllNotificationsButton {
|
|||
|
||||
// begin of own functions
|
||||
|
||||
processGuilds (instance, wrapper, returnvalue, methodnames) {
|
||||
if (methodnames.includes("componentDidMount") || (methodnames.includes("componentDidUpdate") && document.querySelector(".bd-guild ~ .RANbutton-frame"))) {
|
||||
BDFDB.DOMUtils.remove(".RANbutton-frame");
|
||||
let insertnode = this.getInsertNode();
|
||||
if (insertnode) {
|
||||
let ranbutton = BDFDB.DOMUtils.create(this.RANbuttonMarkup);
|
||||
insertnode.parentElement.insertBefore(ranbutton, insertnode);
|
||||
ranbutton.addEventListener("click", () => {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
if (settings.includeGuilds) BDFDB.GuildUtils.markAsRead(settings.includeMuted ? BDFDB.GuildUtils.getAll() : BDFDB.GuildUtils.getUnread());
|
||||
if (settings.includeDMs) BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
||||
});
|
||||
ranbutton.addEventListener("contextmenu", e => {
|
||||
const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_unreadguilds_text,
|
||||
action: e => {
|
||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getUnread());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_pingedguilds_text,
|
||||
action: e => {
|
||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getPinged());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_mutedguilds_text,
|
||||
action: e => {
|
||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getMuted());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_guilds_text,
|
||||
action: e => {
|
||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
||||
this.addPinnedRecent(instance.props.channel.id);
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getAll());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_dms_text,
|
||||
action: e => {
|
||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
||||
BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
||||
processGuilds (e) {
|
||||
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "ConnectedUnreadDMs"});
|
||||
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement("div", {
|
||||
className: `${BDFDB.disCN.guildouter} RANbutton-frame`,
|
||||
style: {height: 20},
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: `${BDFDB.disCN.guildiconwrapper} RANbutton-inner`,
|
||||
style: {height: 20},
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: `${BDFDB.disCN.guildiconchildwrapper} RANbutton`,
|
||||
style: {height: 20},
|
||||
children: "read all",
|
||||
onClick: _ => {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
if (settings.includeGuilds) BDFDB.GuildUtils.markAsRead(settings.includeMuted ? BDFDB.GuildUtils.getAll() : BDFDB.GuildUtils.getUnread());
|
||||
if (settings.includeDMs) BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
||||
},
|
||||
onContextMenu: event => {
|
||||
BDFDB.ContextMenuUtils.open(this, event, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_unreadguilds_text,
|
||||
action: event2 => {
|
||||
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getUnread());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_pingedguilds_text,
|
||||
action: event2 => {
|
||||
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getPinged());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_mutedguilds_text,
|
||||
action: event2 => {
|
||||
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getMuted());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_guilds_text,
|
||||
action: event2 => {
|
||||
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||
this.addPinnedRecent(instance.props.channel.id);
|
||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getAll());
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||
label: this.labels.context_dms_text,
|
||||
action: event2 => {
|
||||
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||
BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
||||
}
|
||||
})
|
||||
]
|
||||
}));
|
||||
}
|
||||
})
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
processRecentMentions (e) {
|
||||
if (typeof e.returnvalue.props.renderHeader == "function" && e.instance.props.popoutName == "RECENT_MENTIONS_POPOUT" && BDFDB.DataUtils.get(this, "settings", "addClearButton")) {
|
||||
let renderHeader = e.returnvalue.props.renderHeader;
|
||||
e.returnvalue.props.renderHeader = () => {
|
||||
let renderedHeader = renderHeader(e.instance);
|
||||
renderedHeader.props.children = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.BASELINE,
|
||||
children: [,
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: renderedHeader.props.children
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 0,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
look: BDFDB.LibraryComponents.Button.Looks.OUTLINED,
|
||||
color: BDFDB.LibraryComponents.Button.Colors.GREY,
|
||||
hover: BDFDB.LibraryComponents.Button.Hovers.RED,
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.SMALL,
|
||||
children: BDFDB.LanguageUtils.LanguageStrings.REMOVE,
|
||||
onClick: (event, buttoninstance) => {
|
||||
this.clearMentions(e.instance, BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagespopoutwrap, BDFDB.ReactUtils.findDOMNode(buttoninstance)));
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
BDFDB.ContextMenuUtils.open(this, e, itemGroup);
|
||||
})
|
||||
]
|
||||
});
|
||||
BDFDB.DOMUtils.addClass(wrapper, "RAN-added");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processDirectMessage (instance, wrapper, returnvalue, methodnames) {
|
||||
let ranbutton = document.querySelector(".RANbutton-frame");
|
||||
let insertnode = this.getInsertNode();
|
||||
if (ranbutton && insertnode) insertnode.parentElement.insertBefore(ranbutton, insertnode);
|
||||
}
|
||||
|
||||
processRecentMentions (instance, wrapper, returnvalue) {
|
||||
BDFDB.DOMUtils.remove(".RAMbutton");
|
||||
if (instance.props.popoutName == "RECENT_MENTIONS_POPOUT" && BDFDB.DataUtils.get(this, "settings", "addClearButton")) {
|
||||
let recentmentionstitle = wrapper.querySelector(BDFDB.dotCN.messagespopouttitle);
|
||||
if (recentmentionstitle) {
|
||||
let ranbutton = BDFDB.DOMUtils.create(this.RAMbuttonMarkup);
|
||||
recentmentionstitle.appendChild(ranbutton);
|
||||
ranbutton.addEventListener("click", () => {this.clearMentions(instance, wrapper);});
|
||||
BDFDB.DOMUtils.addClass(wrapper, "RAM-added");
|
||||
}
|
||||
return renderedHeader;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
clearMentions (instance, wrapper) {
|
||||
if (!Node.prototype.isPrototypeOf(wrapper)) return;
|
||||
let closebuttons = wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
|
||||
for (let btn of wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton)) btn.click();
|
||||
if (closebuttons.length) {
|
||||
|
@ -223,17 +227,6 @@ class ReadAllNotificationsButton {
|
|||
}
|
||||
}
|
||||
|
||||
getInsertNode () {
|
||||
let homebutton = BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, document.querySelector(BDFDB.dotCN.homebuttonicon));
|
||||
if (!homebutton) return null;
|
||||
let nextsibling = homebutton.nextElementSibling, insertnode = null;
|
||||
while (nextsibling && insertnode == null) {
|
||||
if (nextsibling.querySelector(`${BDFDB.dotCN.guildseparator}:not(.folderseparator)`)) insertnode = nextsibling;
|
||||
nextsibling = nextsibling.nextElementSibling
|
||||
}
|
||||
return insertnode;
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
//META{"name":"StalkerNotifications","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/StalkerNotifications","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/StalkerNotifications/StalkerNotifications.plugin.js"}*//
|
||||
|
||||
class StalkerNotifications {
|
||||
getName () {return "StalkerNotifications";}
|
||||
|
||||
getVersion () {return "9.9.9";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "DISCONTINUED.";}
|
||||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"improved":[["Merged FriendNotifications and StalkerNotifications","Since both of these plugins now work the same, I decided to merge them. FriendNotifications will be continued and StalkerNotifications will be disconntinued. You can find the old StalkerNotifications settings in the FriendNotifications settings. <i style='color:rgb(200, 100, 100); font-weight: 800;'>All old configurations of FriendNotifications and StalkerNotifications should have been merged</i>"]]
|
||||
};
|
||||
}
|
||||
|
||||
//legacy
|
||||
load () {}
|
||||
|
||||
start () {
|
||||
if (!global.BDFDB) global.BDFDB = {myPlugins:{}};
|
||||
if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this;
|
||||
var 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);
|
||||
this.libLoadTimeout = BDFDB.TimeUtils.timeout(() => {
|
||||
libraryScript.remove();
|
||||
require("request")("https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js", (error, response, body) => {
|
||||
if (body) {
|
||||
libraryScript = document.createElement("script");
|
||||
libraryScript.setAttribute("id", "BDFDBLibraryScript");
|
||||
libraryScript.setAttribute("type", "text/javascript");
|
||||
libraryScript.setAttribute("date", performance.now());
|
||||
libraryScript.innerText = body;
|
||||
document.head.appendChild(libraryScript);
|
||||
}
|
||||
this.initialize();
|
||||
});
|
||||
}, 15000);
|
||||
}
|
||||
else if (global.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 (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.PluginUtils.init(this);
|
||||
|
||||
BDFDB.ModalUtils.confirm(this, "StalkerNotifications has been discontinued and was merged with FriendNotifications. To download FriendNotifications click the 'OK' button bellow. This will delete StalkerNotifications and download FriendNotifications.", "Update Notification", () => {
|
||||
require("request")("https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/FriendNotifications/FriendNotifications.plugin.js", (error, response, body) => {
|
||||
if (error) BDFDB.NotificationUtils.toast(`Unable to download FriendNotifications.plugin.js.`, {type:"error"});
|
||||
else {
|
||||
require("fs").writeFile(require("path").join(BDFDB.BDUtils.getPluginsFolder(), "FriendNotifications.plugin.js"), body, (error) => {
|
||||
if (!error) {
|
||||
BDFDB.NotificationUtils.toast(`Successfully downloaded FriendNotifications.plugin.js.`, {type:"success"});
|
||||
require("fs").unlinkSync(require("path").join(BDFDB.BDUtils.getPluginsFolder(), "StalkerNotifications.plugin.js"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
|
||||
}
|
||||
|
||||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopping = true;
|
||||
|
||||
BDFDB.PluginUtils.clear(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
}
|
Loading…
Reference in New Issue