Plugin 1.0, and readme
This commit is contained in:
commit
e0c2c83577
2 changed files with 115 additions and 0 deletions
12
README.md
Normal file
12
README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Chatless Discord
|
||||
|
||||
A discord plugin I wrote to remove the chat from discord
|
||||
|
||||
It additionally causes the discord call pop-out to open when joining a call
|
||||
|
||||
I use this for my personal setup where I use Beeper for my discord channels, and
|
||||
use Discord exclusively for calling.
|
||||
|
||||
It can be installed by first installing
|
||||
[Better Discord](https://betterdiscord.app/) and then putting the file into the
|
||||
plugins folder.
|
||||
103
core.plugin.js
Normal file
103
core.plugin.js
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* @name chatlessdisc
|
||||
* @version 1.0.0
|
||||
* @description removes the chatting from disc, as god intended
|
||||
* @author Julia Lange
|
||||
*
|
||||
*/
|
||||
|
||||
const TITLE = "chatless-disc";
|
||||
|
||||
function getChat() {
|
||||
let chatsPotentialChild = document.querySelector(
|
||||
"div > section[aria-label='Channel header']");
|
||||
if(chatsPotentialChild) {
|
||||
let chat = chatsPotentialChild.parentElement;
|
||||
return chat;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeChat() {
|
||||
let chat = getChat()
|
||||
if (chat) chat.style = "display: none";
|
||||
}
|
||||
function restoreChat() {
|
||||
let chat = getChat()
|
||||
if (chat) chat.style = "display: flex";
|
||||
}
|
||||
|
||||
function expandSidebar() {
|
||||
let userArea = document.querySelector("section[aria-label='User area']");
|
||||
let sidebar = userArea.parentElement;
|
||||
sidebar.style = "width: 100%";
|
||||
removeChat();
|
||||
|
||||
userArea.childNodes.forEach(node => {
|
||||
node.style = "justify-content: space-between";
|
||||
});
|
||||
}
|
||||
|
||||
function contractSidebar() {
|
||||
let userArea = document.querySelector("section[aria-label='User area']");
|
||||
let sidebar = userArea.parentElement;
|
||||
sidebar.style = "";
|
||||
restoreChat();
|
||||
|
||||
userArea.childNodes.forEach(node => {
|
||||
node.style = "";
|
||||
});
|
||||
}
|
||||
|
||||
function addChannelClass() {
|
||||
let dms = document.querySelector("ul[aria-label='Direct Messages'");
|
||||
if(dms == null) return "";
|
||||
let friendsElement = dms.childNodes[1]
|
||||
if(friendsElement == null) return "";
|
||||
let channelClassName = friendsElement.className.split(" ")[0]
|
||||
if (channelClassName != "") {
|
||||
BdApi.DOM.addStyle(TITLE, `.${channelClassName} {
|
||||
max-width: 100%;
|
||||
}`);
|
||||
}
|
||||
return channelClassName;
|
||||
}
|
||||
|
||||
function clickPopOut() {
|
||||
let popOutButton = document.querySelector("button[aria-label='Pop Out'");
|
||||
if(popOutButton == null) return;
|
||||
popOutButton.click();
|
||||
}
|
||||
|
||||
class chatlessdisc {
|
||||
|
||||
constructor() {
|
||||
// this.channelClassName = "";
|
||||
this.channelActionsModule = BdApi.findModuleByProps('selectChannel');
|
||||
}
|
||||
|
||||
start() {
|
||||
expandSidebar();
|
||||
this.channelClassName = addChannelClass();
|
||||
|
||||
BdApi.Patcher.instead(TITLE, this.channelActionsModule,
|
||||
"selectChannel", async (_, args, originalFunction) => {
|
||||
await originalFunction(...args);
|
||||
removeChat();
|
||||
if (this.channelClassName == "")
|
||||
this.channelClassName = addChannelClass();
|
||||
});
|
||||
BdApi.Patcher.instead(TITLE, this.channelActionsModule,
|
||||
"selectVoiceChannel", async (_, args, originalFunction) => {
|
||||
await originalFunction(...args);
|
||||
await this.channelActionsModule.selectPrivateChannel(args[0]);
|
||||
clickPopOut();
|
||||
});
|
||||
}
|
||||
//Turn off and remove all parts of the plugin
|
||||
stop() {
|
||||
contractSidebar();
|
||||
BdApi.Patcher.unpatchAll(TITLE);
|
||||
BdApi.DOM.removeStyle(TITLE);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue