This commit is contained in:
poslop
2023-02-03 18:50:35 -06:00
parent a81ed41ae7
commit d038ef3742
17 changed files with 426 additions and 422 deletions

View File

@@ -1,9 +1,15 @@
{ {
"currentVersionInfo": { "currentVersionInfo": {
"version": "1.0.1", "version": "1.0.2",
"hasShownChangelog": true "hasShownChangelog": true
}, },
"blurred": [], "blurred": [],
"sen": [], "sen": [],
"seen": [] "seen": [
"1004559719433764898",
"1006296543915155536",
"1006208838434828350",
"751477930021879808",
"732807937457782895"
]
} }

View File

@@ -1,7 +1,7 @@
/** /**
* @name BlurNSFW * @name BlurNSFW
* @description Blurs images and videos until you hover over them. * @description Blurs images and videos until you hover over them.
* @version 1.0.1 * @version 1.0.2
* @author Zerebos * @author Zerebos
* @authorId 249746236008169473 * @authorId 249746236008169473
* @website https://github.com/rauenzi/BetterDiscordAddons/tree/master/Plugins/BlurNSFW * @website https://github.com/rauenzi/BetterDiscordAddons/tree/master/Plugins/BlurNSFW
@@ -41,7 +41,7 @@ const config = {
twitter_username: "ZackRauen" twitter_username: "ZackRauen"
} }
], ],
version: "1.0.1", version: "1.0.2",
description: "Blurs images and videos until you hover over them.", description: "Blurs images and videos until you hover over them.",
github: "https://github.com/rauenzi/BetterDiscordAddons/tree/master/Plugins/BlurNSFW", github: "https://github.com/rauenzi/BetterDiscordAddons/tree/master/Plugins/BlurNSFW",
github_raw: "https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BlurNSFW/BlurNSFW.plugin.js" github_raw: "https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BlurNSFW/BlurNSFW.plugin.js"
@@ -51,15 +51,7 @@ const config = {
title: "What's New?", title: "What's New?",
type: "fixed", type: "fixed",
items: [ items: [
"Context menu and blurring should work again!", "Can join voice channels without causing loading issues!"
"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."
] ]
} }
], ],
@@ -232,7 +224,6 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
} }
channelChange() { channelChange() {
Dispatcher?.removeAllListeners();
const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId()); const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId());
if (this.seenChannels.has(channel.id)) return; if (this.seenChannels.has(channel.id)) return;

View File

@@ -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 = `<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]) => {
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));
})();

View File

@@ -2,7 +2,7 @@
* @name EditRoles * @name EditRoles
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.1.2 * @version 1.1.4
* @description Allows you to locally edit Roles * @description Allows you to locally edit Roles
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@@ -60,19 +60,17 @@ module.exports = (_ => {
return class EditRoles extends Plugin { return class EditRoles extends Plugin {
onLoad () { onLoad () {
this.patchedModules = { this.modulePatches = {
before: { before: [
RoleMention: "default", "AutocompleteRoleResult",
AutocompleteRoleResult: "render", "ChannelMembers",
MessageHeader: "default", "MemberListItem",
ChannelMembers: "render", "MessageContent",
MemberListItem: "render", "UserPopoutBody"
UserPopoutBodySection: "default", ],
UserPopoutBody: "default" after: [
}, "RichRoleMention"
after: { ]
RichRoleMention: "RoleMention"
}
}; };
} }
@@ -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) { if (e.returnValue) {
let guild = BDFDB.LibraryModules.GuildStore.getGuild(e.methodArguments[0]); let guild = BDFDB.LibraryStores.GuildStore.getGuild(e.methodArguments[0]);
if (guild) { if (guild) {
let colorRole, iconRole; let colorRole, iconRole;
for (let id of e.returnValue.roles) { for (let id of e.returnValue.roles) {
@@ -159,19 +157,17 @@ module.exports = (_ => {
} }
onUserContextMenu (e) { onUserContextMenu (e) {
if (e.subType == "useUserRolesItems") { let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "roles"});
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 (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]) {
if (child && child.props && typeof child.props.label == "function" && changedRoles[child.props.id]) { let data = changedRoles[child.props.id];
let data = changedRoles[child.props.id]; let renderLabel = child.props.label;
let renderLabel = child.props.label; child.props.label = BDFDB.TimeUtils.suppress((...args) => {
child.props.label = BDFDB.TimeUtils.suppress((...args) => { let label = renderLabel(...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.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;
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;
return label; }, "Error in renderLabel of UserRolesItems", this);
}, "Error in renderLabel of UserRolesItems", this);
}
} }
} }
} }
@@ -199,7 +195,7 @@ module.exports = (_ => {
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.submenu_resetsettings, label: this.labels.submenu_resetsettings,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-reset"), 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], disabled: !changedRoles[e.instance.props.id],
action: event => { action: event => {
let remove = _ => { let remove = _ => {
@@ -217,29 +213,27 @@ module.exports = (_ => {
e.returnvalue.props.children e.returnvalue.props.children
].flat(10).filter(n => n); ].flat(10).filter(n => n);
} }
processRichRoleMention (e) { processMessageContent (e) {
if (e.instance.props.id && changedRoles[e.instance.props.id]) { if (!BDFDB.ArrayUtils.is(e.instance.props.content)) 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; 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]) {
e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.props.children[1]; 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) { processRichRoleMention (e) {
if (e.instance.props.roleId && changedRoles[e.instance.props.roleId]) { if (!e.instance.props.id || !changedRoles[e.instance.props.id]) return;
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.returnvalue.props.color = changedRoles[e.instance.props.id].color ? BDFDB.ColorUtils.convert(changedRoles[e.instance.props.id].color, "int") : e.returnvalue.props.color;
e.instance.props.children = [`@${changedRoles[e.instance.props.roleId].name || e.instance.props.children[1]}`]; e.returnvalue.props.children[1] = changedRoles[e.instance.props.id].name || e.returnvalue.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]}`;
}
} }
processAutocompleteRoleResult (e) { processAutocompleteRoleResult (e) {
if (e.instance.props.role && changedRoles[e.instance.props.role.id]) { 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 = 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.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.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; e.instance.props.role.name = changedRoles[e.instance.props.role.id].name || e.instance.props.role.name;
}
} }
processChannelMembers (e) { processChannelMembers (e) {
@@ -256,14 +250,9 @@ module.exports = (_ => {
} }
processMemberListItem (e) { processMemberListItem (e) {
if (e.instance.props.user) { if (!e.instance.props.user) return;
let member = BDFDB.LibraryModules.MemberStore.getMember(e.instance.props.guildId, e.instance.props.user.id); let member = BDFDB.LibraryStores.GuildMemberStore.getMember(e.instance.props.guildId, e.instance.props.user.id);
if (member) e.instance.props.colorString = member.colorString; 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);
} }
processUserPopoutBody (e) { processUserPopoutBody (e) {
@@ -271,7 +260,7 @@ module.exports = (_ => {
} }
getGuildFromRoleId (roleId) { 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) { changeRolesInGuild (guild, useNative) {
@@ -300,7 +289,7 @@ module.exports = (_ => {
BDFDB.DataUtils.remove(this, "roles", id); BDFDB.DataUtils.remove(this, "roles", id);
} }
else { 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 = {}; cachedRoles = {};
BDFDB.DataUtils.remove(this, "roles"); BDFDB.DataUtils.remove(this, "roles");
} }
@@ -360,15 +349,15 @@ module.exports = (_ => {
children: [ children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
className: BDFDB.disCN.marginreset, className: BDFDB.disCN.marginreset,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5, tag: BDFDB.LibraryComponents.FormComponents.FormTags.H5,
children: BDFDB.LibraryModules.LanguageStore.Messages.FORM_LABEL_ROLE_ICON children: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ROLE_ICON
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch", type: "Switch",
margin: 0, margin: 0,
grow: 0, grow: 0,
label: BDFDB.LanguageUtils.LanguageStrings.REMOVE, label: BDFDB.LanguageUtils.LanguageStrings.REMOVE,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5, tag: BDFDB.LibraryComponents.FormComponents.FormTags.H5,
value: data.removeIcon, value: data.removeIcon,
onChange: value => { onChange: value => {
newData.removeIcon = value; newData.removeIcon = value;

View File

@@ -13,6 +13,7 @@
"Baidu": true, "Baidu": true,
"Bing": true, "Bing": true,
"Google": true, "Google": true,
"GoogleLens": true,
"ImgOps": true, "ImgOps": true,
"IQDB": true, "IQDB": true,
"Reddit": true, "Reddit": true,
@@ -22,6 +23,24 @@
"WhatAnime": true, "WhatAnime": true,
"Yandex": 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": { "general": {
"nsfwMode": true "nsfwMode": true
}, },
@@ -54,7 +73,7 @@
"zoomSettings": { "zoomSettings": {
"lensSize": 1459, "lensSize": 1459,
"pixelMode": false, "pixelMode": false,
"zoomLevel": 1.8000000000000016 "zoomLevel": 1.6000000000000014
} }
} }
} }

View File

@@ -2,7 +2,7 @@
* @name ImageUtilities * @name ImageUtilities
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 4.9.5 * @version 5.1.0
* @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.) * @description Adds several Utilities for Images/Videos (Gallery, Download, Reverse Search, Zoom, Copy, etc.)
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@@ -61,6 +61,7 @@ module.exports = (_ => {
var ownLocations = {}, downloadsFolder; var ownLocations = {}, downloadsFolder;
var firstViewedImage, viewedImage, viewedImageTimeout; var firstViewedImage, viewedImage, viewedImageTimeout;
var switchedImageProps;
var cachedImages; var cachedImages;
var eventTypes = {}; var eventTypes = {};
@@ -73,55 +74,49 @@ module.exports = (_ => {
}; };
const fileTypes = { const fileTypes = {
"3gp": {copyable: false, searchable: false, video: true}, "3gp": {copyable: false, searchable: false, video: true, signs: [[0x66, 0x74, 0x79, 0x70, 0x33, 0x67]]},
"3g2": {copyable: false, searchable: false, video: true}, "avi": {copyable: false, searchable: false, video: true, signs: [[0x41, 0x56, 0x49, 0x20]]},
"amv": {copyable: false, searchable: false, video: true}, "flv": {copyable: false, searchable: false, video: true, signs: [[0x46, 0x4C, 0x56]]},
"apng": {copyable: false, searchable: true, video: false}, "jpeg": {copyable: true, searchable: true, video: false, signs: [[0xFF, 0xD8, 0xFF, 0xEE]]},
"avi": {copyable: false, searchable: false, video: true}, "jpg": {copyable: true, searchable: true, video: false, signs: [[0xFF, 0xD8, 0xFF, 0xDB], [0xFF, 0xD8, 0xFF, 0xE0], [0xFF, 0xD8, 0xFF, 0xE1]]},
"flv": {copyable: false, searchable: false, video: true}, "gif": {copyable: false, searchable: true, video: false, signs: [[0x47, 0x49, 0x46, 0x38, 0x37, 0x61], [0x47, 0x49, 0x46, 0x38, 0x39, 0x61]]},
"jpeg": {copyable: true, searchable: true, video: false}, "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]]},
"jpg": {copyable: true, searchable: true, video: false}, "mp4": {copyable: false, searchable: false, video: true, signs: [[null, null, null, null, 0x66, 0x74, 0x79, 0x70]]},
"gif": {copyable: false, searchable: true, video: false}, "mpeg-1": {copyable: false, searchable: false, video: true, signs: [[0x00, 0x00, 0x01, 0xBA]]},
"m4v": {copyable: false, searchable: false, video: true}, "mpeg-2": {copyable: false, searchable: false, video: true, signs: [[0x00, 0x00, 0x01, 0xB3]]},
"mkv": {copyable: false, searchable: false, video: true}, "ogg": {copyable: false, searchable: false, video: true, signs: [[0x4F, 0x67, 0x67, 0x53]]},
"mov": {copyable: false, searchable: false, video: true}, "png": {copyable: true, searchable: true, video: false, signs: [[0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]]},
"mp4": {copyable: false, searchable: false, video: true}, "svg": {copyable: false, searchable: false, video: false, signs: [[0x3C]]},
"mpeg-1": {copyable: false, searchable: false, video: true}, "webm": {copyable: false, searchable: false, video: true, signs: [[0x1A, 0x45, 0xDF, 0xA3]]},
"mpeg-2": {copyable: false, searchable: false, video: true}, "webp": {copyable: false, searchable: true, video: false, signs: [[0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50]]},
"ogg": {copyable: false, searchable: false, video: true}, "wmv": {copyable: false, searchable: false, video: true, signs: [[0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11], [0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C]]}
"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}
}; };
const LazyImageSiblingComponent = class LazyImageSibling extends BdApi.React.Component { const LazyImageSiblingComponent = class LazyImageSibling extends BdApi.React.Component {
render() { render() {
if (!this.props.loadedImage) { if (!this.props.loadedImage) {
const instace = this; const instance = this;
const imageThrowaway = document.createElement("img"); const imageThrowaway = document.createElement("img");
imageThrowaway.addEventListener("load", function() { imageThrowaway.addEventListener("load", function() {
let aRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.appmount)); 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 resizeX = (aRects.width/this.width) * 0.8, resizeY = (aRects.height/this.height) * 0.65
let ratio = resizeX < resizeY ? resizeX : resizeY; 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, src: imageThrowaway.src,
width: this.width, width: this.width,
height: this.height, height: this.height,
maxWidth: this.width * ratio, maxWidth: this.width * ratio,
maxHeight: this.height * 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", { return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._imageutilitiessibling, this.props.className), className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._imageutilitiessibling, this.props.className),
onClick: event => { onClick: event => {
BDFDB.ListenerUtils.stopEvent(event); BDFDB.ListenerUtils.stopEvent(event);
_this.switchImages(this.props.modalInstance, this.props.offset); _this.switchImages(this.props.offset);
}, },
children: [ children: [
this.props.loadedImage || BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SpinnerComponents.Spinner, { this.props.loadedImage || BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SpinnerComponents.Spinner, {
@@ -176,7 +171,7 @@ module.exports = (_ => {
height: 16, height: 16,
onClick: event => { onClick: event => {
BDFDB.ListenerUtils.stopEvent(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 => { onContextMenu: event => {
let locations = Object.keys(ownLocations).filter(n => ownLocations[n].enabled); 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, { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
id: BDFDB.ContextMenuUtils.createItemId(_this.name, "download", name, i), id: BDFDB.ContextMenuUtils.createItemId(_this.name, "download", name, i),
label: name, 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"}, saveImage: {value: true, description: "Adds a 'Save Image as' Option"},
jumpTo: {value: true, description: "Adds a 'Jump to Message' Option in Gallery Mode"} jumpTo: {value: true, description: "Adds a 'Jump to Message' Option in Gallery Mode"}
}, },
galleryFilter: {},
zoomSettings: { zoomSettings: {
pixelMode: {value: false, label: "Uses Pixel Lens instead of a Blur Lens"}, 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"}, zoomLevel: {value: 2, digits: 1, minValue: 1, maxValue: 20, unit: "x", label: "ACCESSIBILITY_ZOOM_LEVEL_LABEL"},
@@ -238,8 +234,9 @@ module.exports = (_ => {
engines: { engines: {
_all: {value: true, name: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL, url: null}, _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}, 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"}, 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}, 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}, 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}, IQDB: {value: true, name: "IQDB", url: "https://iqdb.org/?url=" + imgUrlReplaceString},
Reddit: {value: true, name: "Reddit", url: "http://karmadecay.com/search?q=" + 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"} 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 = { this.modulePatches = {
before: [ before: [
"ImageModal",
"MessageAccessories", "MessageAccessories",
"Spoiler" "Spoiler"
], ],
@@ -262,18 +262,16 @@ module.exports = (_ => {
"LazyImageZoomable", "LazyImageZoomable",
"ModalCarousel", "ModalCarousel",
"Spoiler", "Spoiler",
"UserBanner", "UserBanner"
"UserThemedBanner"
], ],
componentDidMount: [ componentDidMount: [
"ImageModal",
"LazyImage" "LazyImage"
], ],
componentDidUpdate: [ componentDidUpdate: [
"LazyImage" "LazyImage"
], ],
componentWillUnmount: [ 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, { settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Resize Settings", title: "Resize Settings",
collapseStates: collapseStates, collapseStates: collapseStates,
@@ -504,7 +514,7 @@ module.exports = (_ => {
children: [ children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
className: BDFDB.disCN.marginbottom4, className: BDFDB.disCN.marginbottom4,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3, tag: BDFDB.LibraryComponents.FormComponents.FormTags.H3,
children: "Add additional Download Locations" children: "Add additional Download Locations"
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
@@ -657,51 +667,50 @@ module.exports = (_ => {
} }
onGuildContextMenu (e) { onGuildContextMenu (e) {
if (e.instance.props.guild && this.settings.places.guildIcons) { 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) { 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); 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); 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);
} }
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) { onUserContextMenu (e) {
if (e.instance.props.user && this.settings.places.userAvatars) { if (!this.settings.places.userAvatars || !e.instance.props.user) return;
const guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId(); const guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId();
const member = BDFDB.LibraryStores.GuildMemberStore.getMember(guildId, e.instance.props.user.id); 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)]); 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) { 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) { 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) { onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel && e.instance.props.target) { 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]); 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 { 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; const reaction = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagereaction, 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]); if (reaction && this.settings.places.emojis) {
else if (target.tagName == "IMG" && target.complete && target.naturalHeight) { const emoji = reaction.querySelector(BDFDB.dotCN.emojiold);
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)}]); if (emoji) this.injectItem(e, [{file: emoji.src, alternativeName: emoji.getAttribute("data-name")}], null, true);
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")}]);
}
} }
} }
} }
@@ -714,10 +723,9 @@ module.exports = (_ => {
return href || src; return href || src;
} }
injectItem (e, urls, prefix) { injectItem (e, urls, prefix, isNative = false) {
let validUrls = this.filterUrls(...urls); let validUrls = this.filterUrls(...urls);
if (!validUrls.length) return; if (!validUrls.length) return;
let isNative = false;
let [nativeParent, nativeIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "copy-native-link", group: true}); let [nativeParent, nativeIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "copy-native-link", group: true});
if (nativeIndex > -1) { if (nativeIndex > -1) {
if (validUrls.length == 1) isNative = true; if (validUrls.length == 1) isNative = true;
@@ -736,7 +744,7 @@ module.exports = (_ => {
target: e.instance.props.target 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.splice(index > -1 ? index : children.length, 0, isNative ? subMenu : BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.isValid(validUrls[0].file, "video") ? this.labels.context_videoactions : this.labels.context_imageactions, 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}`))); 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) { 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, { 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(" "), 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, { !this.isValid(urlData.file, "copyable") ? null : BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_copy.replace("{{var0}}", type), label: this.labels.context_copy.replace("{{var0}}", type),
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-file"), 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, { !document.querySelector(BDFDB.dotCN.imagemodal) && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_view.replace("{{var0}}", type), label: this.labels.context_view.replace("{{var0}}", type),
@@ -836,12 +848,15 @@ module.exports = (_ => {
shouldAnimate: true, shouldAnimate: true,
renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props), renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props),
children: !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, { children: !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, {
ignoreMaxSize: true,
poster: _this.getPosterUrl(urlData.src || urlData.file),
src: urlData.src || urlData.file, src: urlData.src || urlData.file,
width: videoData.size.width, width: videoData.size.width,
height: videoData.size.height, height: videoData.size.height,
naturalWidth: this.videoWidth, naturalWidth: this.videoWidth,
naturalHeight: this.videoHeight, naturalHeight: this.videoHeight,
play: true play: true,
playOnHover: !!BDFDB.LibraryStores.AccessibilityStore.useReducedMotion
})) }))
}) })
}), true); }), true);
@@ -853,12 +868,12 @@ module.exports = (_ => {
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_saveas.replace("{{var0}}", type), label: this.labels.context_saveas.replace("{{var0}}", type),
id: BDFDB.ContextMenuUtils.createItemId(this.name, "download-file-as"), 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.length && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i), id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i),
label: name, 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) { processImageModal (e) {
if (e.methodname == "componentDidMount") { if (!e.returnvalue) {
BDFDB.TimeUtils.clear(viewedImageTimeout); if (switchedImageProps) {
e.instance.props = Object.assign(e.instance.props, switchedImageProps);
let modal = BDFDB.DOMUtils.getParent(BDFDB.dotCN.modal, e.node); switchedImageProps = null;
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);
}
} }
} }
else if (e.methodname == "componentWillUnmount") {
firstViewedImage = null;
viewedImage = null;
this.cleanupListeners("Gallery");
}
else { 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 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"); let isVideo = this.isValid(url, "video");
@@ -980,7 +984,7 @@ module.exports = (_ => {
children: this.labels.context_saveas.replace("{{var0}}", type), children: this.labels.context_saveas.replace("{{var0}}", type),
onClick: event => { onClick: event => {
BDFDB.ListenerUtils.stopEvent(event); BDFDB.ListenerUtils.stopEvent(event);
this.downloadFileAs(url); this.downloadFile({url: url});
}, },
onContextMenu: event => { onContextMenu: event => {
let locations = Object.keys(ownLocations).filter(n => ownLocations[n].enabled); 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, { children: locations.map((name, i) => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i), id: BDFDB.ContextMenuUtils.createItemId(this.name, "download", name, i),
label: name, 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 (this.settings.viewerSettings.galleryMode && viewedImage) {
if (!cachedImages || cachedImages.channelId != viewedImage.channelId || cachedImages.amount && this.getImageIndex(cachedImages.all, viewedImage) == -1) { if (!cachedImages || cachedImages.channelId != viewedImage.channelId || cachedImages.amount && this.getImageIndex(cachedImages.all, viewedImage) == -1) {
BDFDB.TimeUtils.clear(viewedImageTimeout); BDFDB.TimeUtils.clear(viewedImageTimeout);
@@ -1089,7 +1092,7 @@ module.exports = (_ => {
newestId: null, newestId: null,
lastReached: null lastReached: null
}; };
BDFDB.ReactUtils.forceUpdate(e.instance); this.updateImageModal();
}).then(result => { }).then(result => {
if (!viewedImage) return; if (!viewedImage) return;
let messages = [], index = -1; let messages = [], index = -1;
@@ -1117,20 +1120,18 @@ module.exports = (_ => {
newestId: null, newestId: null,
lastReached: null lastReached: null
}; };
BDFDB.ReactUtils.forceUpdate(e.instance); this.updateImageModal();
}); });
} }
else { else {
if (cachedImages.all[cachedImages.index - 1]) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(LazyImageSiblingComponent, { if (cachedImages.all[cachedImages.index - 1]) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(LazyImageSiblingComponent, {
className: BDFDB.disCN._imageutilitiesprevious, className: BDFDB.disCN._imageutilitiesprevious,
modalInstance: e.instance,
url: this.getImageSrc(cachedImages.all[cachedImages.index - 1].thumbnail || cachedImages.all[cachedImages.index - 1]), url: this.getImageSrc(cachedImages.all[cachedImages.index - 1].thumbnail || cachedImages.all[cachedImages.index - 1]),
offset: -1, offset: -1,
svgIcon: BDFDB.LibraryComponents.SvgIcon.Names.LEFT_CARET svgIcon: BDFDB.LibraryComponents.SvgIcon.Names.LEFT_CARET
})); }));
if (cachedImages.all[cachedImages.index + 1]) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(LazyImageSiblingComponent, { if (cachedImages.all[cachedImages.index + 1]) e.returnvalue.props.children.push(BDFDB.ReactUtils.createElement(LazyImageSiblingComponent, {
className: BDFDB.disCN._imageutilitiesnext, className: BDFDB.disCN._imageutilitiesnext,
modalInstance: e.instance,
url: this.getImageSrc(cachedImages.all[cachedImages.index + 1].thumbnail || cachedImages.all[cachedImages.index + 1]), url: this.getImageSrc(cachedImages.all[cachedImages.index + 1].thumbnail || cachedImages.all[cachedImages.index + 1]),
offset: 1, offset: 1,
svgIcon: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_CARET svgIcon: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_CARET
@@ -1139,8 +1140,8 @@ module.exports = (_ => {
this.addListener("keydown", "Gallery", event => { this.addListener("keydown", "Gallery", event => {
if (!firedEvents.includes("Gallery")) { if (!firedEvents.includes("Gallery")) {
firedEvents.push("Gallery"); firedEvents.push("Gallery");
if (event.keyCode == 37) this.switchImages(e.instance, -1); if (event.keyCode == 37) this.switchImages(-1);
else if (event.keyCode == 39) this.switchImages(e.instance, 1); else if (event.keyCode == 39) this.switchImages(1);
} }
}); });
this.addListener("keyup", "Gallery", _ => BDFDB.ArrayUtils.remove(firedEvents, "Gallery", true)); this.addListener("keyup", "Gallery", _ => BDFDB.ArrayUtils.remove(firedEvents, "Gallery", true));
@@ -1151,10 +1152,10 @@ module.exports = (_ => {
} }
processModalCarousel (e) { processModalCarousel (e) {
if (this.settings.viewerSettings.galleryMode) { if (!this.settings.viewerSettings.galleryMode || !BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ImageModal"})) return;
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ImageModal"}); e.returnvalue.props.className = "";
if (index > -1) return children[index]; e.returnvalue.props.children[0] = null;
} e.returnvalue.props.children[2] = null;
} }
processLazyImage (e) { processLazyImage (e) {
@@ -1176,19 +1177,34 @@ module.exports = (_ => {
BDFDB.ReactUtils.forceUpdate(e.instance); BDFDB.ReactUtils.forceUpdate(e.instance);
} }
} }
if (e.methodname == "componentDidMount") { if (e.methodname == "componentWillUnmount" && BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagemodal, e.node)) {
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"; firstViewedImage = null;
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})) { 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.style.setProperty("cursor", "zoom-in");
e.node.addEventListener("mousedown", event => { e.node.addEventListener("mousedown", event => {
if (event.which != 1) return; if (event.which != 1 || e.node.querySelector("video")) return;
BDFDB.ListenerUtils.stopEvent(event); BDFDB.ListenerUtils.stopEvent(event);
let vanishObserver; let vanishObserver;
let imgRects = BDFDB.DOMUtils.getRects(e.node.firstElementChild); let imgRects = BDFDB.DOMUtils.getRects(e.node.firstElementChild);
let lens = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN._imageutilitieslense}" style="border-radius: 50% !important; pointer-events: none !important; z-index: 10000 !important; width: ${this.settings.zoomSettings.lensSize}px !important; height: ${this.settings.zoomSettings.lensSize}px !important; position: fixed !important;"><div style="position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important;"><${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" : ""}></${e.node.firstElementChild.tagName}></div></div>`);
let lens = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN._imageutilitieslense}" style="border-radius: 50% !important; pointer-events: none !important; z-index: 10000 !important; width: ${this.settings.zoomSettings.lensSize}px !important; height: ${this.settings.zoomSettings.lensSize}px !important; position: fixed !important;"><div style="position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important;"><${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" : ""}></${e.node.firstElementChild.tagName}></div></div>`);
let pane = lens.firstElementChild.firstElementChild; let pane = lens.firstElementChild.firstElementChild;
let backdrop = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN._imageutilitieslensebackdrop}" style="background: rgba(0, 0, 0, 0.3) !important; position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; pointer-events: none !important; z-index: 8000 !important;"></div>`); let backdrop = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN._imageutilitieslensebackdrop}" style="background: rgba(0, 0, 0, 0.3) !important; position: absolute !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important; pointer-events: none !important; z-index: 8000 !important;"></div>`);
let appMount = document.querySelector(BDFDB.dotCN.appmount); let appMount = document.querySelector(BDFDB.dotCN.appmount);
@@ -1217,7 +1233,7 @@ module.exports = (_ => {
}; };
lens.update(); 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 => { let dragging = event2 => {
event = event2; event = event2;
@@ -1225,7 +1241,7 @@ module.exports = (_ => {
}; };
let releasing = event2 => { let releasing = event2 => {
BDFDB.ListenerUtils.stopEvent(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"); this.cleanupListeners("Zoom");
document.removeEventListener("mousemove", dragging); document.removeEventListener("mousemove", dragging);
document.removeEventListener("mouseup", releasing); document.removeEventListener("mouseup", releasing);
@@ -1292,7 +1308,7 @@ module.exports = (_ => {
e.instance.props.resized = true; 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 aRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.appmount));
let mRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCNC.messageaccessory + BDFDB.dotCN.messagecontents)); let mRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCNC.messageaccessory + BDFDB.dotCN.messagecontents));
let mwRects = BDFDB.DOMUtils.getRects(document.querySelector(BDFDB.dotCN.messagewrapper)); 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; if (!this.settings.places.userAvatars || !e.instance.props.displayProfile || !e.instance.props.displayProfile.banner) return;
let div = BDFDB.ReactUtils.findChild(e.returnvalue, {type: "div"}); let div = BDFDB.ReactUtils.findChild(e.returnvalue, {type: "div"});
if (div) div.props.onContextMenu = event => { if (div) div.props.onContextMenu = event => {
@@ -1412,10 +1428,6 @@ module.exports = (_ => {
}; };
} }
processUserBanner (e) {
this.processUserThemedBanner(e);
}
cacheClickedImage (target) { cacheClickedImage (target) {
if (!target) return; if (!target) return;
const image = (BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagewrapper, target) || target).querySelector("img") || target; const image = (BDFDB.DOMUtils.getParent(BDFDB.dotCN.imagewrapper, target) || target).querySelector("img") || target;
@@ -1431,26 +1443,59 @@ module.exports = (_ => {
}, 1000); }, 1000);
} }
downloadFile (url, path, fallbackUrl, alternativeName) { downloadFile (urls, path, alternativeName, fallbackToRequest) {
url = url.startsWith("/assets") ? (window.location.origin + url) : url; if (!urls) return BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", BDFDB.LanguageUtils.LanguageStrings.IMAGE).replace("{{var1}}", path || "PC"), {type: "danger"});
BDFDB.LibraryRequires.request(url, {agentOptions: {rejectUnauthorized: false}, headers: {"Content-Type": "application/json"}}, (error, response, body) => { let url = urls.url.startsWith("/assets") ? (window.location.origin + urls.url) : urls.url;
let type = this.isValid(url, "video") ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE; if (!fallbackToRequest) BDFDB.DiscordUtils.requestFileData(url, {timeout: 3000}, (error, buffer) => {
if (error || response.statusCode != 200 || response.headers["content-type"].indexOf("text/html") > -1) { if (error || !buffer) {
if (fallbackUrl) this.downloadFile(fallbackUrl, path, null, alternativeName); if (urls.fallbackUrl && urls.url != urls.fallbackUrl) this.downloadFile({url: urls.fallbackUrl, oldUrl: urls.url}, path, alternativeName);
else BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", ""), {type: "danger"}); else this.downloadFile({url: urls.oldUrl || urls.url, fallbackUrl: urls.oldUrl ? urls.url : undefined}, path, alternativeName, true);
} }
else { 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 => { let extension = this.getFileExtension(new Uint8Array(buffer));
if (error) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", type).replace("{{var1}}", path), {type: "danger"}); if (!extension) BDFDB.NotificationUtils.toast(this.labels.toast_save_failed.replace("{{var0}}", BDFDB.LanguageUtils.LanguageStrings.IMAGE).replace("{{var1}}", path || "PC"), {type: "danger"});
else BDFDB.NotificationUtils.toast(this.labels.toast_save_success.replace("{{var0}}", type).replace("{{var1}}", path), {type: "success"}); 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) { copyFile (url) {
@@ -1478,9 +1523,14 @@ module.exports = (_ => {
else return wholePath; else return wholePath;
} }
getFileExtenstion (ext) { getFileExtension (intArray) {
if (ext == "quicktime") ext = "mov"; for (let fileType in fileTypes) if (fileTypes[fileType].signs.some(signs => signs.every((hex, i) => hex === null || hex == intArray[i]))) return fileType;
return ext; return "";
}
getMimeType (fileType) {
if (fileTypes[fileType]) return `${fileTypes[fileType].video ? "video" : "image"}/${fileType == "svg" ? "svg+xml" : fileType}`;
return "";
} }
getImageSrc (img) { getImageSrc (img) {
@@ -1493,10 +1543,16 @@ module.exports = (_ => {
} }
filterMessagesForImages (messages, img) { 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); const newIndex = parseInt(cachedImages.index) + parseInt(offset);
if (newIndex < 0 || newIndex > (cachedImages.amount - 1)) return; if (newIndex < 0 || newIndex > (cachedImages.amount - 1)) return;
@@ -1518,7 +1574,7 @@ module.exports = (_ => {
}).then(result => { }).then(result => {
if (result && viewedImage) { if (result && viewedImage) {
const messages = result.body.flat(10).reverse(); 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); const index = this.getImageIndex(cachedImages.all, viewedImage);
cachedImages = Object.assign(cachedImages, { cachedImages = Object.assign(cachedImages, {
channelId: viewedImage.channelId, channelId: viewedImage.channelId,
@@ -1527,7 +1583,7 @@ module.exports = (_ => {
newestId: messages[messages.length-1] ? messages[messages.length-1].id : null, newestId: messages[messages.length-1] ? messages[messages.length-1].id : null,
lastReached: index == (cachedImages.all.length - 1) lastReached: index == (cachedImages.all.length - 1)
}); });
BDFDB.ReactUtils.forceUpdate(modalInstance); this.updateImageModal();
} }
}); });
} }
@@ -1545,7 +1601,7 @@ module.exports = (_ => {
}).then(result => { }).then(result => {
if (result && viewedImage) { if (result && viewedImage) {
const messages = result.body.flat(10).reverse(); 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); const index = this.getImageIndex(cachedImages.all, viewedImage);
cachedImages = Object.assign(cachedImages, { cachedImages = Object.assign(cachedImages, {
channelId: viewedImage.channelId, channelId: viewedImage.channelId,
@@ -1554,27 +1610,42 @@ module.exports = (_ => {
index: index, index: index,
amount: cachedImages.all.length amount: cachedImages.all.length
}); });
BDFDB.ReactUtils.forceUpdate(modalInstance); this.updateImageModal();
} }
}); });
} }
let isVideo = this.isValid(viewedImage.proxy_url, "video"); let isVideo = this.isValid(viewedImage.proxy_url, "video");
modalInstance.props.animated = !!isVideo; let thisViewedImage = viewedImage;
modalInstance.props.original = viewedImage.proxy_url; switchedImageProps = {
modalInstance.props.placeholder = viewedImage.thumbnail && viewedImage.thumbnail.proxy_url || viewedImage.proxy_url; animated: !!isVideo,
modalInstance.props.src = viewedImage.proxy_url; original: thisViewedImage.proxy_url,
modalInstance.props.width = viewedImage.width; placeholder: isVideo && (thisViewedImage.thumbnail && thisViewedImage.thumbnail.proxy_url || thisViewedImage.proxy_url),
modalInstance.props.height = viewedImage.height; src: thisViewedImage.proxy_url,
modalInstance.props.children = !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, { width: thisViewedImage.width,
src: viewedImage.proxy_url, height: thisViewedImage.height,
width: videoData.size.width, children: !isVideo ? null : (videoData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Video, {
height: videoData.size.height, ignoreMaxSize: true,
naturalWidth: viewedImage.width, poster: thisViewedImage.proxy_url.replace("https://cdn.discordapp.com", "https://media.discordapp.net").split("?size=")[0] + "?format=jpeg",
naturalHeight: viewedImage.height, src: thisViewedImage.proxy_url,
play: true, width: videoData.size.width,
playOnHover: !!BDFDB.LibraryStores.AccessibilityStore.useReducedMotion height: videoData.size.height,
})); naturalWidth: thisViewedImage.width,
BDFDB.ReactUtils.forceUpdate(modalInstance); 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) { addListener (eventType, type, callback) {

View File

@@ -5,9 +5,9 @@
}, },
"settings": { "settings": {
"exclude": [ "exclude": [
"709081938622939166" "671439465377562624"
], ],
"autoEnable": false, "autoEnable": true,
"latestUsedVersion": "1.3.3" "latestUsedVersion": "1.3.3"
} }
} }

View File

@@ -250,6 +250,13 @@
"mute": null, "mute": null,
"sound": "---", "sound": "---",
"volume": 100 "volume": 100
},
"stage_waiting": {
"category": "---",
"focus": false,
"mute": false,
"sound": "---",
"volume": 100
} }
}, },
"volumes": { "volumes": {

View File

@@ -2,7 +2,7 @@
* @name NotificationSounds * @name NotificationSounds
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 3.7.5 * @version 3.7.6
* @description Allows you to replace the native Sounds with custom Sounds * @description Allows you to replace the native Sounds with custom Sounds
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@@ -85,9 +85,9 @@ module.exports = (_ => {
const WebAudioSound = class WebAudioSound { const WebAudioSound = class WebAudioSound {
constructor (type) { constructor (type) {
this._name = type; this.name = type;
this._src = audios[choices[type].category][choices[type].sound] || types[type].src; this._src = audios[choices[type].category][choices[type].sound] || types[type].src;
this._volume = choices[type].volume; this._volume = choices[type].volume / 100;
} }
loop () { loop () {
this._ensureAudio().then(audio => { this._ensureAudio().then(audio => {
@@ -133,7 +133,7 @@ module.exports = (_ => {
let audio = new Audio; let audio = new Audio;
audio.src = this._src && this._src.startsWith("data") ? this._src.replace(/ /g, "") : this._src; audio.src = this._src && this._src.startsWith("data") ? this._src.replace(/ /g, "") : this._src;
audio.onloadeddata = _ => { 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); BDFDB.DiscordUtils.isPlaformEmbedded() && audio.setSinkId(currentDevice || defaultDevice);
callback(audio); callback(audio);
}; };
@@ -157,7 +157,9 @@ module.exports = (_ => {
}; };
this.patchPriority = 9; this.patchPriority = 9;
}
onStart () {
const soundKeys = BDFDB.LibraryModules.SoundParser.keys(); const soundKeys = BDFDB.LibraryModules.SoundParser.keys();
for (let key of soundKeys) { for (let key of soundKeys) {
const id = key.replace("./", "").replace(".mp3", ""); const id = key.replace("./", "").replace(".mp3", "");
@@ -193,9 +195,7 @@ module.exports = (_ => {
types = BDFDB.ObjectUtils.sort(types, "name"); types = BDFDB.ObjectUtils.sort(types, "name");
} }
for (let pack in defaultAudios) defaultAudios[pack] = BDFDB.ObjectUtils.sort(defaultAudios[pack]); for (let pack in defaultAudios) defaultAudios[pack] = BDFDB.ObjectUtils.sort(defaultAudios[pack]);
}
onStart () {
if (BDFDB.DiscordUtils.isPlaformEmbedded()) { if (BDFDB.DiscordUtils.isPlaformEmbedded()) {
let change = _ => { let change = _ => {
if (window.navigator.mediaDevices && window.navigator.mediaDevices.enumerateDevices) { 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); let soundObjIndex = Array.from(e.methodArguments).findIndex(n => n && n.sound);
if (soundObjIndex && e.methodArguments[soundObjIndex].sound.includes("message")) e.methodArguments[soundObjIndex].sound = null; if (soundObjIndex && e.methodArguments[soundObjIndex].sound.includes("message")) e.methodArguments[soundObjIndex].sound = null;
}}); }});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {instead: e => { if (BDFDB.LibraryModules.SoundUtils && BDFDB.LibraryModules.SoundUtils.createSound) {
let type = e.methodArguments[0]; let cancel = BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "createSound", {after: e => {
if (type && choices[type]) { if (e.returnValue && e.returnValue.constructor && e.returnValue.constructor.prototype && typeof e.returnValue.constructor.prototype.play == "function") {
e.stopOriginalMethodCall(); cancel();
BDFDB.TimeUtils.timeout(_ => { BDFDB.PatchUtils.patch(this, e.returnValue.constructor.prototype, ["play", "loop"], {instead: e2 => {
if (type == "message1") { let type = e2.instance && e2.instance.name;
let called = false; if (type && choices[type]) {
for (let subType of [type].concat(Object.keys(message1Types))) if (firedEvents[subType]) { let loop = e2.originalMethodName == "loop";
delete firedEvents[subType]; e2.stopOriginalMethodCall();
called = true; BDFDB.TimeUtils.timeout(_ => {
break; 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 e2.callOriginalMethodAfterwards();
} }});
else this.playAudio(type); 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();
else e.callOriginalMethodAfterwards(); }});
}}); }
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, ["createSound", "createSoundpackSound"], {after: e => { return;
let type = e.methodArguments[0]; let type = e.methodArguments[0];
if (type && choices[type]) { if (type && choices[type]) {
let audio = new WebAudioSound(type); let audio = new WebAudioSound(type);
createdAudios[type] = audio; createdAudios[type] = audio;
return audio; return audio;
} }
else BDFDB.LogUtils.warn(`Could not create Sound for "${type}".`, this); else BDFDB.LogUtils.warn(`Could not create Sound for "${type}".`, this);
}}); }}, {noCache: true});
BDFDB.LibraryModules.SoundUtils.createSound("call_calling");
}
this.loadAudios(); this.loadAudios();
this.loadChoices(); this.loadChoices();
@@ -661,7 +673,7 @@ module.exports = (_ => {
forceUpdateAll () { forceUpdateAll () {
volumes = BDFDB.DataUtils.get(this, "volumes"); volumes = BDFDB.DataUtils.get(this, "volumes");
if (BDFDB.LibraryStores.SoundpackStore) BDFDB.LibraryStores.SoundpackStore.emitChange();
BDFDB.PatchUtils.forceAllUpdates(this); BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.DiscordUtils.rerenderAll(); 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 (this.dontPlayAudio(type) || BDFDB.LibraryStores.StreamerModeStore.disableSounds) return;
if (createdAudios[type]) createdAudios[type].stop(); if (createdAudios[type]) createdAudios[type].stop();
createdAudios[type] = new WebAudioSound(type); createdAudios[type] = new WebAudioSound(type);
createdAudios[type].play(); createdAudios[type][loop ? "loop" : "play"]();
} }
isSuppressMentionsEnabled (guildId, channelId) { isSuppressMentionsEnabled (guildId, channelId) {

View File

@@ -15,7 +15,6 @@
"851263280551165977", "851263280551165977",
"709081938622939166", "709081938622939166",
"736308155964850176", "736308155964850176",
"662733504534020118",
"740325591684874305", "740325591684874305",
"815678838809296926" "815678838809296926"
], ],

View File

@@ -1,6 +1,6 @@
{ {
"all": { "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": { "filters": {
"updated": true, "updated": true,
"outdated": true, "outdated": true,

View File

@@ -2,7 +2,7 @@
* @name PluginRepo * @name PluginRepo
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 2.4.0 * @version 2.4.5
* @description Allows you to download all Plugins from BD's Website within Discord * @description Allows you to download all Plugins from BD's Website within Discord
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@@ -72,12 +72,12 @@ module.exports = (_ => {
}; };
const buttonData = { const buttonData = {
INSTALLED: { INSTALLED: {
backgroundColor: "var(--bdfdb-green)", backgroundColor: "var(--status-positive)",
icon: "CHECKMARK", icon: "CHECKMARK",
text: "installed" text: "installed"
}, },
OUTDATED: { OUTDATED: {
backgroundColor: "var(--bdfdb-red)", backgroundColor: "var(--status-danger)",
icon: "CLOSE", icon: "CLOSE",
text: "outdated" text: "outdated"
}, },
@@ -122,6 +122,7 @@ module.exports = (_ => {
} }
filterPlugins() { filterPlugins() {
let plugins = grabbedPlugins.map(plugin => { let plugins = grabbedPlugins.map(plugin => {
if (plugin.failed) return;
const installedPlugin = _this.getInstalledPlugin(plugin); const installedPlugin = _this.getInstalledPlugin(plugin);
const state = installedPlugin ? (plugin.version && _this.compareVersions(plugin.version, _this.getString(installedPlugin.version)) ? pluginStates.OUTDATED : pluginStates.INSTALLED) : pluginStates.DOWNLOADABLE; const state = installedPlugin ? (plugin.version && _this.compareVersions(plugin.version, _this.getString(installedPlugin.version)) ? pluginStates.OUTDATED : pluginStates.INSTALLED) : pluginStates.DOWNLOADABLE;
return Object.assign(plugin, { return Object.assign(plugin, {
@@ -131,7 +132,7 @@ module.exports = (_ => {
new: state == pluginStates.DOWNLOADABLE && !cachedPlugins.includes(plugin.id) && 1, new: state == pluginStates.DOWNLOADABLE && !cachedPlugins.includes(plugin.id) && 1,
state: state state: state
}); });
}); }).filter(n => n);
if (!this.props.updated) plugins = plugins.filter(plugin => plugin.state != pluginStates.INSTALLED); 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.outdated) plugins = plugins.filter(plugin => plugin.state != pluginStates.OUTDATED);
if (!this.props.downloadable) plugins = plugins.filter(plugin => plugin.state != pluginStates.DOWNLOADABLE); if (!this.props.downloadable) plugins = plugins.filter(plugin => plugin.state != pluginStates.DOWNLOADABLE);
@@ -165,7 +166,7 @@ module.exports = (_ => {
grow: 1, grow: 1,
shrink: 0, shrink: 0,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, { 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, className: BDFDB.disCN.marginreset,
children: `Plugin Repo — ${loading.is ? 0 : entries.length || 0}/${loading.is ? 0 : grabbedPlugins.length}` children: `Plugin Repo — ${loading.is ? 0 : entries.length || 0}/${loading.is ? 0 : grabbedPlugins.length}`
}) })
@@ -483,30 +484,28 @@ module.exports = (_ => {
this.props.downloading = true; 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 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"; let autoloadKey = this.props.data.state == pluginStates.OUTDATED ? "startUpdated" : "startDownloaded";
BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => { BDFDB.DiscordUtils.requestFileData(this.props.data.rawSourceUrl, {timeout: 10000}, (error, buffer) => {
if (error) { if (error || !buffer) {
delete this.props.downloading; delete this.props.downloading;
loadingToast.close(); loadingToast.close();
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Plugin "${this.props.data.name}"`), {type: "danger"}); BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
} }
else { else BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), Buffer.from(buffer).toString(), error2 => {
BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), body, error2 => { delete this.props.downloading;
delete this.props.downloading; loadingToast.close();
loadingToast.close(); if (error2) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
if (error2) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Plugin "${this.props.data.name}"`), {type: "danger"}); else {
else { BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Plugin "${this.props.data.name}"`), {type: "success"});
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.settings.general[autoloadKey]) BDFDB.TimeUtils.timeout(_ => { if (this.props.data.state == pluginStates.INSTALLED && BDFDB.BDUtils.isPluginEnabled(this.props.data.name) == false) {
if (this.props.data.state == pluginStates.INSTALLED && BDFDB.BDUtils.isPluginEnabled(this.props.data.name) == false) { BDFDB.BDUtils.enablePlugin(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);
BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", this.props.data.name), _this); }
} }, 3000);
}, 3000); this.props.data.state = pluginStates.INSTALLED;
this.props.data.state = pluginStates.INSTALLED; BDFDB.ReactUtils.forceUpdate(this);
BDFDB.ReactUtils.forceUpdate(this); }
} });
});
}
}); });
}, },
onDelete: _ => { onDelete: _ => {
@@ -579,10 +578,10 @@ module.exports = (_ => {
this.defaults = { this.defaults = {
general: { general: {
notifyOutdated: {value: true, autoload: false, description: "Get a Notification when one of your Plugins is outdated"}, notifyOutdated: {value: true, autoload: false, description: "Shows 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"}, notifyNewEntries: {value: true, autoload: false, description: "Shows a Notification when there are new Entries in the Repo"},
startDownloaded: {value: false, autoload: true, description: "Start new Plugins after Download"}, startDownloaded: {value: false, autoload: true, description: "Starts new Plugins after Download"},
startUpdated: {value: false, autoload: true, description: "Start updated Plugins after Download"} startUpdated: {value: false, autoload: true, description: "Starts updated Plugins after Download"}
}, },
filters: { filters: {
updated: {value: true, description: "Updated"}, updated: {value: true, description: "Updated"},
@@ -678,7 +677,7 @@ module.exports = (_ => {
} }
processStandardSidebarView (e) { 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 () { loadPlugins () {
@@ -755,19 +754,23 @@ module.exports = (_ => {
delete plugin.release_date; delete plugin.release_date;
delete plugin.latest_source_url; delete plugin.latest_source_url;
delete plugin.thumbnail_url; delete plugin.thumbnail_url;
BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => { BDFDB.DiscordUtils.requestFileData(plugin.rawSourceUrl, {timeout: 10000}, (error, buffer) => {
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) { if (error || !buffer) plugin.failed = true;
const META = body.split("*/")[0]; else {
plugin.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.name || ""); let body = Buffer.from(buffer).toString();
plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author; if (body && body.indexOf("404: Not Found") != 0) {
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1]; const META = body.split("*/")[0];
if (version) { plugin.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.name || "");
plugin.version = version; plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author;
const installedPlugin = this.getInstalledPlugin(plugin); const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1];
if (installedPlugin && this.compareVersions(version, this.getString(installedPlugin.version))) outdatedEntries++; 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; plugin.loaded = true;

View File

@@ -1,6 +1,6 @@
{ {
"currentVersionInfo": { "currentVersionInfo": {
"version": "2.0.9", "version": "2.0.11",
"hasShownChangelog": true "hasShownChangelog": true
} }
} }

View File

@@ -14,14 +14,14 @@
# Any items in the `env` entry below will be added as # Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables # environment variables. Some entries may override variables
# set by alacritty itself. # set by alacritty itself.
#env: env:
# TERM variable # TERM variable
# #
# This value is used to set the `$TERM` environment variable for # This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will # each instance of Alacritty. If it is not present, alacritty will
# check the local terminfo database and use `alacritty` if it is # check the local terminfo database and use `alacritty` if it is
# available, otherwise `xterm-256color` is used. # available, otherwise `xterm-256color` is used.
#TERM: alacritty TERM: xterm-256color
window: window:
# Window dimensions (changes require restart) # Window dimensions (changes require restart)

View File

@@ -3,3 +3,6 @@ export GTK_THEME=oomox-rice
#export QT_STYLE_OVERRIDE=gtk2 #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 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

7
.zshrc
View File

@@ -107,3 +107,10 @@ export wf='94:DB:56:1A:FB:7F'
export wh='94:DB:56:F7:8A:40' 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 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/"

View File

@@ -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)