stuff
This commit is contained in:
parent
30e5f9c7fb
commit
fdb6219fdf
|
@ -1774,7 +1774,7 @@ var BDFDB = {
|
||||||
};
|
};
|
||||||
BDFDB.GuildUtils.getData = function (eleOrInfoOrId) {
|
BDFDB.GuildUtils.getData = function (eleOrInfoOrId) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
for (let info of BDFDB.GuildUtils.getAll()) if (info && info.id == id) return info;
|
for (let info of BDFDB.GuildUtils.getAll()) if (info && info.id == id) return info;
|
||||||
return null;
|
return null;
|
||||||
|
@ -1802,7 +1802,7 @@ var BDFDB = {
|
||||||
var found = [];
|
var found = [];
|
||||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
if (id && (LibraryModules.UnreadGuildUtils.hasUnread(id) || LibraryModules.MentionUtils.getMentionCount(id) > 0)) found.push(eleOrInfoOrId);
|
if (id && (LibraryModules.UnreadGuildUtils.hasUnread(id) || LibraryModules.MentionUtils.getMentionCount(id) > 0)) found.push(eleOrInfoOrId);
|
||||||
}
|
}
|
||||||
|
@ -1812,7 +1812,7 @@ var BDFDB = {
|
||||||
var found = [];
|
var found = [];
|
||||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
if (id && LibraryModules.MentionUtils.getMentionCount(id) > 0) found.push(eleOrInfoOrId);
|
if (id && LibraryModules.MentionUtils.getMentionCount(id) > 0) found.push(eleOrInfoOrId);
|
||||||
}
|
}
|
||||||
|
@ -1822,7 +1822,7 @@ var BDFDB = {
|
||||||
var found = [];
|
var found = [];
|
||||||
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.GuildUtils.getAll() : servers) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
if (id && LibraryModules.MutedUtils.isGuildOrCategoryOrChannelMuted(id)) found.push(eleOrInfoOrId);
|
if (id && LibraryModules.MutedUtils.isGuildOrCategoryOrChannelMuted(id)) found.push(eleOrInfoOrId);
|
||||||
}
|
}
|
||||||
|
@ -1925,7 +1925,7 @@ var BDFDB = {
|
||||||
};
|
};
|
||||||
BDFDB.GuildUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.mousePosition) {
|
BDFDB.GuildUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.mousePosition) {
|
||||||
if (!eleOrInfoOrId) return;
|
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);
|
let guild = LibraryModules.GuildStore.getGuild(id);
|
||||||
if (guild) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
if (guild) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
|
||||||
return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("GuildContextMenu"), Object.assign({}, e, {
|
return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("GuildContextMenu"), Object.assign({}, e, {
|
||||||
|
@ -1941,8 +1941,8 @@ var BDFDB = {
|
||||||
if (!guilds) return;
|
if (!guilds) return;
|
||||||
var unreadchannels = [];
|
var unreadchannels = [];
|
||||||
for (let guild of BDFDB.ArrayUtils.is(guilds) ? guilds : (typeof guilds == "string" || typeof guilds == "number" ? Array.of(guilds) : Array.from(guilds))) {
|
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 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 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 (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);
|
if (unreadchannels.length) LibraryModules.AckUtils.bulkAck(unreadchannels);
|
||||||
|
@ -1962,7 +1962,7 @@ var BDFDB = {
|
||||||
};
|
};
|
||||||
BDFDB.FolderUtils.getData = function (eleOrInfoOrId) {
|
BDFDB.FolderUtils.getData = function (eleOrInfoOrId) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
for (let info of BDFDB.FolderUtils.getAll()) if (info && info.folderId == id) return info;
|
for (let info of BDFDB.FolderUtils.getAll()) if (info && info.folderId == id) return info;
|
||||||
return null;
|
return null;
|
||||||
|
@ -1990,7 +1990,7 @@ var BDFDB = {
|
||||||
};
|
};
|
||||||
BDFDB.ChannelUtils.getData = function (eleOrInfoOrId) {
|
BDFDB.ChannelUtils.getData = function (eleOrInfoOrId) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
for (let info of BDFDB.ChannelUtils.getAll()) if (info && info.id == id) return info;
|
for (let info of BDFDB.ChannelUtils.getAll()) if (info && info.id == id) return info;
|
||||||
return null;
|
return null;
|
||||||
|
@ -2011,7 +2011,7 @@ var BDFDB = {
|
||||||
};
|
};
|
||||||
BDFDB.ChannelUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.mousePosition) {
|
BDFDB.ChannelUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.mousePosition) {
|
||||||
if (!eleOrInfoOrId) return;
|
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);
|
let channel = LibraryModules.ChannelStore.getChannel(id);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
let type = null;
|
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 = {};
|
||||||
BDFDB.DMUtils.getIcon = function (id) {
|
BDFDB.DMUtils.getIcon = function (id) {
|
||||||
|
@ -2062,7 +2071,7 @@ var BDFDB = {
|
||||||
};
|
};
|
||||||
BDFDB.DMUtils.getData = function (eleOrInfoOrId) {
|
BDFDB.DMUtils.getData = function (eleOrInfoOrId) {
|
||||||
if (!eleOrInfoOrId) return null;
|
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;
|
id = typeof id == "number" ? id.toFixed() : id;
|
||||||
for (let info of BDFDB.DMUtils.getAll()) if (info && info.id == id) return info;
|
for (let info of BDFDB.DMUtils.getAll()) if (info && info.id == id) return info;
|
||||||
return null;
|
return null;
|
||||||
|
@ -2074,14 +2083,14 @@ var BDFDB = {
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
};
|
};
|
||||||
BDFDB.DMUtils.markAsRead = BDFDB.ChannelUtils.markAsRead = function (channels) {
|
BDFDB.DMUtils.markAsRead = function (dms) {
|
||||||
if (!channels) return;
|
if (!dms) return;
|
||||||
var unreadchannels = [];
|
var unreadchannels = [];
|
||||||
for (let cha of channels = BDFDB.ArrayUtils.is(channels) ? channels : (typeof channels == "string" || typeof channels == "number" ? Array.of(channels) : Array.from(channels))) {
|
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(cha) ? (BDFDB.ChannelUtils.getId(cha) || BDFDB.getDmID(cha)) : cha && typeof cha == "object" ? cha.id : cha;
|
let id = Node.prototype.isPrototypeOf(dm) ? BDFDB.BDFDB.DMUtils.getId(dm) : (dm && typeof dm == "object" ? dm.id : dm);
|
||||||
if (id) unreadchannels.push(id);
|
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 = {};
|
BDFDB.DataUtils = {};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
||||||
class ReadAllNotificationsButton {
|
class ReadAllNotificationsButton {
|
||||||
getName () {return "ReadAllNotificationsButton";}
|
getName () {return "ReadAllNotificationsButton";}
|
||||||
|
|
||||||
getVersion () {return "1.5.1";}
|
getVersion () {return "1.5.2";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,29 +11,16 @@ class ReadAllNotificationsButton {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
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 = {
|
this.patchModules = {
|
||||||
"Guilds":["componentDidMount","componentDidUpdate"],
|
Guilds: "render",
|
||||||
"RecentMentions":"componentDidMount",
|
RecentMentions: "render"
|
||||||
"DirectMessage":"componentDidMount"
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
initConstructor () {
|
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 = `
|
this.css = `
|
||||||
.RANbutton-frame {
|
.RANbutton-frame {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
@ -126,8 +113,8 @@ class ReadAllNotificationsButton {
|
||||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||||
this.stopping = true;
|
this.stopping = true;
|
||||||
|
|
||||||
BDFDB.DOMUtils.remove(".RANbutton-frame", ".RAMbutton");
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||||
BDFDB.DOMUtils.removeClassFromDOM("RAN-added", "RAM-added");
|
|
||||||
BDFDB.PluginUtils.clear(this);
|
BDFDB.PluginUtils.clear(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,86 +122,103 @@ class ReadAllNotificationsButton {
|
||||||
|
|
||||||
// begin of own functions
|
// begin of own functions
|
||||||
|
|
||||||
processGuilds (instance, wrapper, returnvalue, methodnames) {
|
processGuilds (e) {
|
||||||
if (methodnames.includes("componentDidMount") || (methodnames.includes("componentDidUpdate") && document.querySelector(".bd-guild ~ .RANbutton-frame"))) {
|
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "ConnectedUnreadDMs"});
|
||||||
BDFDB.DOMUtils.remove(".RANbutton-frame");
|
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement("div", {
|
||||||
let insertnode = this.getInsertNode();
|
className: `${BDFDB.disCN.guildouter} RANbutton-frame`,
|
||||||
if (insertnode) {
|
style: {height: 20},
|
||||||
let ranbutton = BDFDB.DOMUtils.create(this.RANbuttonMarkup);
|
children: BDFDB.ReactUtils.createElement("div", {
|
||||||
insertnode.parentElement.insertBefore(ranbutton, insertnode);
|
className: `${BDFDB.disCN.guildiconwrapper} RANbutton-inner`,
|
||||||
ranbutton.addEventListener("click", () => {
|
style: {height: 20},
|
||||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
children: BDFDB.ReactUtils.createElement("div", {
|
||||||
if (settings.includeGuilds) BDFDB.GuildUtils.markAsRead(settings.includeMuted ? BDFDB.GuildUtils.getAll() : BDFDB.GuildUtils.getUnread());
|
className: `${BDFDB.disCN.guildiconchildwrapper} RANbutton`,
|
||||||
if (settings.includeDMs) BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
style: {height: 20},
|
||||||
});
|
children: "read all",
|
||||||
ranbutton.addEventListener("contextmenu", e => {
|
onClick: _ => {
|
||||||
const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||||
children: [
|
if (settings.includeGuilds) BDFDB.GuildUtils.markAsRead(settings.includeMuted ? BDFDB.GuildUtils.getAll() : BDFDB.GuildUtils.getUnread());
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
if (settings.includeDMs) BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.getAll());
|
||||||
label: this.labels.context_unreadguilds_text,
|
},
|
||||||
action: e => {
|
onContextMenu: event => {
|
||||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
BDFDB.ContextMenuUtils.open(this, event, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
||||||
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getUnread());
|
children: [
|
||||||
}
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||||
}),
|
label: this.labels.context_unreadguilds_text,
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
action: event2 => {
|
||||||
label: this.labels.context_pingedguilds_text,
|
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||||
action: e => {
|
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getUnread());
|
||||||
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_pingedguilds_text,
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
action: event2 => {
|
||||||
label: this.labels.context_mutedguilds_text,
|
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||||
action: e => {
|
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getPinged());
|
||||||
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_mutedguilds_text,
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
action: event2 => {
|
||||||
label: this.labels.context_guilds_text,
|
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||||
action: e => {
|
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getMuted());
|
||||||
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_guilds_text,
|
||||||
}),
|
action: event2 => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
BDFDB.ContextMenuUtils.close(event2._targetInst);
|
||||||
label: this.labels.context_dms_text,
|
this.addPinnedRecent(instance.props.channel.id);
|
||||||
action: e => {
|
BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getAll());
|
||||||
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
}
|
||||||
BDFDB.DMUtils.markAsRead(BDFDB.DMUtils.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");
|
return renderedHeader;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearMentions (instance, wrapper) {
|
clearMentions (instance, wrapper) {
|
||||||
|
if (!Node.prototype.isPrototypeOf(wrapper)) return;
|
||||||
let closebuttons = wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
|
let closebuttons = wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
|
||||||
for (let btn of wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton)) btn.click();
|
for (let btn of wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton)) btn.click();
|
||||||
if (closebuttons.length) {
|
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 () {
|
setLabelsByLanguage () {
|
||||||
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
||||||
case "hr": //croatian
|
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