@@ -498,6 +502,41 @@ Core.prototype.showStartupErrors = function() {
modal.find('.tab-bar-item')[0].click();
};
+/**
+ * This shows a toast similar to android towards the bottom of the screen.
+ *
+ * @param {string} content The string to show in the toast.
+ * @param {object} options Options object. Optional parameter.
+ * @param {string} options.type Changes the type of the toast stylistically and semantically. Choices: "", "info", "success", "danger"/"error", "warning"/"warn". Default: ""
+ * @param {boolean} options.icon Determines whether the icon should show corresponding to the type. A toast without type will always have no icon. Default: true
+ * @param {number} options.timeout Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: 3000
+ */
+Core.prototype.showToast = function(content, options = {}) {
+ if (!document.querySelector('.bd-toasts')) {
+ let toastWrapper = document.createElement("div");
+ toastWrapper.classList.add("bd-toasts");
+ let boundingElement = document.querySelector('.chat form, #friends, .noChannel-2EQ0a9, .activityFeed-HeiGwL');
+ toastWrapper.style.setProperty("left", boundingElement ? boundingElement.getBoundingClientRect().left + "px" : "0px");
+ toastWrapper.style.setProperty("width", boundingElement ? boundingElement.offsetWidth + "px" : "100%");
+ toastWrapper.style.setProperty("bottom", (document.querySelector('.chat form') ? document.querySelector('.chat form').offsetHeight : 80) + "px");
+ document.querySelector('.app').appendChild(toastWrapper);
+ }
+ const {type = "", icon = true, timeout = 3000} = options;
+ let toastElem = document.createElement("div");
+ toastElem.classList.add("bd-toast");
+ if (type) toastElem.classList.add("toast-" + type);
+ if (type && icon) toastElem.classList.add("icon");
+ toastElem.innerText = content;
+ document.querySelector('.bd-toasts').appendChild(toastElem);
+ setTimeout(() => {
+ toastElem.classList.add('closing');
+ setTimeout(() => {
+ toastElem.remove();
+ if (!document.querySelectorAll('.bd-toasts .bd-toast').length) document.querySelector('.bd-toasts').remove();
+ }, 300);
+ }, timeout);
+};
+
/* BetterDiscordApp EmoteModule JavaScript
* Version: 1.5
@@ -822,7 +861,7 @@ QuickEmoteMenu.prototype.init = function() {
QuickEmoteMenu.prototype.favContext = function(e, em) {
e.stopPropagation();
- var menu = $('
', { id: "rmenu", "data-emoteid": $(em).prop("title"), text: "Remove" });
+ var menu = $('
', { id: "rmenu", "data-emoteid": $(em).prop("title"), text: "Remove", class: "context-menu theme-dark" });
menu.css({
top: e.pageY - $("#bda-qem-favourite-container").offset().top,
left: e.pageX - $("#bda-qem-favourite-container").offset().left
@@ -868,6 +907,7 @@ QuickEmoteMenu.prototype.switchQem = function(id) {
case "bda-qem-emojis":
emojis.addClass("active");
$(".emoji-picker").show();
+ $(".emoji-picker .search-bar-inner input").focus();
break;
}
this.lastTab = id;
@@ -920,7 +960,7 @@ QuickEmoteMenu.prototype.updateFavorites = function () {
for (var emote in this.favoriteEmotes) {
var url = this.favoriteEmotes[emote];
faContainer += "
";
- faContainer += "
![\"" \"\"](\"")
";
+ faContainer += "
![\"" \"\"](\"")
";
faContainer += " ";
faContainer += "
";
}
@@ -1105,7 +1145,10 @@ PluginModule.prototype.loadPlugins = function () {
};
PluginModule.prototype.startPlugin = function (plugin) {
- try { bdplugins[plugin].plugin.start(); }
+ try {
+ bdplugins[plugin].plugin.start();
+ mainCore.showToast(`${bdplugins[plugin].plugin.getName()} v${bdplugins[plugin].plugin.getVersion()} has started.`);
+ }
catch (err) {
pluginCookie[plugin] = false;
this.savePluginData();
@@ -1114,8 +1157,13 @@ PluginModule.prototype.startPlugin = function (plugin) {
};
PluginModule.prototype.stopPlugin = function (plugin) {
- try { bdplugins[plugin].plugin.stop(); }
- catch (err) { utils.err("Plugin " + name + " could not be stopped.", err); }
+ try {
+ bdplugins[plugin].plugin.stop();
+ mainCore.showToast(`${bdplugins[plugin].plugin.getName()} v${bdplugins[plugin].plugin.getVersion()} has stopped.`);
+ }
+ catch (err) {
+ utils.err("Plugin " + name + " could not be stopped.", err);
+ }
};
PluginModule.prototype.enablePlugin = function (plugin) {
@@ -1304,39 +1352,9 @@ BdApi.alert = function (title, content) {
mainCore.alert(title, content);
};
-/**
- * This shows a toast similar to android towards the bottom of the screen.
- *
- * @param {string} content The string to show in the toast.
- * @param {object} options Options object. Optional parameter.
- * @param {string} options.type Changes the type of the toast stylistically and semantically. Choices: "", "info", "success", "danger"/"error", "warning"/"warn". Default: ""
- * @param {boolean} options.icon Determines whether the icon should show corresponding to the type. A toast without type will always have no icon. Default: true
- * @param {number} options.timeout Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: 3000
- */
+//Show toast alert
BdApi.showToast = function(content, options = {}) {
- if (!document.querySelector('.bd-toasts')) {
- let toastWrapper = document.createElement("div");
- toastWrapper.classList.add("bd-toasts");
- let boundingElement = document.querySelector('.chat form, #friends, .noChannel-2EQ0a9, .activityFeed-HeiGwL');
- toastWrapper.style.setProperty("left", boundingElement ? boundingElement.getBoundingClientRect().left + "px" : "0px");
- toastWrapper.style.setProperty("width", boundingElement ? boundingElement.offsetWidth + "px" : "100%");
- toastWrapper.style.setProperty("bottom", (document.querySelector('.chat form') ? document.querySelector('.chat form').offsetHeight : 80) + "px");
- document.querySelector('.app').appendChild(toastWrapper);
- }
- const {type = "", icon = true, timeout = 3000} = options;
- let toastElem = document.createElement("div");
- toastElem.classList.add("bd-toast");
- if (type) toastElem.classList.add("toast-" + type);
- if (type && icon) toastElem.classList.add("icon");
- toastElem.innerText = content;
- document.querySelector('.bd-toasts').appendChild(toastElem);
- setTimeout(() => {
- toastElem.classList.add('closing');
- setTimeout(() => {
- toastElem.remove();
- if (!document.querySelectorAll('.bd-toasts .bd-toast').length) document.querySelector('.bd-toasts').remove();
- }, 300);
- }, timeout);
+ mainCore.showToast(content, options);
};
/* BetterDiscordApp DevMode JavaScript