diff --git a/.config/BetterDiscord/plugins/BlurNSFW.config.json b/.config/BetterDiscord/plugins/BlurNSFW.config.json index 57cab7f..ff77873 100755 --- a/.config/BetterDiscord/plugins/BlurNSFW.config.json +++ b/.config/BetterDiscord/plugins/BlurNSFW.config.json @@ -1,9 +1,15 @@ { "currentVersionInfo": { - "version": "1.0.1", + "version": "1.0.2", "hasShownChangelog": true }, "blurred": [], "sen": [], - "seen": [] + "seen": [ + "1004559719433764898", + "1006296543915155536", + "1006208838434828350", + "751477930021879808", + "732807937457782895" + ] } \ No newline at end of file diff --git a/.config/BetterDiscord/plugins/BlurNSFW.plugin.js b/.config/BetterDiscord/plugins/BlurNSFW.plugin.js index 1b05541..1db5a2c 100755 --- a/.config/BetterDiscord/plugins/BlurNSFW.plugin.js +++ b/.config/BetterDiscord/plugins/BlurNSFW.plugin.js @@ -1,7 +1,7 @@ /** * @name BlurNSFW * @description Blurs images and videos until you hover over them. - * @version 1.0.1 + * @version 1.0.2 * @author Zerebos * @authorId 249746236008169473 * @website https://github.com/rauenzi/BetterDiscordAddons/tree/master/Plugins/BlurNSFW @@ -41,7 +41,7 @@ const config = { twitter_username: "ZackRauen" } ], - version: "1.0.1", + version: "1.0.2", description: "Blurs images and videos until you hover over them.", github: "https://github.com/rauenzi/BetterDiscordAddons/tree/master/Plugins/BlurNSFW", github_raw: "https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BlurNSFW/BlurNSFW.plugin.js" @@ -51,15 +51,7 @@ const config = { title: "What's New?", type: "fixed", items: [ - "Context menu and blurring should work again!", - "Blurring and unblurring happen quicker and using less resources now!" - ] - }, - { - title: "Known Issues", - items: [ - "The checkbox in the context menu won't update after clicking.", - "This is just a visual issue, the functionality is fine." + "Can join voice channels without causing loading issues!" ] } ], @@ -232,7 +224,6 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { } channelChange() { - Dispatcher?.removeAllListeners(); const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId()); if (this.seenChannels.has(channel.id)) return; diff --git a/.config/BetterDiscord/plugins/CreationDate.plugin.js b/.config/BetterDiscord/plugins/CreationDate.plugin.js deleted file mode 100755 index fa238ae..0000000 --- a/.config/BetterDiscord/plugins/CreationDate.plugin.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @name CreationDate - * @author DevilBro - * @authorId 278543574059057154 - * @version 9.9.9 - * @description PLUGIN WAS DISCONTINUED - */ - -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 = `
The Library Plugin needed for ${this.name} is missing.\nPlease click Download Now to install it.
`; - template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary); - return template.content.firstElementChild; - } - } : (([Plugin, BDFDB]) => { - return class CreationDate extends Plugin { - onLoad () {} - - onStart () { - BDFDB.ModalUtils.open(this, { - header: "PLUGIN WAS DISCONTINUED", - children: [ - BDFDB.ReactUtils.createElement("span", {children: "DISCORD ADDED THIS FEATURE BY THEMSELVES, MAKING THIS PLUGIN USELESS "}), - BDFDB.ReactUtils.createElement("strong", {children: "DELETE"}), - BDFDB.ReactUtils.createElement("span", {children: " TO REMOVE THIS EMPTY PLUGIN FILE."}) - BDFDB.ReactUtils.createElement("strong", {children: "DELETE"}), - BDFDB.ReactUtils.createElement("span", {children: " TO REMOVE THIS EMPTY PLUGIN FILE."}) - ], - buttons: [ - {contents: "DELETE", close: true, color: "RED", onClick: _ => { - BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), "CreationDate.plugin.js"), error => {}); - BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), "CreationDate.config.json"), error => {}); - }} - ] - }); - } - - onStop () {} - }; - })(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog)); -})(); diff --git a/.config/BetterDiscord/plugins/EditRoles.plugin.js b/.config/BetterDiscord/plugins/EditRoles.plugin.js index be03333..7a99a83 100755 --- a/.config/BetterDiscord/plugins/EditRoles.plugin.js +++ b/.config/BetterDiscord/plugins/EditRoles.plugin.js @@ -2,7 +2,7 @@ * @name EditRoles * @author DevilBro * @authorId 278543574059057154 - * @version 1.1.2 + * @version 1.1.4 * @description Allows you to locally edit Roles * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -60,19 +60,17 @@ module.exports = (_ => { return class EditRoles extends Plugin { onLoad () { - this.patchedModules = { - before: { - RoleMention: "default", - AutocompleteRoleResult: "render", - MessageHeader: "default", - ChannelMembers: "render", - MemberListItem: "render", - UserPopoutBodySection: "default", - UserPopoutBody: "default" - }, - after: { - RichRoleMention: "RoleMention" - } + this.modulePatches = { + before: [ + "AutocompleteRoleResult", + "ChannelMembers", + "MemberListItem", + "MessageContent", + "UserPopoutBody" + ], + after: [ + "RichRoleMention" + ] }; } @@ -87,9 +85,9 @@ module.exports = (_ => { }); } }}); - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.MemberStore, "getMember", {after: e => { + BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.GuildMemberStore, "getMember", {after: e => { if (e.returnValue) { - let guild = BDFDB.LibraryModules.GuildStore.getGuild(e.methodArguments[0]); + let guild = BDFDB.LibraryStores.GuildStore.getGuild(e.methodArguments[0]); if (guild) { let colorRole, iconRole; for (let id of e.returnValue.roles) { @@ -159,19 +157,17 @@ module.exports = (_ => { } onUserContextMenu (e) { - if (e.subType == "useUserRolesItems") { - let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"}); - if (index > -1 && children[index].props && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) { - if (child && child.props && typeof child.props.label == "function" && changedRoles[child.props.id]) { - let data = changedRoles[child.props.id]; - let renderLabel = child.props.label; - child.props.label = BDFDB.TimeUtils.suppress((...args) => { - let label = renderLabel(...args); - if (data.color && label.props.children[0] && label.props.children[0].props) label.props.children[0].props.color = BDFDB.ColorUtils.convert(data.color, "hex"); - if (data.name && label.props.children[1] && label.props.children[1].props && label.props.children[1].props.children) label.props.children[1].props.children = data.name; - return label; - }, "Error in renderLabel of UserRolesItems", this); - } + let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"}); + if (index > -1 && children[index].props && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) { + if (child && child.props && typeof child.props.label == "function" && changedRoles[child.props.id]) { + let data = changedRoles[child.props.id]; + let renderLabel = child.props.label; + child.props.label = BDFDB.TimeUtils.suppress((...args) => { + let label = renderLabel(...args); + if (data.color && label.props.children[0] && label.props.children[0].props) label.props.children[0].props.color = BDFDB.ColorUtils.convert(data.color, "hex"); + if (data.name && label.props.children[1] && label.props.children[1].props && label.props.children[1].props.children) label.props.children[1].props.children = data.name; + return label; + }, "Error in renderLabel of UserRolesItems", this); } } } @@ -199,7 +195,7 @@ module.exports = (_ => { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.submenu_resetsettings, id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-reset"), - color: BDFDB.LibraryComponents.MenuItems.Colors.DANGER, + color: BDFDB.DiscordConstants.MenuItemColors.DANGER, disabled: !changedRoles[e.instance.props.id], action: event => { let remove = _ => { @@ -217,29 +213,27 @@ module.exports = (_ => { e.returnvalue.props.children ].flat(10).filter(n => n); } - - processRichRoleMention (e) { - if (e.instance.props.id && changedRoles[e.instance.props.id]) { - e.returnvalue.props.color = changedRoles[e.instance.props.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.id].color, "int") : e.returnvalue.props.color; - e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.props.children[1]; + + processMessageContent (e) { + if (!BDFDB.ArrayUtils.is(e.instance.props.content)) return; + for (let ele of e.instance.props.content) if (BDFDB.ReactUtils.isValidElement(ele) && ele.props && ele.props.type == "mention" && ele.props.roleId && changedRoles[ele.props.roleId]) { + ele.props.roleColor = changedRoles[ele.props.roleId].color ? BDFDB.ColorUtils.convert(changedRoles[ele.props.roleId].color, "int") : ele.props.roleColor; + if (changedRoles[ele.props.roleId].name) ele.props.children = ["@" + changedRoles[ele.props.roleId].name]; } } - processRoleMention (e) { - if (e.instance.props.roleId && changedRoles[e.instance.props.roleId]) { - e.instance.props.roleColor = changedRoles[e.instance.props.roleId].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.roleId].color, "int") : e.instance.props.roleColor; - e.instance.props.children = [`@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`]; - if (e.instance.props.content && e.instance.props.content[0]) e.instance.props.content[0].content = `@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`; - } + processRichRoleMention (e) { + if (!e.instance.props.id || !changedRoles[e.instance.props.id]) return; + e.returnvalue.props.color = changedRoles[e.instance.props.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.id].color, "int") : e.returnvalue.props.color; + e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.props.children[1]; } processAutocompleteRoleResult (e) { - if (e.instance.props.role && changedRoles[e.instance.props.role.id]) { - e.instance.props.role = Object.assign({}, e.instance.props.role); - e.instance.props.role.color = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "int") : e.instance.props.role.color; - e.instance.props.role.colorString = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "hex") : e.instance.props.role.colorString; - e.instance.props.role.name = changedRoles[e.instance.props.role.id].name || e.instance.props.role.name; - } + if (!e.instance.props.role || !changedRoles[e.instance.props.role.id]) return; + e.instance.props.role = Object.assign({}, e.instance.props.role); + e.instance.props.role.color = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "int") : e.instance.props.role.color; + e.instance.props.role.colorString = changedRoles[e.instance.props.role.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.role.id].color, "hex") : e.instance.props.role.colorString; + e.instance.props.role.name = changedRoles[e.instance.props.role.id].name || e.instance.props.role.name; } processChannelMembers (e) { @@ -256,14 +250,9 @@ module.exports = (_ => { } processMemberListItem (e) { - if (e.instance.props.user) { - let member = BDFDB.LibraryModules.MemberStore.getMember(e.instance.props.guildId, e.instance.props.user.id); - if (member) e.instance.props.colorString = member.colorString; - } - } - - processUserPopoutBodySection (e) { - if (e.instance.props.guild) e.instance.props.guild = this.changeRolesInGuild(e.instance.props.guild); + if (!e.instance.props.user) return; + let member = BDFDB.LibraryStores.GuildMemberStore.getMember(e.instance.props.guildId, e.instance.props.user.id); + if (member) e.instance.props.colorString = member.colorString; } processUserPopoutBody (e) { @@ -271,7 +260,7 @@ module.exports = (_ => { } getGuildFromRoleId (roleId) { - return BDFDB.LibraryModules.FolderStore.getFlattenedGuilds().find(g => g.roles[roleId]); + return BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds().find(g => g.roles[roleId]); } changeRolesInGuild (guild, useNative) { @@ -300,7 +289,7 @@ module.exports = (_ => { BDFDB.DataUtils.remove(this, "roles", id); } else { - for (let guild of BDFDB.LibraryModules.FolderStore.getFlattenedGuilds()) if (cachedRoles[guild.id]) guild.roles = cachedRoles[guild.id]; + for (let guild of BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds()) if (cachedRoles[guild.id]) guild.roles = cachedRoles[guild.id]; cachedRoles = {}; BDFDB.DataUtils.remove(this, "roles"); } @@ -360,15 +349,15 @@ module.exports = (_ => { children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, { className: BDFDB.disCN.marginreset, - tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5, - children: BDFDB.LibraryModules.LanguageStore.Messages.FORM_LABEL_ROLE_ICON + tag: BDFDB.LibraryComponents.FormComponents.FormTags.H5, + children: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ROLE_ICON }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { type: "Switch", margin: 0, grow: 0, label: BDFDB.LanguageUtils.LanguageStrings.REMOVE, - tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5, + tag: BDFDB.LibraryComponents.FormComponents.FormTags.H5, value: data.removeIcon, onChange: value => { newData.removeIcon = value; diff --git a/.config/BetterDiscord/plugins/ImageUtilities.config.json b/.config/BetterDiscord/plugins/ImageUtilities.config.json index c5aad78..2774a74 100755 --- a/.config/BetterDiscord/plugins/ImageUtilities.config.json +++ b/.config/BetterDiscord/plugins/ImageUtilities.config.json @@ -13,6 +13,7 @@ "Baidu": true, "Bing": true, "Google": true, + "GoogleLens": true, "ImgOps": true, "IQDB": true, "Reddit": true, @@ -22,6 +23,24 @@ "WhatAnime": true, "Yandex": true }, + "galleryFilter": { + "3gp": true, + "avi": true, + "flv": true, + "jpeg": true, + "jpg": true, + "gif": true, + "mov": true, + "mp4": true, + "mpeg-1": true, + "mpeg-2": true, + "ogg": true, + "png": true, + "svg": true, + "webm": true, + "webp": true, + "wmv": true + }, "general": { "nsfwMode": true }, @@ -54,7 +73,7 @@ "zoomSettings": { "lensSize": 1459, "pixelMode": false, - "zoomLevel": 1.8000000000000016 + "zoomLevel": 1.6000000000000014 } } } \ No newline at end of file diff --git a/.config/BetterDiscord/plugins/ImageUtilities.plugin.js b/.config/BetterDiscord/plugins/ImageUtilities.plugin.js index 6ebae79..84b0e3d 100755 --- a/.config/BetterDiscord/plugins/ImageUtilities.plugin.js +++ b/.config/BetterDiscord/plugins/ImageUtilities.plugin.js @@ -2,7 +2,7 @@ * @name ImageUtilities * @author DevilBro * @authorId 278543574059057154 - * @version 4.9.5 + * @version 5.1.0 * @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.) * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -61,6 +61,7 @@ module.exports = (_ => { var ownLocations = {}, downloadsFolder; var firstViewedImage, viewedImage, viewedImageTimeout; + var switchedImageProps; var cachedImages; var eventTypes = {}; @@ -73,55 +74,49 @@ module.exports = (_ => { }; const fileTypes = { - "3gp": {copyable: false, searchable: false, video: true}, - "3g2": {copyable: false, searchable: false, video: true}, - "amv": {copyable: false, searchable: false, video: true}, - "apng": {copyable: false, searchable: true, video: false}, - "avi": {copyable: false, searchable: false, video: true}, - "flv": {copyable: false, searchable: false, video: true}, - "jpeg": {copyable: true, searchable: true, video: false}, - "jpg": {copyable: true, searchable: true, video: false}, - "gif": {copyable: false, searchable: true, video: false}, - "m4v": {copyable: false, searchable: false, video: true}, - "mkv": {copyable: false, searchable: false, video: true}, - "mov": {copyable: false, searchable: false, video: true}, - "mp4": {copyable: false, searchable: false, video: true}, - "mpeg-1": {copyable: false, searchable: false, video: true}, - "mpeg-2": {copyable: false, searchable: false, video: true}, - "ogg": {copyable: false, searchable: false, video: true}, - "ogv": {copyable: false, searchable: false, video: true}, - "png": {copyable: true, searchable: true, video: false}, - "svg": {copyable: false, searchable: false, video: false}, - "webm": {copyable: false, searchable: false, video: true}, - "webp": {copyable: false, searchable: true, video: false}, - "wmv": {copyable: false, searchable: false, video: true} + "3gp": {copyable: false, searchable: false, video: true, signs: [[0x66, 0x74, 0x79, 0x70, 0x33, 0x67]]}, + "avi": {copyable: false, searchable: false, video: true, signs: [[0x41, 0x56, 0x49, 0x20]]}, + "flv": {copyable: false, searchable: false, video: true, signs: [[0x46, 0x4C, 0x56]]}, + "jpeg": {copyable: true, searchable: true, video: false, signs: [[0xFF, 0xD8, 0xFF, 0xEE]]}, + "jpg": {copyable: true, searchable: true, video: false, signs: [[0xFF, 0xD8, 0xFF, 0xDB], [0xFF, 0xD8, 0xFF, 0xE0], [0xFF, 0xD8, 0xFF, 0xE1]]}, + "gif": {copyable: false, searchable: true, video: false, signs: [[0x47, 0x49, 0x46, 0x38, 0x37, 0x61], [0x47, 0x49, 0x46, 0x38, 0x39, 0x61]]}, + "mov": {copyable: false, searchable: false, video: true, signs: [[null, null, null, null, 0x6D, 0x6F, 0x6F, 0x76], [null, null, null, null, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]]}, + "mp4": {copyable: false, searchable: false, video: true, signs: [[null, null, null, null, 0x66, 0x74, 0x79, 0x70]]}, + "mpeg-1": {copyable: false, searchable: false, video: true, signs: [[0x00, 0x00, 0x01, 0xBA]]}, + "mpeg-2": {copyable: false, searchable: false, video: true, signs: [[0x00, 0x00, 0x01, 0xB3]]}, + "ogg": {copyable: false, searchable: false, video: true, signs: [[0x4F, 0x67, 0x67, 0x53]]}, + "png": {copyable: true, searchable: true, video: false, signs: [[0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]]}, + "svg": {copyable: false, searchable: false, video: false, signs: [[0x3C]]}, + "webm": {copyable: false, searchable: false, video: true, signs: [[0x1A, 0x45, 0xDF, 0xA3]]}, + "webp": {copyable: false, searchable: true, video: false, signs: [[0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50]]}, + "wmv": {copyable: false, searchable: false, video: true, signs: [[0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11], [0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C]]} }; const LazyImageSiblingComponent = class LazyImageSibling extends BdApi.React.Component { render() { if (!this.props.loadedImage) { - const instace = this; + const instance = this; const imageThrowaway = document.createElement("img"); imageThrowaway.addEventListener("load", function() { let aRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.appmount)); let resizeX = (aRects.width/this.width) * 0.8, resizeY = (aRects.height/this.height) * 0.65 let ratio = resizeX < resizeY ? resizeX : resizeY; - instace.props.loadedImage = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.LazyImage, { + instance.props.loadedImage = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.LazyImage, { src: imageThrowaway.src, width: this.width, height: this.height, maxWidth: this.width * ratio, maxHeight: this.height * ratio }); - BDFDB.ReactUtils.forceUpdate(instace); + BDFDB.ReactUtils.forceUpdate(instance); }); - imageThrowaway.src = this.props.url; + imageThrowaway.src = !_this.isValid(this.props.url, "video") ? this.props.url : _this.getPosterUrl(this.props.url); } return BDFDB.ReactUtils.createElement("div", { className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._imageutilitiessibling, this.props.className), onClick: event => { BDFDB.ListenerUtils.stopEvent(event); - _this.switchImages(this.props.modalInstance, this.props.offset); + _this.switchImages(this.props.offset); }, children: [ this.props.loadedImage || BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SpinnerComponents.Spinner, { @@ -176,7 +171,7 @@ module.exports = (_ => { height: 16, onClick: event => { BDFDB.ListenerUtils.stopEvent(event); - _this.downloadFileAs(this.props.attachment.proxy_url || this.props.original); + _this.downloadFile({url: this.props.attachment.proxy_url || this.props.original}); }, onContextMenu: event => { let locations = Object.keys(ownLocations).filter(n => ownLocations[n].enabled); @@ -184,7 +179,7 @@ module.exports = (_ => { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { id: BDFDB.ContextMenuUtils.createItemId(_this.name, "download", name, i), label: name, - action: _ => _this.downloadFile(this.props.attachment.proxy_url || this.props.original, ownLocations[name].location) + action: _ => _this.downloadFile({url: this.props.attachment.proxy_url || this.props.original}, ownLocations[name].location) })) })); } @@ -215,6 +210,7 @@ module.exports = (_ => { saveImage: {value: true, description: "Adds a 'Save Image as' Option"}, jumpTo: {value: true, description: "Adds a 'Jump to Message' Option in Gallery Mode"} }, + galleryFilter: {}, zoomSettings: { pixelMode: {value: false, label: "Uses Pixel Lens instead of a Blur Lens"}, zoomLevel: {value: 2, digits: 1, minValue: 1, maxValue: 20, unit: "x", label: "ACCESSIBILITY_ZOOM_LEVEL_LABEL"}, @@ -238,8 +234,9 @@ module.exports = (_ => { engines: { _all: {value: true, name: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL, url: null}, Baidu: {value: true, name: "Baidu", url: "http://image.baidu.com/pcdutu?queryImageUrl=" + imgUrlReplaceString}, - Bing: {value: true, name: "Bing", url: "https://www.bing.com/images/search?q=imgurl: " + imgUrlReplaceString + "&view=detailv2&iss=sbi&FORM=IRSBIQ"}, - Google: {value: true, name: "Google", url: "https://images.google.com/searchbyimage?image_url=" + imgUrlReplaceString}, + Bing: {value: true, name: "Bing", url: "https://www.bing.com/images/search?q=imgurl:" + imgUrlReplaceString + "&view=detailv2&iss=sbi&FORM=IRSBIQ"}, + Google: {value: true, name: "Google", url: "https://www.google.com/searchbyimage?sbisrc=1&image_url=" + imgUrlReplaceString}, + GoogleLens: {value: true, name: "Google Lens", url: "https://lens.google.com/uploadbyurl?url=" + imgUrlReplaceString}, ImgOps: {value: true, name: "ImgOps", raw: true, url: "https://imgops.com/specialized+reverse/" + imgUrlReplaceString}, IQDB: {value: true, name: "IQDB", url: "https://iqdb.org/?url=" + imgUrlReplaceString}, Reddit: {value: true, name: "Reddit", url: "http://karmadecay.com/search?q=" + imgUrlReplaceString}, @@ -250,9 +247,12 @@ module.exports = (_ => { Yandex: {value: true, name: "Yandex", url: "https://yandex.com/images/search?url=" + imgUrlReplaceString + "&rpt=imageview"} } }; + + for (let fileType in fileTypes) this.defaults.galleryFilter[fileType] = {value: true}; this.modulePatches = { before: [ + "ImageModal", "MessageAccessories", "Spoiler" ], @@ -262,18 +262,16 @@ module.exports = (_ => { "LazyImageZoomable", "ModalCarousel", "Spoiler", - "UserBanner", - "UserThemedBanner" + "UserBanner" ], componentDidMount: [ - "ImageModal", "LazyImage" ], componentDidUpdate: [ "LazyImage" ], componentWillUnmount: [ - "ImageModal" + "LazyImage" ] }; @@ -455,6 +453,18 @@ module.exports = (_ => { })) })); + settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { + title: "Gallery Filter Settings", + collapseStates: collapseStates, + children: Object.keys(this.defaults.galleryFilter).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { + type: "Switch", + plugin: this, + keys: ["galleryFilter", key], + label: key, + value: this.settings.galleryFilter[key] + })) + })); + settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { title: "Resize Settings", collapseStates: collapseStates, @@ -504,7 +514,7 @@ module.exports = (_ => { children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, { className: BDFDB.disCN.marginbottom4, - tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3, + tag: BDFDB.LibraryComponents.FormComponents.FormTags.H3, children: "Add additional Download Locations" }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { @@ -657,51 +667,50 @@ module.exports = (_ => { } onGuildContextMenu (e) { - if (e.instance.props.guild && this.settings.places.guildIcons) { - if (BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildheader, e.instance.props.target) || BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildchannels, e.instance.props.target) && !e.instance.props.target.className && e.instance.props.target.parentElement.firstElementChild == e.instance.props.target) { - let banner = BDFDB.GuildUtils.getBanner(e.instance.props.guild.id); - if (banner) this.injectItem(e, [banner.replace(/\.webp|\.gif/, ".png"), e.instance.props.guild.banner && BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(e.instance.props.guild.banner), banner], BDFDB.LanguageUtils.LibraryStrings.guildbanner); - } - else if (!BDFDB.DOMUtils.getParent(BDFDB.dotCN.channels, e.instance.props.target)) this.injectItem(e, [(e.instance.props.guild.getIconURL(4096) || "").replace(/\.webp|\.gif/, ".png"), e.instance.props.guild.icon && BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(e.instance.props.guild.icon) && e.instance.props.guild.getIconURL(4096, true)], BDFDB.LanguageUtils.LibraryStrings.guildicon); + if (!this.settings.places.guildIcons || !e.instance.props.guild) return; + if (BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildheader, e.instance.props.target) || BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildchannels, e.instance.props.target) && !e.instance.props.target.className && e.instance.props.target.parentElement.firstElementChild == e.instance.props.target) { + let banner = BDFDB.GuildUtils.getBanner(e.instance.props.guild.id); + if (banner) this.injectItem(e, [banner.replace(/\.webp|\.gif/, ".png"), e.instance.props.guild.banner && BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(e.instance.props.guild.banner), banner], BDFDB.LanguageUtils.LibraryStrings.guildbanner); } + else if (!BDFDB.DOMUtils.getParent(BDFDB.dotCN.channels, e.instance.props.target)) this.injectItem(e, [(e.instance.props.guild.getIconURL(4096) || "").replace(/\.webp|\.gif/, ".png"), e.instance.props.guild.icon && BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(e.instance.props.guild.icon) && e.instance.props.guild.getIconURL(4096, true)], BDFDB.LanguageUtils.LibraryStrings.guildicon); } onUserContextMenu (e) { - if (e.instance.props.user && this.settings.places.userAvatars) { - const guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId(); - const member = BDFDB.LibraryStores.GuildMemberStore.getMember(guildId, e.instance.props.user.id); - this.injectItem(e, [(e.instance.props.user.getAvatarURL(null, 4096) || "").replace(/\.webp|\.gif/, ".png"), BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(e.instance.props.user.avatar) && e.instance.props.user.getAvatarURL(null, 4096, true), (e.instance.props.user.getAvatarURL(guildId, 4096) || "").replace(/\.webp|\.gif/, ".png"), member && member.avatar && BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(member.avatar) && e.instance.props.user.getAvatarURL(guildId, 4096, true)]); - } + if (!this.settings.places.userAvatars || !e.instance.props.user) return; + const guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId(); + const member = BDFDB.LibraryStores.GuildMemberStore.getMember(guildId, e.instance.props.user.id); + this.injectItem(e, [(e.instance.props.user.getAvatarURL(null, 4096) || "").replace(/\.webp|\.gif/, ".png"), BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(e.instance.props.user.avatar) && e.instance.props.user.getAvatarURL(null, 4096, true), (e.instance.props.user.getAvatarURL(guildId, 4096) || "").replace(/\.webp|\.gif/, ".png"), member && member.avatar && BDFDB.LibraryModules.IconUtils.isAnimatedIconHash(member.avatar) && e.instance.props.user.getAvatarURL(guildId, 4096, true)]); } onGroupDMContextMenu (e) { - if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.groupIcons) this.injectItem(e, [(BDFDB.DMUtils.getIcon(e.instance.props.channel.id) || "").replace(/\.webp|\.gif/, ".png")]); + if (!this.settings.places.groupIcons || !e.instance.props.channel || !e.instance.props.channel.isGroupDM()) return; + this.injectItem(e, [(BDFDB.DMUtils.getIcon(e.instance.props.channel.id) || "").replace(/\.webp|\.gif/, ".png")]); } onImageContextMenu (e) { - if (e.instance.props.href || e.instance.props.src) this.injectItem(e, [e.instance.props.href || e.instance.props.src]); + if (!e.instance.props.href && !e.instance.props.src) return; + this.injectItem(e, [e.instance.props.href || e.instance.props.src]); } onMessageContextMenu (e) { - if (e.instance.props.message && e.instance.props.channel && e.instance.props.target) { - if (e.instance.props.attachment) this.injectItem(e, [e.instance.props.attachment.url]); + if (!e.instance.props.message || !e.instance.props.channel || !e.instance.props.target) return; + if (e.instance.props.attachment) this.injectItem(e, [e.instance.props.attachment.url], null, true); + else { + const target = e.instance.props.target.tagName == "A" && BDFDB.DOMUtils.containsClass(e.instance.props.target, BDFDB.disCN.imageoriginallink) && e.instance.props.target.parentElement.querySelector("img, video") || e.instance.props.target; + if (target.tagName == "A" && e.instance.props.message.embeds && e.instance.props.message.embeds[0] && (e.instance.props.message.embeds[0].type == "image" || e.instance.props.message.embeds[0].type == "video" || e.instance.props.message.embeds[0].type == "gifv")) this.injectItem(e, [target.href], null, true); + else if (target.tagName == "IMG" && target.complete && target.naturalHeight) { + if (BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagewrapper, target) || BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.imagesticker)) this.injectItem(e, [{file: target.src, original: this.getTargetLink(e.instance.props.target) || this.getTargetLink(target)}], null, true); + else if (BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.embedauthoricon) && this.settings.places.userAvatars) this.injectItem(e, [target.src], null, true); + else if (BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.emojiold, "emote", false) && this.settings.places.emojis) this.injectItem(e, [{file: target.src, alternativeName: target.getAttribute("data-name")}], null, true); + } + else if (target.tagName == "VIDEO") { + if (BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.embedvideo) || BDFDB.DOMUtils.getParent(BDFDB.dotCN.attachmentvideo, target)) this.injectItem(e, [{file: target.src, original: this.getTargetLink(e.instance.props.target) || this.getTargetLink(target)}], null, true); + } else { - const target = e.instance.props.target.tagName == "A" && BDFDB.DOMUtils.containsClass(e.instance.props.target, BDFDB.disCN.imageoriginallink) && e.instance.props.target.parentElement.querySelector("img, video") || e.instance.props.target; - if (target.tagName == "A" && e.instance.props.message.embeds && e.instance.props.message.embeds[0] && (e.instance.props.message.embeds[0].type == "image" || e.instance.props.message.embeds[0].type == "video" || e.instance.props.message.embeds[0].type == "gifv")) this.injectItem(e, [target.href]); - else if (target.tagName == "IMG" && target.complete && target.naturalHeight) { - if (BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagewrapper, target) || BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.imagesticker)) this.injectItem(e, [{file: target.src, original: this.getTargetLink(e.instance.props.target) || this.getTargetLink(target)}]); - else if (BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.embedauthoricon) && this.settings.places.userAvatars) this.injectItem(e, [target.src]); - else if (BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.emojiold, "emote", false) && this.settings.places.emojis) this.injectItem(e, [{file: target.src, alternativeName: target.getAttribute("data-name")}]); - } - else if (target.tagName == "VIDEO") { - if (BDFDB.DOMUtils.containsClass(target, BDFDB.disCN.embedvideo) || BDFDB.DOMUtils.getParent(BDFDB.dotCN.attachmentvideo, target)) this.injectItem(e, [{file: target.src, original: this.getTargetLink(e.instance.props.target) || this.getTargetLink(target)}]); - } - else { - const reaction = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagereaction, target); - if (reaction && this.settings.places.emojis) { - const emoji = reaction.querySelector(BDFDB.dotCN.emojiold); - if (emoji) this.injectItem(e, [{file: emoji.src, alternativeName: emoji.getAttribute("data-name")}]); - } + const reaction = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagereaction, target); + if (reaction && this.settings.places.emojis) { + const emoji = reaction.querySelector(BDFDB.dotCN.emojiold); + if (emoji) this.injectItem(e, [{file: emoji.src, alternativeName: emoji.getAttribute("data-name")}], null, true); } } } @@ -714,10 +723,9 @@ module.exports = (_ => { return href || src; } - injectItem (e, urls, prefix) { + injectItem (e, urls, prefix, isNative = false) { let validUrls = this.filterUrls(...urls); if (!validUrls.length) return; - let isNative = false; let [nativeParent, nativeIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "copy-native-link", group: true}); if (nativeIndex > -1) { if (validUrls.length == 1) isNative = true; @@ -736,7 +744,7 @@ module.exports = (_ => { target: e.instance.props.target }); - let [children, index] = isNative ? [nativeParent, nativeIndex] : BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true}); + let [children, index] = isNative && nativeIndex > -1 ? [nativeParent, nativeIndex] : BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true}); children.splice(index > -1 ? index : children.length, 0, isNative ? subMenu : BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.isValid(validUrls[0].file, "video") ? this.labels.context_videoactions : this.labels.context_imageactions, @@ -770,6 +778,10 @@ module.exports = (_ => { return file && (!type && (url.indexOf("discord.com/streams/guild:") > -1 || url.indexOf("discordapp.com/streams/guild:") > -1 || url.indexOf("discordapp.net/streams/guild:") > -1 || url.startsWith("https://images-ext-1.discordapp.net/") || url.startsWith("https://images-ext-2.discordapp.net/") || Object.keys(fileTypes).some(t => file.endsWith(`/${t}`) || file.endsWith(`.${t}`))) || type && Object.keys(fileTypes).filter(t => fileTypes[t][type]).some(t => file.endsWith(`/${t}`) || file.endsWith(`.${t}`))); } + getPosterUrl (url) { + return (url || "").replace("https://cdn.discordapp.com", "https://media.discordapp.net").split("?size=")[0] + "?format=jpeg"; + } + createSubMenus (data) { return data.urls.length == 1 ? this.createUrlMenu(data.instance, data.urls[0], data.target) : data.urls.map((urlData, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: [urlData.isGuildSpecific && BDFDB.LanguageUtils.LanguageStrings.CHANGE_IDENTITY_SERVER_PROFILE, data.prefix, urlData.fileType.toUpperCase()].filter(n => n).join(" "), @@ -811,7 +823,7 @@ module.exports = (_ => { !this.isValid(urlData.file, "copyable") ? null : BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.context_copy.replace("{{var0}}", type), id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-file"), - action: _ => this.copyFile(urlData.original) + action: _ => this.copyFile(urlData.src) }), !document.querySelector(BDFDB.dotCN.imagemodal) && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.context_view.replace("{{var0}}", type), @@ -836,12 +848,15 @@ module.exports = (_ => { shouldAnimate: true, renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props), children: !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, { + ignoreMaxSize: true, + poster: _this.getPosterUrl(urlData.src || urlData.file), src: urlData.src || urlData.file, width: videoData.size.width, height: videoData.size.height, naturalWidth: this.videoWidth, naturalHeight: this.videoHeight, - play: true + play: true, + playOnHover: !!BDFDB.LibraryStores.AccessibilityStore.useReducedMotion })) }) }), true); @@ -853,12 +868,12 @@ module.exports = (_ => { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.context_saveas.replace("{{var0}}", type), id: BDFDB.ContextMenuUtils.createItemId(this.name, "download-file-as"), - action: _ => this.downloadFileAs(urlData.original, urlData.src, urlData.alternativeName), + action: _ => this.downloadFile({url: urlData.src, fallbackUrl: urlData.file || urlData.original}, null, urlData.alternativeName), children: locations.length && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i), label: name, - action: _ => this.downloadFile(urlData.original, ownLocations[name].location, urlData.src, urlData.alternativeName) + action: _ => this.downloadFile({url: urlData.src, fallbackUrl: urlData.file || urlData.original}, ownLocations[name].location, urlData.alternativeName) })) }) }), @@ -899,23 +914,12 @@ module.exports = (_ => { } processImageModal (e) { - if (e.methodname == "componentDidMount") { - BDFDB.TimeUtils.clear(viewedImageTimeout); - - let modal = BDFDB.DOMUtils.getParent(BDFDB.dotCN.modal, e.node); - if (modal) { - modal.className = BDFDB.DOMUtils.formatClassName(modal.className, this.settings.viewerSettings.galleryMode && BDFDB.disCN._imageutilitiesgallery, this.settings.viewerSettings.details && BDFDB.disCN._imageutilitiesdetailsadded); - if (this.settings.viewerSettings.galleryMode) { - BDFDB.DOMUtils.addClass(modal, BDFDB.disCN.imagemodal); - BDFDB.DOMUtils.removeClass(modal, BDFDB.disCN.modalcarouselmodal, BDFDB.disCN.modalcarouselmodalzoomed); - } + if (!e.returnvalue) { + if (switchedImageProps) { + e.instance.props = Object.assign(e.instance.props, switchedImageProps); + switchedImageProps = null; } } - else if (e.methodname == "componentWillUnmount") { - firstViewedImage = null; - viewedImage = null; - this.cleanupListeners("Gallery"); - } else { let url = this.getImageSrc(viewedImage && viewedImage.proxy_url || typeof e.instance.props.children == "function" && e.instance.props.children(Object.assign({}, e.instance.props, {size: e.instance.props})).props.src || e.instance.props.src); let isVideo = this.isValid(url, "video"); @@ -980,7 +984,7 @@ module.exports = (_ => { children: this.labels.context_saveas.replace("{{var0}}", type), onClick: event => { BDFDB.ListenerUtils.stopEvent(event); - this.downloadFileAs(url); + this.downloadFile({url: url}); }, onContextMenu: event => { let locations = Object.keys(ownLocations).filter(n => ownLocations[n].enabled); @@ -988,7 +992,7 @@ module.exports = (_ => { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i), label: name, - action: _ => this.downloadFile(url, ownLocations[name].location) + action: _ => this.downloadFile({url: url}, ownLocations[name].location) })) })); } @@ -1064,7 +1068,6 @@ module.exports = (_ => { })); } } - if (this.settings.viewerSettings.galleryMode && viewedImage) { if (!cachedImages || cachedImages.channelId != viewedImage.channelId || cachedImages.amount && this.getImageIndex(cachedImages.all, viewedImage) == -1) { BDFDB.TimeUtils.clear(viewedImageTimeout); @@ -1089,7 +1092,7 @@ module.exports = (_ => { newestId: null, lastReached: null }; - BDFDB.ReactUtils.forceUpdate(e.instance); + this.updateImageModal(); }).then(result => { if (!viewedImage) return; let messages = [], index = -1; @@ -1117,20 +1120,18 @@ module.exports = (_ => { newestId: null, lastReached: null }; - BDFDB.ReactUtils.forceUpdate(e.instance); + this.updateImageModal(); }); } else { if (cachedImages.all[cachedImages.index - 1]) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(LazyImageSiblingComponent, { className: BDFDB.disCN._imageutilitiesprevious, - modalInstance: e.instance, url: this.getImageSrc(cachedImages.all[cachedImages.index - 1].thumbnail || cachedImages.all[cachedImages.index - 1]), offset: -1, svgIcon: BDFDB.LibraryComponents.SvgIcon.Names.LEFT_CARET })); if (cachedImages.all[cachedImages.index + 1]) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(LazyImageSiblingComponent, { className: BDFDB.disCN._imageutilitiesnext, - modalInstance: e.instance, url: this.getImageSrc(cachedImages.all[cachedImages.index + 1].thumbnail || cachedImages.all[cachedImages.index + 1]), offset: 1, svgIcon: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_CARET @@ -1139,8 +1140,8 @@ module.exports = (_ => { this.addListener("keydown", "Gallery", event => { if (!firedEvents.includes("Gallery")) { firedEvents.push("Gallery"); - if (event.keyCode == 37) this.switchImages(e.instance, -1); - else if (event.keyCode == 39) this.switchImages(e.instance, 1); + if (event.keyCode == 37) this.switchImages(-1); + else if (event.keyCode == 39) this.switchImages(1); } }); this.addListener("keyup", "Gallery", _ => BDFDB.ArrayUtils.remove(firedEvents, "Gallery", true)); @@ -1151,10 +1152,10 @@ module.exports = (_ => { } processModalCarousel (e) { - if (this.settings.viewerSettings.galleryMode) { - let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ImageModal"}); - if (index > -1) return children[index]; - } + if (!this.settings.viewerSettings.galleryMode || !BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ImageModal"})) return; + e.returnvalue.props.className = ""; + e.returnvalue.props.children[0] = null; + e.returnvalue.props.children[2] = null; } processLazyImage (e) { @@ -1176,19 +1177,34 @@ module.exports = (_ => { BDFDB.ReactUtils.forceUpdate(e.instance); } } - if (e.methodname == "componentDidMount") { - let isVideo = (typeof e.instance.props.children == "function" && e.instance.props.children(Object.assign({}, e.instance.props, {size: e.instance.props})) || {type: {}}).type.displayName == "Video"; - if (this.settings.viewerSettings.zoomMode && !isVideo && !BDFDB.DOMUtils.containsClass(e.node.parentElement, BDFDB.disCN._imageutilitiessibling) && BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.getInstance(e.node), {name: "ImageModal", up: true})) { + if (e.methodname == "componentWillUnmount" && BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagemodal, e.node)) { + firstViewedImage = null; + viewedImage = null; + this.cleanupListeners("Gallery"); + } + if (e.methodname == "componentDidMount" && BDFDB.DOMUtils.getParent(BDFDB.dotCNC.imagemodal + BDFDB.dotCN.modalcarouselmodal, e.node)) { + BDFDB.TimeUtils.clear(viewedImageTimeout); + let modal = BDFDB.DOMUtils.getParent(BDFDB.dotCN.modal, e.node); + if (modal) { + modal.className = BDFDB.DOMUtils.formatClassName(modal.className, this.settings.viewerSettings.galleryMode && BDFDB.disCN._imageutilitiesgallery, this.settings.viewerSettings.details && BDFDB.disCN._imageutilitiesdetailsadded); + if (this.settings.viewerSettings.galleryMode) { + BDFDB.DOMUtils.addClass(modal, BDFDB.disCN.imagemodal); + BDFDB.DOMUtils.removeClass(modal, BDFDB.disCN.modalcarouselmodal, BDFDB.disCN.modalcarouselmodalzoomed); + } + } + + let isVideo = typeof e.instance.props.children == "function"; + if (isVideo && !BDFDB.LibraryStores.AccessibilityStore.useReducedMotion) e.node.style.setProperty("pointer-events", "none"); + if (this.settings.viewerSettings.zoomMode && !isVideo && !BDFDB.DOMUtils.containsClass(e.node.parentElement, BDFDB.disCN._imageutilitiessibling)) { e.node.style.setProperty("cursor", "zoom-in"); e.node.addEventListener("mousedown", event => { - if (event.which != 1) return; + if (event.which != 1 || e.node.querySelector("video")) return; BDFDB.ListenerUtils.stopEvent(event); let vanishObserver; let imgRects = BDFDB.DOMUtils.getRects(e.node.firstElementChild); - - let lens = BDFDB.DOMUtils.create(`
<${e.node.firstElementChild.tagName} src="${e.instance.props.src}" style="width: ${imgRects.width * this.settings.zoomSettings.zoomLevel}px; height: ${imgRects.height * this.settings.zoomSettings.zoomLevel}px; position: fixed !important;${this.settings.zoomSettings.pixelMode ? " image-rendering: pixelated !important;" : ""}"${e.node.firstElementChild.tagName == "VIDEO" ? " loop autoplay" : ""}>
`); + let lens = BDFDB.DOMUtils.create(`
<${e.node.firstElementChild.tagName} src="${!this.isValid(e.instance.props.src, "video") ? e.instance.props.src : this.getPosterUrl(e.instance.props.src)}" style="width: ${imgRects.width * this.settings.zoomSettings.zoomLevel}px; height: ${imgRects.height * this.settings.zoomSettings.zoomLevel}px; position: fixed !important;${this.settings.zoomSettings.pixelMode ? " image-rendering: pixelated !important;" : ""}"${e.node.firstElementChild.tagName == "VIDEO" ? " loop autoplay" : ""}>
`); let pane = lens.firstElementChild.firstElementChild; let backdrop = BDFDB.DOMUtils.create(`
`); let appMount = document.querySelector(BDFDB.dotCN.appmount); @@ -1217,7 +1233,7 @@ module.exports = (_ => { }; lens.update(); - e.node.style.setProperty("pointer-events", "none", "important"); + for (let ele of [e.node, document.querySelector(BDFDB.dotCN.modalcarouselwrapper)]) if (ele) ele.style.setProperty("pointer-events", "none", "important"); let dragging = event2 => { event = event2; @@ -1225,7 +1241,7 @@ module.exports = (_ => { }; let releasing = event2 => { BDFDB.ListenerUtils.stopEvent(event2); - e.node.style.removeProperty("pointer-events"); + for (let ele of [e.node, document.querySelector(BDFDB.dotCN.modalcarouselwrapper)]) if (ele) ele.style.removeProperty("pointer-events"); this.cleanupListeners("Zoom"); document.removeEventListener("mousemove", dragging); document.removeEventListener("mouseup", releasing); @@ -1292,7 +1308,7 @@ module.exports = (_ => { e.instance.props.resized = true; } } - if (this.settings.rescaleSettings.messages != "NONE" && (!e.instance.props.className || e.instance.props.className.indexOf(BDFDB.disCN.embedthumbnail) == -1) && (!e.instance.props.containerClassName || e.instance.props.containerClassName.indexOf(BDFDB.disCN.embedthumbnail) == -1) && BDFDB.ReactUtils.findOwner(reactInstance, {name: "LazyImageZoomable", up: true})) { + if (this.settings.rescaleSettings.messages != "NONE" && (!e.instance.props.className || e.instance.props.className.indexOf(BDFDB.disCN.embedthumbnail) == -1) && (!e.instance.props.containerClassName || e.instance.props.containerClassName.indexOf(BDFDB.disCN.embedthumbnail) == -1 && e.instance.props.containerClassName.indexOf(BDFDB.disCN.embedvideoimagecomponent) == -1) && BDFDB.ReactUtils.findOwner(reactInstance, {name: "LazyImageZoomable", up: true})) { let aRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.appmount)); let mRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCNC.messageaccessory + BDFDB.dotCN.messagecontents)); let mwRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.messagewrapper)); @@ -1389,7 +1405,7 @@ module.exports = (_ => { } } - processUserThemedBanner (e) { + processUserBanner (e) { if (!this.settings.places.userAvatars || !e.instance.props.displayProfile || !e.instance.props.displayProfile.banner) return; let div = BDFDB.ReactUtils.findChild(e.returnvalue, {type: "div"}); if (div) div.props.onContextMenu = event => { @@ -1412,10 +1428,6 @@ module.exports = (_ => { }; } - processUserBanner (e) { - this.processUserThemedBanner(e); - } - cacheClickedImage (target) { if (!target) return; const image = (BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagewrapper, target) || target).querySelector("img") || target; @@ -1431,26 +1443,59 @@ module.exports = (_ => { }, 1000); } - downloadFile (url, path, fallbackUrl, alternativeName) { - url = url.startsWith("/assets") ? (window.location.origin + url) : url; - BDFDB.LibraryRequires.request(url, {agentOptions: {rejectUnauthorized: false}, headers: {"Content-Type": "application/json"}}, (error, response, body) => { - let type = this.isValid(url, "video") ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; - if (error || response.statusCode != 200 || response.headers["content-type"].indexOf("text/html") > -1) { - if (fallbackUrl) this.downloadFile(fallbackUrl, path, null, alternativeName); - else BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", ""), {type: "danger"}); + downloadFile (urls, path, alternativeName, fallbackToRequest) { + if (!urls) return BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", BDFDB.LanguageUtils.LanguageStrings.IMAGE).replace("{{var1}}", path || "PC"), {type: "danger"}); + let url = urls.url.startsWith("/assets") ? (window.location.origin + urls.url) : urls.url; + if (!fallbackToRequest) BDFDB.DiscordUtils.requestFileData(url, {timeout: 3000}, (error, buffer) => { + if (error || !buffer) { + if (urls.fallbackUrl && urls.url != urls.fallbackUrl) this.downloadFile({url: urls.fallbackUrl, oldUrl: urls.url}, path, alternativeName); + else this.downloadFile({url: urls.oldUrl || urls.url, fallbackUrl: urls.oldUrl ? urls.url : undefined}, path, alternativeName, true); } else { - BDFDB.LibraryRequires.fs.writeFile(this.getFileName(path, (alternativeName || url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown").slice(0, 35), this.getFileExtenstion(response.headers["content-type"].split("/").pop().split("+")[0]), 0), Buffer.from(body), error => { - if (error) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", path), {type: "danger"}); - else BDFDB.NotificationUtils.toast(this.labels.toast_save_success.replace("{{var0}}", type).replace("{{var1}}", path), {type: "success"}); - }); + let extension = this.getFileExtension(new Uint8Array(buffer)); + if (!extension) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", BDFDB.LanguageUtils.LanguageStrings.IMAGE).replace("{{var1}}", path || "PC"), {type: "danger"}); + else { + let type = fileTypes[extension].video ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; + if (path) BDFDB.LibraryRequires.fs.writeFile(this.getFileName(path, (alternativeName || url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown").slice(0, 35), extension, 0), Buffer.from(buffer), error => { + if (error) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", path), {type: "danger"}); + else BDFDB.NotificationUtils.toast(this.labels.toast_save_success.replace("{{var0}}", type).replace("{{var1}}", path), {type: "success"}); + }); + else { + let hrefURL = window.URL.createObjectURL(new Blob([buffer], {type: this.getMimeType(extension)})); + let tempLink = document.createElement("a"); + tempLink.href = hrefURL; + tempLink.download = `${(alternativeName || url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown").slice(0, 35)}.${extension}`; + tempLink.click(); + window.URL.revokeObjectURL(hrefURL); + } + } + } + }); + else BDFDB.LibraryRequires.request(url, {agentOptions: {rejectUnauthorized: false}, headers: {"Content-Type": "application/json"}}, (error, response, buffer) => { + if (error || response.statusCode != 200 || response.headers["content-type"].indexOf("text/html") > -1) { + if (urls.fallbackUrl && urls.url != urls.fallbackUrl) this.downloadFile({url: urls.fallbackUrl}, path, alternativeName, true); + else BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", BDFDB.LanguageUtils.LanguageStrings.IMAGE).replace("{{var1}}", path || "PC"), {type: "danger"}); + } + else { + let extension = this.getFileExtension(new Uint8Array(buffer)); + if (!extension) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", BDFDB.LanguageUtils.LanguageStrings.IMAGE).replace("{{var1}}", path || "PC"), {type: "danger"}); + else { + let type = fileTypes[extension].video ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; + if (path) BDFDB.LibraryRequires.fs.writeFile(this.getFileName(path, (alternativeName || url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown").slice(0, 35), extension, 0), Buffer.from(buffer), error => { + if (error) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", path), {type: "danger"}); + else BDFDB.NotificationUtils.toast(this.labels.toast_save_success.replace("{{var0}}", type).replace("{{var1}}", path), {type: "success"}); + }); + else { + let hrefURL = window.URL.createObjectURL(new Blob([buffer], {type: this.getMimeType(extension)})); + let tempLink = document.createElement("a"); + tempLink.href = hrefURL; + tempLink.download = `${(alternativeName || url.split("/").pop().split(".").slice(0, -1).join(".") || "unknown").slice(0, 35)}.${extension}`; + tempLink.click(); + window.URL.revokeObjectURL(hrefURL); + } + } } }); - } - - downloadFileAs (url, fallbackUrl, alternativeName) { - url = url.startsWith("/assets") ? (window.location.origin + url) : url; - BDFDB.LibraryModules.WindowUtils.saveImage(url.startsWith("/assets") ? (window.location.origin + url) : url); } copyFile (url) { @@ -1478,9 +1523,14 @@ module.exports = (_ => { else return wholePath; } - getFileExtenstion (ext) { - if (ext == "quicktime") ext = "mov"; - return ext; + getFileExtension (intArray) { + for (let fileType in fileTypes) if (fileTypes[fileType].signs.some(signs => signs.every((hex, i) => hex === null || hex == intArray[i]))) return fileType; + return ""; + } + + getMimeType (fileType) { + if (fileTypes[fileType]) return `${fileTypes[fileType].video ? "video" : "image"}/${fileType == "svg" ? "svg+xml" : fileType}`; + return ""; } getImageSrc (img) { @@ -1493,10 +1543,16 @@ module.exports = (_ => { } filterMessagesForImages (messages, img) { - return messages.filter(m => m && m.channel_id == img.channelId && !BDFDB.LibraryStores.RelationshipStore.isBlocked(m.author.id) && (m.id == firstViewedImage.messageId || m.id == img.messageId || m.embeds.filter(e => e.image || e.thumbnail || e.video).length || m.attachments.filter(a => !a.filename.startsWith("SPOILER_")).length)).map(m => [m.attachments, m.embeds].flat(10).filter(n => n).map(i => Object.assign({m, messageId: m.id, channelId: img.channelId}, i, i.image, i.thumbnail, i.video))).flat(10); + return messages.filter(m => m && m.channel_id == img.channelId && !BDFDB.LibraryStores.RelationshipStore.isBlocked(m.author.id) && (firstViewedImage && m.id == firstViewedImage.messageId || m.id == img.messageId || m.embeds.filter(e => e.image || e.thumbnail || e.video).length || m.attachments.filter(a => !a.filename.startsWith("SPOILER_")).length)).map(m => [m.attachments, m.embeds].flat(10).filter(n => n).map(i => Object.assign({messageId: m.id, channelId: img.channelId}, i, i.image, i.thumbnail, i.video))).flat(10).filter(n => { + if (!n) return false; + if (!n.content_type || img.proxy_url == n.proxy_url || img.proxy_url == n.url || img.proxy_url == n.href) return true; + let extension = (n.content_type.split("/")[1] || "").split("+")[0] || ""; + if (extension && this.settings.galleryFilter[extension] === false) return false; + return true; + }); } - switchImages (modalInstance, offset) { + switchImages (offset) { const newIndex = parseInt(cachedImages.index) + parseInt(offset); if (newIndex < 0 || newIndex > (cachedImages.amount - 1)) return; @@ -1518,7 +1574,7 @@ module.exports = (_ => { }).then(result => { if (result && viewedImage) { const messages = result.body.flat(10).reverse(); - Object.assign(cachedImages, {all: BDFDB.ArrayUtils.removeCopies([].concat(cachedImages.all, this.filterMessagesForImages(messages, viewedImage)))}); + Object.assign(cachedImages, {all: this.filterForCopies([].concat(cachedImages.all, this.filterMessagesForImages(messages, viewedImage)))}); const index = this.getImageIndex(cachedImages.all, viewedImage); cachedImages = Object.assign(cachedImages, { channelId: viewedImage.channelId, @@ -1527,7 +1583,7 @@ module.exports = (_ => { newestId: messages[messages.length-1] ? messages[messages.length-1].id : null, lastReached: index == (cachedImages.all.length - 1) }); - BDFDB.ReactUtils.forceUpdate(modalInstance); + this.updateImageModal(); } }); } @@ -1545,7 +1601,7 @@ module.exports = (_ => { }).then(result => { if (result && viewedImage) { const messages = result.body.flat(10).reverse(); - Object.assign(cachedImages, {all: BDFDB.ArrayUtils.removeCopies([].concat(this.filterMessagesForImages(messages, viewedImage), cachedImages.all))}); + Object.assign(cachedImages, {all: this.filterForCopies([].concat(this.filterMessagesForImages(messages, viewedImage), cachedImages.all))}); const index = this.getImageIndex(cachedImages.all, viewedImage); cachedImages = Object.assign(cachedImages, { channelId: viewedImage.channelId, @@ -1554,27 +1610,42 @@ module.exports = (_ => { index: index, amount: cachedImages.all.length }); - BDFDB.ReactUtils.forceUpdate(modalInstance); + this.updateImageModal(); } }); } let isVideo = this.isValid(viewedImage.proxy_url, "video"); - modalInstance.props.animated = !!isVideo; - modalInstance.props.original = viewedImage.proxy_url; - modalInstance.props.placeholder = viewedImage.thumbnail && viewedImage.thumbnail.proxy_url || viewedImage.proxy_url; - modalInstance.props.src = viewedImage.proxy_url; - modalInstance.props.width = viewedImage.width; - modalInstance.props.height = viewedImage.height; - modalInstance.props.children = !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, { - src: viewedImage.proxy_url, - width: videoData.size.width, - height: videoData.size.height, - naturalWidth: viewedImage.width, - naturalHeight: viewedImage.height, - play: true, - playOnHover: !!BDFDB.LibraryStores.AccessibilityStore.useReducedMotion - })); - BDFDB.ReactUtils.forceUpdate(modalInstance); + let thisViewedImage = viewedImage; + switchedImageProps = { + animated: !!isVideo, + original: thisViewedImage.proxy_url, + placeholder: isVideo && (thisViewedImage.thumbnail && thisViewedImage.thumbnail.proxy_url || thisViewedImage.proxy_url), + src: thisViewedImage.proxy_url, + width: thisViewedImage.width, + height: thisViewedImage.height, + children: !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, { + ignoreMaxSize: true, + poster: thisViewedImage.proxy_url.replace("https://cdn.discordapp.com", "https://media.discordapp.net").split("?size=")[0] + "?format=jpeg", + src: thisViewedImage.proxy_url, + width: videoData.size.width, + height: videoData.size.height, + naturalWidth: thisViewedImage.width, + naturalHeight: thisViewedImage.height, + play: true, + playOnHover: !!BDFDB.LibraryStores.AccessibilityStore.useReducedMotion + })) + }; + this.updateImageModal(); + } + + updateImageModal () { + BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.imagemodal), {up: true, filter: n => n && n.stateNode && n.stateNode.props && n.stateNode.props.isTopModal && n.stateNode.props.modalKey})); + } + + filterForCopies (messages) { + let filtered = []; + for (let message of messages) if (!filtered.find(n => n.messageId == message.messageId)) filtered.push(message); + return filtered; } addListener (eventType, type, callback) { diff --git a/.config/BetterDiscord/plugins/InvisibleTyping.config.json b/.config/BetterDiscord/plugins/InvisibleTyping.config.json index 866c9f2..022fe37 100755 --- a/.config/BetterDiscord/plugins/InvisibleTyping.config.json +++ b/.config/BetterDiscord/plugins/InvisibleTyping.config.json @@ -5,9 +5,9 @@ }, "settings": { "exclude": [ - "709081938622939166" + "671439465377562624" ], - "autoEnable": false, + "autoEnable": true, "latestUsedVersion": "1.3.3" } } \ No newline at end of file diff --git a/.config/BetterDiscord/plugins/NotificationSounds.config.json b/.config/BetterDiscord/plugins/NotificationSounds.config.json index f641392..25cedd9 100755 --- a/.config/BetterDiscord/plugins/NotificationSounds.config.json +++ b/.config/BetterDiscord/plugins/NotificationSounds.config.json @@ -250,6 +250,13 @@ "mute": null, "sound": "---", "volume": 100 + }, + "stage_waiting": { + "category": "---", + "focus": false, + "mute": false, + "sound": "---", + "volume": 100 } }, "volumes": { diff --git a/.config/BetterDiscord/plugins/NotificationSounds.plugin.js b/.config/BetterDiscord/plugins/NotificationSounds.plugin.js index 9997935..04354f6 100644 --- a/.config/BetterDiscord/plugins/NotificationSounds.plugin.js +++ b/.config/BetterDiscord/plugins/NotificationSounds.plugin.js @@ -2,7 +2,7 @@ * @name NotificationSounds * @author DevilBro * @authorId 278543574059057154 - * @version 3.7.5 + * @version 3.7.6 * @description Allows you to replace the native Sounds with custom Sounds * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -85,9 +85,9 @@ module.exports = (_ => { const WebAudioSound = class WebAudioSound { constructor (type) { - this._name = type; + this.name = type; this._src = audios[choices[type].category][choices[type].sound] || types[type].src; - this._volume = choices[type].volume; + this._volume = choices[type].volume / 100; } loop () { this._ensureAudio().then(audio => { @@ -133,7 +133,7 @@ module.exports = (_ => { let audio = new Audio; audio.src = this._src && this._src.startsWith("data") ? this._src.replace(/ /g, "") : this._src; audio.onloadeddata = _ => { - audio.volume = Math.min((BDFDB.LibraryStores.MediaEngineStore.getOutputVolume() / 100) * (this._volume / 100) * (volumes.globalVolume / 100), 1); + audio.volume = Math.min((BDFDB.LibraryStores.MediaEngineStore.getOutputVolume() / 100) * this._volume * (volumes.globalVolume / 100), 1); BDFDB.DiscordUtils.isPlaformEmbedded() && audio.setSinkId(currentDevice || defaultDevice); callback(audio); }; @@ -157,7 +157,9 @@ module.exports = (_ => { }; this.patchPriority = 9; - + } + + onStart () { const soundKeys = BDFDB.LibraryModules.SoundParser.keys(); for (let key of soundKeys) { const id = key.replace("./", "").replace(".mp3", ""); @@ -193,9 +195,7 @@ module.exports = (_ => { types = BDFDB.ObjectUtils.sort(types, "name"); } for (let pack in defaultAudios) defaultAudios[pack] = BDFDB.ObjectUtils.sort(defaultAudios[pack]); - } - - onStart () { + if (BDFDB.DiscordUtils.isPlaformEmbedded()) { let change = _ => { if (window.navigator.mediaDevices && window.navigator.mediaDevices.enumerateDevices) { @@ -280,34 +280,46 @@ module.exports = (_ => { let soundObjIndex = Array.from(e.methodArguments).findIndex(n => n && n.sound); if (soundObjIndex && e.methodArguments[soundObjIndex].sound.includes("message")) e.methodArguments[soundObjIndex].sound = null; }}); - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {instead: e => { - let type = e.methodArguments[0]; - if (type && choices[type]) { - e.stopOriginalMethodCall(); - BDFDB.TimeUtils.timeout(_ => { - if (type == "message1") { - let called = false; - for (let subType of [type].concat(Object.keys(message1Types))) if (firedEvents[subType]) { - delete firedEvents[subType]; - called = true; - break; + if (BDFDB.LibraryModules.SoundUtils && BDFDB.LibraryModules.SoundUtils.createSound) { + let cancel = BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "createSound", {after: e => { + if (e.returnValue && e.returnValue.constructor && e.returnValue.constructor.prototype && typeof e.returnValue.constructor.prototype.play == "function") { + cancel(); + BDFDB.PatchUtils.patch(this, e.returnValue.constructor.prototype, ["play", "loop"], {instead: e2 => { + let type = e2.instance && e2.instance.name; + if (type && choices[type]) { + let loop = e2.originalMethodName == "loop"; + e2.stopOriginalMethodCall(); + BDFDB.TimeUtils.timeout(_ => { + if (type == "message1") { + let called = false; + for (let subType of [type].concat(Object.keys(message1Types))) if (firedEvents[subType]) { + delete firedEvents[subType]; + called = true; + break; + } + if (!called) this.playAudio(type, loop); + } + else this.playAudio(type, loop); + }); } - if (!called) this.playAudio(type); - } - else this.playAudio(type); - }); - } - else e.callOriginalMethodAfterwards(); - }}); - BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, ["createSound", "createSoundpackSound"], {after: e => { - let type = e.methodArguments[0]; - if (type && choices[type]) { - let audio = new WebAudioSound(type); - createdAudios[type] = audio; - return audio; - } - else BDFDB.LogUtils.warn(`Could not create Sound for "${type}".`, this); - }}); + else e2.callOriginalMethodAfterwards(); + }}); + BDFDB.PatchUtils.patch(this, e.returnValue.constructor.prototype, "stop", {after: e2 => { + let type = e2.instance && e2.instance.name; + if (type && createdAudios[type]) createdAudios[type].stop(); + }}); + } + return; + let type = e.methodArguments[0]; + if (type && choices[type]) { + let audio = new WebAudioSound(type); + createdAudios[type] = audio; + return audio; + } + else BDFDB.LogUtils.warn(`Could not create Sound for "${type}".`, this); + }}, {noCache: true}); + BDFDB.LibraryModules.SoundUtils.createSound("call_calling"); + } this.loadAudios(); this.loadChoices(); @@ -661,7 +673,7 @@ module.exports = (_ => { forceUpdateAll () { volumes = BDFDB.DataUtils.get(this, "volumes"); - if (BDFDB.LibraryStores.SoundpackStore) BDFDB.LibraryStores.SoundpackStore.emitChange(); + BDFDB.PatchUtils.forceAllUpdates(this); BDFDB.DiscordUtils.rerenderAll(); } @@ -700,11 +712,11 @@ module.exports = (_ => { } } - playAudio (type) { + playAudio (type, loop = false) { if (this.dontPlayAudio(type) || BDFDB.LibraryStores.StreamerModeStore.disableSounds) return; if (createdAudios[type]) createdAudios[type].stop(); createdAudios[type] = new WebAudioSound(type); - createdAudios[type].play(); + createdAudios[type][loop ? "loop" : "play"](); } isSuppressMentionsEnabled (guildId, channelId) { diff --git a/.config/BetterDiscord/plugins/PinDMs.config.json b/.config/BetterDiscord/plugins/PinDMs.config.json index 701003a..f6fa6bf 100755 --- a/.config/BetterDiscord/plugins/PinDMs.config.json +++ b/.config/BetterDiscord/plugins/PinDMs.config.json @@ -15,7 +15,6 @@ "851263280551165977", "709081938622939166", "736308155964850176", - "662733504534020118", "740325591684874305", "815678838809296926" ], diff --git a/.config/BetterDiscord/plugins/PluginRepo.config.json b/.config/BetterDiscord/plugins/PluginRepo.config.json index 44b8725..cdcbc6f 100755 --- a/.config/BetterDiscord/plugins/PluginRepo.config.json +++ b/.config/BetterDiscord/plugins/PluginRepo.config.json @@ -1,6 +1,6 @@ { "all": { - "cached": "2 7 8 9 11 14 15 17 28 29 30 59 60 61 62 63 64 65 66 67 68 70 71 73 74 75 76 77 80 81 82 83 85 86 87 88 89 91 92 93 94 95 96 97 98 99 100 101 102 104 105 106 108 109 110 111 116 120 122 126 127 131 132 133 134 137 138 139 146 157 158 159 160 162 164 171 173 176 179 181 182 183 184 185 186 188 189 190 193 195 196 197 200 201 220 228 234 237 238 240 245 247 253 262 272 274 278 284 287 291 292 293 295 301 306 312 314 317 318 323 331 336 337 338 340 344 349 350 351 352 353 354 356 364 366 368 377 379 381 382 383 390 395 401 404 407 420 421 429 438 442 476 479 489 509 518 519 520 523 525 535 538 539 547 554 566 577 579 589 592 593 598 599 606 608 611 614 620 621 627 638 644 645 669 670 671 679 686 692 693 694 699 708 760 762 772", + "cached": "2 7 8 9 11 14 15 17 28 29 30 59 60 61 62 63 64 65 66 67 68 70 71 73 74 75 76 77 80 81 82 83 85 86 87 88 89 91 92 93 94 95 96 97 98 99 100 101 102 104 105 106 108 109 110 111 116 120 122 126 127 131 132 133 134 137 138 139 146 157 158 159 160 162 164 171 173 176 179 181 182 183 184 185 186 188 189 190 193 195 196 197 200 201 220 228 234 237 238 240 245 247 253 262 272 274 278 284 287 291 292 293 295 301 306 312 314 317 318 323 331 336 337 338 340 344 349 350 351 352 353 354 356 364 366 368 377 379 381 382 383 390 395 401 404 420 421 429 438 442 476 479 489 509 518 520 523 525 535 538 539 547 554 566 577 579 589 592 593 598 599 606 608 611 614 620 621 627 638 644 645 669 670 671 679 686 692 693 694 699 708 760 762 772 798 802 805 806 807 819 827 843", "filters": { "updated": true, "outdated": true, diff --git a/.config/BetterDiscord/plugins/PluginRepo.plugin.js b/.config/BetterDiscord/plugins/PluginRepo.plugin.js index 0143e5a..0ce5844 100644 --- a/.config/BetterDiscord/plugins/PluginRepo.plugin.js +++ b/.config/BetterDiscord/plugins/PluginRepo.plugin.js @@ -2,7 +2,7 @@ * @name PluginRepo * @author DevilBro * @authorId 278543574059057154 - * @version 2.4.0 + * @version 2.4.5 * @description Allows you to download all Plugins from BD's Website within Discord * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -72,12 +72,12 @@ module.exports = (_ => { }; const buttonData = { INSTALLED: { - backgroundColor: "var(--bdfdb-green)", + backgroundColor: "var(--status-positive)", icon: "CHECKMARK", text: "installed" }, OUTDATED: { - backgroundColor: "var(--bdfdb-red)", + backgroundColor: "var(--status-danger)", icon: "CLOSE", text: "outdated" }, @@ -122,6 +122,7 @@ module.exports = (_ => { } filterPlugins() { let plugins = grabbedPlugins.map(plugin => { + if (plugin.failed) return; const installedPlugin = _this.getInstalledPlugin(plugin); const state = installedPlugin ? (plugin.version && _this.compareVersions(plugin.version, _this.getString(installedPlugin.version)) ? pluginStates.OUTDATED : pluginStates.INSTALLED) : pluginStates.DOWNLOADABLE; return Object.assign(plugin, { @@ -131,7 +132,7 @@ module.exports = (_ => { new: state == pluginStates.DOWNLOADABLE && !cachedPlugins.includes(plugin.id) && 1, state: state }); - }); + }).filter(n => n); if (!this.props.updated) plugins = plugins.filter(plugin => plugin.state != pluginStates.INSTALLED); if (!this.props.outdated) plugins = plugins.filter(plugin => plugin.state != pluginStates.OUTDATED); if (!this.props.downloadable) plugins = plugins.filter(plugin => plugin.state != pluginStates.DOWNLOADABLE); @@ -165,7 +166,7 @@ module.exports = (_ => { grow: 1, shrink: 0, children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, { - tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H1, + tag: BDFDB.LibraryComponents.FormComponents.FormTags.H1, className: BDFDB.disCN.marginreset, children: `Plugin Repo — ${loading.is ? 0 : entries.length || 0}/${loading.is ? 0 : grabbedPlugins.length}` }) @@ -483,30 +484,28 @@ module.exports = (_ => { this.props.downloading = true; let loadingToast = BDFDB.NotificationUtils.toast(`${BDFDB.LanguageUtils.LibraryStringsFormat("loading", this.props.data.name)} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true}); let autoloadKey = this.props.data.state == pluginStates.OUTDATED ? "startUpdated" : "startDownloaded"; - BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => { - if (error) { + BDFDB.DiscordUtils.requestFileData(this.props.data.rawSourceUrl, {timeout: 10000}, (error, buffer) => { + if (error || !buffer) { delete this.props.downloading; loadingToast.close(); BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Plugin "${this.props.data.name}"`), {type: "danger"}); } - else { - BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), body, error2 => { - delete this.props.downloading; - loadingToast.close(); - if (error2) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Plugin "${this.props.data.name}"`), {type: "danger"}); - else { - BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Plugin "${this.props.data.name}"`), {type: "success"}); - if (_this.settings.general[autoloadKey]) BDFDB.TimeUtils.timeout(_ => { - if (this.props.data.state == pluginStates.INSTALLED && BDFDB.BDUtils.isPluginEnabled(this.props.data.name) == false) { - BDFDB.BDUtils.enablePlugin(this.props.data.name, false); - BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", this.props.data.name), _this); - } - }, 3000); - this.props.data.state = pluginStates.INSTALLED; - BDFDB.ReactUtils.forceUpdate(this); - } - }); - } + else BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), Buffer.from(buffer).toString(), error2 => { + delete this.props.downloading; + loadingToast.close(); + if (error2) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Plugin "${this.props.data.name}"`), {type: "danger"}); + else { + BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Plugin "${this.props.data.name}"`), {type: "success"}); + if (_this.settings.general[autoloadKey]) BDFDB.TimeUtils.timeout(_ => { + if (this.props.data.state == pluginStates.INSTALLED && BDFDB.BDUtils.isPluginEnabled(this.props.data.name) == false) { + BDFDB.BDUtils.enablePlugin(this.props.data.name, false); + BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", this.props.data.name), _this); + } + }, 3000); + this.props.data.state = pluginStates.INSTALLED; + BDFDB.ReactUtils.forceUpdate(this); + } + }); }); }, onDelete: _ => { @@ -579,10 +578,10 @@ module.exports = (_ => { this.defaults = { general: { - notifyOutdated: {value: true, autoload: false, description: "Get a Notification when one of your Plugins is outdated"}, - notifyNewEntries: {value: true, autoload: false, description: "Get a Notification when there are new Entries in the Repo"}, - startDownloaded: {value: false, autoload: true, description: "Start new Plugins after Download"}, - startUpdated: {value: false, autoload: true, description: "Start updated Plugins after Download"} + notifyOutdated: {value: true, autoload: false, description: "Shows a Notification when one of your Plugins is outdated"}, + notifyNewEntries: {value: true, autoload: false, description: "Shows a Notification when there are new Entries in the Repo"}, + startDownloaded: {value: false, autoload: true, description: "Starts new Plugins after Download"}, + startUpdated: {value: false, autoload: true, description: "Starts updated Plugins after Download"} }, filters: { updated: {value: true, description: "Updated"}, @@ -678,7 +677,7 @@ module.exports = (_ => { } processStandardSidebarView (e) { - if (e.instance.props.section == "pluginrepo") e.instance.props.contentType = "custom"; + if (e.instance.props && e.instance.props.section == "pluginrepo") e.instance.props.contentType = "custom"; } loadPlugins () { @@ -755,19 +754,23 @@ module.exports = (_ => { delete plugin.release_date; delete plugin.latest_source_url; delete plugin.thumbnail_url; - BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => { - if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) { - const META = body.split("*/")[0]; - plugin.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.name || ""); - plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author; - const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1]; - if (version) { - plugin.version = version; - const installedPlugin = this.getInstalledPlugin(plugin); - if (installedPlugin && this.compareVersions(version, this.getString(installedPlugin.version))) outdatedEntries++; + BDFDB.DiscordUtils.requestFileData(plugin.rawSourceUrl, {timeout: 10000}, (error, buffer) => { + if (error || !buffer) plugin.failed = true; + else { + let body = Buffer.from(buffer).toString(); + if (body && body.indexOf("404: Not Found") != 0) { + const META = body.split("*/")[0]; + plugin.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.name || ""); + plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author; + const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1]; + if (version) { + plugin.version = version; + const installedPlugin = this.getInstalledPlugin(plugin); + if (installedPlugin && this.compareVersions(version, this.getString(installedPlugin.version))) outdatedEntries++; + } } + if (!cachedPlugins.includes(plugin.id)) newEntries++; } - if (!cachedPlugins.includes(plugin.id)) newEntries++; plugin.loaded = true; diff --git a/.config/BetterDiscord/plugins/ZeresPluginLibrary.config.json b/.config/BetterDiscord/plugins/ZeresPluginLibrary.config.json index 5047173..f5d3a1a 100755 --- a/.config/BetterDiscord/plugins/ZeresPluginLibrary.config.json +++ b/.config/BetterDiscord/plugins/ZeresPluginLibrary.config.json @@ -1,6 +1,6 @@ { "currentVersionInfo": { - "version": "2.0.9", + "version": "2.0.11", "hasShownChangelog": true } } \ No newline at end of file diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index 26aeda1..fc91b11 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -14,14 +14,14 @@ # Any items in the `env` entry below will be added as # environment variables. Some entries may override variables # set by alacritty itself. -#env: +env: # TERM variable # # This value is used to set the `$TERM` environment variable for # each instance of Alacritty. If it is not present, alacritty will # check the local terminfo database and use `alacritty` if it is # available, otherwise `xterm-256color` is used. - #TERM: alacritty + TERM: xterm-256color window: # Window dimensions (changes require restart) diff --git a/.profile b/.profile index ced0f88..4630bb2 100644 --- a/.profile +++ b/.profile @@ -3,3 +3,6 @@ export GTK_THEME=oomox-rice #export QT_STYLE_OVERRIDE=gtk2 export QSYS_ROOTDIR="/home/poslop/.cache/yay/quartus-free/pkg/quartus-free-quartus/opt/intelFPGA/21.1/quartus/sopc_builder/bin" + +export DISCORD_TOKEN=ODAwNDQ2NDI4NTU1OTAzMDE3.Gp5hQe.lRy1jG5BBFwSjPmRJ36gs1dKciuR4L6xc4lgZg + diff --git a/.zshrc b/.zshrc index d0b21b7..c06e864 100644 --- a/.zshrc +++ b/.zshrc @@ -107,3 +107,10 @@ export wf='94:DB:56:1A:FB:7F' export wh='94:DB:56:F7:8A:40' export QSYS_ROOTDIR="/home/poslop/.cache/yay/quartus-free/pkg/quartus-free-quartus/opt/intelFPGA/21.1/quartus/sopc_builder/bin" + export PATH="/home/poslop/.cargo/bin:$PATH" + alias ecan="ssh -p 60052 poslop@goku.ecansol.com" + # Spoons!21 + +export X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR="/usr/bin/openssl" +export X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR="/usr/include/openssl/" + diff --git a/README.md b/README.md deleted file mode 100644 index b3a8680..0000000 --- a/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Dotfiles - -Dotfiles for my Arch Linux rice - -## Screenshots - -![Ss](/.ricejpg/rice1.jpg?raw=true) - -![Ss](/.ricejpg/rice2.jpg?raw=true) - -![Ss](/.ricejpg/rice3.jpg?raw=true) - -## Things I riced/use - -- Alacritty -- Qt -- Gtk -- Oomox ([Theming engine for Gtk/Qt](https://github.com/themix-project/oomox)) -- i3-gaps -- Rofi -- Polybar -- Firefox ([This Website/Extension](https://color.firefox.com/?theme=XQAAAAIdAQAAAAAAAABBKYhm849SCia2CaaEGccwS-xMDPr4zmCkdaHQeyMiAsBLvzmxZf3j3hKpT1c-8ef11QR8saNEuUZ9JYhZdHfKxRx8etCdGfltKx5Pdr_WIeV3iWOVg-fmX2-gTe41bNPCWjGyWnjwpTUQzHLndbQGV-F3rFUjqlehpM7K8sHsnZFIJAEA1pDFKsNTBMnPJ41ZbbQvzVeRB-UEBbj4r4rrbjcZYlYWtPy1U2A)) -- Youtube ([Enhancer for YouTube Extension](https://addons.mozilla.org/en-US/firefox/addon/enhancer-for-youtube/)) -- Discord ([BetterDiscord](https://betterdiscord.app/)) -- Spotify ([Spicetify](https://github.com/spicetify/)) -- Picom -- [Background Source](https://www.artstation.com/artwork/LeVwnv)