stuff
This commit is contained in:
parent
81fe3314c1
commit
7232dc7092
|
@ -489,7 +489,7 @@ module.exports = (_ => {
|
||||||
let startMsg = BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", "v" + plugin.version);
|
let startMsg = BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", "v" + plugin.version);
|
||||||
BDFDB.LogUtils.log(startMsg, plugin.name);
|
BDFDB.LogUtils.log(startMsg, plugin.name);
|
||||||
if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${startMsg}`, {
|
if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${startMsg}`, {
|
||||||
noPointer: true
|
disableInteractions: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (plugin.css) BDFDB.DOMUtils.appendLocalStyle(plugin.name, plugin.css);
|
if (plugin.css) BDFDB.DOMUtils.appendLocalStyle(plugin.name, plugin.css);
|
||||||
|
@ -505,7 +505,7 @@ module.exports = (_ => {
|
||||||
let stopMsg = BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_stopped", "v" + plugin.version);
|
let stopMsg = BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_stopped", "v" + plugin.version);
|
||||||
BDFDB.LogUtils.log(stopMsg, plugin.name);
|
BDFDB.LogUtils.log(stopMsg, plugin.name);
|
||||||
if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${stopMsg}`, {
|
if (settings.showToasts && !BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.showToasts)) BDFDB.NotificationUtils.toast(`${plugin.name} ${stopMsg}`, {
|
||||||
noPointer: true
|
disableInteractions: true
|
||||||
});
|
});
|
||||||
|
|
||||||
let url = plugin.rawUrl ||`https://mwittrien.github.io/BetterDiscordAddons/Plugins/${plugin.name}/${plugin.name}.plugin.js`;
|
let url = plugin.rawUrl ||`https://mwittrien.github.io/BetterDiscordAddons/Plugins/${plugin.name}/${plugin.name}.plugin.js`;
|
||||||
|
@ -573,7 +573,7 @@ module.exports = (_ => {
|
||||||
if (pluginName == newName && BDFDB.NumberUtils.getVersionDifference(newVersion[0], window.PluginUpdates.plugins[url].version) > 0.2) {
|
if (pluginName == newName && BDFDB.NumberUtils.getVersionDifference(newVersion[0], window.PluginUpdates.plugins[url].version) > 0.2) {
|
||||||
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_force_updated", pluginName), {
|
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_force_updated", pluginName), {
|
||||||
type: "warning",
|
type: "warning",
|
||||||
noPointer: true
|
disableInteractions: true
|
||||||
});
|
});
|
||||||
BDFDB.PluginUtils.downloadUpdate(pluginName, url);
|
BDFDB.PluginUtils.downloadUpdate(pluginName, url);
|
||||||
return callback(2);
|
return callback(2);
|
||||||
|
@ -702,7 +702,7 @@ module.exports = (_ => {
|
||||||
if (updateNotice) BDFDB.PluginUtils.removeUpdateNotice(pluginName, updateNotice);
|
if (updateNotice) BDFDB.PluginUtils.removeUpdateNotice(pluginName, updateNotice);
|
||||||
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_update_failed", pluginName), {
|
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_update_failed", pluginName), {
|
||||||
type: "danger",
|
type: "danger",
|
||||||
noPointer: true
|
disableInteractions: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -723,7 +723,7 @@ module.exports = (_ => {
|
||||||
BDFDB.TimeUtils.timeout(_ => {if (wasEnabled && !BDFDB.BDUtils.isPluginEnabled(newName)) BDFDB.BDUtils.enablePlugin(newName);}, 3000);
|
BDFDB.TimeUtils.timeout(_ => {if (wasEnabled && !BDFDB.BDUtils.isPluginEnabled(newName)) BDFDB.BDUtils.enablePlugin(newName);}, 3000);
|
||||||
}
|
}
|
||||||
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_updated", pluginName, "v" + oldVersion, newName, "v" + newVersion), {
|
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_updated", pluginName, "v" + oldVersion, newName, "v" + newVersion), {
|
||||||
noPointer: true
|
disableInteractions: true
|
||||||
});
|
});
|
||||||
let updateNotice = document.querySelector("#pluginNotice");
|
let updateNotice = document.querySelector("#pluginNotice");
|
||||||
if (updateNotice) {
|
if (updateNotice) {
|
||||||
|
@ -1161,7 +1161,7 @@ module.exports = (_ => {
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (config.noPointer && typeof config.onClick != "function") toast.style.setProperty("pointer-events", "none", "important");
|
if (config.disableInteractions && typeof config.onClick != "function") toast.style.setProperty("pointer-events", "none", "important");
|
||||||
else toast.addEventListener("click", _ => {
|
else toast.addEventListener("click", _ => {
|
||||||
if (typeof config.onClick == "function") config.onClick();
|
if (typeof config.onClick == "function") config.onClick();
|
||||||
toast.close();
|
toast.close();
|
||||||
|
@ -1173,9 +1173,9 @@ module.exports = (_ => {
|
||||||
BDFDB.NotificationUtils.desktop = function (parsedContent, parsedOptions = {}) {
|
BDFDB.NotificationUtils.desktop = function (parsedContent, parsedOptions = {}) {
|
||||||
const queue = _ => {
|
const queue = _ => {
|
||||||
DesktopNotificationQueue.queue.push({parsedContent, parsedOptions});
|
DesktopNotificationQueue.queue.push({parsedContent, parsedOptions});
|
||||||
runqueue();
|
runQueue();
|
||||||
};
|
};
|
||||||
const runqueue = _ => {
|
const runQueue = _ => {
|
||||||
if (!DesktopNotificationQueue.running) {
|
if (!DesktopNotificationQueue.running) {
|
||||||
let notification = DesktopNotificationQueue.queue.shift();
|
let notification = DesktopNotificationQueue.queue.shift();
|
||||||
if (notification) notify(notification.parsedContent, notification.parsedOptions);
|
if (notification) notify(notification.parsedContent, notification.parsedOptions);
|
||||||
|
@ -1187,11 +1187,13 @@ module.exports = (_ => {
|
||||||
config.silent = config.silent || config.sound ? true : false;
|
config.silent = config.silent || config.sound ? true : false;
|
||||||
let notification = new Notification(content, config);
|
let notification = new Notification(content, config);
|
||||||
let audio = new Audio();
|
let audio = new Audio();
|
||||||
let timeout = BDFDB.TimeUtils.timeout(_ => {close();}, config.timeout ? config.timeout : 3000);
|
let closeTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||||
if (typeof config.click == "function") notification.onclick = _ => {
|
|
||||||
BDFDB.TimeUtils.clear(timeout);
|
|
||||||
close();
|
close();
|
||||||
config.click();
|
}, config.timeout ? config.timeout : 3000);
|
||||||
|
notification.onclick = _ => {
|
||||||
|
BDFDB.TimeUtils.clear(closeTimeout);
|
||||||
|
close();
|
||||||
|
if (typeof config.onClick == "function") config.onClick();
|
||||||
};
|
};
|
||||||
if (!muted && config.sound) {
|
if (!muted && config.sound) {
|
||||||
audio.src = config.sound;
|
audio.src = config.sound;
|
||||||
|
@ -1201,7 +1203,7 @@ module.exports = (_ => {
|
||||||
audio.pause();
|
audio.pause();
|
||||||
notification.close();
|
notification.close();
|
||||||
DesktopNotificationQueue.running = false;
|
DesktopNotificationQueue.running = false;
|
||||||
BDFDB.TimeUtils.timeout(_ => {runqueue();}, 1000);
|
BDFDB.TimeUtils.timeout(_ => {runQueue();}, 1000);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (!("Notification" in window)) {}
|
if (!("Notification" in window)) {}
|
||||||
|
|
|
@ -950,8 +950,6 @@
|
||||||
"icon": "icon-OZgBPQ",
|
"icon": "icon-OZgBPQ",
|
||||||
"info": "colorInfo-ujWH4-",
|
"info": "colorInfo-ujWH4-",
|
||||||
"inner": "inner-6Fsw34",
|
"inner": "inner-6Fsw34",
|
||||||
"left": "toLeft-q_-2S6",
|
|
||||||
"right": "toRight-9_8sT2",
|
|
||||||
"success": "colorSuccess-6GreWs",
|
"success": "colorSuccess-6GreWs",
|
||||||
"text": "text-28VADE",
|
"text": "text-28VADE",
|
||||||
"toast": "toast-g4bfgI bd-toast",
|
"toast": "toast-g4bfgI bd-toast",
|
||||||
|
@ -2704,8 +2702,6 @@
|
||||||
"toastinfo": ["Toast", "info"],
|
"toastinfo": ["Toast", "info"],
|
||||||
"toastinner": ["Toast", "inner"],
|
"toastinner": ["Toast", "inner"],
|
||||||
"toasts": ["Toast", "toasts"],
|
"toasts": ["Toast", "toasts"],
|
||||||
"toastsleft": ["Toast", "left"],
|
|
||||||
"toastsright": ["Toast", "right"],
|
|
||||||
"toastsuccess": ["Toast", "success"],
|
"toastsuccess": ["Toast", "success"],
|
||||||
"toasttext": ["Toast", "text"],
|
"toasttext": ["Toast", "text"],
|
||||||
"toastwarning": ["Toast", "warning"],
|
"toastwarning": ["Toast", "warning"],
|
||||||
|
|
|
@ -1092,6 +1092,12 @@ img:not([src]), img[src=""], img[src="null"] {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@keyframes toast-down {
|
||||||
|
to {
|
||||||
|
transform: translateY(0px);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
[REPLACE_CLASS_toast] {
|
[REPLACE_CLASS_toast] {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -1108,12 +1114,6 @@ img:not([src]), img[src=""], img[src="null"] {
|
||||||
animation: toast-up 300ms ease;
|
animation: toast-up 300ms ease;
|
||||||
transform: translateY(-10px);
|
transform: translateY(-10px);
|
||||||
}
|
}
|
||||||
@keyframes toast-down {
|
|
||||||
to {
|
|
||||||
transform: translateY(0px);
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[REPLACE_CLASS_toastclosing] {
|
[REPLACE_CLASS_toastclosing] {
|
||||||
animation: toast-down 200ms ease;
|
animation: toast-down 200ms ease;
|
||||||
animation-fill-mode: forwards;
|
animation-fill-mode: forwards;
|
||||||
|
|
|
@ -776,7 +776,13 @@ module.exports = (_ => {
|
||||||
let desktopString = string.replace(/\$user/g, `${name}${settings.showDiscriminator ? ("#" + user.discriminator) : ""}`).replace(/\$status/g, statusName);
|
let desktopString = string.replace(/\$user/g, `${name}${settings.showDiscriminator ? ("#" + user.discriminator) : ""}`).replace(/\$status/g, statusName);
|
||||||
if (status.activity) desktopString = desktopString.replace(/\$song|\$game/g, status.activity.name || status.activity.details || "").replace(/\$artist|\$custom/g, [status.activity.emoji && status.activity.emoji.name, status.activity.state].filter(n => n).join(" ") || "");
|
if (status.activity) desktopString = desktopString.replace(/\$song|\$game/g, status.activity.name || status.activity.details || "").replace(/\$artist|\$custom/g, [status.activity.emoji && status.activity.emoji.name, status.activity.state].filter(n => n).join(" ") || "");
|
||||||
let notificationSound = notificationSounds["desktop" + status.name] || {};
|
let notificationSound = notificationSounds["desktop" + status.name] || {};
|
||||||
BDFDB.NotificationUtils.desktop(desktopString, {icon: avatar, timeout: desktopTime, click: openChannel, silent: notificationSound.mute, sound: notificationSound.song});
|
BDFDB.NotificationUtils.desktop(desktopString, {
|
||||||
|
icon: avatar,
|
||||||
|
timeout: desktopTime,
|
||||||
|
silent: notificationSound.mute,
|
||||||
|
sound: notificationSound.song,
|
||||||
|
onClick: openChannel
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (!document.querySelector(`.friendnotifications-${id}-toast`)) {
|
else if (!document.querySelector(`.friendnotifications-${id}-toast`)) {
|
||||||
BDFDB.NotificationUtils.toast(toastString, {
|
BDFDB.NotificationUtils.toast(toastString, {
|
||||||
|
|
Loading…
Reference in New Issue