From ac13cff731eba5c447580ba30e042e11d0378a81 Mon Sep 17 00:00:00 2001 From: ImAFrogOwO <90235641+ImAFrogOwO@users.noreply.github.com> Date: Sat, 2 Sep 2023 21:34:03 -0500 Subject: [PATCH 1/3] Update scrollToLast.plugin.js --- plugins/scrollToLast.plugin.js | 59 ++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/plugins/scrollToLast.plugin.js b/plugins/scrollToLast.plugin.js index 2c713e6..76bae26 100644 --- a/plugins/scrollToLast.plugin.js +++ b/plugins/scrollToLast.plugin.js @@ -1,31 +1,42 @@ -//META { "name": "scrollToLast" } *// +/** + * @name ScrollToLast + * @author square,imafrogowo + */ -var scrollToLast = function() { +const { + findModuleByProps, + Patcher, + Webpack: { getModule }, +} = BdApi; - var Keybinds, onSwitch, cancels = []; +class ScrollToLatest { + constructor() { + this.Name = ScrollToLatest.name; + this.Keybinds = findModuleByProps("MARK_CHANNEL_READ"); + this.FluxDispatch = getModule( + (e) => e.dispatch && !e.emitter && !e.commands + ); - Keybinds = BdApi.findModuleByProps("MARK_CHANNEL_READ"); + this.onSwitch = this.onSwitch.bind(this); + } - onSwitch = (ev) => { - if(("CHANNEL_SELECT" === ev.type || "GUILD_SELECT" === ev.type) && /^\/channels\/(?:@me|\d+)\/\d+$/.test(window.location.pathname)) - Keybinds.MARK_CHANNEL_READ.action(); - }; + onSwitch(Gullible) { + // HAHAH LOSER + console.log(Gullible); + if (Gullible != undefined) { + this.Keybinds.MARK_CHANNEL_READ.action({ target: Gullible }); + } + } - 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() { + this.FluxDispatch.subscribe("CHANNEL_SELECT", this.onSwitch); + this.FluxDispatch.subscribe("GUILD_SELECT", this.onSwitch); + } - 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() { + this.FluxDispatch.unsubscribe("CHANNEL_SELECT", this.onSwitch); + this.FluxDispatch.unsubscribe("GUILD_SELECT", this.onSwitch); + } +} - stop: () => { - cancels.forEach(c => c()); - cancels = []; - } - }; -}; +module.exports = ScrollToLatest; From b7147cb0a2b5c694702438739c6ad9a581c6369c Mon Sep 17 00:00:00 2001 From: ImAFrogOwO <90235641+ImAFrogOwO@users.noreply.github.com> Date: Sat, 2 Sep 2023 21:34:47 -0500 Subject: [PATCH 2/3] Update scrollToLast.plugin.js --- plugins/scrollToLast.plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scrollToLast.plugin.js b/plugins/scrollToLast.plugin.js index 76bae26..7dcbeac 100644 --- a/plugins/scrollToLast.plugin.js +++ b/plugins/scrollToLast.plugin.js @@ -1,5 +1,5 @@ /** - * @name ScrollToLast + * @name ScrollToLatest * @author square,imafrogowo */ From d12133e107d6fae66fd616fb0eb9a89f4067360f Mon Sep 17 00:00:00 2001 From: hsiF <90235641+zrodevkaan@users.noreply.github.com> Date: Sat, 9 Mar 2024 02:50:27 -0600 Subject: [PATCH 3/3] Update scrollToLast.plugin.js --- plugins/scrollToLast.plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/scrollToLast.plugin.js b/plugins/scrollToLast.plugin.js index 7dcbeac..609e36c 100644 --- a/plugins/scrollToLast.plugin.js +++ b/plugins/scrollToLast.plugin.js @@ -1,5 +1,7 @@ /** * @name ScrollToLatest + * @version 1.0.0 + * @description Allows you to automatically scroll down to the most recent messages in the current channel. * @author square,imafrogowo */ @@ -21,8 +23,6 @@ class ScrollToLatest { } onSwitch(Gullible) { - // HAHAH LOSER - console.log(Gullible); if (Gullible != undefined) { this.Keybinds.MARK_CHANNEL_READ.action({ target: Gullible }); }