Compare commits
3 commits
7e5410cf20
...
eacebcb981
Author | SHA1 | Date | |
---|---|---|---|
♥ Minnie ♥ | eacebcb981 | ||
♥ Minnie ♥ | 6c82d0a7be | ||
♥ Minnie ♥ | b08d54abb6 |
|
@ -59,6 +59,8 @@
|
||||||
eval "$(direnv hook zsh)"
|
eval "$(direnv hook zsh)"
|
||||||
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
|
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
|
||||||
path+=('/home/sajenim/.local/bin')
|
path+=('/home/sajenim/.local/bin')
|
||||||
|
bindkey "^[[1;5C" forward-word
|
||||||
|
bindkey "^[[1;5D" backward-word
|
||||||
export PATH
|
export PATH
|
||||||
PROMPT='%F{blue}%n@%m %F{cyan}%~ %F{red}♥ %f';
|
PROMPT='%F{blue}%n@%m %F{cyan}%~ %F{red}♥ %f';
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -17,16 +17,6 @@
|
||||||
source = ./config/custom.css;
|
source = ./config/custom.css;
|
||||||
};
|
};
|
||||||
|
|
||||||
home.file.".config/BetterDiscord/plugins/HideChannels.plugin.js" = {
|
|
||||||
enable = true;
|
|
||||||
source = ./plugins/HideChannels.plugin.js;
|
|
||||||
};
|
|
||||||
|
|
||||||
home.file.".config/BetterDiscord/plugins/RemoveBlockedUsers.plugin.js" = {
|
|
||||||
enable = true;
|
|
||||||
source = ./plugins/RemoveBlockedUsers.plugin.js;
|
|
||||||
};
|
|
||||||
|
|
||||||
home.persistence."/persist/home/sajenim".directories = [
|
home.persistence."/persist/home/sajenim".directories = [
|
||||||
".config/discord"
|
".config/discord"
|
||||||
".config/BetterDiscord"
|
".config/BetterDiscord"
|
||||||
|
|
|
@ -1,351 +0,0 @@
|
||||||
/**
|
|
||||||
* @name Hide Channels
|
|
||||||
* @author Farcrada
|
|
||||||
* @version 2.2.11
|
|
||||||
* @description Hide channel list from view.
|
|
||||||
*
|
|
||||||
* @invite qH6UWCwfTu
|
|
||||||
* @website https://github.com/Farcrada/DiscordPlugins
|
|
||||||
* @source https://github.com/Farcrada/DiscordPlugins/edit/master/Hide-Channels/HideChannels.plugin.js
|
|
||||||
* @updateUrl https://raw.githubusercontent.com/Farcrada/DiscordPlugins/master/Hide-Channels/HideChannels.plugin.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @type {typeof import("react")} */
|
|
||||||
const React = BdApi.React;
|
|
||||||
|
|
||||||
const { Webpack, Webpack: { Filters }, Data, DOM, Patcher } = BdApi,
|
|
||||||
|
|
||||||
config = {
|
|
||||||
info: {
|
|
||||||
name: "Hide Channels",
|
|
||||||
id: "HideChannels",
|
|
||||||
description: "Hide channel list from view.",
|
|
||||||
version: "2.2.11",
|
|
||||||
author: "Farcrada",
|
|
||||||
updateUrl: "https://raw.githubusercontent.com/Farcrada/DiscordPlugins/master/Hide-Channels/HideChannels.plugin.js"
|
|
||||||
},
|
|
||||||
constants: {
|
|
||||||
//The names we need for CSS
|
|
||||||
cssStyle: "HideChannelsStyle",
|
|
||||||
hideElementsName: "hideChannelElement",
|
|
||||||
buttonID: "toggleChannels",
|
|
||||||
buttonHidden: "channelsHidden",
|
|
||||||
buttonVisible: "channelsVisible"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = class HideChannels {
|
|
||||||
|
|
||||||
|
|
||||||
load() {
|
|
||||||
try { global.ZeresPluginLibrary.PluginUpdater.checkForUpdate(config.info.name, config.info.version, config.info.updateUrl); }
|
|
||||||
catch (err) { console.error(config.info.name, "Failed to reach the ZeresPluginLibrary for Plugin Updater.", err); }
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
try {
|
|
||||||
//React components for settings
|
|
||||||
this.WindowInfoStore = Webpack.getModule(Filters.byKeys("isFocused", "isElementFullScreen"));
|
|
||||||
|
|
||||||
this.KeybindToCombo = Webpack.getModule(Filters.byStrings("numpad plus"), { searchExports: true });
|
|
||||||
this.KeybindToString = Webpack.getModule(Filters.byStrings(".join(\"+\")"), { searchExports: true });
|
|
||||||
|
|
||||||
//The sidebar to "minimize"/hide
|
|
||||||
this.sidebarClass = Webpack.getModule(Filters.byKeys("container", "base")).sidebar;
|
|
||||||
this.headerBarClass = Webpack.getModule(Filters.byKeys("chat", "title")).title;
|
|
||||||
|
|
||||||
//And the keybind
|
|
||||||
this.animation = this.checkKeybindLoad(Data.load(config.info.id, "animation")) ?? true;
|
|
||||||
this.keybindSetting = this.checkKeybindLoad(Data.load(config.info.id, "keybind"));
|
|
||||||
this.keybind = this.keybindSetting.split('+');
|
|
||||||
|
|
||||||
//Predefine for the eventlistener
|
|
||||||
this.currentlyPressed = {};
|
|
||||||
|
|
||||||
this.generateCSS();
|
|
||||||
|
|
||||||
//Render the button and we're off to the races!
|
|
||||||
const filter = f => f?.Icon && f.Title,
|
|
||||||
modules = Webpack.getModule(m => Object.values(m).some(filter), { first: false });
|
|
||||||
for (const module of modules) {
|
|
||||||
const HeaderBar = [module, Object.keys(module).find(k => filter(module[k]))];
|
|
||||||
this.patchTitleBar(HeaderBar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
try {
|
|
||||||
console.error("Attempting to stop after starting error...", err)
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
console.error(config.info.name + ".stop()", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getSettingsPanel() {
|
|
||||||
//Settings window is lazy loaded so we need to cache this after it's been loaded (i.e. open settings).
|
|
||||||
//This also allows for a (delayed) call to retrieve a way to prompt a Form
|
|
||||||
if (!this.KeybindRecorder) {
|
|
||||||
this.KeybindRecorder = Webpack.getModule(m => m.prototype?.cleanUp);
|
|
||||||
this.FormItem = Webpack.getModule(Filters.byRegex(/(case .\.LEGEND:)/), { searchExports: true });
|
|
||||||
this.SwitchItem = Webpack.getModule(Filters.byStrings("=e.note", "checked:"), { searchExports: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return our keybind settings wrapped in a form item
|
|
||||||
return () => {
|
|
||||||
const [animation, setanimation] = React.useState(this.animation);
|
|
||||||
|
|
||||||
return [
|
|
||||||
React.createElement(this.SwitchItem, {
|
|
||||||
value: animation,
|
|
||||||
note: "Enable the hide animation. Useful if the animation is \"unstatisfactory\".",
|
|
||||||
onChange: (newState) => {
|
|
||||||
//Save new state
|
|
||||||
this.animation = newState;
|
|
||||||
Data.save(config.info.id, "animation", newState);
|
|
||||||
setanimation(newState);
|
|
||||||
|
|
||||||
//Update CSS to reflect new settings.
|
|
||||||
this.generateCSS()
|
|
||||||
}
|
|
||||||
}, "Enable Hide Animation"),
|
|
||||||
React.createElement(this.FormItem, {
|
|
||||||
tag: "h5"
|
|
||||||
}, "Toggle by keybind:",
|
|
||||||
//Containing a keybind recorder.
|
|
||||||
React.createElement(this.KeybindRecorder, {
|
|
||||||
//The `keyup` and `keydown` events register the Ctrl key different
|
|
||||||
//We need to accomodate for that
|
|
||||||
defaultValue: this.KeybindToCombo(this.keybindSetting.replace("control", "ctrl")),
|
|
||||||
onChange: (e) => {
|
|
||||||
//Convert the keybind to current locale
|
|
||||||
//Once again accomodate for event differences
|
|
||||||
const keybindString = this.KeybindToString(e).toLowerCase().replace("ctrl", "control");
|
|
||||||
|
|
||||||
//Set the keybind and save it.
|
|
||||||
Data.save(config.info.id, "keybind", keybindString);
|
|
||||||
//And the keybindSetting
|
|
||||||
this.keybindSetting = keybindString;
|
|
||||||
this.keybind = keybindString.split('+');
|
|
||||||
}
|
|
||||||
}))];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
Patcher.unpatchAll(config.info.id);
|
|
||||||
|
|
||||||
//Our CSS
|
|
||||||
DOM.removeStyle(config.constants.cssStyle);
|
|
||||||
|
|
||||||
//And if there are remnants of css left,
|
|
||||||
//make sure we remove the class from the sidebar to ensure visual confirmation.
|
|
||||||
let sidebar = document.querySelector(`.${this.sidebarClass}`);
|
|
||||||
if (sidebar?.classList.contains(config.constants.hideElementsName))
|
|
||||||
sidebar.classList.remove(config.constants.hideElementsName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {object[]} headerBar The module and the export's name (as a string) that contains it
|
|
||||||
*/
|
|
||||||
patchTitleBar(headerBar) {
|
|
||||||
Patcher.before(config.info.id, ...headerBar, (thisObject, methodArguments, returnValue) => {
|
|
||||||
//When elements are being re-rendered we need to check if there actually is a place for us.
|
|
||||||
//Along with that we need to check if what we're adding to is an array.
|
|
||||||
if (Array.isArray(methodArguments[0]?.children))
|
|
||||||
if (methodArguments[0].children.some?.(child =>
|
|
||||||
//Make sure we're on the "original" headerbar and not that of a Voice channel's chat, or thread.
|
|
||||||
child?.props?.channel ||
|
|
||||||
//The friends page
|
|
||||||
child?.type?.Header ||
|
|
||||||
//The Nitro page
|
|
||||||
child?.props?.children === "Nitro" ||
|
|
||||||
//Home page of certain servers. This is gonna be broken next update, calling it.
|
|
||||||
child?.props?.children?.some?.(grandChild => typeof grandChild === 'string')))
|
|
||||||
|
|
||||||
//Make sure our component isn't already present.
|
|
||||||
if (!methodArguments[0].children.some?.(child => child?.key === config.info.id))
|
|
||||||
//And since we want to be on the most left of the header bar for style we unshift into the array.
|
|
||||||
methodArguments[0].children.unshift?.(React.createElement(this.hideChannelComponent, { key: config.info.id }));
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* React component for our button.
|
|
||||||
* @returns React element
|
|
||||||
*/
|
|
||||||
hideChannelComponent = () => {
|
|
||||||
//Only fetch the sidebar on a rerender.
|
|
||||||
const sidebarNode = document.querySelector(`.${this.sidebarClass}`),
|
|
||||||
//When a state updates, it rerenders.
|
|
||||||
[hidden, setHidden] = React.useState(
|
|
||||||
//Check on a rerender where our side bar is so we can correctly reflect this.
|
|
||||||
sidebarNode?.classList.contains(config.constants.hideElementsName));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this to make a despensable easy to use listener with React.
|
|
||||||
* @param {string} eventName The name of the event to listen for.
|
|
||||||
* @param {callback} callback Function to call when said event is triggered.
|
|
||||||
* @param {boolean} bubbling Handle bubbling or not
|
|
||||||
* @param {object} [target] The object to attach our listener to.
|
|
||||||
*/
|
|
||||||
function useListener(eventName, callback, bubbling, target = window) {
|
|
||||||
React.useEffect(() => {
|
|
||||||
//ComponentDidMount
|
|
||||||
target.addEventListener(eventName, callback, bubbling);
|
|
||||||
//ComponentWillUnmount
|
|
||||||
return () => target.removeEventListener(eventName, callback, bubbling);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function useWindowChangeListener(windowStore, callback) {
|
|
||||||
React.useEffect(() => {
|
|
||||||
windowStore.addChangeListener(callback);
|
|
||||||
return () => windowStore.removeChangeListener(callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Node} sidebar Sidebar node we want to toggle.
|
|
||||||
* @returns The passed state in reverse.
|
|
||||||
*/
|
|
||||||
function toggleSidebar(sidebar) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds and removes our CSS to make our sidebar appear and disappear.
|
|
||||||
* @param {boolean} state State that determines the toggle.
|
|
||||||
* @returns The passed state in reverse.
|
|
||||||
*/
|
|
||||||
return state => {
|
|
||||||
//If it is showing, we need to hide it.
|
|
||||||
if (!state)
|
|
||||||
//We hide it through CSS by adding a class.
|
|
||||||
sidebar?.classList.add(config.constants.hideElementsName);
|
|
||||||
//If it is hidden, we need to show it.
|
|
||||||
else
|
|
||||||
sidebar?.classList.remove(config.constants.hideElementsName);
|
|
||||||
|
|
||||||
return !state;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//Keydown event
|
|
||||||
useListener("keydown", e => {
|
|
||||||
//Since we made this an object,
|
|
||||||
//we can make new properties with `[]`
|
|
||||||
if (e?.key?.toLowerCase)
|
|
||||||
this.currentlyPressed[e.key.toLowerCase()] = true;
|
|
||||||
|
|
||||||
//Account for bubbling
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
//Keyup event
|
|
||||||
useListener("keyup", e => {
|
|
||||||
//Check if every currentlyPessed is in our saved keybind.
|
|
||||||
if (this.keybind.every(key => this.currentlyPressed[key.toLowerCase()] === true))
|
|
||||||
//Toggle the sidebar and rerender on toggle; change the state
|
|
||||||
setHidden(toggleSidebar(sidebarNode));
|
|
||||||
|
|
||||||
//Current key goes up, so...
|
|
||||||
this.currentlyPressed[e.key.toLowerCase()] = false;
|
|
||||||
|
|
||||||
//Account for bubbling
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
//Lose focus event
|
|
||||||
useWindowChangeListener(this.WindowInfoStore, () => {
|
|
||||||
//Clear when it gets back into focus
|
|
||||||
if (this.WindowInfoStore.isFocused())
|
|
||||||
this.currentlyPressed = {};
|
|
||||||
});
|
|
||||||
|
|
||||||
//Return our element.
|
|
||||||
return React.createElement("div", {
|
|
||||||
//Styling
|
|
||||||
id: config.constants.buttonID,
|
|
||||||
//The icon
|
|
||||||
className: hidden ? config.constants.buttonHidden : config.constants.buttonVisible,
|
|
||||||
//Toggle the sidebar and rerender on toggle; change the state.
|
|
||||||
onClick: () => setHidden(toggleSidebar(sidebarNode))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks the given keybind for validity. If not valid returns a default keybind.
|
|
||||||
* @param {String|Array.<number>|Array.<Array.<number>>} keybindToLoad The keybind to filter and load in.
|
|
||||||
* @param {String} [defaultKeybind] A default keybind to fall back on in case of invalidity.
|
|
||||||
* @returns Will return the keybind or return a default keybind.
|
|
||||||
*/
|
|
||||||
checkKeybindLoad(keybindToLoad, defaultKeybind = "control+h") {
|
|
||||||
defaultKeybind = defaultKeybind.toLowerCase().replace("ctrl", "control");
|
|
||||||
|
|
||||||
//If no keybind
|
|
||||||
if (!keybindToLoad)
|
|
||||||
return defaultKeybind;
|
|
||||||
|
|
||||||
//Error sensitive, so just plump it into a try-catch
|
|
||||||
try {
|
|
||||||
//If it's already a string, double check it
|
|
||||||
if (typeof (keybindToLoad) === typeof (defaultKeybind)) {
|
|
||||||
keybindToLoad = keybindToLoad.toLowerCase().replace("control", "ctrl");
|
|
||||||
//Does it go into a combo? (i.e.: is it the correct format?)
|
|
||||||
if (this.KeybindToCombo(keybindToLoad))
|
|
||||||
return keybindToLoad.replace("ctrl", "control");
|
|
||||||
else
|
|
||||||
return defaultKeybind;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
//If it's not a string, check if it's a combo.
|
|
||||||
if (this.KeybindToString(keybindToLoad))
|
|
||||||
return this.KeybindToString(keybindToLoad).toLowerCase().replace("ctrl", "control");
|
|
||||||
}
|
|
||||||
catch (e) { return defaultKeybind; }
|
|
||||||
}
|
|
||||||
|
|
||||||
generateCSS() {
|
|
||||||
//Check if there is any CSS we have already, and remove it.
|
|
||||||
DOM.removeStyle(config.constants.cssStyle);
|
|
||||||
|
|
||||||
//Now inject our (new) CSS
|
|
||||||
DOM.addStyle(config.constants.cssStyle, `
|
|
||||||
/* Button CSS */
|
|
||||||
#${config.constants.buttonID} {
|
|
||||||
min-width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
background-position: center !important;
|
|
||||||
background-size: 100% !important;
|
|
||||||
opacity: 0.8;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* How the button looks */
|
|
||||||
.theme-dark #${config.constants.buttonID}.${config.constants.buttonVisible} {
|
|
||||||
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmZiIgd2lkdGg9IjE4cHgiIGhlaWdodD0iMThweCI+PHBhdGggZD0iTTE4LjQxIDE2LjU5TDEzLjgyIDEybDQuNTktNC41OUwxNyA2bC02IDYgNiA2ek02IDZoMnYxMkg2eiIvPjxwYXRoIGQ9Ik0yNCAyNEgwVjBoMjR2MjR6IiBmaWxsPSJub25lIi8+PC9zdmc+) no-repeat;
|
|
||||||
}
|
|
||||||
.theme-dark #${config.constants.buttonID}.${config.constants.buttonHidden} {
|
|
||||||
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmZiIgd2lkdGg9IjE4cHgiIGhlaWdodD0iMThweCI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTUuNTkgNy40MUwxMC4xOCAxMmwtNC41OSA0LjU5TDcgMThsNi02LTYtNnpNMTYgNmgydjEyaC0yeiIvPjwvc3ZnPg==) no-repeat;
|
|
||||||
}
|
|
||||||
/* In light theme */
|
|
||||||
.theme-light #${config.constants.buttonID}.${config.constants.buttonVisible} {
|
|
||||||
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iIzRmNTY2MCIgd2lkdGg9IjE4cHgiIGhlaWdodD0iMThweCI+PHBhdGggZD0iTTE4LjQxIDE2LjU5TDEzLjgyIDEybDQuNTktNC41OUwxNyA2bC02IDYgNiA2ek02IDZoMnYxMkg2eiIvPjxwYXRoIGQ9Ik0yNCAyNEgwVjBoMjR2MjR6IiBmaWxsPSJub25lIi8+PC9zdmc+) no-repeat;
|
|
||||||
}
|
|
||||||
.theme-light #${config.constants.buttonID}.${config.constants.buttonHidden} {
|
|
||||||
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iIzRmNTY2MCIgd2lkdGg9IjE4cHgiIGhlaWdodD0iMThweCI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTUuNTkgNy40MUwxMC4xOCAxMmwtNC41OSA0LjU5TDcgMThsNi02LTYtNnpNMTYgNmgydjEyaC0yeiIvPjwvc3ZnPg==) no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Attached CSS to sidebar */
|
|
||||||
.${config.constants.hideElementsName} {
|
|
||||||
width: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set animations */
|
|
||||||
.${this.sidebarClass} {
|
|
||||||
${this.animation ? "transition: width 400ms ease;" : ""}
|
|
||||||
overflow: hidden;
|
|
||||||
}`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,529 +0,0 @@
|
||||||
/**
|
|
||||||
* @name RemoveBlockedUsers
|
|
||||||
* @author DevilBro
|
|
||||||
* @authorId 278543574059057154
|
|
||||||
* @version 1.6.7
|
|
||||||
* @description Removes blocked Messages/Users
|
|
||||||
* @invite Jx3TjNS
|
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
|
||||||
* @patreon https://www.patreon.com/MircoWittrien
|
|
||||||
* @website https://mwittrien.github.io/
|
|
||||||
* @source https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RemoveBlockedUsers/
|
|
||||||
* @updateUrl https://mwittrien.github.io/BetterDiscordAddons/Plugins/RemoveBlockedUsers/RemoveBlockedUsers.plugin.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = (_ => {
|
|
||||||
const changeLog = {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
|
||||||
constructor (meta) {for (let key in meta) this[key] = meta[key];}
|
|
||||||
getName () {return this.name;}
|
|
||||||
getAuthor () {return this.author;}
|
|
||||||
getVersion () {return this.version;}
|
|
||||||
getDescription () {return `The Library Plugin needed for ${this.name} is missing. Open the Plugin Settings to download it. \n\n${this.description}`;}
|
|
||||||
|
|
||||||
downloadLibrary () {
|
|
||||||
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
|
|
||||||
if (!e && b && r.statusCode == 200) require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => BdApi.showToast("Finished downloading BDFDB Library", {type: "success"}));
|
|
||||||
else BdApi.alert("Error", "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
load () {
|
|
||||||
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
|
|
||||||
if (!window.BDFDB_Global.downloadModal) {
|
|
||||||
window.BDFDB_Global.downloadModal = true;
|
|
||||||
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${this.name} is missing. Please click "Download Now" to install it.`, {
|
|
||||||
confirmText: "Download Now",
|
|
||||||
cancelText: "Cancel",
|
|
||||||
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
|
|
||||||
onConfirm: _ => {
|
|
||||||
delete window.BDFDB_Global.downloadModal;
|
|
||||||
this.downloadLibrary();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!window.BDFDB_Global.pluginQueue.includes(this.name)) window.BDFDB_Global.pluginQueue.push(this.name);
|
|
||||||
}
|
|
||||||
start () {this.load();}
|
|
||||||
stop () {}
|
|
||||||
getSettingsPanel () {
|
|
||||||
let template = document.createElement("template");
|
|
||||||
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${this.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
|
|
||||||
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
|
|
||||||
return template.content.firstElementChild;
|
|
||||||
}
|
|
||||||
} : (([Plugin, BDFDB]) => {
|
|
||||||
var cachedChannelId, cachedReactions;
|
|
||||||
|
|
||||||
return class RemoveBlockedUsers extends Plugin {
|
|
||||||
onLoad () {
|
|
||||||
this.defaults = {
|
|
||||||
notifications: {
|
|
||||||
messages: {value: true, description: "Messages Notifications"},
|
|
||||||
voiceChat: {value: true, description: "Voice Chat Notifications"},
|
|
||||||
},
|
|
||||||
places: {
|
|
||||||
messages: {value: true, description: "Messages"},
|
|
||||||
pins: {value: true, description: "Pinned Messages"},
|
|
||||||
inbox: {value: true, description: "Inbox Messages"},
|
|
||||||
replies: {value: true, description: "Replies"},
|
|
||||||
mentions: {value: true, description: "Mentions"},
|
|
||||||
reactions: {value: true, description: "Reactions"},
|
|
||||||
threads: {value: true, description: "Threads"},
|
|
||||||
autocompletes: {value: true, description: "Autocomplete Entries"},
|
|
||||||
memberList: {value: true, description: "Members in List"},
|
|
||||||
voiceList: {value: true, description: "Members in Voice List"},
|
|
||||||
voiceChat: {value: true, description: "Members in Voice Chat"},
|
|
||||||
activity: {value: true, description: "Activity Page"},
|
|
||||||
channelList: {value: true, description: "Channel/Group List"},
|
|
||||||
recentDms: {value: true, description: "Group Notifications"}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.modulePatches = {
|
|
||||||
before: [
|
|
||||||
"ChannelCall",
|
|
||||||
"ChannelItem",
|
|
||||||
"ChannelMembers",
|
|
||||||
"PrivateChannel",
|
|
||||||
"PrivateChannelRecipients",
|
|
||||||
"Message",
|
|
||||||
"Messages",
|
|
||||||
"NowPlayingItem",
|
|
||||||
"ReactionsModalUsers",
|
|
||||||
"RTCConnectionVoiceUsers",
|
|
||||||
"SearchResults",
|
|
||||||
"UserSummaryItem",
|
|
||||||
"VoiceUsers"
|
|
||||||
],
|
|
||||||
after: [
|
|
||||||
"BlockedMessageGroup",
|
|
||||||
"ChannelPins",
|
|
||||||
"DirectMessage",
|
|
||||||
"PrivateChannel",
|
|
||||||
"Reactions",
|
|
||||||
"ReactionsModal",
|
|
||||||
"RecentMentions",
|
|
||||||
"RichUserMention",
|
|
||||||
"SearchResultsInner",
|
|
||||||
"ThreadCard",
|
|
||||||
"UserMention",
|
|
||||||
"VoiceUser",
|
|
||||||
"VoiceUsers"
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
this.patchPriority = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
onStart () {
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.ChannelStore, "getChannel", {after: e => {
|
|
||||||
if (e.returnValue && e.returnValue.isGroupDM()) return new BDFDB.DiscordObjects.Channel(Object.assign({}, e.returnValue, {rawRecipients: e.returnValue.rawRecipients.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id)), recipients: e.returnValue.recipients.filter(id => !id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(id))}))
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.StageChannelParticipantStore, "getMutableParticipants", {after: e => {
|
|
||||||
e.returnValue = e.returnValue.filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.RelationshipUtils, "addRelationship", {after: e => {
|
|
||||||
if (e.methodArguments[2] == BDFDB.DiscordConstants.RelationshipTypes.BLOCKED) BDFDB.DiscordUtils.rerenderAll();
|
|
||||||
}});
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.RelationshipUtils, "removeRelationship", {after: e => BDFDB.DiscordUtils.rerenderAll()});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.ReadStateStore, "getUnreadCount", {after: e => {
|
|
||||||
if (e.returnValue && this.settings.notifications.messages && e.returnValue < BDFDB.DiscordConstants.MAX_MESSAGES_PER_CHANNEL) {
|
|
||||||
let sub = 0, messages = [].concat(BDFDB.LibraryStores.MessageStore.getMessages(e.methodArguments[0])._array).reverse();
|
|
||||||
for (let i = 0; i < e.returnValue; i++) if (messages[i] && messages[i].blocked) sub++;
|
|
||||||
e.returnValue -= sub;
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.ReadStateStore, "hasUnread", {after: e => {
|
|
||||||
if (e.returnValue && this.settings.notifications.messages && BDFDB.LibraryStores.ReadStateStore.getUnreadCount(e.methodArguments[0]) < BDFDB.DiscordConstants.MAX_MESSAGES_PER_CHANNEL) {
|
|
||||||
let id = BDFDB.LibraryStores.ReadStateStore.lastMessageId(e.methodArguments[0]);
|
|
||||||
let message = id && BDFDB.LibraryStores.MessageStore.getMessage(e.methodArguments[0], id);
|
|
||||||
if (message && message.blocked) {
|
|
||||||
let oldestId = BDFDB.LibraryStores.ReadStateStore.getOldestUnreadMessageId(e.methodArguments[0]);
|
|
||||||
let messages = BDFDB.LibraryStores.MessageStore.getMessages(e.methodArguments[0]);
|
|
||||||
if (messages && oldestId) {
|
|
||||||
let index = messages._array.indexOf(messages._array.find(c => c.id == oldestId));
|
|
||||||
if (index > -1) return messages._array.slice(index).some(c => !c.blocked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.GuildReadStateStore, "hasUnread", {after: e => {
|
|
||||||
if (e.returnValue && this.settings.notifications.messages) return BDFDB.LibraryStores.GuildChannelStore.getChannels(e.methodArguments[0]).SELECTABLE.map(n => n.channel && n.channel.id).filter(n => n && n != "null").some(id => BDFDB.LibraryStores.ReadStateStore.hasUnread(id));
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.QuerySearchUtils, ["queryDMUsers", "queryFriends", "queryGuildUsers", "queryChannelUsers"], {after: e => {
|
|
||||||
if (!e.methodArguments[0].query) return;
|
|
||||||
e.returnValue = e.returnValue.filter(n => !n || !n.record || !n.record.id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.record.id));
|
|
||||||
}});
|
|
||||||
|
|
||||||
let muteTimeout;
|
|
||||||
let channelId = BDFDB.LibraryModules.RTCConnectionUtils.getChannelId();
|
|
||||||
let oldUnblockedConnectedUsers = [BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId())[channelId]].flat().filter(n => n && n.user && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {before: e => {
|
|
||||||
let type = e.methodArguments[0];
|
|
||||||
if (!this.settings.notifications.voiceChat || !["disconnect", "user_join", "user_leave", "user_moved"].includes(type)) return;
|
|
||||||
channelId = BDFDB.LibraryModules.RTCConnectionUtils.getChannelId();
|
|
||||||
if (channelId) {
|
|
||||||
let allConnectedUsers = [BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId())[channelId]].flat();
|
|
||||||
let unblockedUsers = allConnectedUsers.filter(n => n && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
let unmutedBlockedUsers = allConnectedUsers.filter(n => n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id) && !BDFDB.LibraryStores.MediaEngineStore.isLocalMute(n.userId));
|
|
||||||
if (unmutedBlockedUsers.length) {
|
|
||||||
BDFDB.TimeUtils.clear(muteTimeout);
|
|
||||||
muteTimeout = BDFDB.TimeUtils.timeout(_ => {
|
|
||||||
while (unmutedBlockedUsers.length) {
|
|
||||||
let userId = unmutedBlockedUsers.pop().user.id;
|
|
||||||
if (!BDFDB.LibraryStores.MediaEngineStore.isLocalMute(userId)) BDFDB.LibraryModules.MediaEngineUtils.toggleLocalMute(userId);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
if (unblockedUsers.length == oldUnblockedConnectedUsers.length) e.methodArguments[1] = 0;
|
|
||||||
oldUnblockedConnectedUsers = unblockedUsers;
|
|
||||||
}
|
|
||||||
else oldUnblockedConnectedUsers = [];
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.DiscordUtils.rerenderAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
onStop () {
|
|
||||||
BDFDB.DiscordUtils.rerenderAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
getSettingsPanel (collapseStates = {}) {
|
|
||||||
let settingsPanel;
|
|
||||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
|
||||||
collapseStates: collapseStates,
|
|
||||||
children: _ => {
|
|
||||||
let settingsItems = [];
|
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
|
||||||
title: "Disable",
|
|
||||||
children: Object.keys(this.defaults.notifications).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
|
||||||
type: "Switch",
|
|
||||||
plugin: this,
|
|
||||||
keys: ["notifications", key],
|
|
||||||
label: this.defaults.notifications[key].description,
|
|
||||||
value: this.settings.notifications[key]
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
|
||||||
title: "Remove",
|
|
||||||
children: Object.keys(this.defaults.places).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
|
||||||
type: "Switch",
|
|
||||||
plugin: this,
|
|
||||||
keys: ["places", key],
|
|
||||||
label: this.defaults.places[key].description,
|
|
||||||
value: this.settings.places[key]
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
return settingsItems;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onSettingsClosed () {
|
|
||||||
if (this.SettingsUpdated) {
|
|
||||||
delete this.SettingsUpdated;
|
|
||||||
BDFDB.DiscordUtils.rerenderAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processMessages (e) {
|
|
||||||
if (!this.settings.places.messages) return;
|
|
||||||
if (BDFDB.ArrayUtils.is(e.instance.props.channelStream)) {
|
|
||||||
let oldStream = e.instance.props.channelStream.filter(n => n.type != "MESSAGE_GROUP_BLOCKED"), newStream = [];
|
|
||||||
if (oldStream.length != e.instance.props.channelStream.length) {
|
|
||||||
for (let i in oldStream) {
|
|
||||||
let next = parseInt(i)+1;
|
|
||||||
if (oldStream[i].type != "DIVIDER" || (oldStream[next] && oldStream[i].type == "DIVIDER" && oldStream[next].type != "DIVIDER" && oldStream.slice(next).some(nextStream => nextStream.type != "DIVIDER"))) newStream.push(oldStream[i]);
|
|
||||||
}
|
|
||||||
let groupId, timestamp, author;
|
|
||||||
for (let i in newStream) {
|
|
||||||
if (newStream[i].type == "MESSAGE" && BDFDB.DiscordConstants.MessageTypeGroups.USER_MESSAGE.has(newStream[i].content.type) && groupId != newStream[i].groupId && timestamp && newStream[i].content.timestamp - timestamp < 600000) {
|
|
||||||
if (author && author.id == newStream[i].content.author.id && author.username == newStream[i].content.author.username) newStream[i] = Object.assign({}, newStream[i], {groupId: groupId});
|
|
||||||
author = newStream[i].content.author;
|
|
||||||
}
|
|
||||||
else author = null;
|
|
||||||
groupId = newStream[i].groupId;
|
|
||||||
timestamp = newStream[i].content.timestamp;
|
|
||||||
}
|
|
||||||
e.instance.props.channelStream = newStream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BDFDB.ObjectUtils.is(e.instance.props.messages) && BDFDB.ArrayUtils.is(e.instance.props.messages._array)) {
|
|
||||||
let messages = e.instance.props.messages;
|
|
||||||
e.instance.props.messages = new BDFDB.DiscordObjects.Messages(messages);
|
|
||||||
for (let key in messages) e.instance.props.messages[key] = messages[key];
|
|
||||||
e.instance.props.messages._array = [].concat(e.instance.props.messages._array.filter(n => !n.author || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.author.id)));
|
|
||||||
if (e.instance.props.oldestUnreadMessageId && e.instance.props.messages._array.every(n => n.id != e.instance.props.oldestUnreadMessageId)) e.instance.props.oldestUnreadMessageId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processBlockedMessageGroup (e) {
|
|
||||||
if (!this.settings.places.messages) return;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
processMessage (e) {
|
|
||||||
if (!this.settings.places.replies) return;
|
|
||||||
let repliedMessage = e.instance.props.childrenRepliedMessage;
|
|
||||||
if (repliedMessage && repliedMessage.props && repliedMessage.props.children && repliedMessage.props.children.props && repliedMessage.props.children.props.referencedMessage && repliedMessage.props.children.props.referencedMessage.message && repliedMessage.props.children.props.referencedMessage.message.author && BDFDB.LibraryStores.RelationshipStore.isBlocked(repliedMessage.props.children.props.referencedMessage.message.author.id)) {
|
|
||||||
delete e.instance.props.childrenRepliedMessage;
|
|
||||||
let header = e.instance.props.childrenHeader;
|
|
||||||
if (header && header.props) {
|
|
||||||
delete header.props.referencedMessage;
|
|
||||||
delete header.props.referencedUsernameProfile;
|
|
||||||
delete header.props.replyReference;
|
|
||||||
header.props.message = new BDFDB.DiscordObjects.Message(Object.assign({}, header.props.message, {messageReference: null}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processSearchResults (e) {
|
|
||||||
if (this.settings.places.messages && e.instance.props.blockCount && e.instance.props.search && e.instance.props.search.totalResults <= BDFDB.DiscordConstants.SEARCH_PAGE_SIZE) e.instance.props.search = Object.assign({}, e.instance.props.search, {totalResults: e.instance.props.search.totalResults - e.instance.props.blockCount});
|
|
||||||
}
|
|
||||||
|
|
||||||
processSearchResultsInner (e) {
|
|
||||||
if (!this.settings.places.messages || !e.instance.props.search) return;
|
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.searchresultsblocked]]});
|
|
||||||
if (index > -1) children.splice(index, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
processChannelPins (e) {
|
|
||||||
if (this.settings.places.pins && e.returnvalue.props && e.returnvalue.props.children && e.returnvalue.props.children.props && BDFDB.ArrayUtils.is(e.returnvalue.props.children.props.messages)) e.returnvalue.props.children.props.messages = e.returnvalue.props.children.props.messages.filter(n => !n || !n.author || !n.author.id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.author.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
processRecentMentions (e) {
|
|
||||||
if (this.settings.places.inbox && BDFDB.ArrayUtils.is(e.returnvalue.props.messages)) e.returnvalue.props.messages = e.returnvalue.props.messages.filter(n => !n || !n.author || !n.author.id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.author.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
processReactions (e) {
|
|
||||||
if (!this.settings.places.reactions) return;
|
|
||||||
if (!e.returnvalue || !e.returnvalue.props.children) return;
|
|
||||||
let emojiArrayIndex = e.returnvalue.props.children.findIndex(n => BDFDB.ArrayUtils.is(n) && n[0] && n[0].props && n[0].props.emoji);
|
|
||||||
if (emojiArrayIndex == -1) return;
|
|
||||||
for (let i in e.returnvalue.props.children[emojiArrayIndex]) {
|
|
||||||
let reaction = e.returnvalue.props.children[emojiArrayIndex][i];
|
|
||||||
let nativeReaction = reaction.props.message.reactions.find(n => n && n.emoji == reaction.props.emoji);
|
|
||||||
if (nativeReaction) reaction.props.count = nativeReaction.count;
|
|
||||||
let reactions = BDFDB.ObjectUtils.toArray(BDFDB.LibraryStores.MessageReactionsStore.getReactions(reaction.props.message.channel_id, reaction.props.message.id, reaction.props.emoji));
|
|
||||||
if (!reactions || !reactions.length) return;
|
|
||||||
let blocked = 0;
|
|
||||||
reactions.forEach(n => {if (n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id)) blocked++;});
|
|
||||||
if (blocked) {
|
|
||||||
reaction.props.count -= blocked;
|
|
||||||
if (!reaction.props.count) e.returnvalue.props.children[emojiArrayIndex][i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!e.returnvalue.props.children[emojiArrayIndex].filter(n => n).length) return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
processReactionsModal (e) {
|
|
||||||
if (!this.settings.places.reactions) return;
|
|
||||||
let [reactionEntries, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children, {filter: n => n && n.props && n.props.emoji});
|
|
||||||
if (index == -1) return;
|
|
||||||
for (let i in reactionEntries) {
|
|
||||||
let reaction = reactionEntries[i];
|
|
||||||
reaction.props = Object.assign({}, reaction.props);
|
|
||||||
let reactions = BDFDB.ObjectUtils.toArray(BDFDB.LibraryStores.MessageReactionsStore.getReactions(e.instance.props.message.channel_id, e.instance.props.message.id, reaction.props.emoji));
|
|
||||||
if (reactions && reactions.length) {
|
|
||||||
let blocked = 0;
|
|
||||||
reactions.forEach(n => {if (n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id)) blocked++;});
|
|
||||||
if (blocked) reaction.props.count -= blocked;
|
|
||||||
if (!reaction.props.count) reactionEntries[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processReactionsModalUsers (e) {
|
|
||||||
if (this.settings.places.reactions && BDFDB.ArrayUtils.is(e.instance.props.reactors)) e.instance.props.reactors = e.instance.props.reactors.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
processThreadCard (e) {
|
|
||||||
if (!this.settings.places.threads) return;
|
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {filter: n => n && n.type && n.type.toString().indexOf(".getMostRecentMessage") > -1});
|
|
||||||
if (index > -1 && children[index].props && children[index].props.channel) {
|
|
||||||
let message = BDFDB.LibraryStores.MessageStore.getMessage(children[index].props.channel.id, children[index].props.channel.lastMessageId);
|
|
||||||
if (message && BDFDB.LibraryStores.RelationshipStore.isBlocked(message.author.id)) children[index] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processChannelMembers (e) {
|
|
||||||
if (!this.settings.places.memberList) return;
|
|
||||||
let hiddenRows = false, newRows = new Array(e.instance.props.rows.length), newGroups = new Array(e.instance.props.groups.length);
|
|
||||||
for (let i in e.instance.props.groups) newGroups[i] = Object.assign({}, e.instance.props.groups[i]);
|
|
||||||
for (let i in e.instance.props.rows) {
|
|
||||||
let row = e.instance.props.rows[i];
|
|
||||||
if (!row || row.type != "MEMBER") newRows[i] = row;
|
|
||||||
else if (!row.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(row.user.id)) newRows[i] = row;
|
|
||||||
else {
|
|
||||||
hiddenRows = true;
|
|
||||||
let found = false, rowIndex = i - 1;
|
|
||||||
while (!found && rowIndex > -1) {
|
|
||||||
if (newRows[rowIndex] && newRows[rowIndex].type == "GROUP") {
|
|
||||||
found = true;
|
|
||||||
let groupIndex = newGroups.findIndex(r => r.id == newRows[rowIndex].id);
|
|
||||||
if (groupIndex > -1) {
|
|
||||||
newGroups[groupIndex].count = newGroups[groupIndex].count - 1;
|
|
||||||
newRows[rowIndex].count = newGroups[groupIndex].count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else rowIndex--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hiddenRows) {
|
|
||||||
let indexSum = 0;
|
|
||||||
for (let i in newGroups) {
|
|
||||||
newGroups[i].index = indexSum;
|
|
||||||
if (newGroups[i].count > 0) indexSum += (newGroups[i].count + 1);
|
|
||||||
}
|
|
||||||
for (let i in newRows) if (newRows[i] && newRows[i].type == "GROUP" && newRows[i].count <= 0) newRows[i] = undefined;
|
|
||||||
const removeEmptyWithin = (array, filter) => {
|
|
||||||
let reversed = [].concat(array).reverse(), suffixLength = 0;
|
|
||||||
for (let i in reversed) if (reversed[i] !== undefined) {
|
|
||||||
suffixLength = parseInt(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return [].concat(array.filter(filter), new Array(suffixLength))
|
|
||||||
};
|
|
||||||
e.instance.props.rows = removeEmptyWithin(newRows, n => n);
|
|
||||||
e.instance.props.groups = removeEmptyWithin(newGroups, g => g && g.count > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processPrivateChannelRecipients (e) {
|
|
||||||
if (this.settings.places.voiceChat && e.instance.props.channel && e.instance.props.channel.isGroupDM()) e.instance.props.channel = new BDFDB.DiscordObjects.Channel(Object.assign({}, e.instance.props.channel, {rawRecipients: e.instance.props.channel.rawRecipients.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id)), recipients: e.instance.props.channel.recipients.filter(id => !id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(id))}));
|
|
||||||
}
|
|
||||||
|
|
||||||
processNowPlayingItem (e) {
|
|
||||||
if (!this.settings.places.activity) return;
|
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.instance, {name: "NowPlayingHeader"});
|
|
||||||
if (index > -1) for (let child of children) if (child && child.props && child.props.party) {
|
|
||||||
child.props.party = Object.assign({}, child.props.party);
|
|
||||||
if (child.props.party.priorityMembers) {
|
|
||||||
child.props.party.priorityMembers = child.props.party.priorityMembers.filter(n => !n || !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
if (!child.props.party.priorityMembers.length) child.props.party.priorityMembers.push({user: new BDFDB.DiscordObjects.User({id: 0, username: ""})});
|
|
||||||
}
|
|
||||||
if (child.props.party.partiedMembers) child.props.party.partiedMembers = child.props.party.partiedMembers.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id));
|
|
||||||
if (child.props.party.voiceChannels) for (let i in child.props.party.voiceChannels) child.props.party.voiceChannels[i] = Object.assign({}, child.props.party.voiceChannels[i], {members: child.props.party.voiceChannels[i].members.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id))});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processChannelItem (e) {
|
|
||||||
if (!this.settings.places.voiceList) return;
|
|
||||||
let channelInfo = BDFDB.ReactUtils.findChild(e.instance.props.children, {props: [["className", BDFDB.disCN.channelinfo]]});
|
|
||||||
if (channelInfo && channelInfo.props && channelInfo.props.children && channelInfo.props.children.props && BDFDB.ArrayUtils.is(channelInfo.props.children.props.voiceStates)) {
|
|
||||||
let newVoiceStates = [].concat(channelInfo.props.children.props.voiceStates).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
if (channelInfo.props.children.props.channel.userLimit) channelInfo.props.children.props.channel = new BDFDB.DiscordObjects.Channel(Object.assign({}, channelInfo.props.children.props.channel, {userLimit: channelInfo.props.children.props.channel.userLimit - (channelInfo.props.children.props.voiceStates.length - newVoiceStates.length)}));
|
|
||||||
channelInfo.props.children.props.voiceStates = newVoiceStates;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processVoiceUser (e) {
|
|
||||||
if (this.settings.places.voiceList && e.instance.props.user && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.user.id)) return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
processVoiceUsers (e) {
|
|
||||||
if (!this.settings.places.voiceList || !BDFDB.ArrayUtils.is(e.instance.props.voiceStates)) return;
|
|
||||||
if (!e.returnvalue) {
|
|
||||||
if (e.instance.props.children && e.instance.props.children.props && e.instance.props.children.props.numAudience) e.instance.props.children.props.numAudience = BDFDB.LibraryStores.StageChannelParticipantStore.getMutableParticipants(e.instance.props.channel.id).length;
|
|
||||||
e.instance.props.voiceStates = [].concat(e.instance.props.voiceStates).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (e.instance.props.children && e.instance.props.children.props && e.instance.props.children.props.numAudience === 0) return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processRTCConnectionVoiceUsers (e) {
|
|
||||||
if (!this.settings.places.voiceChat || !e.instance.props.voiceStates) return;
|
|
||||||
e.instance.props.voiceStates = [].concat(e.instance.props.voiceStates).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
processDirectMessage (e) {
|
|
||||||
if (!this.settings.places.recentDms || !e.instance.props.channel) return;
|
|
||||||
if (e.instance.props.channel.isGroupDM()) {
|
|
||||||
if (!e.instance.props.channel.name) {
|
|
||||||
let tooltip = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ListItemTooltip"});
|
|
||||||
if (tooltip) tooltip.props.text = this.getGroupName(e.instance.props.channel.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.channel.getRecipientId())) e.returnvalue = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processPrivateChannel (e) {
|
|
||||||
if (!this.settings.places.channelList || !e.instance.props.channel) return;
|
|
||||||
if (e.instance.props.channel.isGroupDM()) {
|
|
||||||
if (!e.returnvalue) {
|
|
||||||
e.instance.props.channel = new BDFDB.DiscordObjects.Channel(Object.assign({}, e.instance.props.channel, {rawRecipients: e.instance.props.channel.rawRecipients.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id)), recipients: e.instance.props.channel.recipients.filter(id => !id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(id))}));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!e.instance.props.channel.name) {
|
|
||||||
let wrapper = e.returnvalue && e.returnvalue.props.children && e.returnvalue.props.children.props && typeof e.returnvalue.props.children.props.children == "function" ? e.returnvalue.props.children : e.returnvalue;
|
|
||||||
if (typeof wrapper.props.children == "function") {
|
|
||||||
let childrenRender = wrapper.props.children;
|
|
||||||
wrapper.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
|
||||||
let children = childrenRender(...args);
|
|
||||||
children.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(e.instance.props.channel.id)});
|
|
||||||
return children;
|
|
||||||
}, "Error in Children Render of PrivateChannel!", this);
|
|
||||||
}
|
|
||||||
else wrapper.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(e.instance.props.channel.id)});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (e.returnvalue && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.channel.getRecipientId())) e.returnvalue = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processChannelCall (e) {
|
|
||||||
if (!this.settings.places.voiceChat) return;
|
|
||||||
if (BDFDB.ArrayUtils.is(e.instance.props.participants)) e.instance.props.participants = [].concat(e.instance.props.participants).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
if (BDFDB.ArrayUtils.is(e.instance.props.filteredParticipants)) e.instance.props.filteredParticipants = [].concat(e.instance.props.filteredParticipants).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
processUserSummaryItem (e) {
|
|
||||||
if (this.settings.places.memberList && BDFDB.ArrayUtils.is(e.instance.props.users)) e.instance.props.users = [].concat(e.instance.props.users).filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
processRichUserMention (e) {
|
|
||||||
if (e.instance.props.id && this.settings.places.mentions && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.id)) return BDFDB.ReactUtils.createElement("span", {
|
|
||||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.mention, BDFDB.disCN.mentionwrapper, e.instance.props.className),
|
|
||||||
children: ["@" + BDFDB.LanguageUtils.LanguageStrings.UNKNOWN_USER]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
processUserMention (e) {
|
|
||||||
if (e.instance.props.userId && this.settings.places.mentions && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.userId)) {
|
|
||||||
let childrenRender = e.returnvalue.props.children;
|
|
||||||
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
|
||||||
let children = childrenRender(...args);
|
|
||||||
if (children && children.props) children.props.children = "@" + BDFDB.LanguageUtils.LanguageStrings.UNKNOWN_USER;
|
|
||||||
return children;
|
|
||||||
}, "Error in Children Render of PrivateChannel!", this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getGroupName (channelId) {
|
|
||||||
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(channelId);
|
|
||||||
if (channel.name) return channel.name;
|
|
||||||
let recipients = channel.recipients.map(BDFDB.LibraryStores.UserStore.getUser).filter(n => n && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id));
|
|
||||||
return recipients.length > 0 ? recipients.map(u => u.toString()).join(", ") : BDFDB.LanguageUtils.LanguageStrings.UNNAMED;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
|
||||||
})();
|
|
|
@ -45,8 +45,8 @@ myKeys =
|
||||||
[ ((myModMask, xK_n ), spawn myTerminal ) -- %! Launch terminal
|
[ ((myModMask, xK_n ), spawn myTerminal ) -- %! Launch terminal
|
||||||
, ((myModMask, xK_e ), spawn myLauncher ) -- %! Launch rofi
|
, ((myModMask, xK_e ), spawn myLauncher ) -- %! Launch rofi
|
||||||
, ((myModMask, xK_s ), spawn myScrot ) -- %! Take screenshot
|
, ((myModMask, xK_s ), spawn myScrot ) -- %! Take screenshot
|
||||||
, ((myModMask .|. controlMask, xK_w ), kill ) -- %! Close the focused window
|
, ((myModMask, xK_Escape ), kill ) -- %! Close the focused window
|
||||||
, ((myModMask .|. shiftMask, xK_q ), io exitSuccess ) -- %! Quit xmonad
|
, ((myModMask .|. controlMask, xK_Escape ), io exitSuccess ) -- %! Quit xmonad
|
||||||
|
|
||||||
-- multimedia
|
-- multimedia
|
||||||
, ((noModMask, xF86XK_AudioPlay ), spawn "mpc toggle" ) -- %! Play/Pause music
|
, ((noModMask, xF86XK_AudioPlay ), spawn "mpc toggle" ) -- %! Play/Pause music
|
||||||
|
@ -69,8 +69,8 @@ myKeys =
|
||||||
, ((myModMask .|. shiftMask, xK_Up ), windows W.swapUp ) -- %! Swap the focused window with the previous window
|
, ((myModMask .|. shiftMask, xK_Up ), windows W.swapUp ) -- %! Swap the focused window with the previous window
|
||||||
|
|
||||||
-- master slave
|
-- master slave
|
||||||
, ((myModMask, xK_space ), windows W.focusMaster ) -- %! Move focus to the master window
|
, ((myModMask, xK_Return ), windows W.focusMaster ) -- %! Move focus to the master window
|
||||||
, ((myModMask .|. shiftMask, xK_space ), windows W.swapMaster ) -- %! Swap the focused window with the master window
|
, ((myModMask .|. shiftMask, xK_Return ), windows W.swapMaster ) -- %! Swap the focused window with the master window
|
||||||
, ((myModMask, xK_Page_Up ), sendMessage Shrink ) -- %! Shrink the master area
|
, ((myModMask, xK_Page_Up ), sendMessage Shrink ) -- %! Shrink the master area
|
||||||
, ((myModMask, xK_Page_Down), sendMessage Expand ) -- %! Expand the master area
|
, ((myModMask, xK_Page_Down), sendMessage Expand ) -- %! Expand the master area
|
||||||
, ((myModMask .|. shiftMask, xK_Page_Up ), sendMessage (IncMasterN 1) ) -- %! Increase the number of windows in the master area
|
, ((myModMask .|. shiftMask, xK_Page_Up ), sendMessage (IncMasterN 1) ) -- %! Increase the number of windows in the master area
|
||||||
|
|
Loading…
Reference in a new issue