Skip to content

Commit

Permalink
2 plugins that arent on the bd store.
Browse files Browse the repository at this point in the history
  • Loading branch information
zrodevkaan committed Feb 19, 2024
1 parent 6e97a5d commit 096ffcf
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
77 changes: 77 additions & 0 deletions DMHistory.plugin.js
Original file line number Diff line number Diff line change
@@ -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;
34 changes: 34 additions & 0 deletions FileNameRandomization.plugin.js
Original file line number Diff line number Diff line change
@@ -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}`
}
}

0 comments on commit 096ffcf

Please sign in to comment.