forked from Inve1951/BetterDiscordStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollToLast.plugin.js
More file actions
36 lines (29 loc) · 1.11 KB
/
Copy pathscrollToLast.plugin.js
File metadata and controls
36 lines (29 loc) · 1.11 KB
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
32
33
34
35
36
//META { "name": "scrollToLast" } *//
var scrollToLast = function() {
var Keybinds, onSwitch, cancels = [];
Keybinds = BdApi.findModuleByProps("MARK_CHANNEL_READ");
onSwitch = ({methodArguments: [ev]}) => {
if(("CHANNEL_SELECT" === ev.type || "GUILD_SELECT" === ev.type) && /^\/channels\/(?:@me|\d+)\/\d+$/.test(window.location.pathname))
process.nextTick(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.1",
start: () => {
cancels.push(BdApi.monkeyPatch(
BdApi.findModule(m => m._actionHandlers && m._actionHandlers.CHANNEL_SELECT)._actionHandlers,
"CHANNEL_SELECT", {before: onSwitch}
));
cancels.push(BdApi.monkeyPatch(
BdApi.findModule(m => m._actionHandlers && m._actionHandlers.GUILD_SELECT)._actionHandlers,
"GUILD_SELECT", {before: onSwitch}
));
},
stop: () => {
cancels.forEach(c => c());
cancels = [];
}
};
};