forked from Inve1951/BetterDiscordStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrollToLast.plugin.js
31 lines (24 loc) · 994 Bytes
/
scrollToLast.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//META { "name": "scrollToLast" } *//
var scrollToLast = function() {
var Keybinds, onSwitch, cancels = [];
Keybinds = BdApi.findModuleByProps("MARK_CHANNEL_READ");
onSwitch = (ev) => {
if(("CHANNEL_SELECT" === ev.type || "GUILD_SELECT" === ev.type) && /^\/channels\/(?:@me|\d+)\/\d+$/.test(window.location.pathname))
Keybinds.MARK_CHANNEL_READ.action();
};
return {
getName: () => "Scroll-To-Last",
getDescription: () => "When entering any text channel, scrolls to the bottom and marks it as read.",
getAuthor: () => "square",
getVersion: () => "1.0.2",
start: () => {
var _ = BdApi.findModuleByProps("_orderedActionHandlers");
_.subscribe("CHANNEL_SELECT", onSwitch); cancels.push(_.unsubscribe.bind(_, "CHANNEL_SELECT", onSwitch));
_.subscribe("GUILD_SELECT", onSwitch); cancels.push(_.unsubscribe.bind(_, "GUILD_SELECT", onSwitch));
},
stop: () => {
cancels.forEach(c => c());
cancels = [];
}
};
};