stuff
This commit is contained in:
parent
9764fa7099
commit
40d308ae1f
|
@ -1,169 +0,0 @@
|
||||||
/**
|
|
||||||
* @name ForceImagePreviews
|
|
||||||
* @author DevilBro
|
|
||||||
* @authorId 278543574059057154
|
|
||||||
* @version 1.2.0
|
|
||||||
* @description Forces unrendered embedded Image Previews to render. Caution: Externals Images can contain malicious code and reveal your IP!
|
|
||||||
* @invite Jx3TjNS
|
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
|
||||||
* @patreon https://www.patreon.com/MircoWittrien
|
|
||||||
* @website https://mwittrien.github.io/
|
|
||||||
* @source https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ForceImagePreviews/
|
|
||||||
* @updateUrl https://mwittrien.github.io/BetterDiscordAddons/Plugins/ForceImagePreviews/ForceImagePreviews.plugin.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = (_ => {
|
|
||||||
const changeLog = {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
|
||||||
constructor (meta) {for (let key in meta) this[key] = meta[key];}
|
|
||||||
getName () {return this.name;}
|
|
||||||
getAuthor () {return this.author;}
|
|
||||||
getVersion () {return this.version;}
|
|
||||||
getDescription () {return `The Library Plugin needed for ${this.name} is missing. Open the Plugin Settings to download it. \n\n${this.description}`;}
|
|
||||||
|
|
||||||
downloadLibrary () {
|
|
||||||
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
|
|
||||||
if (!e && b && r.statusCode == 200) require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => BdApi.showToast("Finished downloading BDFDB Library", {type: "success"}));
|
|
||||||
else BdApi.alert("Error", "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
load () {
|
|
||||||
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
|
|
||||||
if (!window.BDFDB_Global.downloadModal) {
|
|
||||||
window.BDFDB_Global.downloadModal = true;
|
|
||||||
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${this.name} is missing. Please click "Download Now" to install it.`, {
|
|
||||||
confirmText: "Download Now",
|
|
||||||
cancelText: "Cancel",
|
|
||||||
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
|
|
||||||
onConfirm: _ => {
|
|
||||||
delete window.BDFDB_Global.downloadModal;
|
|
||||||
this.downloadLibrary();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!window.BDFDB_Global.pluginQueue.includes(this.name)) window.BDFDB_Global.pluginQueue.push(this.name);
|
|
||||||
}
|
|
||||||
start () {this.load();}
|
|
||||||
stop () {}
|
|
||||||
getSettingsPanel () {
|
|
||||||
let template = document.createElement("template");
|
|
||||||
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${this.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
|
|
||||||
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
|
|
||||||
return template.content.firstElementChild;
|
|
||||||
}
|
|
||||||
} : (([Plugin, BDFDB]) => {
|
|
||||||
var loadedEmbeds, requestedEmbeds;
|
|
||||||
|
|
||||||
return class ForceImagePreviews extends Plugin {
|
|
||||||
onLoad () {
|
|
||||||
loadedEmbeds = {};
|
|
||||||
requestedEmbeds = [];
|
|
||||||
|
|
||||||
this.patchedModules = {
|
|
||||||
before: {
|
|
||||||
MessageAccessories: "default"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
onStart () {
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
|
||||||
BDFDB.MessageUtils.rerenderAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
onStop () {
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
|
||||||
BDFDB.MessageUtils.rerenderAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
processMessageAccessories (e) {
|
|
||||||
if (e.instance.props.message && e.instance.props.message.content) {
|
|
||||||
let message = new BDFDB.DiscordObjects.Message(e.instance.props.message);
|
|
||||||
for (let link of e.instance.props.message.content.split(/\n|\s|\r|\t|\0/g)) if (link.indexOf("https://") > -1 || link.indexOf("http://") > -1) {
|
|
||||||
link = link.indexOf("<") == 0 && link.indexOf(">") == link.length - 1 ? link.slice(1, -1) : link;
|
|
||||||
if (!this.isEmbedded(message.embeds, link)) {
|
|
||||||
if (!requestedEmbeds.includes(link)) {
|
|
||||||
requestedEmbeds.push(link);
|
|
||||||
BDFDB.LibraryRequires.request(link, (error, response, result) => {
|
|
||||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") > -1) {
|
|
||||||
let imageThrowaway = document.createElement("img");
|
|
||||||
imageThrowaway.src = link;
|
|
||||||
imageThrowaway.onload = _ => {
|
|
||||||
if (!this.isEmbedded(message.embeds, link)) {
|
|
||||||
loadedEmbeds[link] = {
|
|
||||||
image: {
|
|
||||||
url: link,
|
|
||||||
proxyURL: link,
|
|
||||||
height: imageThrowaway.naturalHeight,
|
|
||||||
width: imageThrowaway.naturalWidth
|
|
||||||
},
|
|
||||||
type: "image",
|
|
||||||
url: link
|
|
||||||
};
|
|
||||||
message.embeds.push(loadedEmbeds[link]);
|
|
||||||
BDFDB.ReactUtils.forceUpdate(e.instance);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (response && response.headers["server"] && response.headers["server"].toLowerCase().indexOf("youtube") > -1 && result.indexOf("yt-user-info") > -1) {
|
|
||||||
if (!this.isEmbedded(message.embeds, link)) {
|
|
||||||
result = result.replace(/[\r|\n|\t]|[\s]{2,}/g, "");
|
|
||||||
let width = result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta itemprop="width" content="'), "i"))[1].split('"')[0];
|
|
||||||
let height = result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta itemprop="height" content="'), "i"))[1].split('"')[0];
|
|
||||||
let thumbnail = result.split(new RegExp(BDFDB.StringUtils.regEscape('<link itemprop="thumbnailUrl" href="'), "i"))[1].split('"')[0];
|
|
||||||
loadedEmbeds[link] = {
|
|
||||||
author: {
|
|
||||||
name: result.split(new RegExp(BDFDB.StringUtils.regEscape('<div class="yt-user-info"><a href="'), "i"))[1].split('>')[1].split('<')[0],
|
|
||||||
url: `https://www.youtube.com${result.split(new RegExp(BDFDB.StringUtils.regEscape('<div class="yt-user-info"><a href="'), "i"))[1].split('"')[0]}`
|
|
||||||
},
|
|
||||||
color: "#ff0000",
|
|
||||||
provider: {
|
|
||||||
name: "YouTube",
|
|
||||||
url: "https://www.youtube.com/"
|
|
||||||
},
|
|
||||||
rawDescription: result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta property="og: description" content="'), "i"))[1].split('"')[0],
|
|
||||||
rawTitle: result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta property="og: title" content="'), "i"))[1].split('"')[0],
|
|
||||||
thumbnail: {
|
|
||||||
url: thumbnail,
|
|
||||||
proxyURL: thumbnail,
|
|
||||||
width: width,
|
|
||||||
height: height
|
|
||||||
},
|
|
||||||
type: "video",
|
|
||||||
url: link,
|
|
||||||
video: {
|
|
||||||
url: result.split(new RegExp(BDFDB.StringUtils.regEscape('<link itemprop="embedUrl" href="'), "i"))[1].split('"')[0],
|
|
||||||
width: width,
|
|
||||||
height: height
|
|
||||||
}
|
|
||||||
};
|
|
||||||
message.embeds.push(loadedEmbeds[link]);
|
|
||||||
BDFDB.ReactUtils.forceUpdate(e.instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (loadedEmbeds[link]) message.embeds.push(loadedEmbeds[link]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e.instance.props.message = message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isEmbedded (embeds, link) {
|
|
||||||
if (link.indexOf("youtube.") > -1 || link.indexOf("youtu.be") > -1) {
|
|
||||||
let videoId = (link.split("watch?v=")[1] || link.split("?")[0].split("/").pop() || "").split("&").shift();
|
|
||||||
if (videoId) for (let embed of embeds) if (embed.url == link || embed.video && embed.url.indexOf(videoId) > -1) return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (let embed of embeds) if (embed.url == link || embed.image && embed.image.url == link) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
|
||||||
})();
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Force Image Previews [![Download][download-badge]][download-link] [![Support][support-badge]][support-link] [![PayPal][paypal-badge]][paypal-link] [![Patreon][patreon-badge]][patreon-link]
|
|
||||||
|
|
||||||
[download-badge]: https://img.shields.io/badge/Download-%233a71c1.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAgCAYAAAAIXrg4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAd5gAAHeYBMKt3fAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE9SURBVEiJ7ZQ7TsNAFEWv06IAShOkEDD5UNCwB8RCWEYWAqkIYiEgZQERoqLgFz4hUIaC+tCM4cmyk4mxCyRfaSRL8+49781YI3kKOASmwBtw4OvzFnDJry58fZUlGGvme70IQCaVgBLwXwBADegDp0AjaxjQAAbACVCzG+fmGRgDYYJ5ZGpGCfuh80Ya/EwgqWpqQ0lDoLVE5y1JQ+eNVLUFXfdSWr0A7UUTAG1XazUFuvEudoFJrPAd2EsDuMZeY56PyJM0aqohDljU0Lzz7KSMbMMmJB9px/fStoFH/PWMuS9fyBbw4Bnu/cclQe7nhD8BO5nCDaQJ3CWEj/8cbiAbwI0JvwU2cwk3kDpw7FY91/BShSoAmpKOJK3knP0l6SwAriXt5xwe6SoAPiWtFgSYVST1JM2KCJfU+wadgFl0/0HGbQAAAABJRU5ErkJggg==
|
|
||||||
[download-link]: https://mwittrien.github.io/downloader/?plugin=ForceImagePreviews
|
|
||||||
|
|
||||||
[support-badge]: https://img.shields.io/badge/Support-%2343b581.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAC4UlEQVRYR8WXS4jNcRTHP195bEgWkoVsCAspNcVoLGblsaAoFCalBqU8BhuPPDZeQ5LBRmHBYsok7KYor5TyKDI2UiQLZWwojs6d351+85977+93J7q/uqt7Hp/fOed3zvmLzGNm44BWYAUwB5gafm7hc/i9AXqAXkk/c0wrJWRmU4BDwHpgQko+/N8PXAcOS/pSS6cqgJmNBfYBe4HxmY6LYj+AE8BxSb8q2agIEG7dDSwaoeOi2kNgVaVoDAMws7nAHWDaP3JeNvMRWC7pVWx3CEC4+bMM533AE+B5MDYfWADMTEA7RFMciUGAkPPeRNi9svcDnZL+xM7MbBSwCzgG+IupdjwdreWaiAEOAEdqKLrzZknlW1cUNTOPxqMExEFJR91ACSCE/n2i2vdIOpVTF2bWAZysIeuvY4anogxwAdhaQ8FzPjsOu5lNAjYFnSuSvpX1QzreJmqiS9I2hQ73NdFkrknaGDlw5x8iHW880wsQV4ENNS7lOpMdYClwNxHanZLORgBebKcLOrsldUYyO4AzCbvLHOAi0J4QbJd0OTJ+D1iSANgOnEvYveQA94HFCcHvgDv1M7GC80op6AK2JOw+cIB3GQ2kmh1/Oe6oWISjgdfArARAnwM4fb3D5jew0lu2JCs6MbOc8Lvaj5EC9EhygGHHzFqA2yFVqbZRAhhJCtok+TMbPGY2BmgDzie6YKxWSkFOERZvsk7SjehVbA4zwJeXek6pCHOeYdHoWkk3IwCHWVOP5yBbeoY5jahoO6cv5PCUGpGPzlQrLhpL9YUc5wOt2CXNLDWMKhn0ifYSWFieqjleI5mBYRQAvHhS4zi2/wJokdRvZk3A0zohho7jAJFaSGKADkmDw8jMfMtpriMCQxeSAOBreGolK/volrQ66Pm3wqc6umnllSxKRc5S6q34FvA4zPx5mbevvpRGb7pxa3kE4UXZmA+TCKJxn2ZxPhv2cVosqv/1ef4XvUY7+DQzteEAAAAASUVORK5CYII=
|
|
||||||
[support-link]: https://discord.com/invite/Jx3TjNS
|
|
||||||
|
|
||||||
[paypal-badge]: https://img.shields.io/badge/PayPal-%23003087.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAgCAYAAAABtRhCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAdhwAAHYcBj+XxZQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIZSURBVEiJvZa7a1RREIe/CRsIqBBQJEEUO5+YRgSx0JTBwkKwsBMU/4HY2dmKFmm1tRBREEGFYGMhvgolPlBsRBuJj5iIiRvzWWxuOF7v3r2Ld/ODhXNmhvnOzHnshZzU82rTamqqn9XX6jV1XB3K52wrtaHOV4S104J6Ue2vAtz2n7BUt9S+PCNv2FG5HZ11GDi1mkCA052AO2sG7s63tdcV9gON1BDZQA1gFlhTI3AmIgZTQ1rhlpphAFN5Qwqse/8A7uYNaX/r3j+Am9lAHQbmegmcjIhnyfwosLFXwEXgbM52BBhemdl6hOvSeEpSR9QldTYzDNUE+q2eyZer3lj2rwBHa4A9UA8UwE4kMS+yPexm/xZpPRDTwBvgCXA9Ip4XwEaBicT0MHNMlKz8ijrQxYKynMfVn7lcxzLnZAnwYJegEfV2QZ6P6kDW0rJX5lUHwAZgD7CP1l3b2yb0XETMow6WVDedS35Bfbf8+2LrqFfRVVt/DqDuLwm8nwM+qghIdcnk+6aP8hO60s7lFW4va2+iReAOcCgiTkZEM3M0OgBfJuNNwLqCmHvAY+AbMAO8BZ5GxNeihA2qH5iiuO/AWET8Ksnxl/o6ANMKizox1Q0sA65t45sDPiTzov0rvTJFagC7gM0FvoWIMJkXVdg1sLLUTwVHfqxXsPVt7tjWbnP98+3fRkXt/AG8Xy3gEnA5Ipa6Bf4BbzmPtw84RMAAAAAASUVORK5CYII=
|
|
||||||
[paypal-link]: https://paypal.me/MircoWittrien
|
|
||||||
|
|
||||||
[patreon-badge]: https://img.shields.io/badge/Patreon-%23F96854.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAdhwAAHYcBj+XxZQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAGBSURBVFiF7Za9ThtBFEbPBUpERWMwCorfJjY4aVLxBFHCKyCl4hWQUqVMBULmbfiRCNACqSJsDsXakjHGO8Y7ovFXrmbmO3NnZ74bqrzUeUR8HPP9mdQ60AZawCZQBwK4BC6ADnAUEZeTFhmnsxLjdfVAfXhl/rB66h/1QyUAalu9TzAe1Z26NROAutvf0VvVU7+/CUD9PKP5MMT2VADqhvqvAvOB7tQ1gIXXznpEP4HlxLEpWgH2AEInX0OLv/cUWKwQAKALbKZU4EsGc4AloJ0C8CmD+UDNFIBGRoBGCkAtI8B66i3IpccUgJuMANcpAKcZAc5SAE4yAnRSAA6BXgbzLnBUChARF8DvDAC/IuIqNYzqFYfRrVqDxDCKiL/AV6o5ikdgJyJuBrsrrcBQJX44W0/QVb+NLpoM0B/f6pdwWt2qL3NlWoD+nFV1X/2fYPxg0cCOfdJL+4ESkBqwDTQpQmuNoi2/onjAOsBxRFxPWmTqClSp9w6jOcAcYA7AE1OMk5ulhBZCAAAAAElFTkSuQmCC
|
|
||||||
[patreon-link]: https://patreon.com/MircoWittrien
|
|
||||||
|
|
||||||
Forces unrendered embedded Image Previews to render
|
|
||||||
|
|
||||||
|
|
||||||
![cover](https://mwittrien.github.io/BetterDiscordAddons/Plugins/ForceImagePreviews/_res/cover.png)
|
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
|
@ -25,7 +25,6 @@
|
||||||
- [Edit Servers](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditServers) - Allows you to locally edit Servers
|
- [Edit Servers](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditServers) - Allows you to locally edit Servers
|
||||||
- [Edit Users](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditUsers) - Allows you to locally edit Users
|
- [Edit Users](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditUsers) - Allows you to locally edit Users
|
||||||
- [Emoji Statistics](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EmojiStatistics) - Shows you an Overview of Emojis and Emoji Servers
|
- [Emoji Statistics](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EmojiStatistics) - Shows you an Overview of Emojis and Emoji Servers
|
||||||
- [Force Image Previews](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ForceImagePreviews) - Forces unrendered embedded Image Previews to render
|
|
||||||
- [Friend Notifications](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/FriendNotifications) - Shows a Notification when a Friend or a User, you choose to observe, changes their Status
|
- [Friend Notifications](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/FriendNotifications) - Shows a Notification when a Friend or a User, you choose to observe, changes their Status
|
||||||
- [Game Activity Toggle](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/GameActivityToggle) - Adds a Quick-Toggle Game Activity Button
|
- [Game Activity Toggle](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/GameActivityToggle) - Adds a Quick-Toggle Game Activity Button
|
||||||
- [Google Search Replace](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/GoogleSearchReplace) - Replaces the default Google Text Search with a custom Search Engine
|
- [Google Search Replace](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/GoogleSearchReplace) - Replaces the default Google Text Search with a custom Search Engine
|
||||||
|
|
|
@ -58,8 +58,6 @@ module.exports = (_ => {
|
||||||
BDFDB.ReactUtils.createElement("span", {children: "DISCORD ADDED THIS FEATURE BY THEMSELVES, MAKING THIS PLUGIN USELESS "}),
|
BDFDB.ReactUtils.createElement("span", {children: "DISCORD ADDED THIS FEATURE BY THEMSELVES, MAKING THIS PLUGIN USELESS "}),
|
||||||
BDFDB.ReactUtils.createElement("strong", {children: "DELETE"}),
|
BDFDB.ReactUtils.createElement("strong", {children: "DELETE"}),
|
||||||
BDFDB.ReactUtils.createElement("span", {children: " TO REMOVE THIS EMPTY PLUGIN FILE."})
|
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: [
|
buttons: [
|
||||||
{contents: "DELETE", close: true, color: "RED", onClick: _ => {
|
{contents: "DELETE", close: true, color: "RED", onClick: _ => {
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* @name ForceImagePreviews
|
||||||
|
* @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 ForceImagePreviews extends Plugin {
|
||||||
|
onLoad () {}
|
||||||
|
|
||||||
|
onStart () {
|
||||||
|
BDFDB.ModalUtils.open(this, {
|
||||||
|
header: "PLUGIN WAS DISCONTINUED",
|
||||||
|
children: [
|
||||||
|
BDFDB.ReactUtils.createElement("span", {children: "THIS PLUGIN ALWAYS HAD A SLIGHT SECURITY RISK, SINCE IT LOADED IMAGES FROM EXTERNAL WEBSITES, DUE TO THE NEW PLUGIN GUIDELINES AND MY OWN OPINION ON NOT FURTHER RISKING OTHER USERS, I DECIDED TO DISCONTINUE THIS PLUGIN "}),
|
||||||
|
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(), "ForceImagePreviews.plugin.js"), error => {});
|
||||||
|
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), "ForceImagePreviews.config.json"), error => {});
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop () {}
|
||||||
|
};
|
||||||
|
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
||||||
|
})();
|
Loading…
Reference in New Issue