dotfiles

My PC Dotfiles & Website
commit e1ec889188d38c9a863f7cdb9a77ad571a5da9f4
parent a6808736ca8b0c03d64dadb6bd424fcf5b2388fb
Author: maydayv7 <maydayv7@gmail.com>
Date:   Thu,  5 Oct 2023 12:46:31 +0530

refactor: Move out proprietary files

Diffstat:

M.gitattributes | 5++---
M.prettierignore | 1-
MREADME.md | 1-
Mconfiguration.nix | 15++++++++++++---
Mfiles/README.md | 4++--
Mfiles/default.nix | 21++++++---------------
Dfiles/discord/plugins/CreationDate.plugin.js | 309-------------------------------------------------------------------------------
Dfiles/discord/plugins/DoubleClickToEdit.plugin.js | 328-------------------------------------------------------------------------------
Dfiles/discord/plugins/ReadAllNotificationsButton.plugin.js | 687-------------------------------------------------------------------------------
Dfiles/discord/plugins/ShowHiddenChannels.plugin.js | 986-------------------------------------------------------------------------------
Dfiles/discord/plugins/SplitLargeMessages.plugin.js | 350-------------------------------------------------------------------------------
Dfiles/discord/plugins/TypingUsersAvatars.plugin.js | 193-------------------------------------------------------------------------------
Dfiles/discord/theme.css | 1-
Dfiles/fonts/proprietary/ms-core/arial.ttf | 0
Dfiles/fonts/proprietary/ms-core/calibri.ttf | 0
Dfiles/fonts/proprietary/ms-core/cour.ttf | 0
Dfiles/fonts/proprietary/ms-core/symbol.ttf | 0
Dfiles/fonts/proprietary/ms-core/times.ttf | 0
Dfiles/fonts/proprietary/ms-core/wingding.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Black.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Bold.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Book.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Light.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Medium.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Regular.ttf | 0
Dfiles/fonts/proprietary/oneplus-slate/OnePlusSlate-Thin.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Black.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-BlackItalic.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Bold.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-BoldItalic.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Italic.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Light.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-LightItalic.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Medium.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-MediumItalic.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Regular.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-Thin.ttf | 0
Dfiles/fonts/proprietary/product-sans/ProductSans-ThinItalic.ttf | 0
Mfiles/gnome/dconf.nix | 4+---
Dfiles/images/wallpapers/Beauty.jpg | 0
Dfiles/images/wallpapers/City.jpg | 0
Dfiles/images/wallpapers/Firewatch.jpg | 0
Dfiles/images/wallpapers/Future.jpg | 0
Dfiles/images/wallpapers/Island.jpg | 0
Dfiles/images/wallpapers/Metro.jpg | 0
Dfiles/images/wallpapers/Neon.jpg | 0
Dfiles/images/wallpapers/Saturn.jpg | 0
Dfiles/images/wallpapers/Shards.jpg | 0
Dfiles/images/wallpapers/Sunrise.jpg | 0
Dfiles/images/wallpapers/Sunset.jpg | 0
Dfiles/images/wallpapers/Tomorrow.jpg | 0
Mflake.lock | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mflake.nix | 3+++
Mmodules/apps/discord.nix | 2+-
Mmodules/apps/office.nix | 2+-
Mmodules/gui/gnome.nix | 3++-
Mmodules/nix/index.nix | 1-
Dpackages/fonts.nix | 20--------------------
58 files changed, 100 insertions(+), 2908 deletions(-)

diff --git a/.gitattributes b/.gitattributes @@ -1,2 +1 @@ -*.secret binary -files/discord/plugins/* linguist-vendored -\ No newline at end of file +*.secret binary +\ No newline at end of file diff --git a/.prettierignore b/.prettierignore @@ -1,5 +1,4 @@ result -files/discord/plugins # Formatting Errors site/templates/macros/edit.html diff --git a/README.md b/README.md @@ -614,7 +614,6 @@ You can navigate to the `README`'s present in the various directories to know mo - **GNOME Extensions**: - Fly Pie - VS Code Themes and Plugins -- Discord Plugins - [Wine](./packages/wine) Applications </details> diff --git a/configuration.nix b/configuration.nix @@ -67,17 +67,26 @@ in # Custom Packages apps = map.modules ./scripts (name: lib.mkApp {drv = call name;}) // {default = self.apps."${system}".nixos;}; - packages = map.modules ./packages call // map.modules ./scripts call // {default = self.packages."${system}".dotfiles;}; + packages = + map.modules ./packages call + // map.modules ./scripts call + // {default = self.packages."${system}".dotfiles;} + // proprietary.packages."${system}"; }) // { # Overrides overlays = map.modules ./packages/overlays import; ## Custom Library Functions ## - lib = lib.util // {nixpkgs = library.lib;}; + lib = + lib.util + // { + inherit platforms; + nixpkgs = library.lib; + }; ## Program Configuration and 'dotfiles' ## - files = import ./files lib self.legacyPackages."${head platforms}"; + files = import ./files lib inputs self.legacyPackages."${head platforms}"; ## Custom Configuration Modules ## nixosModules = diff --git a/files/README.md b/files/README.md @@ -4,9 +4,8 @@ The `files` directory is used to store all my plain-text program configuration f - [`archive`](./archive) - Old, Archived Files - [`ascii`](./ascii) - Personal Collection of beautiful Ascii Art -- [`discord`](./discord) - `discord` Chat Theming and Plugins - [`firefox`](./firefox) - `firefox` Web Browser Theming -- [`fonts`](./fonts) - Proprietary Fonts and Configuration +- [`fonts`](./fonts) - Font Configuration - [`git`](./git) - Configuration for `git` Version Control - [`gnome`](./gnome) - Configuration Files for GNOME Desktop - [`gpg`](./gpg) - Encrypted GPG Keys @@ -15,6 +14,7 @@ The `files` directory is used to store all my plain-text program configuration f - [`nano`](./nano) - `nano` Text Editor Global Configuration - [`neofetch`](./neofetch) - `neofetch` CLI Theming - [`plank`](./plank) - `plank` Dock Theming +- [`proprietary`](https://github.com/maydayv7/proprietary) - Custom Proprietary Files - [`templates`](./templates) - Document Templates - [`vscode`](./vscode) - Visual Studio Code Editor Configuration - [`wine`](./wine) - Configuration and Theming for `wine` applications diff --git a/files/default.nix b/files/default.nix @@ -1,4 +1,4 @@ -lib: pkgs: let +lib: inputs: pkgs: let inherit (lib.util) build map; inherit (builtins) fromJSON readFile replaceStrings; in rec { @@ -15,12 +15,6 @@ in rec { # ASCII Art ascii = map.files' ./ascii lib.id ""; - # Discord Chat - discord = { - plugins = ./discord/plugins; - theme = readFile ./discord/theme.css; - }; - # Neofetch fetch = readFile ./neofetch/config.conf; @@ -28,10 +22,7 @@ in rec { firefox.theme = readFile ./firefox/userContent.css; # Custom Fonts - fonts = { - path = ./fonts/proprietary; - config = readFile ./fonts/fontconfig.xml; - }; + fonts.config = readFile ./fonts/fontconfig.xml; # 'git' Version Control git.hooks = ./git/hooks; @@ -50,10 +41,7 @@ in rec { gtk.bookmarks = readFile ./gtk/bookmarks; # Pictures - images = { - profile = ./images/Profile.png; - wallpapers = ./images/wallpapers; - }; + images.profile = ./images/Profile.png; # Persisted Files persist = "/nix/state"; @@ -65,6 +53,9 @@ in rec { theme = readFile ./plank/dock.theme; }; + # Custom Proprietary Files + proprietary = inputs.proprietary.files; + # Nano Text Editor nano = readFile ./nano/nanorc; diff --git a/files/discord/plugins/CreationDate.plugin.js b/files/discord/plugins/CreationDate.plugin.js @@ -1,308 +0,0 @@ -/** - * @name CreationDate - * @author DevilBro - * @authorId 278543574059057154 - * @version 1.4.6 - * @description Displays the Creation Date of an Account in the UserPopout and UserModal - * @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/CreationDate/ - */ - -module.exports = (_ => { - const config = { - "info": { - "name": "CreationDate", - "author": "DevilBro", - "version": "1.4.6", - "description": "Displays the Creation Date of an Account in the UserPopout and UserModal" - }, - "changeLog": { - "fixed": { - "User Popout": "Fixing Stuff for the User Popout Update, thanks Discord" - } - } - }; - - return (window.Lightcord && !Node.prototype.isPrototypeOf(window.Lightcord) || window.LightCord && !Node.prototype.isPrototypeOf(window.LightCord) || window.Astra && !Node.prototype.isPrototypeOf(window.Astra)) ? class { - getName () {return config.info.name;} - getAuthor () {return config.info.author;} - getVersion () {return config.info.version;} - getDescription () {return "Do not use LightCord!";} - load () {BdApi.alert("Attention!", "By using LightCord you are risking your Discord Account, due to using a 3rd Party Client. Switch to an official Discord Client (https://discord.com/) with the proper BD Injection (https://betterdiscord.app/)");} - start() {} - stop() {} - } : !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class { - getName () {return config.info.name;} - getAuthor () {return config.info.author;} - getVersion () {return config.info.version;} - getDescription () {return `The Library Plugin needed for ${config.info.name} is missing. Open the Plugin Settings to download it. \n\n${config.info.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 ${config.info.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(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.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 ${config.info.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]) => { - return class CreationDate extends Plugin { - onLoad () { - this.defaults = { - general: { - displayText: {value: true, description: "Display '{{presuffix}}' in the Date"} - }, - places: { - userPopout: {value: true, description: "User Popouts"}, - userProfile: {value: true, description: "User Profile Modal"} - }, - dates: { - creationDate: {value: {}, description: "Creation Date"}, - } - }; - - this.patchedModules = { - after: { - UserPopoutInfo: "UserPopoutInfo", - UserProfileModalHeader: "default" - } - }; - - } - - onStart () { - BDFDB.PatchUtils.forceAllUpdates(this); - } - - onStop () { - BDFDB.PatchUtils.forceAllUpdates(this); - } - - getSettingsPanel (collapseStates = {}) { - let settingsPanel; - return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, { - collapseStates: collapseStates, - children: _ => { - let settingsItems = []; - - settingsItems.push(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Switch", - plugin: this, - keys: ["general", key], - label: key == "displayText" ? this.defaults.general[key].description.replace("{{presuffix}}", this.labels.created_at.replace("{{time}}", "").trim()) : this.defaults.general[key].description, - value: this.settings.general[key] - }))); - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { - className: BDFDB.disCN.marginbottom8 - })); - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, { - title: "Add Date in:", - 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] - })) - })); - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { - className: BDFDB.disCN.marginbottom8 - })); - - settingsItems.push(Object.keys(this.defaults.dates).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.DateInput, Object.assign({}, this.settings.dates[key], { - label: this.defaults.dates[key].description, - prefix: _ => (this.settings.general.displayText && this.labels.created_at.split("{{time}}")[0] || "").trim(), - suffix: _ => (this.settings.general.displayText && this.labels.created_at.split("{{time}}")[1] || "").trim(), - onChange: valueObj => { - this.SettingsUpdated = true; - this.settings.dates[key] = valueObj; - BDFDB.DataUtils.save(this.settings.dates, this, "dates"); - } - })))); - - return settingsItems.flat(10); - } - }); - } - - onSettingsClosed () { - if (this.SettingsUpdated) { - delete this.SettingsUpdated; - BDFDB.PatchUtils.forceAllUpdates(this); - } - } - - processUserPopoutInfo (e) { - if (e.instance.props.user && this.settings.places.userPopout) { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["DiscordTag", "ColoredFluxTag"]}); - if (index > -1) this.injectDate(children, index + 1, e.instance.props.user); - } - } - - processUserProfileModalHeader (e) { - if (e.instance.props.user && this.settings.places.userProfile) { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["DiscordTag", "ColoredFluxTag"]}); - if (index > -1) this.injectDate(children, index + 1, e.instance.props.user); - } - } - - injectDate (children, index, user) { - let timestamp = BDFDB.LibraryComponents.DateInput.format(this.settings.dates.creationDate, user.createdAt); - children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, { - className: BDFDB.disCNS._creationdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow, - children: this.settings.general.displayText ? this.labels.created_at.replace("{{time}}", timestamp) : timestamp - })); - } - - setLabelsByLanguage () { - switch (BDFDB.LanguageUtils.getLanguage().id) { - case "bg": // Bulgarian - return { - created_at: "Създадено на {{time}}" - }; - case "cs": // Czech - return { - created_at: "Vytvořeno {{time}}" - }; - case "da": // Danish - return { - created_at: "Oprettet den {{time}}" - }; - case "de": // German - return { - created_at: "Erstellt am {{time}}" - }; - case "el": // Greek - return { - created_at: "Δημιουργήθηκε στις {{time}}" - }; - case "es": // Spanish - return { - created_at: "Creado el {{time}}" - }; - case "fi": // Finnish - return { - created_at: "Luotu {{time}}" - }; - case "fr": // French - return { - created_at: "Créé le {{time}}" - }; - case "hi": // Hindi - return { - created_at: "{{time}} को बनाया गया" - }; - case "hr": // Croatian - return { - created_at: "Izrađeno {{time}}" - }; - case "hu": // Hungarian - return { - created_at: "Létrehozva: {{time}}" - }; - case "it": // Italian - return { - created_at: "Creato il {{time}}" - }; - case "ja": // Japanese - return { - created_at: "{{time}}に作成" - }; - case "ko": // Korean - return { - created_at: "{{time}}에 생성됨" - }; - case "lt": // Lithuanian - return { - created_at: "Sukurta {{time}}" - }; - case "nl": // Dutch - return { - created_at: "Gemaakt op {{time}}" - }; - case "no": // Norwegian - return { - created_at: "Opprettet {{time}}" - }; - case "pl": // Polish - return { - created_at: "Utworzono {{time}}" - }; - case "pt-BR": // Portuguese (Brazil) - return { - created_at: "Criado em {{time}}" - }; - case "ro": // Romanian - return { - created_at: "Creat la {{time}}" - }; - case "ru": // Russian - return { - created_at: "Создано {{time}}" - }; - case "sv": // Swedish - return { - created_at: "Skapad {{time}}" - }; - case "th": // Thai - return { - created_at: "สร้างเมื่อ {{time}}" - }; - case "tr": // Turkish - return { - created_at: "{{time}} tarihinde oluşturuldu" - }; - case "uk": // Ukrainian - return { - created_at: "Створено {{time}}" - }; - case "vi": // Vietnamese - return { - created_at: "Được tạo vào {{time}}" - }; - case "zh-CN": // Chinese (China) - return { - created_at: "创建于{{time}}" - }; - case "zh-TW": // Chinese (Taiwan) - return { - created_at: "創建於{{time}}" - }; - default: // English - return { - created_at: "Created on {{time}}" - }; - } - } - }; - })(window.BDFDB_Global.PluginUtils.buildPlugin(config)); -})(); -\ No newline at end of file diff --git a/files/discord/plugins/DoubleClickToEdit.plugin.js b/files/discord/plugins/DoubleClickToEdit.plugin.js @@ -1,328 +0,0 @@ -/** - * @name Double Click To Edit - * @author Farcrada, original idea by Jiiks - * @version 9.4.4 - * @description Double click a message you wrote to quickly edit it. - * - * @invite qH6UWCwfTu - * @website https://github.com/Farcrada/DiscordPlugins/ - * @source https://github.com/Farcrada/DiscordPlugins/blob/master/Double-click-to-edit/DoubleClickToEdit.plugin.js - */ - -/** @type {typeof import("react")} */ -const React = BdApi.React, - - { Webpack, Webpack: { Filters }, Data } = BdApi, - - config = { - info: { - name: "Double Click To Edit", - id: "DoubleClickToEdit", - description: "Double click a message you wrote to quickly edit it", - version: "9.4.4", - author: "Farcrada", - updateUrl: "https://raw.githubusercontent.com/Farcrada/DiscordPlugins/master/Double-click-to-edit/DoubleClickToEdit.plugin.js" - } - }, - - blacklist = [ - //Object - "video", - "emoji", - //Classes - "content", - "reactionInner" - ]; - - -module.exports = class DoubleClickToEdit { - - - 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 { - //Classes - this.selectedClass = Webpack.getModule(Filters.byProps("message", "selected")).selected; - this.messagesWrapper = Webpack.getModule(Filters.byProps("empty", "messagesWrapper")).messagesWrapper; - - //Copy to clipboard - this.copyToClipboard = Webpack.getModule(Filters.byProps("clipboard", "app")).clipboard.copy; - - //Reply functions - this.replyToMessage = Webpack.getModule(m => m?.toString?.()?.replace('\n', '')?.search(/(channel:[\w|\w],message:[\w|\w],shouldMention:!)/) > -1, { searchExports: true }) - this.getChannel = Webpack.getModule(Filters.byProps("getChannel", "getDMFromUserId")).getChannel; - - //Stores - this.MessageStore = Webpack.getModule(Filters.byProps("receiveMessage", "editMessage")); - this.CurrentUserStore = Webpack.getModule(Filters.byProps("getCurrentUser")); - - //Settings - const filter = Webpack.Filters.byStrings(`["tag","children","className","faded","disabled","required","error"]`), - target = Webpack.getModule(m => Object.values(m).some(filter)); - this.FormTitle = target[Object.keys(target).find(k => filter(target[k]))]; - this.RadioItem = Webpack.getModule(m => m?.Sizes?.NONE, { searchExports: true }); - this.SwitchItem = Webpack.getModule(Filters.byStrings("=e.note")); - - - //Events - global.document.addEventListener('dblclick', this.doubleclickFunc); - - //Load settings - //Edit - this.doubleClickToEditModifier = Data.load(config.info.id, "doubleClickToEditModifier") ?? false; - this.editModifier = Data.load(config.info.id, "editModifier") ?? "shift"; - //Reply - this.doubleClickToReply = Data.load(config.info.id, "doubleClickToReply") ?? false; - this.doubleClickToReplyModifier = Data.load(config.info.id, "doubleClickToReplyModifier") ?? false; - this.replyModifier = Data.load(config.info.id, "replyModifier") ?? "shift"; - //Copy - this.doubleClickToCopy = Data.load(config.info.id, "doubleClickToCopy") ?? false; - this.copyModifier = Data.load(config.info.id, "copyModifier") ?? "shift"; - - } - catch (err) { - try { - console.error("Attempting to stop after starting error...", err); - this.stop(); - } - catch (err) { - console.error(config.info.name + ".stop()", err); - } - } - } - - //By doing this we make sure we're able to remove our event - //otherwise it gets stuck on the page and never actually unloads. - doubleclickFunc = (e) => this.handler(e); - - stop = () => document.removeEventListener('dblclick', this.doubleclickFunc); - - getSettingsPanel() { - //Anonymous function to preserve the this scope, - //which also makes it an anonymous functional component; - //Pretty neat. - return () => { - //Edit - const [editEnableModifier, setEditEnableModifier] = React.useState(this.doubleClickToEditModifier), - [editModifier, setEditModifier] = React.useState(this.editModifier), - //Reply - [reply, setReply] = React.useState(this.doubleClickToReply), - [replyEnableModifier, setReplyEnableModifier] = React.useState(this.doubleClickToReplyModifier), - [replyModifier, setReplyModifier] = React.useState(this.replyModifier), - //Copy - [copy, setCopy] = React.useState(this.doubleClickToCopy), - [copyModifier, setCopyModifier] = React.useState(this.copyModifier); - - return [ - //Edit - React.createElement(this.SwitchItem, { - //The state that is loaded with the default value - value: editEnableModifier, - note: "Enable modifier for double clicking to edit", - //Since onChange passes the current state we can simply invoke it as such - onChange: (newState) => { - //Saving the new state - this.doubleClickToEditModifier = newState; - Data.save(config.info.id, "doubleClickToEditModifier", newState); - setEditEnableModifier(newState); - } - //Discord Is One Of Those - }, "Enable Edit Modifier"), - React.createElement(this.FormTitle, { - disabled: !editEnableModifier, - tag: "h3" - }, "Modifer to hold to edit a message"), - React.createElement(this.RadioItem, { - disabled: !editEnableModifier, - value: editModifier, - options: [ - { name: "Shift", value: "shift" }, - { name: "Ctrl", value: "ctrl" }, - { name: "Alt", value: "alt" } - ], - onChange: (newState) => { - this.editModifier = newState.value; - Data.save(config.info.id, "editModifier", newState.value); - setEditModifier(newState.value); - } - }), - - //Reply - React.createElement(this.SwitchItem, { - value: reply, - note: "Double click another's message and start replying.", - onChange: (newState) => { - this.doubleClickToReply = newState; - Data.save(config.info.id, "doubleClickToReply", newState); - setReply(newState); - } - }, "Enable Replying"), - React.createElement(this.SwitchItem, { - disabled: !reply, - value: replyEnableModifier, - note: "Enable modifier for double clicking to reply", - onChange: (newState) => { - this.doubleClickToReplyModifier = newState; - Data.save(config.info.id, "doubleClickToReplyModifier", newState); - setReplyEnableModifier(newState); - } - }, "Enable Reply Modifier"), - React.createElement(this.FormTitle, { - disabled: (!reply || !replyEnableModifier), - tag: "h3" - }, "Modifier to hold when replying to a message"), - React.createElement(this.RadioItem, { - disabled: (!reply || !replyEnableModifier), - value: replyModifier, - options: [ - { name: "Shift", value: "shift" }, - { name: "Ctrl", value: "ctrl" }, - { name: "Alt", value: "alt" } - ], - onChange: (newState) => { - this.replyModifier = newState.value; - Data.save(config.info.id, "replyModifier", newState.value); - setReplyModifier(newState.value); - } - }), - - //Copy - React.createElement(this.SwitchItem, { - value: copy, - note: "Copy selection before entering edit-mode.", - onChange: (newState) => { - this.doubleClickToCopy = newState; - Data.save(config.info.id, "doubleClickToCopy", newState); - setCopy(newState); - } - }, "Enable Copying"), - React.createElement(this.FormTitle, { - disabled: !copy, - tag: "h3" - }, "Modifier to hold before copying text"), - React.createElement(this.RadioItem, { - disabled: !copy, - value: copyModifier, - options: [ - { name: "Shift", value: "shift" }, - { name: "Ctrl", value: "ctrl" }, - { name: "Alt", value: "alt" } - ], - onChange: (newState) => { - this.copyModifier = newState.value; - Data.save(config.info.id, "copyModifier", newState.value); - setCopyModifier(newState.value); - } - }) - ]; - } - } - - handler(e) { - //Check if we're not double clicking - if (typeof (e?.target?.className) !== typeof ("") || - blacklist.some(nameOfClass => e?.target?.className?.indexOf?.(nameOfClass) > -1)) - return; - - //Target the message - const messageDiv = e.target.closest('li > [class^=message]'); - - //If it finds nothing, null it. - if (!messageDiv) - return; - //Make sure we're not resetting when the message is already in edit-mode. - if (messageDiv.classList.contains(this.selectedClass)) - return; - - //Basically make a HTMLElement/Node interactable with it's React components. - const instance = BdApi.getInternalInstance(messageDiv); - //Mandatory nullcheck - if (!instance) - return; - - //When selecting text it might be useful to copy. - const copyKeyHeld = this.checkForModifier(this.doubleClickToCopy, this.copyModifier, e); - if (copyKeyHeld) - this.copyToClipboard(document.getSelection().toString()); - - //The message instance is filled top to bottom, as it is in view. - //As a result, "baseMessage" will be the actual message you want to address. And "message" will be the reply. - //Maybe the message has a reply, so check if "baseMessage" exists and otherwise fallback on "message". - const message = this.getValueFromKey(instance, "baseMessage") ?? this.getValueFromKey(instance, "message"); - - if (!message) - return; - - //Now we do the same thing with the edit and reply modifier - const editKeyHeld = this.checkForModifier(this.doubleClickToEditModifier, this.editModifier, e), - replyKeyHeld = this.checkForModifier(this.doubleClickToReplyModifier, this.replyModifier, e); - - //If a modifier is enabled, check if the key is held, otherwise ignore. - if ((this.doubleClickToEditModifier ? editKeyHeld : true) && message.author.id === this.CurrentUserStore.getCurrentUser().id) - this.MessageStore.startEditMessage(message.channel_id, message.id, message.content); - else if ((this.doubleClickToReplyModifier ? replyKeyHeld : true) && this.doubleClickToReply) - this.replyToMessage(this.getChannel(message.channel_id), message, e); - } - - /** - * - * @param {boolean} enabled Is the modifier enabled - * @param {string} modifier Modifier key to be checked for - * @param {Event} event The event checked against - * @returns {boolean} Whether the modifier is enabled and the modifier is pressed - */ - checkForModifier(enabled, modifier, event) { - if (enabled) - switch (modifier) { - case "shift": return event.shiftKey; - case "ctrl": return event.ctrlKey; - case "alt": return event.altKey; - } - return false; - } - - getValueFromKey(instance, searchkey) { - //Where we want to search. - const whitelist = { - memoizedProps: true, - child: true, - sibling: true - }; - - return function getKey(instance) { - //Pre-define - let result = undefined; - //Make sure it exists and isn't a "paradox". - if (instance && !Node.prototype.isPrototypeOf(instance)) { - //Get our own keys - const keys = Object.getOwnPropertyNames(instance); - //As long as we don't have a result, lets go through. - for (let i = 0; result === undefined && i < keys.length; i++) { - //Store our key for readability - const key = keys[i]; - //Check if there is a key - if (key) { - //Store the value - const value = instance[key]; - //Is our key what we want? - if (searchkey === key) - result = value; - //Otherwise check if the value of a key is something we can search through - //and whitelisted; of course. - else if ((typeof value === "object" || typeof value === "function") && - (whitelist[key] || key[0] == "." || !isNaN(key[0]))) - //Lets go nesting; lets go! - result = getKey(value); - } - } - } - //If a poor sod got found this will not be `undefined` - return result; - //Start our mayhem - }(instance); - } -} diff --git a/files/discord/plugins/ReadAllNotificationsButton.plugin.js b/files/discord/plugins/ReadAllNotificationsButton.plugin.js @@ -1,686 +0,0 @@ -/** - * @name ReadAllNotificationsButton - * @author DevilBro - * @authorId 278543574059057154 - * @version 1.7.3 - * @description Adds a Clear Button to the Server List and the Mentions Popout - * @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/ReadAllNotificationsButton/ - */ - -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 _this; - var blacklist, clearing; - - const ReadAllButtonComponent = class ReadAllButton extends BdApi.React.Component { - clearClick() { - if (_this.settings.batch.guilds) this.clearGuilds(_this.settings.batch.muted ? this.getGuilds() : this.getUnread()); - if (_this.settings.batch.dms) BDFDB.DMUtils.markAsRead(this.getPingedDMs()); - } - clearGuilds(guildIds) { - BDFDB.GuildUtils.markAsRead(guildIds.filter(id => id && !blacklist.includes(id))); - } - getGuilds() { - return BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds().map(g => g.id).filter(n => n); - } - getUnread() { - return this.getGuilds().filter(id => BDFDB.LibraryStores.GuildReadStateStore.hasUnread(id) || BDFDB.LibraryStores.GuildReadStateStore.getMentionCount(id) > 0); - } - getPinged() { - return this.getGuilds().filter(id => BDFDB.LibraryStores.GuildReadStateStore.getMentionCount(id) > 0); - } - getMuted() { - return this.getGuilds().filter(id => BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(id)); - } - getPingedDMs() { - return BDFDB.LibraryStores.ChannelStore.getSortedPrivateChannels().map(c => c.id).filter(id => id && BDFDB.LibraryStores.ReadStateStore.getMentionCount(id) > 0); - } - render() { - return BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS.guildouter + BDFDB.disCN._readallnotificationsbuttonframe, - children: BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS.guildiconwrapper + BDFDB.disCN._readallnotificationsbuttoninner, - children: BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS.guildiconchildwrapper + BDFDB.disCN._readallnotificationsbuttonbutton, - children: "read all", - onClick: _ => { - if (!_this.settings.general.confirmClear) this.clearClick(); - else BDFDB.ModalUtils.confirm(_this, _this.labels.modal_confirmnotifications, _ => this.clearClick()); - }, - onContextMenu: event => { - BDFDB.ContextMenuUtils.open(_this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: [ - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: _this.labels.context_unreadguilds, - id: BDFDB.ContextMenuUtils.createItemId(_this.name, "mark-unread-read"), - action: _ => this.clearGuilds(this.getUnread()) - }), - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: _this.labels.context_pingedguilds, - id: BDFDB.ContextMenuUtils.createItemId(_this.name, "mark-pinged-read"), - action: _ => this.clearGuilds(this.getPinged()) - }), - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: _this.labels.context_mutedguilds, - id: BDFDB.ContextMenuUtils.createItemId(_this.name, "mark-muted-read"), - action: _ => this.clearGuilds(this.getMuted()) - }), - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: _this.labels.context_guilds, - id: BDFDB.ContextMenuUtils.createItemId(_this.name, "mark-all-read"), - action: _ => this.clearGuilds(this.getGuilds()) - }), - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: _this.labels.context_dms, - id: BDFDB.ContextMenuUtils.createItemId(_this.name, "mark-dms-read"), - action: _ => BDFDB.DMUtils.markAsRead(this.getPingedDMs()) - }) - ] - })); - } - }) - }) - }); - } - }; - - return class ReadAllNotificationsButton extends Plugin { - onLoad () { - _this = this; - - this.defaults = { - general: { - addClearButton: {value: true, description: "Adds a 'Clear Mentions' button to the recent mentions popout"}, - confirmClear: {value: false, description: "Asks for your confirmation before clearing reads"} - }, - batch: { - guilds: {value: true, description: "unread Servers"}, - muted: {value: false, description: "muted unread Servers"}, - dms: {value: false, description: "unread DMs"} - } - }; - - this.modulePatches = { - after: [ - "GuildsBar", - "InboxHeader" - ] - }; - - this.css = ` - ${BDFDB.dotCN.messagespopouttabbar} { - flex: 1 0 auto; - } - ${BDFDB.dotCN.messagespopoutcontrols} { - display: flex; - } - ${BDFDB.dotCN.messagespopoutcontrols} > * { - margin-left: 10px; - } - ${BDFDB.dotCN._readallnotificationsbuttonframe} { - height: 24px; - margin-bottom: 10px; - } - ${BDFDB.dotCN._readallnotificationsbuttonframe}:active { - transform: translateY(1px); - } - ${BDFDB.dotCN._readallnotificationsbuttoninner} { - height: 24px; - } - ${BDFDB.dotCN._readallnotificationsbuttonbutton} { - border-radius: 4px; - height: 24px; - font-size: 12px; - line-height: 1.3; - white-space: nowrap; - cursor: pointer; - } - `; - } - - onStart () { - let loadedBlacklist = BDFDB.DataUtils.load(this, "blacklist"); - this.saveBlacklist(!BDFDB.ArrayUtils.is(loadedBlacklist) ? [] : loadedBlacklist); - - this.forceUpdateAll(); - } - - onStop () { - this.forceUpdateAll(); - } - - getSettingsPanel (collapseStates = {}) { - let settingsPanel, settingsItems = []; - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { - title: "Settings", - collapseStates: collapseStates, - children: Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Switch", - plugin: this, - keys: ["general", key], - label: this.defaults.general[key].description, - value: this.settings.general[key] - })).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, { - title: "When left clicking the 'read all' Button mark following Elements as read:", - first: false, - last: true, - children: Object.keys(this.defaults.batch).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Switch", - plugin: this, - keys: ["batch", key], - label: this.defaults.batch[key].description, - value: this.settings.batch[key] - })) - })) - })); - - let listInstance = null, batchSetGuilds = value => { - if (!value) { - for (let id of BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuildIds()) blacklist.push(id); - blacklist = BDFDB.ArrayUtils.removeCopies(blacklist); - } - else blacklist = []; - this.saveBlacklist(blacklist); - if (listInstance) { - listInstance.props.disabled = blacklist; - BDFDB.ReactUtils.forceUpdate(listInstance); - } - }; - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { - title: "Server Black List", - collapseStates: collapseStates, - children: [ - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsGuildList, { - className: BDFDB.disCN.marginbottom20, - disabled: BDFDB.DataUtils.load(this, "blacklist"), - onClick: disabledGuilds => this.saveBlacklist(disabledGuilds), - ref: instance => {listInstance = instance;} - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Button", - color: BDFDB.LibraryComponents.Button.Colors.GREEN, - label: "Enable for all Servers", - onClick: _ => batchSetGuilds(true), - children: BDFDB.LanguageUtils.LanguageStrings.ENABLE - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Button", - color: BDFDB.LibraryComponents.Button.Colors.PRIMARY, - label: "Disable for all Servers", - onClick: _ => batchSetGuilds(false), - children: BDFDB.LanguageUtils.LanguageStrings.DISABLE - }) - ] - })); - - return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems); - } - - onSettingsClosed () { - if (this.SettingsUpdated) { - delete this.SettingsUpdated; - this.forceUpdateAll(); - } - } - - forceUpdateAll () { - BDFDB.DiscordUtils.rerenderAll(); - } - - processGuildsBar (e) { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "UnreadDMs"}); - if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(ReadAllButtonComponent, {})); - } - - processInboxHeader (e) { - if (!this.settings.general.addClearButton || e.instance.props.tab != BDFDB.DiscordConstants.InboxTabs.MENTIONS) return; - let mentionedMessages = BDFDB.LibraryStores.RecentMentionsStore.getMentions(); - if (!mentionedMessages || !mentionedMessages.length) return; - let controls = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.messagespopoutcontrols]]}); - if (controls) controls.props.children = [ - controls.props.children, - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { - text: `${BDFDB.LanguageUtils.LanguageStrings.CLOSE} (${BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL})`, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, { - className: BDFDB.disCNS.messagespopoutbutton + BDFDB.disCNS.messagespopoutbuttonsecondary + BDFDB.disCN.messagespopoutbuttonsize32, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { - nativeClass: true, - name: BDFDB.LibraryComponents.SvgIcon.Names.CLOSE, - width: 16, - height: 16 - }), - onClick: _ => { - let clear = _ => { - if (clearing) return BDFDB.NotificationUtils.toast(`${this.labels.toast_alreadyclearing} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {type: "danger"}); - let messages = [].concat(mentionedMessages).filter(n => n); - if (messages.length) { - clearing = true; - let toast = BDFDB.NotificationUtils.toast(`${this.labels.toast_clearing} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true}); - for (let i = 0; i < messages.length; i++) BDFDB.TimeUtils.timeout(_ => { - BDFDB.LibraryModules.RecentMentionUtils.deleteRecentMention(messages[i].id); - if (i == messages.length - 1) { - clearing = false; - toast.close(); - BDFDB.NotificationUtils.toast(this.labels.toastcleared, {type: "success"}); - } - }, i * 1000); - } - }; - if (this.settings.general.confirmClear) BDFDB.ModalUtils.confirm(this, this.labels.modal_confirmmentions, clear); - else clear(); - } - }) - }) - ].flat(10); - } - - saveBlacklist (savedBlacklist) { - blacklist = savedBlacklist; - BDFDB.DataUtils.save(savedBlacklist, this, "blacklist"); - } - - setLabelsByLanguage () { - switch (BDFDB.LanguageUtils.getLanguage().id) { - case "bg": // Bulgarian - return { - context_dms: "Директно съобщение", - context_guilds: "Всички сървъри", - context_mutedguilds: "Приглушени сървъри", - context_pingedguilds: "Pinged сървъри", - context_unreadguilds: "Непрочетени сървъри", - modal_confirmmentions: "Наистина ли искате да изтриете всички непрочетени споменавания?", - modal_confirmnotifications: "Наистина ли искате да изтриете всички непрочетени известия?", - toast_alreadyclearing: "Изтрива някои споменавания вече", - toast_cleared: "Всички последни споменавания бяха изтрити", - toast_clearing: "Изчиства всички скорошни споменавания" - }; - case "da": // Danish - return { - context_dms: "Direkte beskeder", - context_guilds: "Alle servere", - context_mutedguilds: "Dæmpede servere", - context_pingedguilds: "Pingede servere", - context_unreadguilds: "Ulæste servere", - modal_confirmmentions: "Er du sikker på, at du vil slette alle ulæste omtaler?", - modal_confirmnotifications: "Er du sikker på, at du vil slette alle ulæste meddelelser?", - toast_alreadyclearing: "Sletter allerede nogle omtaler", - toast_cleared: "Alle nylige omtaler er blevet slettet", - toast_clearing: "Rydder alle nylige omtaler" - }; - case "de": // German - return { - context_dms: "Direktnachrichten", - context_guilds: "Alle Server", - context_mutedguilds: "Stummgeschaltete Server", - context_pingedguilds: "Gepingte Server", - context_unreadguilds: "Ungelesene Server", - modal_confirmmentions: "Möchten Sie wirklich alle ungelesenen Erwähnungen löschen?", - modal_confirmnotifications: "Möchten Sie wirklich alle ungelesenen Benachrichtigungen löschen?", - toast_alreadyclearing: "Löscht bereits einige Erwähnungen", - toast_cleared: "Alle kürzlich Erwähnungen wurden gelöscht", - toast_clearing: "Löscht alle letzten Erwähnungen" - }; - case "el": // Greek - return { - context_dms: "Αμεσα μηνύματα", - context_guilds: "Όλοι οι διακομιστές", - context_mutedguilds: "Σίγαση διακομιστών", - context_pingedguilds: "Διακομιστές Ping", - context_unreadguilds: "Μη αναγνωσμένοι διακομιστές", - modal_confirmmentions: "Είστε βέβαιοι ότι θέλετε να διαγράψετε όλες τις μη αναγνωσμένες αναφορές;", - modal_confirmnotifications: "Είστε βέβαιοι ότι θέλετε να διαγράψετε όλες τις μη αναγνωσμένες ειδοποιήσεις;", - toast_alreadyclearing: "Διαγράφει ήδη κάποιες αναφορές", - toast_cleared: "Όλες οι πρόσφατες αναφορές έχουν διαγραφεί", - toast_clearing: "Διαγράφει όλες τις πρόσφατες αναφορές" - }; - case "es": // Spanish - return { - context_dms: "Mensajes directos", - context_guilds: "Todos los servidores", - context_mutedguilds: "Servidores silenciados", - context_pingedguilds: "Servidores con ping", - context_unreadguilds: "Servidores no leídos", - modal_confirmmentions: "¿Estás seguro de que deseas eliminar todas las menciones no leídas?", - modal_confirmnotifications: "¿Está seguro de que desea eliminar todas las notificaciones no leídas?", - toast_alreadyclearing: "Elimina algunas menciones ya", - toast_cleared: "Se han eliminado todas las menciones recientes", - toast_clearing: "Borra todas las menciones recientes" - }; - case "fi": // Finnish - return { - context_dms: "Suorat viestit", - context_guilds: "Kaikki palvelimet", - context_mutedguilds: "Mykistetyt palvelimet", - context_pingedguilds: "Pinged-palvelimet", - context_unreadguilds: "Lukemattomat palvelimet", - modal_confirmmentions: "Haluatko varmasti poistaa kaikki lukemattomat maininnat?", - modal_confirmnotifications: "Haluatko varmasti poistaa kaikki lukemattomat ilmoitukset?", - toast_alreadyclearing: "Poistaa jo joitain mainintoja", - toast_cleared: "Kaikki viimeisimmät maininnat on poistettu", - toast_clearing: "Tyhjentää kaikki viimeisimmät maininnat" - }; - case "fr": // French - return { - context_dms: "Messages directs", - context_guilds: "Tous les serveurs", - context_mutedguilds: "Serveurs muets", - context_pingedguilds: "Serveurs ping", - context_unreadguilds: "Serveurs non lus", - modal_confirmmentions: "Voulez-vous vraiment supprimer toutes les mentions non lues?", - modal_confirmnotifications: "Voulez-vous vraiment supprimer toutes les notifications non lues?", - toast_alreadyclearing: "Supprime déjà certaines mentions", - toast_cleared: "Toutes les mentions récentes ont été supprimées", - toast_clearing: "Efface toutes les mentions récentes" - }; - case "hr": // Croatian - return { - context_dms: "Direktna poruka", - context_guilds: "Svi poslužitelji", - context_mutedguilds: "Prigušeni poslužitelji", - context_pingedguilds: "Pingirani poslužitelji", - context_unreadguilds: "Nepročitani poslužitelji", - modal_confirmmentions: "Jeste li sigurni da želite izbrisati sva nepročitana spominjanja?", - modal_confirmnotifications: "Jeste li sigurni da želite izbrisati sve nepročitane obavijesti?", - toast_alreadyclearing: "Briše već spomenute", - toast_cleared: "Sva nedavna spominjanja su izbrisana", - toast_clearing: "Briše sva nedavna spominjanja" - }; - case "hu": // Hungarian - return { - context_dms: "Közvetlen üzenet", - context_guilds: "Minden szerver", - context_mutedguilds: "Némított szerverek", - context_pingedguilds: "Pingelt szerverek", - context_unreadguilds: "Olvasatlan szerverek", - modal_confirmmentions: "Biztosan törli az összes olvasatlan említést?", - modal_confirmnotifications: "Biztosan törli az összes olvasatlan értesítést?", - toast_alreadyclearing: "Néhány említést már töröl", - toast_cleared: "Az összes közelmúltbeli említést törölték", - toast_clearing: "Törli az összes közelmúltbeli említést" - }; - case "it": // Italian - return { - context_dms: "Messaggi diretti", - context_guilds: "Tutti i server", - context_mutedguilds: "Server disattivati", - context_pingedguilds: "Server sottoposti a ping", - context_unreadguilds: "Server non letti", - modal_confirmmentions: "Sei sicuro di voler eliminare tutte le menzioni non lette?", - modal_confirmnotifications: "Sei sicuro di voler eliminare tutte le notifiche non lette?", - toast_alreadyclearing: "Elimina già alcune menzioni", - toast_cleared: "Tutte le menzioni recenti sono state eliminate", - toast_clearing: "Cancella tutte le menzioni recenti" - }; - case "ja": // Japanese - return { - context_dms: "ダイレクトメッセージ", - context_guilds: "すべてのサーバー", - context_mutedguilds: "ミュートされたサーバー", - context_pingedguilds: "pingされたサーバー", - context_unreadguilds: "未読サーバー", - modal_confirmmentions: "未読のメンションをすべて削除してもよろしいですか?", - modal_confirmnotifications: "未読の通知をすべて削除してもよろしいですか?", - toast_alreadyclearing: "すでにいくつかの言及を削除します", - toast_cleared: "最近の言及はすべて削除されました", - toast_clearing: "最近の言及をすべてクリアします" - }; - case "ko": // Korean - return { - context_dms: "쪽지", - context_guilds: "모든 서버", - context_mutedguilds: "음소거 된 서버", - context_pingedguilds: "핑된 서버", - context_unreadguilds: "읽지 않은 서버", - modal_confirmmentions: "읽지 않은 모든 멘션을 삭제 하시겠습니까?", - modal_confirmnotifications: "읽지 않은 모든 알림을 삭제 하시겠습니까?", - toast_alreadyclearing: "이미 일부 멘션을 삭제합니다.", - toast_cleared: "모든 최근 멘션이 삭제되었습니다.", - toast_clearing: "최근 멘션을 모두 지 웁니다." - }; - case "lt": // Lithuanian - return { - context_dms: "Tiesioginiai pranešimai", - context_guilds: "Visi serveriai", - context_mutedguilds: "Nutildyti serveriai", - context_pingedguilds: "„Pinged“ serveriai", - context_unreadguilds: "Neskaityti serveriai", - modal_confirmmentions: "Ar tikrai norite ištrinti visus neperskaitytus paminėjimus?", - modal_confirmnotifications: "Ar tikrai norite ištrinti visus neperskaitytus pranešimus?", - toast_alreadyclearing: "Kai kurie paminėjimai jau ištrinami", - toast_cleared: "Visi naujausi paminėjimai buvo ištrinti", - toast_clearing: "Išvalo visus naujausius paminėjimus" - }; - case "nl": // Dutch - return { - context_dms: "Directe berichten", - context_guilds: "Alle servers", - context_mutedguilds: "Gedempte servers", - context_pingedguilds: "Gepingde servers", - context_unreadguilds: "Ongelezen servers", - modal_confirmmentions: "Weet u zeker dat u alle ongelezen vermeldingen wilt verwijderen?", - modal_confirmnotifications: "Weet u zeker dat u alle ongelezen meldingen wilt verwijderen?", - toast_alreadyclearing: "Verwijdert al enkele vermeldingen", - toast_cleared: "Alle recente vermeldingen zijn verwijderd", - toast_clearing: "Wist alle recente vermeldingen" - }; - case "no": // Norwegian - return { - context_dms: "Direktemeldinger", - context_guilds: "Alle servere", - context_mutedguilds: "Dempede servere", - context_pingedguilds: "Pingede servere", - context_unreadguilds: "Uleste servere", - modal_confirmmentions: "Er du sikker på at du vil slette alle uleste omtaler?", - modal_confirmnotifications: "Er du sikker på at du vil slette alle uleste varsler?", - toast_alreadyclearing: "Sletter allerede noen omtaler", - toast_cleared: "Alle nylige omtaler er slettet", - toast_clearing: "Fjerner alle nylige omtaler" - }; - case "pl": // Polish - return { - context_dms: "Bezpośrednie wiadomości", - context_guilds: "Wszystkie serwery", - context_mutedguilds: "Wyciszone serwery", - context_pingedguilds: "Serwery pingowane", - context_unreadguilds: "Nieprzeczytane serwery", - modal_confirmmentions: "Czy na pewno chcesz usunąć wszystkie nieprzeczytane wzmianki?", - modal_confirmnotifications: "Czy na pewno chcesz usunąć wszystkie nieprzeczytane powiadomienia?", - toast_alreadyclearing: "Usuwa już niektóre wzmianki", - toast_cleared: "Wszystkie ostatnie wzmianki zostały usunięte", - toast_clearing: "Usuwa wszystkie ostatnie wzmianki" - }; - case "pt-BR": // Portuguese (Brazil) - return { - context_dms: "Mensagens diretas", - context_guilds: "Todos os servidores", - context_mutedguilds: "Servidores Silenciados", - context_pingedguilds: "Servidores com ping", - context_unreadguilds: "Servidores não lidos", - modal_confirmmentions: "Tem certeza de que deseja excluir todas as menções não lidas?", - modal_confirmnotifications: "Tem certeza de que deseja excluir todas as notificações não lidas?", - toast_alreadyclearing: "Exclui algumas menções já", - toast_cleared: "Todas as menções recentes foram excluídas", - toast_clearing: "Limpa todas as menções recentes" - }; - case "ro": // Romanian - return { - context_dms: "Mesaje directe", - context_guilds: "Toate serverele", - context_mutedguilds: "Servere mutate", - context_pingedguilds: "Servere pinged", - context_unreadguilds: "Servere necitite", - modal_confirmmentions: "Sigur doriți să ștergeți toate mențiunile necitite?", - modal_confirmnotifications: "Sigur doriți să ștergeți toate notificările necitite?", - toast_alreadyclearing: "Șterge deja câteva mențiuni", - toast_cleared: "Toate mențiunile recente au fost șterse", - toast_clearing: "Șterge toate mențiunile recente" - }; - case "ru": // Russian - return { - context_dms: "Прямые сообщения", - context_guilds: "Все серверы", - context_mutedguilds: "Отключенные серверы", - context_pingedguilds: "Проверенные серверы", - context_unreadguilds: "Непрочитанные серверы", - modal_confirmmentions: "Вы уверены, что хотите удалить все непрочитанные упоминания?", - modal_confirmnotifications: "Вы действительно хотите удалить все непрочитанные уведомления?", - toast_alreadyclearing: "Удаляет уже некоторые упоминания", - toast_cleared: "Все недавние упоминания были удалены", - toast_clearing: "Удаляет все недавние упоминания" - }; - case "sv": // Swedish - return { - context_dms: "Direktmeddelanden", - context_guilds: "Alla servrar", - context_mutedguilds: "Dämpade servrar", - context_pingedguilds: "Pingade servrar", - context_unreadguilds: "Olästa servrar", - modal_confirmmentions: "Är du säker på att du vill ta bort alla olästa omnämnanden?", - modal_confirmnotifications: "Är du säker på att du vill ta bort alla olästa aviseringar?", - toast_alreadyclearing: "Raderar några omnämnanden redan", - toast_cleared: "Alla nya omnämnanden har tagits bort", - toast_clearing: "Rensar alla senaste omnämnanden" - }; - case "th": // Thai - return { - context_dms: "ข้อความโดยตรง", - context_guilds: "เซิร์ฟเวอร์ทั้งหมด", - context_mutedguilds: "เซิร์ฟเวอร์ที่ปิดเสียง", - context_pingedguilds: "เซิร์ฟเวอร์ Pinged", - context_unreadguilds: "เซิร์ฟเวอร์ที่ยังไม่ได้อ่าน", - modal_confirmmentions: "แน่ใจไหมว่าต้องการลบข้อความที่ยังไม่ได้อ่านทั้งหมด", - modal_confirmnotifications: "แน่ใจไหมว่าต้องการลบการแจ้งเตือนที่ยังไม่ได้อ่านทั้งหมด", - toast_alreadyclearing: "ลบการกล่าวถึงบางส่วนแล้ว", - toast_cleared: "ลบการกล่าวถึงล่าสุดทั้งหมดแล้ว", - toast_clearing: "ล้างการพูดถึงล่าสุดทั้งหมด" - }; - case "tr": // Turkish - return { - context_dms: "Direkt Mesajlar", - context_guilds: "Tüm Sunucular", - context_mutedguilds: "Sessiz Sunucular", - context_pingedguilds: "Ping Gönderilen Sunucular", - context_unreadguilds: "Okunmamış Sunucular", - modal_confirmmentions: "Okunmamış tüm bahisleri silmek istediğinizden emin misiniz?", - modal_confirmnotifications: "Okunmamış tüm bildirimleri silmek istediğinizden emin misiniz?", - toast_alreadyclearing: "Zaten bazı bahsetmeleri siler", - toast_cleared: "Son bahsedenlerin tümü silindi", - toast_clearing: "Tüm son bahsedilenleri temizler" - }; - case "uk": // Ukrainian - return { - context_dms: "Прямі повідомлення", - context_guilds: "Усі сервери", - context_mutedguilds: "Приглушені сервери", - context_pingedguilds: "Pinged сервери", - context_unreadguilds: "Непрочитані сервери", - modal_confirmmentions: "Ви впевнені, що хочете видалити всі непрочитані згадки?", - modal_confirmnotifications: "Ви впевнені, що хочете видалити всі непрочитані сповіщення?", - toast_alreadyclearing: "Видаляє деякі згадки вже", - toast_cleared: "Усі останні згадування були видалені", - toast_clearing: "Очищає всі останні згадування" - }; - case "vi": // Vietnamese - return { - context_dms: "Tin nhắn trực tiếp", - context_guilds: "Tất cả máy chủ", - context_mutedguilds: "Máy chủ bị tắt tiếng", - context_pingedguilds: "Máy chủ Pinged", - context_unreadguilds: "Máy chủ chưa đọc", - modal_confirmmentions: "Bạn có chắc chắn muốn xóa tất cả các đề cập chưa đọc không?", - modal_confirmnotifications: "Bạn có chắc chắn muốn xóa tất cả các thông báo chưa đọc không?", - toast_alreadyclearing: "Đã xóa một số đề cập", - toast_cleared: "Tất cả các đề cập gần đây đã bị xóa", - toast_clearing: "Xóa tất cả các đề cập gần đây" - }; - case "zh-CN": // Chinese (China) - return { - context_dms: "直接讯息", - context_guilds: "所有服务器", - context_mutedguilds: "静音服务器", - context_pingedguilds: "绑定服务器", - context_unreadguilds: "未读服务器", - modal_confirmmentions: "您确定要删除所有未读的提及吗?", - modal_confirmnotifications: "您确定要删除所有未读的通知吗?", - toast_alreadyclearing: "已删除一些提及", - toast_cleared: "最近所有提及的内容均已删除", - toast_clearing: "清除所有最近提及的内容" - }; - case "zh-TW": // Chinese (Taiwan) - return { - context_dms: "直接訊息", - context_guilds: "所有服務器", - context_mutedguilds: "靜音服務器", - context_pingedguilds: "綁定服務器", - context_unreadguilds: "未讀服務器", - modal_confirmmentions: "您確定要刪除所有未讀的提及嗎?", - modal_confirmnotifications: "您確定要刪除所有未讀的通知嗎?", - toast_alreadyclearing: "已刪除一些提及", - toast_cleared: "最近所有提及的內容均已刪除", - toast_clearing: "清除所有最近提及的內容" - }; - default: // English - return { - context_dms: "Direct Messages", - context_guilds: "All Servers", - context_mutedguilds: "Muted Servers", - context_pingedguilds: "Pinged Servers", - context_unreadguilds: "Unread Servers", - modal_confirmmentions: "Are you sure you want to delete all unread Mentions?", - modal_confirmnotifications: "Are you sure you want to delete all unread Notifications?", - toast_alreadyclearing: "Already clearing some Mentions", - toast_cleared: "All recent Mentions have been cleared", - toast_clearing: "Clearing all recent Mentions" - }; - } - } - }; - })(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog)); -})(); -\ No newline at end of file diff --git a/files/discord/plugins/ShowHiddenChannels.plugin.js b/files/discord/plugins/ShowHiddenChannels.plugin.js @@ -1,986 +0,0 @@ -/** - * @name ShowHiddenChannels - * @author DevilBro - * @authorId 278543574059057154 - * @version 3.0.6 - * @description Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible) - * @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/ShowHiddenChannels/ - */ - -module.exports = (_ => { - const config = { - "info": { - "name": "ShowHiddenChannels", - "author": "DevilBro", - "version": "3.0.6", - "description": "Displays all hidden Channels, which can't be accessed due to Role Restrictions, this won't allow you to read them (impossible)" - }, - "changeLog": { - "fixed": { - "Permissions Tabs": "Fixed Issue, where Users that are specifically allowed/denied weren't listed in the tabs" - } - } - }; - - return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class { - getName () {return config.info.name;} - getAuthor () {return config.info.author;} - getVersion () {return config.info.version;} - getDescription () {return `The Library Plugin needed for ${config.info.name} is missing. Open the Plugin Settings to download it. \n\n${config.info.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 ${config.info.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(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.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 ${config.info.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 blackList = [], collapseList = [], hiddenCategory, lastGuildId, overrideTypes = []; - var hiddenChannelCache = {}; - var accessModal; - - const channelGroupMap = { - GUILD_TEXT: "SELECTABLE", - GUILD_VOICE: "VOCAL", - GUILD_ANNOUNCEMENT: "SELECTABLE", - GUILD_STORE: "SELECTABLE", - }; - - const typeNameMap = { - GUILD_TEXT: "TEXT_CHANNEL", - GUILD_VOICE: "VOICE_CHANNEL", - GUILD_ANNOUNCEMENT: "NEWS_CHANNEL", - GUILD_STORE: "STORE_CHANNEL", - GUILD_CATEGORY: "CATEGORY", - GUILD_STAGE_VOICE: "STAGE_CHANNEL", - PUBLIC_THREAD: "THREAD", - PRIVATE_THREAD: "PRIVATE_THREAD" - }; - - const sortOrders = { - NATIVE: {value: "native", label: "Native Category in correct Order"}, - BOTTOM: {value: "bottom", label: "Native Category at the bottom"}, - EXTRA: {value: "extra", label: "Extra Category 'Hidden'"} - }; - - const UserRowComponent = class UserRow extends BdApi.React.Component { - componentDidMount() { - if (this.props.user.fetchable) { - this.props.user.fetchable = false; - BDFDB.LibraryModules.UserProfileUtils.getUser(this.props.user.id).then(fetchedUser => { - this.props.user = Object.assign({}, fetchedUser, BDFDB.LibraryModules.MemberStore.getMember(this.props.guildId, this.props.user.id) || {}); - BDFDB.ReactUtils.forceUpdate(this); - }); - } - } - render() { - return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, { - prefix: BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCN.listavatar, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AvatarComponents.default, { - src: BDFDB.UserUtils.getAvatar(this.props.user.id), - status: BDFDB.UserUtils.getStatus(this.props.user.id), - size: BDFDB.LibraryComponents.AvatarComponents.Sizes.SIZE_40, - onClick: _ => { - if (accessModal) accessModal.props.onClose(); - BDFDB.LibraryModules.UserProfileModalUtils.openUserProfileModal({ - userId: this.props.user.id, - guildId: this.props.guildId - }); - } - }) - }), - labelClassName: BDFDB.disCN.nametag, - label: [ - BDFDB.ReactUtils.createElement("span", { - className: BDFDB.disCN.username, - children: this.props.user.nick || this.props.user.username, - style: {color: this.props.user.colorString} - }), - !this.props.user.discriminator ? null : BDFDB.ReactUtils.createElement("span", { - className: BDFDB.disCN.listdiscriminator, - children: `#${this.props.user.discriminator}` - }), - this.props.user.bot && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, { - style: {marginLeft: 6} - }) - ] - }); - } - }; - - const RoleRowComponent = class RoleRow extends BdApi.React.Component { - render() { - return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, { - prefix: BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS.avataricon + BDFDB.disCNS.listavatar + BDFDB.disCNS.avatariconsizemedium + BDFDB.disCN.avatariconinactive, - style: { - boxSizing: "border-box", - padding: 10 - }, - children: BDFDB.ReactUtils.createElement("div", { - style: { - borderRadius: "50%", - height: "100%", - width: "100%", - backgroundColor: BDFDB.ColorUtils.convert(this.props.role.colorString, "RGB") || BDFDB.DiscordConstants.Colors.PRIMARY_DARK_300 - } - }) - }), - labelClassName: this.props.role.overwritten && BDFDB.disCN.strikethrough, - label: BDFDB.ReactUtils.createElement("span", { - children: this.props.role.name, - style: {color: this.props.role.colorString} - }) - }); - } - }; - - return class ShowHiddenChannels extends Plugin { - onLoad () { - overrideTypes = Object.keys(BDFDB.DiscordConstants.PermissionOverrideType); - - this.defaults = { - sortOrder: { - hidden: { - value: sortOrders[Object.keys(sortOrders)[0]].value, - description: "Sorts hidden Channels in", - options: Object.keys(sortOrders).map(n => sortOrders[n]) - } - }, - general: { - alwaysCollapse: {value: false, description: "Always collapse 'Hidden' Category after switching Servers"}, - showVoiceUsers: {value: true, description: "Show connected Users in hidden Voice Channels"}, - showForNormal: {value: true, description: "Add Access-Overview ContextMenu Entry for non-hidden Channels"} - }, - channels: { - GUILD_TEXT: {value: true}, - GUILD_VOICE: {value: true}, - GUILD_ANNOUNCEMENT: {value: true}, - GUILD_STORE: {value: true}, - GUILD_STAGE_VOICE: {value: true} - } - }; - - this.patchedModules = { - before: { - Channels: "render", - ChannelCategoryItem: "type", - ChannelItem: "default", - VoiceUsers: "render" - }, - after: { - ChannelItem: "default" - } - }; - - this.css = ` - ${BDFDB.dotCNS._showhiddenchannelsaccessmodal + BDFDB.dotCN.messagespopoutemptyplaceholder} { - position: absolute; - bottom: 0; - width: 100%; - } - `; - } - - onStart () { - let loadedBlackList = BDFDB.DataUtils.load(this, "blacklist"); - this.saveBlackList(!BDFDB.ArrayUtils.is(loadedBlackList) ? [] : loadedBlackList); - - let loadedCollapseList = BDFDB.DataUtils.load(this, "categorydata"); - this.saveCollapseList(!BDFDB.ArrayUtils.is(loadedCollapseList) ? [] : loadedCollapseList); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.UnreadChannelUtils, "hasUnread", {after: e => { - return e.returnValue && !this.isChannelHidden(e.methodArguments[0]); - }}); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.UnreadChannelUtils, "getMentionCount", {after: e => { - return this.isChannelHidden(e.methodArguments[0]) ? 0 : e.returnValue; - }}); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseStore, "isCollapsed", {after: e => { - if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) { - if (this.settings.general.alwaysCollapse && e.methodArguments[0] != lastGuildId && !collapseList.includes(e.methodArguments[0])) { - collapseList.push(e.methodArguments[0]); - this.saveCollapseList(BDFDB.ArrayUtils.removeCopies(collapseList)); - } - lastGuildId = e.methodArguments[0]; - return collapseList.includes(e.methodArguments[0]); - } - }}); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseUtils, "categoryCollapse", {before: e => { - if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) { - if (!collapseList.includes(e.methodArguments[0])) { - collapseList.push(e.methodArguments[0]); - this.saveCollapseList(BDFDB.ArrayUtils.removeCopies(collapseList)); - } - } - }}); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseUtils, "categoryExpand", {before: e => { - if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) { - if (collapseList.includes(e.methodArguments[0])) { - BDFDB.ArrayUtils.remove(collapseList, e.methodArguments[0], true); - this.saveCollapseList(BDFDB.ArrayUtils.removeCopies(collapseList)); - } - } - }}); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.GuildChannelStore, "getTextChannelNameDisambiguations", {after: e => { - let all = this.getAllChannels(); - for (let channel_id in all) if (all[channel_id].guild_id == e.methodArguments[0] && !e.returnValue[channel_id] && (all[channel_id].type != BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY && all[channel_id].type != BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE)) e.returnValue[channel_id] = {id: channel_id, name: all[channel_id].name}; - }}); - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.ChannelIconUtils, "getChannelIconComponent", {before: e => { - if (e.methodArguments[2] && e.methodArguments[2].locked && e.methodArguments[0] && this.isChannelHidden(e.methodArguments[0].id)) e.methodArguments[2].locked = false; - }}); - - this.forceUpdateAll(); - } - - onStop () { - this.forceUpdateAll(); - } - - getSettingsPanel (collapseStates = {}) { - let settingsPanel; - return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, { - collapseStates: collapseStates, - children: _ => { - let settingsItems = []; - - for (let key in this.defaults.selections) settingsItems.push(); - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { - title: "Settings", - collapseStates: collapseStates, - children: Object.keys(this.defaults.sortOrder).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Select", - plugin: this, - keys: ["sortOrder", key], - label: this.defaults.sortOrder[key].description, - basis: "50%", - options: this.defaults.sortOrder[key].options, - value: this.settings.sortOrder[key] - })).concat(Object.keys(this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Switch", - plugin: this, - keys: ["general", key], - label: this.defaults.general[key].description, - value: this.settings.general[key] - }))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, { - title: "Show Channels:", - children: Object.keys(this.defaults.channels).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Switch", - plugin: this, - keys: ["channels", key], - label: BDFDB.LanguageUtils.LanguageStrings[typeNameMap[key]], - value: this.settings.channels[key] - })) - })) - })); - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { - title: "Server Black List", - collapseStates: collapseStates, - children: [ - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsGuildList, { - className: BDFDB.disCN.marginbottom20, - disabled: blackList, - onClick: disabledGuilds => this.saveBlackList(disabledGuilds) - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Button", - color: BDFDB.LibraryComponents.Button.Colors.GREEN, - label: "Enable for all Servers", - onClick: _ => this.batchSetGuilds(settingsPanel, collapseStates, true), - children: BDFDB.LanguageUtils.LanguageStrings.ENABLE - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Button", - color: BDFDB.LibraryComponents.Button.Colors.PRIMARY, - label: "Disable for all Servers", - onClick: _ => this.batchSetGuilds(settingsPanel, collapseStates, false), - children: BDFDB.LanguageUtils.LanguageStrings.DISABLE - }) - ] - })); - - return settingsItems; - } - }); - } - - onSettingsClosed () { - if (this.SettingsUpdated) { - delete this.SettingsUpdated; - this.forceUpdateAll(); - } - } - - forceUpdateAll () { - hiddenChannelCache = {}; - - BDFDB.PatchUtils.forceAllUpdates(this); - BDFDB.ChannelUtils.rerenderAll(); - } - - onChannelContextMenu (e) { - if (e.instance.props.channel) { - if (e.instance.props.channel.id.endsWith("hidden") && e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY) { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ChannelMuteItem"}); - if (index > -1) children.splice(index, 1); - [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-channel-read", group: true}); - children.splice(index > -1 ? index + 1 : 0, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels.context_changeorder, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "change_order"), - children: Object.keys(sortOrders).filter(n => sortOrders[n].value != sortOrders.EXTRA.value).map(n => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels["context_changeorder_" + sortOrders[n].value], - id: BDFDB.ContextMenuUtils.createItemId(this.name, "change_order", sortOrders[n].value), - action: _ => { - this.settings.sortOrder.hidden = sortOrders[n].value; - BDFDB.DataUtils.save(this.settings.sortOrder, this, "sortOrder"); - this.forceUpdateAll(); - } - }) - })) - }) - })); - } - let isHidden = this.isChannelHidden(e.instance.props.channel.id); - if (isHidden || this.settings.general.showForNormal) { - let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-channel-read", group: true}); - children.splice(index > -1 ? index + 1 : 0, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels.context_channelaccess, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "permissions"), - action: _ => this.openAccessModal(e.instance.props.channel, !isHidden) - }) - })); - } - } - } - - onGuildContextMenu (e) { - if (e.instance.props.guild) { - let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "hide-muted-channels"}); - if (index > -1) children.splice(index + 1, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuCheckboxItem, { - label: this.labels.context_hidehidden, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "hide-locked-channels"), - checked: blackList.includes(e.instance.props.guild.id), - action: value => { - if (value) blackList.push(e.instance.props.guild.id); - else BDFDB.ArrayUtils.remove(blackList, e.instance.props.guild.id, true); - this.saveBlackList(BDFDB.ArrayUtils.removeCopies(blackList)); - - BDFDB.PatchUtils.forceAllUpdates(this); - BDFDB.ChannelUtils.rerenderAll(true); - } - })); - } - } - - onGuildHeaderContextMenu (e) { - this.onGuildContextMenu(e); - } - - processChannels (e) { - if (!e.instance.props.guild || blackList.includes(e.instance.props.guild.id)) return; - let [hiddenChannels, amount] = this.getHiddenChannels(e.instance.props.guild); - if (amount) { - e.instance.props.categories = Object.assign({}, e.instance.props.categories); - for (let catId in e.instance.props.categories) e.instance.props.categories[catId] = [].concat(e.instance.props.categories[catId]); - e.instance.props.channels = Object.assign({}, e.instance.props.channels); - for (let type in e.instance.props.channels) e.instance.props.channels[type] = [].concat(e.instance.props.channels[type]); - - let hiddenId = e.instance.props.guild.id + "_hidden"; - - delete e.instance.props.categories[hiddenId]; - e.instance.props.categories._categories = e.instance.props.categories._categories.filter(n => n.channel.id != hiddenId); - e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY] = e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY].filter(n => n.channel.id != hiddenId); - - let index = -1; - for (let catId in e.instance.props.categories) { - if (catId != "_categories") e.instance.props.categories[catId] = e.instance.props.categories[catId].filter(n => !this.isChannelHidden(n.channel.id)); - for (let channelObj of e.instance.props.categories[catId]) if (channelObj.index > index) index = parseInt(channelObj.index); - } - if (this.settings.sortOrder.hidden == sortOrders.EXTRA.value) { - hiddenCategory = new BDFDB.DiscordObjects.Channel({ - guild_id: e.instance.props.guild.id, - id: hiddenId, - name: "hidden", - type: BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY - }); - e.instance.props.categories[hiddenId] = []; - e.instance.props.categories._categories.push({ - channel: hiddenCategory, - index: ++index - }); - e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY].push({ - comparator: (e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY][e.instance.props.channels[BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY].length - 1] || {comparator: 0}).comparator + 1, - channel: hiddenCategory - }); - } - else hiddenCategory = null; - - for (let type in hiddenChannels) { - let channelType = channelGroupMap[BDFDB.DiscordConstants.ChannelTypes[type]] || type; - if (!BDFDB.ArrayUtils.is(e.instance.props.channels[channelType])) e.instance.props.channels[channelType] = []; - for (let channel of hiddenChannels[type]) { - let hiddenChannel = new BDFDB.DiscordObjects.Channel(Object.assign({}, channel, { - parent_id: hiddenCategory ? hiddenId : channel.parent_id, - position: this.settings.sortOrder.hidden == sortOrders.BOTTOM.value ? 999999999 : channel.position - })); - let parent_id = hiddenChannel.parent_id || "null"; - e.instance.props.categories[parent_id].push({ - channel: hiddenChannel, - index: hiddenChannel.position - }); - e.instance.props.channels[channelType].push({ - comparator: hiddenChannel.position, - channel: hiddenChannel - }); - } - } - - for (let parent_id in e.instance.props.categories) BDFDB.ArrayUtils.keySort(e.instance.props.categories[parent_id], "index"); - for (let channelType in e.instance.props.channels) BDFDB.ArrayUtils.keySort(e.instance.props.channels[channelType], "comparator"); - } - } - - processChannelCategoryItem (e) { - if (hiddenCategory && e.instance.props.channel && !e.instance.props.channel.id && e.instance.props.channel.type != BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY) e.instance.props.channel = hiddenCategory; - } - - processChannelItem (e) { - if (e.instance.props.channel && !blackList.includes(e.instance.props.channel.guild_id) && this.isChannelHidden(e.instance.props.channel.id)) { - if (!e.returnvalue) e.instance.props.className = BDFDB.DOMUtils.formatClassName(e.instance.props.className, BDFDB.disCN._showhiddenchannelshiddenchannel); - else { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ChannelItemIcon"}); - let channelChildren = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelchildren]]}); - if (channelChildren && channelChildren.props && channelChildren.props.children) { - channelChildren.props.children = [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { - text: BDFDB.LanguageUtils.LanguageStrings.CHANNEL_LOCKED_SHORT, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, { - className: BDFDB.disCN.channeliconitem, - style: {display: "block"}, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { - className: BDFDB.disCN.channelactionicon, - name: BDFDB.LibraryComponents.SvgIcon.Names.LOCK_CLOSED - }) - }) - })]; - } - if (!(e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE && e.instance.props.connected)) { - let wrapper = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelwrapper]]}); - if (wrapper) { - wrapper.props.onMouseDown = _ => {}; - wrapper.props.onMouseUp = _ => {}; - } - let mainContent = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelmaincontent]]}); - if (mainContent) { - mainContent.props.onClick = _ => {}; - mainContent.props.href = null; - } - } - } - } - } - - processVoiceUsers (e) { - if (!this.settings.general.showVoiceUsers && this.isChannelHidden(e.instance.props.channel.id)) e.instance.props.voiceStates = []; - } - - isChannelHidden (channelId) { - let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channelId); - return channel && hiddenChannelCache[channel.guild_id] && hiddenChannelCache[channel.guild_id].hidden[channel.type] && hiddenChannelCache[channel.guild_id].hidden[channel.type].find(c => c.id == channel.id); - } - - getAllChannels () { - return (BDFDB.LibraryModules.ChannelStore.getGuildChannels || BDFDB.LibraryModules.ChannelStore.getMutableGuildChannels || (_ => ({})))(); - } - - getHiddenChannels (guild) { - if (!guild) return [{}, 0]; - let hiddenChannels = {}, visibleAmount = (BDFDB.LibraryModules.GuildChannelStore.getChannels(guild.id) || {count: 0}),count, rolesAmount = (BDFDB.LibraryModules.MemberStore.getMember(guild.id, BDFDB.UserUtils.me.id) || {roles: []}).roles.length; - if (!hiddenChannelCache[guild.id] || hiddenChannelCache[guild.id].visible != visibleAmount || hiddenChannelCache[guild.id].roles != rolesAmount) { - let all = this.getAllChannels(); - for (let type in BDFDB.DiscordConstants.ChannelTypes) hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]] = []; - for (let channel_id in all) { - let channel = all[channel_id]; - if (channel.guild_id == guild.id && channel.type != BDFDB.DiscordConstants.ChannelTypes.GUILD_CATEGORY && (this.settings.channels[BDFDB.DiscordConstants.ChannelTypes[channel.type]] || this.settings.channels[BDFDB.DiscordConstants.ChannelTypes[channel.type]] === undefined) && !BDFDB.DMUtils.isDMChannel(channel.id) && !BDFDB.UserUtils.can("VIEW_CHANNEL", BDFDB.UserUtils.me.id, channel.id)) hiddenChannels[channel.type].push(channel); - } - } - else hiddenChannels = hiddenChannelCache[guild.id].hidden; - for (let type in hiddenChannels) hiddenChannels[type] = hiddenChannels[type].filter(c => BDFDB.LibraryModules.ChannelStore.getChannel(c.id)); - hiddenChannelCache[guild.id] = {hidden: hiddenChannels, amount: BDFDB.ObjectUtils.toArray(hiddenChannels).flat().length, visible: visibleAmount, roles: rolesAmount}; - return [hiddenChannelCache[guild.id].hidden, hiddenChannelCache[guild.id].amount]; - } - - batchSetGuilds (settingsPanel, collapseStates, value) { - if (!value) { - for (let id of BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds()) blackList.push(id); - this.saveBlackList(BDFDB.ArrayUtils.removeCopies(blackList)); - } - else this.saveBlackList([]); - BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); - } - - saveBlackList (savedBlackList) { - blackList = savedBlackList; - BDFDB.DataUtils.save(savedBlackList, this, "blacklist"); - } - - saveCollapseList (savedCollapseList) { - collapseList = savedCollapseList; - BDFDB.DataUtils.save(savedCollapseList, this, "categorydata"); - } - - openAccessModal (channel, allowed) { - let isThread = BDFDB.ChannelUtils.isThread(channel); - let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id); - let myMember = guild && BDFDB.LibraryModules.MemberStore.getMember(guild.id, BDFDB.UserUtils.me.id); - - let parentChannel = isThread && BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.ChannelStore.getChannel(channel.id).parent_id); - let category = parentChannel && parentChannel.parent_id && BDFDB.LibraryModules.ChannelStore.getChannel(parentChannel.parent_id) || BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.ChannelStore.getChannel(channel.id).parent_id); - - let lightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight; - - let addUser = (id, users) => { - let user = BDFDB.LibraryModules.UserStore.getUser(id); - if (user) users.push(Object.assign({}, user, BDFDB.LibraryModules.MemberStore.getMember(guild.id, id) || {})); - else users.push({id: id, username: `UserId: ${id}`, fetchable: true}); - }; - let checkAllowPerm = permString => { - return (permString | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == permString && (channel.type != BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE || (permString | BDFDB.DiscordConstants.Permissions.CONNECT) == permString); - }; - let checkDenyPerm = permString => { - return (permString | BDFDB.DiscordConstants.Permissions.VIEW_CHANNEL) == permString || (channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE && (permString | BDFDB.DiscordConstants.Permissions.CONNECT) == permString); - }; - - let allowedRoles = [], allowedUsers = [], deniedRoles = [], deniedUsers = [], everyoneDenied = false; - for (let id in channel.permissionOverwrites) { - if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.ROLE || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.ROLE) && (guild.roles[id] && guild.roles[id].name != "@everyone") && checkAllowPerm(channel.permissionOverwrites[id].allow)) { - allowedRoles.push(Object.assign({overwritten: myMember && myMember.roles.includes(id) && !allowed}, guild.roles[id])); - } - else if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER) && checkAllowPerm(channel.permissionOverwrites[id].allow)) { - addUser(id, allowedUsers); - } - if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.ROLE || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.ROLE) && checkDenyPerm(channel.permissionOverwrites[id].deny)) { - deniedRoles.push(guild.roles[id]); - if (guild.roles[id] && guild.roles[id].name == "@everyone") everyoneDenied = true; - } - else if ((channel.permissionOverwrites[id].type == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER || overrideTypes[channel.permissionOverwrites[id].type] == BDFDB.DiscordConstants.PermissionOverrideType.MEMBER) && checkDenyPerm(channel.permissionOverwrites[id].deny)) { - addUser(id, deniedUsers); - } - } - - if (![].concat(allowedUsers, deniedUsers).find(user => user.id == guild.ownerId)) addUser(guild.ownerId, allowedUsers); - for (let id in guild.roles) if ((guild.roles[id].permissions | BDFDB.DiscordConstants.Permissions.ADMINISTRATOR) == guild.roles[id].permissions && ![].concat(allowedRoles, deniedRoles).find(role => role.id == id)) allowedRoles.push(Object.assign({overwritten: myMember && myMember.roles.includes(id) && !allowed}, guild.roles[id])); - if (allowed && !everyoneDenied) allowedRoles.push({name: "@everyone"}); - - let allowedElements = [], deniedElements = []; - for (let role of allowedRoles) allowedElements.push(BDFDB.ReactUtils.createElement(RoleRowComponent, {role: role, guildId: guild.id, channelId: channel.id})); - for (let user of allowedUsers) allowedElements.push(BDFDB.ReactUtils.createElement(UserRowComponent, {user: user, guildId: guild.id, channelId: channel.id})); - for (let role of deniedRoles) deniedElements.push(BDFDB.ReactUtils.createElement(RoleRowComponent, {role: role, guildId: guild.id, channelId: channel.id})); - for (let user of deniedUsers) deniedElements.push(BDFDB.ReactUtils.createElement(UserRowComponent, {user: user, guildId: guild.id, channelId: channel.id})); - - const infoStrings = [ - isThread && { - title: BDFDB.LanguageUtils.LanguageStrings.THREAD_NAME, - text: channel.name - }, !isThread && { - title: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_CHANNEL_NAME, - text: channel.name - }, channel.type == BDFDB.DiscordConstants.ChannelTypes.GUILD_VOICE ? { - title: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_BITRATE, - text: channel.bitrate || "---" - } : { - title: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_CHANNEL_TOPIC, - text: BDFDB.ReactUtils.markdownParse(channel.topic || "---") - }, { - title: BDFDB.LanguageUtils.LanguageStrings.CHANNEL_TYPE, - text: BDFDB.LanguageUtils.LanguageStrings[typeNameMap[BDFDB.DiscordConstants.ChannelTypes[channel.type]]] - }, isThread && parentChannel && { - title: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_CHANNEL_NAME, - text: parentChannel.name - }, { - title: BDFDB.LanguageUtils.LanguageStrings.CATEGORY_NAME, - text: category && category.name || BDFDB.LanguageUtils.LanguageStrings.NO_CATEGORY - } - ].map((formLabel, i) => formLabel && [ - i == 0 ? null : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { - className: BDFDB.disCN.marginbottom20 - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { - title: `${formLabel.title}:`, - className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.marginbottom20, i == 0 && BDFDB.disCN.margintop8), - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, { - className: BDFDB.disCN.marginleft8, - children: formLabel.text - }) - }) - ]).flat(10).filter(n => n); - - BDFDB.ModalUtils.open(this, { - size: "MEDIUM", - header: BDFDB.LanguageUtils.LanguageStrings.CHANNEL + " " + BDFDB.LanguageUtils.LanguageStrings.ACCESSIBILITY, - subHeader: "#" + channel.name, - className: BDFDB.disCN._showhiddenchannelsaccessmodal, - contentClassName: BDFDB.DOMUtils.formatClassName(!isThread && BDFDB.disCN.listscroller), - onOpen: modalInstance => {if (modalInstance) accessModal = modalInstance;}, - children: isThread ? infoStrings : [ - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, { - className: BDFDB.disCN.modalsubinner, - tab: BDFDB.LanguageUtils.LanguageStrings.OVERLAY_SETTINGS_GENERAL_TAB, - children: infoStrings - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, { - tab: this.labels.modal_allowed, - children: allowedElements.length ? allowedElements : - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessagesPopoutComponents.EmptyStateBottom, { - msg: BDFDB.LanguageUtils.LanguageStrings.AUTOCOMPLETE_NO_RESULTS_HEADER, - image: lightTheme ? "/assets/9b0d90147f7fab54f00dd193fe7f85cd.svg" : "/assets/308e587f3a68412f137f7317206e92c2.svg" - }) - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, { - tab: this.labels.modal_denied, - children: deniedElements.length ? deniedElements : - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessagesPopoutComponents.EmptyStateBottom, { - msg: BDFDB.LanguageUtils.LanguageStrings.AUTOCOMPLETE_NO_RESULTS_HEADER, - image: lightTheme ? "/assets/9b0d90147f7fab54f00dd193fe7f85cd.svg" : "/assets/308e587f3a68412f137f7317206e92c2.svg" - }) - }) - ] - }); - } - - setLabelsByLanguage () { - switch (BDFDB.LanguageUtils.getLanguage().id) { - case "bg": // Bulgarian - return { - context_changeorder: "Промяна на реда на скритите канали", - context_changeorder_bottom: "Родна категория в долната част", - context_changeorder_native: "Родна категория в правилен ред", - context_channelaccess: "Достъп до канал", - context_hidehidden: "Скриване на заключените канали", - modal_allowed: "Разрешено", - modal_denied: "Отрича се" - }; - case "cs": // Czech - return { - context_changeorder: "Změnit pořadí skrytých kanálů", - context_changeorder_bottom: "Nativní kategorie dole", - context_changeorder_native: "Nativní kategorie ve správném pořadí", - context_channelaccess: "Přístup ke kanálu", - context_hidehidden: "Skrýt zamčené kanály", - modal_allowed: "Povoleno", - modal_denied: "Odepřeno" - }; - case "da": // Danish - return { - context_changeorder: "Skift rækkefølge for skjulte kanaler", - context_changeorder_bottom: "Indfødt kategori i bunden", - context_changeorder_native: "Native Kategori i korrekt rækkefølge", - context_channelaccess: "Kanaltilgang", - context_hidehidden: "Skjul låste kanaler", - modal_allowed: "Tilladt", - modal_denied: "Nægtet" - }; - case "de": // German - return { - context_changeorder: "Reihenfolge der versteckten Kanäle ändern", - context_changeorder_bottom: "Native Kategorie ganz unten", - context_changeorder_native: "Native Kategorie in der richtigen Reihenfolge", - context_channelaccess: "Kanalzugriff", - context_hidehidden: "Versteckte Kanäle ausblenden", - modal_allowed: "Erlaubt", - modal_denied: "Verweigert" - }; - case "el": // Greek - return { - context_changeorder: "Αλλαγή σειράς κρυφών καναλιών", - context_changeorder_bottom: "Εγγενής κατηγορία στο κάτω μέρος", - context_changeorder_native: "Εγγενής κατηγορία σε σωστή σειρά", - context_channelaccess: "Πρόσβαση καναλιού", - context_hidehidden: "Απόκρυψη κλειδωμένων καναλιών", - modal_allowed: "Επιτρεπόμενο", - modal_denied: "Απορρίφθηκε" - }; - case "es": // Spanish - return { - context_changeorder: "Cambiar el orden de los canales ocultos", - context_changeorder_bottom: "Categoría nativa en la parte inferior", - context_changeorder_native: "Categoría nativa en el orden correcto", - context_channelaccess: "Acceso al canal", - context_hidehidden: "Ocultar canales bloqueados", - modal_allowed: "Permitido", - modal_denied: "Negado" - }; - case "fi": // Finnish - return { - context_changeorder: "Muuta piilotettujen kanavien järjestystä", - context_changeorder_bottom: "Alkuperäinen luokka alareunassa", - context_changeorder_native: "Alkuperäinen luokka oikeassa järjestyksessä", - context_channelaccess: "Kanavan käyttöoikeus", - context_hidehidden: "Piilota lukitut kanavat", - modal_allowed: "Sallittu", - modal_denied: "Kielletty" - }; - case "fr": // French - return { - context_changeorder: "Modifier l'ordre des canaux cachés", - context_changeorder_bottom: "Catégorie native en bas", - context_changeorder_native: "Catégorie native dans le bon ordre", - context_channelaccess: "Accès à la chaîne", - context_hidehidden: "Masquer les salons verrouillées", - modal_allowed: "Permis", - modal_denied: "Refusé" - }; - case "hi": // Hindi - return { - context_changeorder: "हिडन चैनल ऑर्डर बदलें", - context_changeorder_bottom: "नीचे की ओर मूल श्रेणी", - context_changeorder_native: "मूल श्रेणी सही क्रम में", - context_channelaccess: "चैनल एक्सेस", - context_hidehidden: "बंद चैनल छुपाएं Hide", - modal_allowed: "अनुमति है", - modal_denied: "निषेध" - }; - case "hr": // Croatian - return { - context_changeorder: "Promijenite redoslijed skrivenih kanala", - context_changeorder_bottom: "Izvorna kategorija na dnu", - context_changeorder_native: "Izvorna kategorija u ispravnom redoslijedu", - context_channelaccess: "Pristup kanalu", - context_hidehidden: "Sakrij zaključane kanale", - modal_allowed: "Dopuštena", - modal_denied: "Odbijen" - }; - case "hu": // Hungarian - return { - context_changeorder: "Rejtett csatornák sorrendjének módosítása", - context_changeorder_bottom: "Natív kategória az alján", - context_changeorder_native: "Natív kategória helyes sorrendben", - context_channelaccess: "Csatornához való hozzáférés", - context_hidehidden: "Zárt csatornák elrejtése", - modal_allowed: "Megengedett", - modal_denied: "Megtagadva" - }; - case "it": // Italian - return { - context_changeorder: "Modifica l'ordine dei canali nascosti", - context_changeorder_bottom: "Categoria nativa in basso", - context_changeorder_native: "Categoria nativa nell'ordine corretto", - context_channelaccess: "Accesso al canale", - context_hidehidden: "Nascondi canali bloccati", - modal_allowed: "Consentito", - modal_denied: "Negato" - }; - case "ja": // Japanese - return { - context_changeorder: "非表示チャネルの順序を変更する", - context_changeorder_bottom: "下部のネイティブカテゴリ", - context_changeorder_native: "正しい順序のネイティブカテゴリ", - context_channelaccess: "チャネルアクセス", - context_hidehidden: "ロックされたチャンネルを非表示にする", - modal_allowed: "許可", - modal_denied: "拒否されました" - }; - case "ko": // Korean - return { - context_changeorder: "숨겨진 채널 순서 변경", - context_changeorder_bottom: "하단의 기본 카테고리", - context_changeorder_native: "올바른 순서의 네이티브 카테고리", - context_channelaccess: "채널 액세스", - context_hidehidden: "잠긴 채널 숨기기", - modal_allowed: "허용됨", - modal_denied: "거부 됨" - }; - case "lt": // Lithuanian - return { - context_changeorder: "Keisti paslėptų kanalų tvarką", - context_changeorder_bottom: "Gimtoji kategorija apačioje", - context_changeorder_native: "Gimtoji kategorija teisinga tvarka", - context_channelaccess: "Prieiga prie kanalo", - context_hidehidden: "Slėpti užrakintus kanalus", - modal_allowed: "Leidžiama", - modal_denied: "Paneigta" - }; - case "nl": // Dutch - return { - context_changeorder: "Wijzig de volgorde van verborgen kanalen", - context_changeorder_bottom: "Native categorie onderaan", - context_changeorder_native: "Native categorie in de juiste volgorde", - context_channelaccess: "Kanaaltoegang", - context_hidehidden: "Verberg vergrendelde kanalen", - modal_allowed: "Toegestaan", - modal_denied: "Geweigerd" - }; - case "no": // Norwegian - return { - context_changeorder: "Endre rekkefølgen på skjulte kanaler", - context_changeorder_bottom: "Innfødt kategori nederst", - context_changeorder_native: "Innfødt kategori i riktig rekkefølge", - context_channelaccess: "Kanaltilgang", - context_hidehidden: "Skjul låste kanaler", - modal_allowed: "Tillatt", - modal_denied: "Nektet" - }; - case "pl": // Polish - return { - context_changeorder: "Zmień kolejność ukrytych kanałów", - context_changeorder_bottom: "Kategoria natywna na dole", - context_changeorder_native: "Kategoria natywna we właściwej kolejności", - context_channelaccess: "Dostęp do kanałów", - context_hidehidden: "Ukryj zablokowane kanały", - modal_allowed: "Dozwolony", - modal_denied: "Odmówiono" - }; - case "pt-BR": // Portuguese (Brazil) - return { - context_changeorder: "Alterar a ordem dos canais ocultos", - context_changeorder_bottom: "Categoria nativa na parte inferior", - context_changeorder_native: "Categoria nativa na ordem correta", - context_channelaccess: "Acesso ao canal", - context_hidehidden: "Ocultar canais bloqueados", - modal_allowed: "Permitido", - modal_denied: "Negado" - }; - case "ro": // Romanian - return { - context_changeorder: "Schimbați comanda canalelor ascunse", - context_changeorder_bottom: "Categorie nativă în partea de jos", - context_changeorder_native: "Categorie nativă în ordine corectă", - context_channelaccess: "Acces la canal", - context_hidehidden: "Ascundeți canalele blocate", - modal_allowed: "Permis", - modal_denied: "Negat" - }; - case "ru": // Russian - return { - context_changeorder: "Изменить порядок скрытых каналов", - context_changeorder_bottom: "Родная категория внизу", - context_changeorder_native: "Собственная категория в правильном порядке", - context_channelaccess: "Доступ к каналу", - context_hidehidden: "Скрыть заблокированные каналы", - modal_allowed: "Разрешенный", - modal_denied: "Отказано" - }; - case "sv": // Swedish - return { - context_changeorder: "Ändra ordning för dolda kanaler", - context_changeorder_bottom: "Naturlig kategori längst ner", - context_changeorder_native: "Naturlig kategori i rätt ordning", - context_channelaccess: "Kanaltillgång", - context_hidehidden: "Dölj låsta kanaler", - modal_allowed: "Tillåtet", - modal_denied: "Förnekad" - }; - case "th": // Thai - return { - context_changeorder: "เปลี่ยนลำดับช่องที่ซ่อนอยู่", - context_changeorder_bottom: "หมวดหมู่ดั้งเดิมที่ด้านล่าง", - context_changeorder_native: "หมวดหมู่ดั้งเดิมในลำดับที่ถูกต้อง", - context_channelaccess: "การเข้าถึงช่อง", - context_hidehidden: "ซ่อนช่องที่ถูกล็อก", - modal_allowed: "ได้รับอนุญาต", - modal_denied: "ถูกปฏิเสธ" - }; - case "tr": // Turkish - return { - context_changeorder: "Gizli Kanal Sırasını Değiştir", - context_changeorder_bottom: "Altta Yerel Kategori", - context_changeorder_native: "Yerel Kategori doğru sırada", - context_channelaccess: "Kanal Erişimi", - context_hidehidden: "Kilitli Kanalları Gizle", - modal_allowed: "İzin veriliyor", - modal_denied: "Reddedildi" - }; - case "uk": // Ukrainian - return { - context_changeorder: "Змінити порядок прихованих каналів", - context_changeorder_bottom: "Рідна категорія внизу", - context_changeorder_native: "Рідна категорія в правильному порядку", - context_channelaccess: "Доступ до каналу", - context_hidehidden: "Сховати заблоковані канали", - modal_allowed: "Дозволено", - modal_denied: "Заперечується" - }; - case "vi": // Vietnamese - return { - context_changeorder: "Thay đổi thứ tự các kênh bị ẩn", - context_changeorder_bottom: "Danh mục Gốc ở dưới cùng", - context_changeorder_native: "Danh mục gốc theo đúng thứ tự", - context_channelaccess: "Quyền truy cập kênh", - context_hidehidden: "Ẩn các kênh đã khóa", - modal_allowed: "Được phép", - modal_denied: "Phủ định" - }; - case "zh-CN": // Chinese (China) - return { - context_changeorder: "更改隐藏频道顺序", - context_changeorder_bottom: "底部的原生类别", - context_changeorder_native: "正确顺序的本地类别", - context_channelaccess: "频道访问", - context_hidehidden: "隐藏锁定的频道", - modal_allowed: "允许的", - modal_denied: "被拒绝" - }; - case "zh-TW": // Chinese (Taiwan) - return { - context_changeorder: "更改隱藏頻道順序", - context_changeorder_bottom: "底部的原生類別", - context_changeorder_native: "正確順序的本地類別", - context_channelaccess: "頻道訪問", - context_hidehidden: "隱藏鎖定的頻道", - modal_allowed: "允許的", - modal_denied: "被拒絕" - }; - default: // English - return { - context_changeorder: "Change Hidden Channels Order", - context_changeorder_bottom: "Native Category at the bottom", - context_changeorder_native: "Native Category in correct Order", - context_channelaccess: "Channel Access", - context_hidehidden: "Hide Locked Channels", - modal_allowed: "Permitted", - modal_denied: "Denied" - }; - } - } - }; - })(window.BDFDB_Global.PluginUtils.buildPlugin(config)); -})(); diff --git a/files/discord/plugins/SplitLargeMessages.plugin.js b/files/discord/plugins/SplitLargeMessages.plugin.js @@ -1,350 +0,0 @@ -/** - * @name SplitLargeMessages - * @author DevilBro - * @authorId 278543574059057154 - * @version 1.8.0 - * @description Allows you to enter larger Messages, which will automatically split into several smaller Messages - * @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/SplitLargeMessages/ - */ - -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]) => { - const messageDelay = 1000; //changing at own risk, might result in bans or mutes - let maxMessageLength = 2000; - - return class SplitLargeMessages extends Plugin { - onLoad () { - this.defaults = { - general: { - byNewlines: {value: false, description: "Try to split Messages on Newlines instead of Spaces", note: "This will stop Sentences from being cut, but might result in more Messages being sent"}, - }, - amounts: { - splitCounter: {value: 0, description: "Messages will be split after roughly X Characters"}, - } - }; - - this.modulePatches = { - before: [ - "ChannelTextAreaContainer", - "ChannelTextAreaEditor" - ], - after: [ - "ChannelTextAreaContainer" - ] - }; - - this.css = ` - ${BDFDB.dotCN.textareacharcounterupsell} { - display: none; - } - `; - } - - onStart () { - maxMessageLength = BDFDB.LibraryModules.NitroUtils.canUseIncreasedMessageLength(BDFDB.LibraryStores.UserStore.getCurrentUser()) ? BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH_PREMIUM : BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH; - - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.ChatRestrictionUtils, "applyChatRestrictions", {before: e => { - if (e.methodArguments[0] && e.methodArguments[0].content && !this.isSlowDowned(e.methodArguments[0].channel)) e.methodArguments[0].content = "_"; - }}); - - BDFDB.PatchUtils.forceAllUpdates(this); - } - - onStop () { - BDFDB.PatchUtils.forceAllUpdates(this); - } - - getSettingsPanel (collapseStates = {}) { - let settingsPanel; - return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, { - collapseStates: collapseStates, - children: _ => { - let settingsItems = []; - - for (let key in this.defaults.general) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "Switch", - plugin: this, - keys: ["general", key], - label: this.defaults.general[key].description, - note: this.defaults.general[key].note, - value: this.settings.general[key] - })); - - settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { - type: "TextInput", - childProps: { - type: "number" - }, - plugin: this, - keys: ["amounts", "splitCounter"], - label: this.defaults.amounts.splitCounter.description, - basis: "20%", - min: 1000, - max: maxMessageLength, - value: this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter - })); - - return settingsItems; - } - }); - } - - onSettingsClosed (e) { - if (this.SettingsUpdated) { - delete this.SettingsUpdated; - BDFDB.PatchUtils.forceAllUpdates(this); - } - } - - processChannelTextAreaContainer (e) { - if (e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY && e.instance.props.type != BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) return; - const splitMessageLength = this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter; - if (!e.returnvalue) { - BDFDB.PatchUtils.patch(this, e.instance.props, "onSubmit", {instead: e2 => { - if (e2.methodArguments[0].value.length > splitMessageLength && !this.isSlowDowned(e.instance.props.channel)) { - e2.stopOriginalMethodCall(); - let messages = this.formatText(e2.methodArguments[0].value).filter(n => n); - for (let i in messages) BDFDB.TimeUtils.timeout(_ => { - let last = i >= messages.length-1; - e2.originalMethod(last ? Object.assign({}, e2.methodArguments[0], {value: messages[i]}) : {stickers: [], uploads: [], value: messages[i]}); - if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent, {type: "success"}); - }, messageDelay * i * (messages > 4 ? 2 : 1)); - return Promise.resolve({ - shouldClear: true, - shouldRefocus: true - }); - } - else return e2.callOriginalMethodAfterwards(); - }}, {noCache: true}); - } - else { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ChannelTextAreaCounter"}); - if (index > -1 && children[index].props.textValue && children[index].props.textValue.length > splitMessageLength && !this.isSlowDowned(e.instance.props.channel)) children[index] = BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS.textareacharcounter + BDFDB.disCN.textareacharcountererror, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { - text: Math.ceil(children[index].props.textValue.length / splitMessageLength * (39/40)) + " " + BDFDB.LanguageUtils.LanguageStrings.MESSAGES, - children: BDFDB.ReactUtils.createElement("span", { - children: splitMessageLength - children[index].props.textValue.length - }) - }) - }); - } - } - - processChannelTextAreaEditor (e) { - if (e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL || e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY || e.instance.props.type == BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) e.instance.props.uploadPromptCharacterCount = 999999999999999; - } - - isSlowDowned (channel) { - return channel.rateLimitPerUser && !BDFDB.UserUtils.can("MANAGE_CHANNELS", BDFDB.UserUtils.me.id, channel.id) && !BDFDB.UserUtils.can("MANAGE_MESSAGES", BDFDB.UserUtils.me.id, channel.id); - } - - formatText (text) { - const separator = !this.settings.general.byNewlines ? "\n" : " "; - const splitMessageLength = this.settings.amounts.splitCounter < 1000 || this.settings.amounts.splitCounter > maxMessageLength ? maxMessageLength : this.settings.amounts.splitCounter; - - text = text.replace(/\t/g, " "); - let longWords = text.match(new RegExp(`[^${separator.replace("\n", "\\n")}]{${splitMessageLength * (19/20)},}`, "gm")); - if (longWords) for (let longWord of longWords) { - let count1 = 0; - let shortWords = []; - longWord.split("").forEach(c => { - if (shortWords[count1] && (shortWords[count1].length >= splitMessageLength * (19/20) || (c == "\n" && shortWords[count1].length >= splitMessageLength * (19/20) - 100))) count1++; - shortWords[count1] = shortWords[count1] ? shortWords[count1] + c : c; - }); - text = text.replace(longWord, shortWords.join(separator)); - } - let messages = []; - let count2 = 0; - text.split(separator).forEach((word) => { - if (messages[count2] && (messages[count2] + "" + word).length > splitMessageLength * (39/40)) count2++; - messages[count2] = messages[count2] ? messages[count2] + separator + word : word; - }); - - let insertCodeBlock = null, insertCodeLine = null; - for (let j = 0; j < messages.length; j++) { - if (insertCodeBlock) { - messages[j] = insertCodeBlock + messages[j]; - insertCodeBlock = null; - } - else if (insertCodeLine) { - messages[j] = insertCodeLine + messages[j]; - insertCodeLine = null; - } - - let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm); - let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm); - - if (codeBlocks && codeBlocks.length % 2 == 1) { - messages[j] = messages[j] + "```"; - insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n"; - } - else if (codeLines && codeLines.length % 2 == 1) { - insertCodeLine = codeLines[codeLines.length-1].replace(/[^`]/g, ""); - messages[j] = messages[j] + insertCodeLine; - } - } - return messages; - } - - setLabelsByLanguage () { - switch (BDFDB.LanguageUtils.getLanguage().id) { - case "bg": // Bulgarian - return { - toast_allsent: "Всички изпратени съобщения" - }; - case "da": // Danish - return { - toast_allsent: "Alle beskeder sendt" - }; - case "de": // German - return { - toast_allsent: "Alle Nachrichten gesendet" - }; - case "el": // Greek - return { - toast_allsent: "Όλα τα μηνύματα εστάλησαν" - }; - case "es": // Spanish - return { - toast_allsent: "Todos los mensajes enviados" - }; - case "fi": // Finnish - return { - toast_allsent: "Kaikki viestit lähetetty" - }; - case "fr": // French - return { - toast_allsent: "Tous les messages envoyés" - }; - case "hr": // Croatian - return { - toast_allsent: "Sve poruke poslane" - }; - case "hu": // Hungarian - return { - toast_allsent: "Minden üzenet elküldve" - }; - case "it": // Italian - return { - toast_allsent: "Tutti i messaggi inviati" - }; - case "ja": // Japanese - return { - toast_allsent: "送信されたすべてのメッセージ" - }; - case "ko": // Korean - return { - toast_allsent: "보낸 모든 메시지" - }; - case "lt": // Lithuanian - return { - toast_allsent: "Visi pranešimai išsiųsti" - }; - case "nl": // Dutch - return { - toast_allsent: "Alle berichten zijn verzonden" - }; - case "no": // Norwegian - return { - toast_allsent: "Alle meldinger sendt" - }; - case "pl": // Polish - return { - toast_allsent: "Wszystkie wiadomości wysłane" - }; - case "pt-BR": // Portuguese (Brazil) - return { - toast_allsent: "Todas as mensagens enviadas" - }; - case "ro": // Romanian - return { - toast_allsent: "Toate mesajele trimise" - }; - case "ru": // Russian - return { - toast_allsent: "Все сообщения отправлены" - }; - case "sv": // Swedish - return { - toast_allsent: "Alla meddelanden skickade" - }; - case "th": // Thai - return { - toast_allsent: "ส่งข้อความทั้งหมดแล้ว" - }; - case "tr": // Turkish - return { - toast_allsent: "Tüm mesajlar gönderildi" - }; - case "uk": // Ukrainian - return { - toast_allsent: "Усі повідомлення надіслано" - }; - case "vi": // Vietnamese - return { - toast_allsent: "Tất cả tin nhắn đã gửi" - }; - case "zh-CN": // Chinese (China) - return { - toast_allsent: "已发送所有消息" - }; - case "zh-TW": // Chinese (Taiwan) - return { - toast_allsent: "已發送所有消息" - }; - default: // English - return { - toast_allsent: "All Messages sent" - }; - } - } - }; - })(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog)); -})(); diff --git a/files/discord/plugins/TypingUsersAvatars.plugin.js b/files/discord/plugins/TypingUsersAvatars.plugin.js @@ -1,193 +0,0 @@ -/** -* @name TypingUsersAvatars -* @source https://github.com/QWERTxD/BetterDiscordPlugins/blob/main/TypingUsersAvatars/TypingUsersAvatars.plugin.js -* @website https://github.com/QWERTxD/BetterDiscordPlugins/tree/main/TypingUsersAvatars -* @version 1.0.5 -* @description Shows avatars of typing users. -*/ - -const request = require('request'); -const fs = require('fs'); -const path = require('path'); - -const config = { - info: { - name: 'TypingUsersAvatars', - authors: [ - { - name: 'QWERT' - } - ], - version: '1.0.5', - description: 'Shows avatars of typing users.', - github_raw: "https://raw.githubusercontent.com/QWERTxD/BetterDiscordPlugins/main/TypingUsersAvatars/TypingUsersAvatars.plugin.js", - }, - changelog: [ - { - title: 'What\'s new?', - type: 'added', - items: [ - 'Added option to show guild avatars of typing users', - ] - } - ], - defaultConfig: [ - { - type: 'switch', - name: 'Show users status', - id: 'showStatus', - value: true - }, - { - type: 'switch', - name: 'Show guild avatars', - id: 'showGuildAvatar', - value: true - } - ] -}; - -module.exports = !global.ZeresPluginLibrary ? class { - constructor() { - this._config = config; - } - - load() { - BdApi.showConfirmationModal('Library plugin is needed', - `The library plugin needed for AQWERT'sPluginBuilder is missing. Please click Download Now to install it.`, { - confirmText: 'Download', - cancelText: 'Cancel', - onConfirm: () => { - request.get('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => { - if (error) - return electron.shell.openExternal('https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js'); - - fs.writeFileSync(path.join(BdApi.Plugins.folder, '0PluginLibrary.plugin.js'), body); - }); - } - }); - } - - start() { } - - stop() { } -} : (([Plugin, Library]) => { - const { DiscordModules, WebpackModules, PluginUtilities, Patcher, ReactComponents, Popouts, Utilities, DiscordSelectors } = Library; - const { React, UserStore, RelationshipStore, UserStatusStore, Strings } = DiscordModules; - const AssetUtils = WebpackModules.getByProps("getUserBannerURL"); - const Avatar = WebpackModules.getByProps('AnimatedAvatar'); - const VoiceUserSummary = WebpackModules.findByDisplayName("VoiceUserSummaryItem") - - class AvatarComponent extends React.Component { - render() { - const { user, status, guildId } = this.props; - const guildAvatar = AssetUtils.getGuildMemberAvatarURL({ guildId: guildId, userId: user.id, avatar: user.guildMemberAvatars[guildId] }); - return React.createElement(Avatar.default, { - src: user?.guildMemberAvatars[guildId] ? guildAvatar : user.getAvatarURL(), - status: status, - size: Avatar.Sizes.SIZE_16, - onClick() { - Popouts.showUserPopout(document.getElementById(`typing-user-${user.id}`), user) - } - }) - } - } - - class plugin extends Plugin { - constructor() { - super(); - this.getSettingsPanel = () => { - return this.buildSettingsPanel().getElement(); - }; - } - - onStart() { - Utilities.suppressErrors(this.patch.bind(this))(); - - PluginUtilities.addStyle('TypingUsersAvatars', ` - .typing-2J1mQU .text-3S7XCz { - margin: 0; - } - - .typing-2J1mQU .wrapper-1VLyxH { - display: flex; - margin: 0 4px; - } - - .typing-2J1mQU .text-3S7XCz, - .typing-2J1mQU .text-3S7XCz > strong { - display: contents; - } - - .several-users { - margin-left: 5px; - margin-right: 5px; - } - - .several-users .avatarSize-1KpZ5E { - margin: 0; - } - `) - } - - onStop() { - Patcher.unpatchAll(); - PluginUtilities.removeStyle('TypingUsersAvatars'); - } - - filter(users) { - return Object.keys(users).filter((user) => { - return user != UserStore.getCurrentUser().id && !RelationshipStore.isBlocked(user); - }) - } - - /* code highly inspired by https://github.com/rauenzi/BetterDiscordAddons/blob/master/Plugins/BetterRoleColors/BetterRoleColors.plugin.js */ - async patch() { - const TypingUsers = await ReactComponents.getComponentByName('TypingUsers', DiscordSelectors.Typing.typing); - Patcher.after(TypingUsers.component.prototype, 'render', (thisObject, [props], ret) => { - const typingUsers = this.filter({ ...thisObject.props.typingUsers }); - const guildId = thisObject.props?.guildId; - - for (let u = 0; u < typingUsers.length; u++) { - const user = UserStore.getUser(typingUsers[u]); - const status = this.settings.showStatus ? UserStatusStore.getStatus(user.id) : null; - - if (ret.props.children[0].props.children[1]?.props.children !== Strings.Messages.SEVERAL_USERS_TYPING) { - const usersComponent = ret.props.children[0].props.children[1].props.children.filter(user => user.props); - - usersComponent[u].props.children.unshift(React.createElement("div", { - id: `typing-user-${user.id}`, - children: React.createElement(AvatarComponent, { user, status, guildId }) - })); - } else { - ret.props.children[0].props.children = [ - React.createElement(VoiceUserSummary, { - className: "several-users", - users: typingUsers.map(UserStore.getUser), - max: 3 - }), - ret.props.children[0].props.children - ] - } - } - - if (!ret) return; - const tree = ret.props.children; - if (!tree) return; - - tree.map((child) => { - const children = child?.props?.children; - if (!children || typeof children !== 'object') return; - - child.props.style = { - display: 'flex', - alignItems: 'center' - }; - }) - }) - } - - } - - return plugin; -})(global.ZeresPluginLibrary.buildPlugin(config)); diff --git a/files/discord/theme.css b/files/discord/theme.css @@ -1 +0,0 @@ -@import "https://raw.githack.com/GeopJr/DNOME/dist/DNOME.css"; diff --git a/files/fonts/proprietary/ms-core/arial.ttf b/files/fonts/proprietary/ms-core/arial.ttf Binary files differ. diff --git a/files/fonts/proprietary/ms-core/calibri.ttf b/files/fonts/proprietary/ms-core/calibri.ttf Binary files differ. diff --git a/files/fonts/proprietary/ms-core/cour.ttf b/files/fonts/proprietary/ms-core/cour.ttf Binary files differ. diff --git a/files/fonts/proprietary/ms-core/symbol.ttf b/files/fonts/proprietary/ms-core/symbol.ttf Binary files differ. diff --git a/files/fonts/proprietary/ms-core/times.ttf b/files/fonts/proprietary/ms-core/times.ttf Binary files differ. diff --git a/files/fonts/proprietary/ms-core/wingding.ttf b/files/fonts/proprietary/ms-core/wingding.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Black.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Black.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Bold.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Bold.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Book.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Book.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Light.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Light.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Medium.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Medium.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Regular.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Regular.ttf Binary files differ. diff --git a/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Thin.ttf b/files/fonts/proprietary/oneplus-slate/OnePlusSlate-Thin.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Black.ttf b/files/fonts/proprietary/product-sans/ProductSans-Black.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-BlackItalic.ttf b/files/fonts/proprietary/product-sans/ProductSans-BlackItalic.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Bold.ttf b/files/fonts/proprietary/product-sans/ProductSans-Bold.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-BoldItalic.ttf b/files/fonts/proprietary/product-sans/ProductSans-BoldItalic.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Italic.ttf b/files/fonts/proprietary/product-sans/ProductSans-Italic.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Light.ttf b/files/fonts/proprietary/product-sans/ProductSans-Light.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-LightItalic.ttf b/files/fonts/proprietary/product-sans/ProductSans-LightItalic.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Medium.ttf b/files/fonts/proprietary/product-sans/ProductSans-Medium.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-MediumItalic.ttf b/files/fonts/proprietary/product-sans/ProductSans-MediumItalic.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Regular.ttf b/files/fonts/proprietary/product-sans/ProductSans-Regular.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-Thin.ttf b/files/fonts/proprietary/product-sans/ProductSans-Thin.ttf Binary files differ. diff --git a/files/fonts/proprietary/product-sans/ProductSans-ThinItalic.ttf b/files/fonts/proprietary/product-sans/ProductSans-ThinItalic.ttf Binary files differ. diff --git a/files/gnome/dconf.nix b/files/gnome/dconf.nix @@ -12,7 +12,7 @@ in { # Home Directory home.file = { # Wallpapers - ".local/share/backgrounds".source = files.images.wallpapers; + ".local/share/backgrounds".source = files.proprietary.wallpapers; # GTK+ Bookmarks ".config/gtk-3.0/bookmarks".text = lib.mkBefore '' @@ -601,8 +601,6 @@ in { grandchild-offset-hover = 31.0; grandchild-size = 17.0; grandchild-size-hover = 27.0; - menu-configuration = '' - [{"name":"Navigation","icon":"application-menu","shortcut":"F9","centered":false,"id":0,"children":[{"name":"Sound","icon":"audio-speakers","children":[{"name":"Mute","icon":"discord-tray-muted","type":"Shortcut","data":"AudioMute","angle":-1},{"name":"Play / Pause","icon":"exaile-play","type":"Shortcut","data":"AudioPlay","angle":-1},{"name":"Next","icon":"go-next-symbolic","type":"Shortcut","data":"AudioNext","angle":90},{"name":"Previous","icon":"go-next-symbolic-rtl","type":"Shortcut","data":"AudioPrev","angle":270}],"type":"CustomMenu","data":{},"angle":-1},{"name":"Menu","type":"Command","icon":"gnome-menu","data":{"command":"gnome-extensions prefs flypie@schneegans.github.com"},"angle":-1},{"name":"Tasks","type":"Command","icon":"gnome-system-monitor","data":{"command":"gnome-system-monitor"},"angle":-1},{"name":"System","type":"System","icon":"system-log-out","angle":-1,"data":{}},{"name":"Previous","icon":"go-previous","type":"Shortcut","data":{"shortcut":"<Super>Left"},"angle":270},{"name":"Close","icon":"window-close","type":"Shortcut","data":"<Alt>F4","angle":-1},{"name":"Switcher","icon":"preferences-system-windows","type":"RunningApps","data":{"activeWorkspaceOnly":false,"appGrouping":true,"hoverPeeking":true,"nameRegex":""},"angle":-1},{"name":"Favorites","icon":"emblem-favorite","type":"Favorites","data":{},"angle":-1},{"name":"Maximize","icon":"view-fullscreen","type":"Shortcut","data":{"shortcut":"<Super>Up"},"angle":-1},{"name":"Next","icon":"go-next","type":"Shortcut","data":{"shortcut":"<Super>Right"},"angle":-1}],"type":"CustomMenu","data":{}}]''; preview-on-right-side = true; stashed-items = "[ ]"; stats-abortions = mkUint32 38; diff --git a/files/images/wallpapers/Beauty.jpg b/files/images/wallpapers/Beauty.jpg Binary files differ. diff --git a/files/images/wallpapers/City.jpg b/files/images/wallpapers/City.jpg Binary files differ. diff --git a/files/images/wallpapers/Firewatch.jpg b/files/images/wallpapers/Firewatch.jpg Binary files differ. diff --git a/files/images/wallpapers/Future.jpg b/files/images/wallpapers/Future.jpg Binary files differ. diff --git a/files/images/wallpapers/Island.jpg b/files/images/wallpapers/Island.jpg Binary files differ. diff --git a/files/images/wallpapers/Metro.jpg b/files/images/wallpapers/Metro.jpg Binary files differ. diff --git a/files/images/wallpapers/Neon.jpg b/files/images/wallpapers/Neon.jpg Binary files differ. diff --git a/files/images/wallpapers/Saturn.jpg b/files/images/wallpapers/Saturn.jpg Binary files differ. diff --git a/files/images/wallpapers/Shards.jpg b/files/images/wallpapers/Shards.jpg Binary files differ. diff --git a/files/images/wallpapers/Sunrise.jpg b/files/images/wallpapers/Sunrise.jpg Binary files differ. diff --git a/files/images/wallpapers/Sunset.jpg b/files/images/wallpapers/Sunset.jpg Binary files differ. diff --git a/files/images/wallpapers/Tomorrow.jpg b/files/images/wallpapers/Tomorrow.jpg Binary files differ. diff --git a/flake.lock b/flake.lock @@ -392,6 +392,21 @@ }, "nixpkgs_4": { "locked": { + "lastModified": 1696484316, + "narHash": "sha256-LE7F+Wrvo1B8OR3E1bITYAcfBaNKXLHqBrXoZEtqrTQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "47db6b44173e3360cb2339f5acda13db04f72ae9", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { "lastModified": 1694760568, "narHash": "sha256-3G07BiXrp2YQKxdcdms22MUx6spc6A++MSePtatCYuI=", "owner": "NixOS", @@ -421,6 +436,25 @@ "type": "github" } }, + "proprietary": { + "inputs": { + "nixpkgs": "nixpkgs_4", + "utils": "utils_2" + }, + "locked": { + "lastModified": 1696490160, + "narHash": "sha256-LIEHEiWs0NDcuxIMk5axmR/IygPH153af7eHaAqQSps=", + "owner": "maydayv7", + "repo": "proprietary", + "rev": "e55e0e20f19c6fdf7d16bd03810c3d4ad6974d5d", + "type": "github" + }, + "original": { + "owner": "maydayv7", + "repo": "proprietary", + "type": "github" + } + }, "root": { "inputs": { "deploy": "deploy", @@ -435,17 +469,18 @@ "index": "index", "library": "library", "nur": "nur", + "proprietary": "proprietary", "sops": "sops", "stable": "stable", "unstable": "unstable", - "utils": "utils_2", + "utils": "utils_3", "windows": "windows", "wine": "wine" } }, "sops": { "inputs": { - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_5", "nixpkgs-stable": "nixpkgs-stable" }, "locked": { @@ -478,6 +513,21 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "unstable": { "locked": { "lastModified": 1695830400, @@ -511,6 +561,24 @@ }, "utils_2": { "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_3": { + "inputs": { "flake-utils": "flake-utils" }, "locked": { diff --git a/flake.nix b/flake.nix @@ -71,6 +71,9 @@ # Nix User Repository nur.url = "github:nix-community/NUR"; + # Proprietary Software + proprietary.url = "github:maydayv7/proprietary"; + # Packaged Games gaming.url = "github:fufexan/nix-gaming"; diff --git a/modules/apps/discord.nix b/modules/apps/discord.nix @@ -16,7 +16,7 @@ in { home.home = { # Plugins file.".config/BetterDiscord/plugins" = { - source = files.discord.plugins; + source = files.proprietary.discord; recursive = true; }; diff --git a/modules/apps/office.nix b/modules/apps/office.nix @@ -63,7 +63,7 @@ in { # Font Rendering ".local/share/fonts" = { - source = files.fonts.path; + source = "${pkgs.custom.fonts}/share/fonts"; recursive = true; }; }; diff --git a/modules/gui/gnome.nix b/modules/gui/gnome.nix @@ -121,7 +121,8 @@ in { # Discord DNOME Theme ".config/BetterDiscord/data/stable/custom.css" = - mkIf (elem pkgs.discord apps) {text = discord.theme;}; + mkIf (elem pkgs.discord apps) + {text = ''@import "https://raw.githack.com/GeopJr/DNOME/dist/DNOME.css";'';}; # Firefox GNOME Theme ".mozilla/firefox/default/chrome/userChrome.css".text = diff --git a/modules/nix/index.nix b/modules/nix/index.nix @@ -1,6 +1,5 @@ { config, - system, lib, inputs, pkgs, diff --git a/packages/fonts.nix b/packages/fonts.nix @@ -1,20 +0,0 @@ -{ - lib, - pkgs, - files, - ... -}: -pkgs.stdenv.mkDerivation rec { - pname = "fonts"; - version = "7"; - - src = files.fonts.path; - dontBuild = true; - installPhase = "mkdir -p $out/share/fonts/ && cp -r . $out/share/fonts/"; - - meta = with lib; { - description = "Custom Proprietary Fonts"; - license = licenses.unfree; - maintainers = ["maydayv7"]; - }; -}