From 096ffcfe444e46ff4d68866112f44c34f61765e3 Mon Sep 17 00:00:00 2001 From: zrodevkaan <90235641+zrodevkaan@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:17:23 -0600 Subject: [PATCH] 2 plugins that arent on the bd store. --- DMHistory.plugin.js | 77 +++++++++++++++++++++++++++++++++ FileNameRandomization.plugin.js | 34 +++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 DMHistory.plugin.js create mode 100644 FileNameRandomization.plugin.js diff --git a/DMHistory.plugin.js b/DMHistory.plugin.js new file mode 100644 index 0000000..f88f15b --- /dev/null +++ b/DMHistory.plugin.js @@ -0,0 +1,77 @@ +/** + * @name DMHistory + * @description Allows you to see users that DMs have closed or users you've directly messaged + * @author kaan + * @version 1.0.4 + */ + +const { Patcher, Webpack, React } = BdApi; + +class DMHistory { + constructor() { + this.Settings = BdApi.React.createContext(); + this.PrivateDMs = Webpack.getByKeys("openPrivateChannel"); + this.FriendRow = Webpack.getByStrings("isActiveRow:!1"); + this.PresenceStore = BdApi.Webpack.getStore("PresenceStore"); + this.UserStore = BdApi.Webpack.getStore("UserStore"); + this.ChannelStore = BdApi.Webpack.getStore("ChannelStore"); + } + + start() { + this.Patch = Patcher.before( + "IforgotANameIaHateBetterDiscord", + this.PrivateDMs, + "closePrivateChannel", + (a, b) => { + const ClosedChannel = b[0]; + const Channel = this.ChannelStore.getChannel(ClosedChannel); + + Channel.recipients.forEach( (userId) => { + let Users = BdApi.Data.load("DMHistory", "ClosedUsers") || []; + if (!Users?.includes(userId)) Users.push(userId); + BdApi.Data.save("DMHistory", "ClosedUsers", Users); + } ) + } + ); + } + + stop() { + this.Patch(); + } + + getSettingsPanel() { + return React.createElement( + this.Settings.Provider, + { value: this }, + React.createElement(this.SettingsPanel.bind(this)) + ); + } + + SettingsPanel() { + const Users = BdApi.Data.load("DMHistory", "ClosedUsers") || []; + + const UserRows = []; + Users.forEach( (userId) => { + if (userId) { + UserRows.push( + React.createElement(this.FriendRow, { + user: this.UserStore.getUser(userId), + activities: [], + type: 1, + status: this.PresenceStore.getStatus(userId), + }) + ); + } + }) + + const maxPanelHeight = "300px"; + const panelStyle = { + maxHeight: maxPanelHeight, + overflowY: "auto", + }; + + return React.createElement("div", { style: panelStyle }, UserRows); + } +} + +module.exports = DMHistory; diff --git a/FileNameRandomization.plugin.js b/FileNameRandomization.plugin.js new file mode 100644 index 0000000..3585815 --- /dev/null +++ b/FileNameRandomization.plugin.js @@ -0,0 +1,34 @@ +/** + * @name FileNameRandomization + * @author kaan + * @description somefile.txt = dsfDFHJhd4u4r.txt + */ + +const characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + +module.exports = class FileNameRandomization { + start() { + this.Main = BdApi.Patcher.after("dfdsf", BdApi.Webpack.getByKeys("uploadFiles"), "uploadFiles", (a, b, c) => { + for (const File of b[0].uploads) { + const NoNoFileName = this.generateRandomFilename(File.filename); + File.filename = NoNoFileName; + } + }); + } + + stop() { + // this will never change but still + this.Main?.(); + } + + generateRandomFilename(originalFilename) { + const splitStuff = originalFilename.split('.'); // something.exe -> ['something', 'exe'] + const fileExt = splitStuff[splitStuff.length - 1] // hi there file ext. :) + let randomFilename = ''; + for (let i = 0; i < originalFilename.length; i++) { + const randomIndex = Math.floor(Math.random() * characters.length); + randomFilename += characters.charAt(randomIndex); + } + return `${randomFilename}.${fileExt}` + } +}