`;
+ let settings = BDFDB.getAllData(this, "settings");
+ let choices = BDFDB.getAllData(this, "choices");
+ let formats = BDFDB.getAllData(this, "formats");
+ let settingshtml = `
${this.getName()}
`;
for (let key in settings) {
- settingshtml += `
`;
+ settingshtml += `
`;
}
for (let key in choices) {
settingshtml += `
${this.defaults.choices[key].description}
${this.languages[choices[key]].name}
${this.getTimestamp(this.languages[choices[key]].id)}
`;
@@ -49,21 +52,20 @@ class CompleteTimestamps {
for (let key in formats) {
settingshtml += `
`;
}
- var infoHidden = BDFDB.loadData("hideInfo", this, "hideInfo");
+ let infoHidden = BDFDB.loadData("hideInfo", this, "hideInfo");
settingshtml += `
`;
settingshtml += `
`;
settingshtml += `
$hour will be replaced with the current hour
$minute will be replaced with the current minutes
$second will be replaced with the current seconds
$msecond will be replaced with the current milliseconds
$timemode will change $hour to a 12h format and will be replaced with AM/PM
$year will be replaced with the current year
$month will be replaced with the current month
$day will be replaced with the current day
$monthnameL will be replaced with the monthname in long format based on the Discord Language
$monthnameS will be replaced with the monthname in short format based on the Discord Language
$weekdayL will be replaced with the weekday in long format based on the Discord Language
$weekdayS will be replaced with the weekday in short format based on the Discord Language
`;
settingshtml += `
`;
- var settingspanel = $(settingshtml)[0];
+ let settingspanel = BDFDB.htmlToElement(settingshtml);
- BDFDB.initElements(settingspanel);
+ BDFDB.initElements(settingspanel, this);
- $(settingspanel)
- .on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);})
- .on("keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);})
- .on("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu(e);})
- .on("click", ".toggle-info", (e) => {this.toggleInfo(settingspanel, e.currentTarget);});
+ BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {this.updateSettingsPanel(settingspanel);});
+ BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
+ BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(e);});
+ BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
return settingspanel;
}
@@ -72,94 +74,55 @@ class CompleteTimestamps {
load () {}
start () {
- var libraryScript = null;
- if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
- libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
+ libraryScript.setAttribute("date", performance.now());
+ libraryScript.addEventListener("load", () => {
+ BDFDB.loaded = true;
+ this.initialize();
+ });
document.head.appendChild(libraryScript);
}
+ else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
- if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
- else libraryScript.addEventListener("load", () => {this.initialize();});
}
initialize () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
- var observer = null;
-
- observer = new MutationObserver((changes, _) => {
- changes.forEach(
- (change, i) => {
- if (change.addedNodes) {
- change.addedNodes.forEach((node) => {
- if (node.tagName && node.querySelector("time")) {
- node.querySelectorAll("time").forEach(stamp => {this.changeTimestamp(stamp);});
- }
- else if (node.tagName && node.tagName == "TIME") {
- this.changeTimestamp(node);
- }
- });
- }
- }
- );
+ this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}},BDFDB.languages);
+
+ BDFDB.addEventListener(this, document, "mouseenter", BDFDB.dotCNS.message + BDFDB.dotCN.messagecontent, e => {
+ if (BDFDB.getData("showOnHover", this, "settings")) {
+ let message = e.currentTarget;
+ let messagegroup = BDFDB.getParentEle(BDFDB.dotCN.messagegroup, message);
+ if (!messagegroup || !messagegroup.tagName) return;
+ let info = this.getMessageData(message, messagegroup);
+ if (!info || !info.timestamp || !info.timestamp._i) return;
+ let choice = BDFDB.getData("creationDateLang", this, "choices");
+ BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, info.timestamp._i), message, {type:"left",selector:"completetimestamp-tooltip"});
+ }
});
- BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"messageObserver",instance:observer}, {childList: true, subtree: true});
-
- observer = new MutationObserver((changes, _) => {
- changes.forEach(
- (change, i) => {
- if (change.removedNodes) {
- change.removedNodes.forEach((node) => {
- if (this.updateTimestamps && node.tagName && node.getAttribute("layer-id") == "user-settings") {
- document.querySelectorAll(".complete-timestamp").forEach(timestamp => {timestamp.classList.remove("complete-timestamp");});
- document.querySelectorAll(".complete-timestamp-divider").forEach(divider => {divider.remove();});
- document.querySelectorAll("time").forEach(stamp => {this.changeTimestamp(stamp);})
- this.updateTimestamps = false;
- }
- });
- }
- }
- );
+ BDFDB.addEventListener(this, document, "mouseenter", BDFDB.dotCNS.message + BDFDB.dotCN.messageedited, e => {
+ if (BDFDB.getData("changeForEdit", this, "settings")) {
+ let marker = e.currentTarget;
+ let time = marker.getAttribute("datetime");
+ if (!time) return;
+ let choice = BDFDB.getData("creationDateLang", this, "choices");
+ let customTooltipCSS = `
+ body ${BDFDB.dotCN.tooltip}:not(.completetimestampedit-tooltip) {
+ display: none !important;
+ }`;
+ BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, time), marker, {type:"top",selector:"completetimestampedit-tooltip",css:customTooltipCSS});
+ }
});
- BDFDB.addObserver(this, BDFDB.dotCN.layers, {name:"settingsWindowObserver",instance:observer}, {childList:true});
- this.languages = Object.assign({},
- {"own": {name:"Own", id:"own", integrated:false, dic:false}},
- BDFDB.languages
- );
-
- $(document)
- .on("mouseenter." + this.getName(), BDFDB.dotCNS.message + BDFDB.dotCN.messagecontent, (e) => {
- if (BDFDB.getData("showOnHover", this, "settings")) {
- let message = e.currentTarget;
- let messagegroup = this.getMessageGroup(message);
- if (!messagegroup || !messagegroup.tagName) return;
- let info = this.getMessageData(message, messagegroup);
- if (!info || !info.timestamp || !info.timestamp._i) return;
- let choice = BDFDB.getData("creationDateLang", this, "choices");
- BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, info.timestamp._i), message, {type:"left",selector:"completetimestamp-tooltip"});
- }
- })
- .on("mouseenter." + this.getName(), BDFDB.dotCNS.message + BDFDB.dotCN.messageedited, (e) => {
- if (BDFDB.getData("changeForEdit", this, "settings")) {
- let marker = e.currentTarget;
- let time = marker.getAttribute("datetime");
- if (!time) return;
- let choice = BDFDB.getData("creationDateLang", this, "choices");
- let customTooltipCSS = `
- body ${BDFDB.dotCN.tooltip}:not(.completetimestampedit-tooltip) {
- display: none !important;
- }`;
- BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, time), marker, {type:"top",selector:"completetimestampedit-tooltip",css:customTooltipCSS});
- }
- });
-
- document.querySelectorAll("time").forEach(stamp => {this.changeTimestamp(stamp);})
+ BDFDB.WebModules.forceAllUpdates();
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
@@ -168,9 +131,9 @@ class CompleteTimestamps {
stop () {
- if (typeof BDFDB === "object") {
- document.querySelectorAll(".complete-timestamp").forEach(stamp => {stamp.classList.remove("complete-timestamp");});
- document.querySelectorAll(".complete-timestamp-divider").forEach(divider => {divider.remove();});
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
+ BDFDB.removeEles(".complete-timestamp-divider");
+ BDFDB.removeClasses("complete-timestamp");
BDFDB.removeLocalStyle(this.getName() + "CompactCorrection");
@@ -181,18 +144,9 @@ class CompleteTimestamps {
// begin of own functions
- updateSettings (settingspanel) {
- var settings = {};
- for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
- settings[input.value] = input.checked;
- }
- BDFDB.saveAllData(settings, this, "settings");
- this.updateSettingsPanel(settingspanel);
- }
-
saveInputs (settingspanel) {
- var formats = {};
- for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.input)) {
+ let formats = {};
+ for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.input)) {
formats[input.getAttribute("option")] = input.value;
}
BDFDB.saveAllData(formats, this, "formats");
@@ -200,71 +154,85 @@ class CompleteTimestamps {
}
updateSettingsPanel (settingspanel) {
- var choices = BDFDB.getAllData(this, "choices");
+ let choices = BDFDB.getAllData(this, "choices");
for (let key in choices) {
settingspanel.querySelector(`${BDFDB.dotCN.select}[option='${key}'] .languageTimestamp`).innerText = this.getTimestamp(this.languages[choices[key]].id);
}
- this.updateTimestamps = true;
+ this.SettingsUpdated = true;
}
-
- toggleInfo (settingspanel, ele) {
- ele.classList.toggle(BDFDB.disCN.categorywrappercollapsed);
- ele.classList.toggle(BDFDB.disCN.categorywrapperdefault);
+
+ toggleInfo (ele) {
+ BDFDB.toggleClass(ele, BDFDB.disCN.categorywrappercollapsed);
+ BDFDB.toggleClass(ele, BDFDB.disCN.categorywrapperdefault);
var svg = ele.querySelector(BDFDB.dotCN.categoryicontransition);
- svg.classList.toggle(BDFDB.disCN.directionright);
- svg.classList.toggle(BDFDB.disCN.categoryiconcollapsed);
- svg.classList.toggle(BDFDB.disCN.categoryicondefault);
+ BDFDB.toggleClass(svg, BDFDB.disCN.directionright);
+ BDFDB.toggleClass(svg, BDFDB.disCN.categoryiconcollapsed);
+ BDFDB.toggleClass(svg, BDFDB.disCN.categoryicondefault);
- var visible = $(settingspanel).find(".info-container").is(":visible");
- $(settingspanel).find(".info-container").toggle(!visible);
- BDFDB.saveData("hideInfo", visible, this, "hideInfo");
+ BDFDB.toggleEles(ele.nextElementSibling);
+ BDFDB.saveData("hideInfo", BDFDB.isEleHidden(ele.nextElementSibling), this, "hideInfo");
}
openDropdownMenu (e) {
- var selectControl = e.currentTarget;
- var selectWrap = selectControl.parentElement;
+ let selectControl = e.currentTarget;
+ let selectWrap = selectControl.parentElement;
+ let plugincard = BDFDB.getParentEle("li", selectWrap);
- if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
+ if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
- selectWrap.classList.add(BDFDB.disCN.selectisopen);
- $("li").has(selectWrap).css("overflow", "visible");
+ BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
+ plugincard.style.setProperty("overflow", "visible", "important");
- var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"));
+ let selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"));
selectWrap.appendChild(selectMenu);
- $(selectMenu).on("mousedown." + this.getName(), BDFDB.dotCN.selectoption, (e2) => {
- var language = e2.currentTarget.getAttribute("value");
+ BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
+ let language = e2.currentTarget.getAttribute("value");
selectWrap.setAttribute("value", language);
selectControl.querySelector(".languageName").innerText = this.languages[language].name;
selectControl.querySelector(".languageTimestamp").innerText = this.getTimestamp(this.languages[language].id);
BDFDB.saveData(selectWrap.getAttribute("option"), language, this, "choices");
});
- $(document).on("mousedown.select" + this.getName(), (e2) => {
- if (e2.target.parentElement == selectMenu) return;
- $(document).off("mousedown.select" + this.getName());
- selectMenu.remove();
- $("li").has(selectWrap).css("overflow", "auto");
- setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
- });
+
+ var removeMenu = e2 => {
+ if (e2.target.parentElement != selectMenu) {
+ document.removeEventListener("mousedown", removeMenu);
+ selectMenu.remove();
+ plugincard.style.removeProperty("overflow");
+ setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
+ }
+ };
+
+ document.addEventListener("mousedown", removeMenu);
}
createDropdownMenu (choice) {
- var menuhtml = ``;
}
-
- getName () {return "PersonalPins";}
-
- getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";}
-
- getVersion () {return "1.7.2";}
-
- getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@@ -163,7 +163,7 @@ class PersonalPins {
let settingspanel = BDFDB.htmlToElement(settingshtml);
- BDFDB.initElements(settingspanel);
+ BDFDB.initElements(settingspanel, this);
settingspanel.querySelector(".reset-button").addEventListener("click", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to delete all pinned notes?", () => {
@@ -177,22 +177,25 @@ class PersonalPins {
load () {}
start () {
- let libraryScript = null;
- if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
- libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
+ libraryScript.setAttribute("date", performance.now());
+ libraryScript.addEventListener("load", () => {
+ BDFDB.loaded = true;
+ this.initialize();
+ });
document.head.appendChild(libraryScript);
}
+ else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
- if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
- else libraryScript.addEventListener("load", () => {this.initialize();});
}
initialize () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
this.SelectChannelUtils = BDFDB.WebModules.findByProperties("selectGuild","selectChannel");
@@ -244,7 +247,7 @@ class PersonalPins {
stop () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".popout-personalpins-notes", ".personalpins-sort-popout", ".notes-button");
BDFDB.unloadMessage(this);
}
@@ -319,6 +322,8 @@ class PersonalPins {
processMessageOptionPopout (instance, wrapper) {
if (instance.props.message && instance.props.channel && instance._reactInternalFiber.memoizedProps.target && !wrapper.querySelector(".personalpins-itembtn")) {
+ let {messagediv, pos} = this.getMessageAndPos(instance._reactInternalFiber.memoizedProps.target);
+ if (!messagediv || pos == -1) return;
let popoutUnpinEntry = BDFDB.htmlToElement(this.getNoteData(instance.props.message, instance._reactInternalFiber.memoizedProps.target, instance.props.channel) ? this.popoutUnpinEntryMarkup : this.popoutPinEntryMarkup);
wrapper.appendChild(popoutUnpinEntry);
popoutUnpinEntry.addEventListener("click", () => {
@@ -330,12 +335,12 @@ class PersonalPins {
openNotesPopout (button) {
let container = document.querySelector(BDFDB.dotCN.popouts);
- if (!container || button.classList.contains("popout-open")) return;
- button.classList.add("popout-open");
+ if (!container || BDFDB.containsClass(button, "popout-open")) return;
+ BDFDB.addClass(button, "popout-open");
let notespopout = BDFDB.htmlToElement(this.notesPopoutMarkup);
container.appendChild(notespopout);
BDFDB.initElements(notespopout);
- let buttonrects = button.getBoundingClientRect();
+ let buttonrects = BDFDB.getRects(button);
notespopout.style.setProperty("left", buttonrects.left + buttonrects.width/2 + "px");
notespopout.style.setProperty("top", buttonrects.top + buttonrects.height + "px")
notespopout.querySelectorAll(BDFDB.dotCN.tabbarheaderitem).forEach(tab => {tab.addEventListener("click", () => {
@@ -353,11 +358,11 @@ class PersonalPins {
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.addNotes(notespopout);});
});
- var removePopout = (e) => {
+ var removePopout = e => {
if (!notespopout.contains(e.target) && !BDFDB.getParentEle(".personalpins-sort-popout", e.target)) {
document.removeEventListener("mousedown", removePopout);
notespopout.remove();
- setTimeout(() => {button.classList.remove("popout-open");},300);
+ setTimeout(() => {BDFDB.removeClass(button, "popout-open");},300);
}
};
document.addEventListener("mousedown", removePopout);
@@ -400,8 +405,7 @@ class PersonalPins {
note.remove();
}
}
- if (container.firstElementChild == placeholder) placeholder.style.removeProperty("display");
- else placeholder.style.setProperty("display", "none", "important");
+ BDFDB.toggleEles(placeholder, container.firstElementChild == placeholder);
}
}
}
@@ -456,7 +460,7 @@ class PersonalPins {
require("request")(ytlink, (error, response, result) => {
if (result) {
wrapper.innerHTML = `
`;
- wrapper.querySelector(BDFDB.dotCN.iconplay).addEventListener("click", (e) => {
+ wrapper.querySelector(BDFDB.dotCN.iconplay).addEventListener("click", e => {
while (wrapper.firstChild) wrapper.firstChild.remove();
let width = 400;
let height = Math.round(width*(result.split('
{
+ messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname).addEventListener("click", e => {
if (!BDFDB.isObjectEmpty(channel)) {
notespopout.remove();
this.SelectChannelUtils.selectChannel(server.id, channel.id);
}
else BDFDB.shake();
});
- message.querySelector(BDFDB.dotCN.messagespopoutclosebutton).addEventListener("click", (e) => {
- messagedivider.remove();
- message.remove();
+ message.querySelector(BDFDB.dotCN.messagespopoutclosebutton).addEventListener("click", e => {
+ BDFDB.removeEles(messagedivider, message);
this.removeNoteData(noteData);
- if (container.firstElementChild == placeholder) placeholder.style.removeProperty("display");
+ BDFDB.toggleEles(placeholder, container.firstElementChild == placeholder);
});
- message.querySelector(BDFDB.dotCN.messagespopoutjumpbutton + ".jump").addEventListener("click", (e) => {
+ message.querySelector(BDFDB.dotCN.messagespopoutjumpbutton + ".jump").addEventListener("click", e => {
this.HistoryUtils.transitionTo(this.MainDiscord.Routes.MESSAGE(noteData.guild_id, noteData.channel_id, noteData.id));
});
- message.querySelector(BDFDB.dotCN.messagespopoutjumpbutton + ".copy").addEventListener("click", (e) => {
+ message.querySelector(BDFDB.dotCN.messagespopoutjumpbutton + ".copy").addEventListener("click", e => {
let clipboard = require("electron").clipboard;
if (noteData.content) clipboard.write({text: noteData.content});
else {
@@ -575,7 +578,7 @@ class PersonalPins {
getMessageAndPos (target) {
let messagediv = BDFDB.getParentEle(BDFDB.dotCN.message, target);
- let pos = Array.from(messagediv.parentElement.querySelectorAll(BDFDB.dotCN.message)).indexOf(messagediv);
+ let pos = messagediv ? Array.from(messagediv.parentElement.querySelectorAll(BDFDB.dotCN.message)).indexOf(messagediv) : -1;
return {messagediv, pos};
}
diff --git a/Plugins/PinDMs/PinDMs.plugin.js b/Plugins/PinDMs/PinDMs.plugin.js
index 52b2ea8cad..f213f03b9c 100644
--- a/Plugins/PinDMs/PinDMs.plugin.js
+++ b/Plugins/PinDMs/PinDMs.plugin.js
@@ -3,7 +3,7 @@
class PinDMs {
getName () {return "PinDMs";}
- getVersion () {return "1.2.6";}
+ getVersion () {return "1.2.7";}
getAuthor () {return "DevilBro";}
@@ -31,22 +31,25 @@ class PinDMs {
load () {}
start () {
- var libraryScript = null;
- if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
- libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
+ libraryScript.setAttribute("date", performance.now());
+ libraryScript.addEventListener("load", () => {
+ BDFDB.loaded = true;
+ this.initialize();
+ });
document.head.appendChild(libraryScript);
}
+ else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
- if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
- else libraryScript.addEventListener("load", () => {this.initialize();});
}
initialize () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
this.ChannelUtils = BDFDB.WebModules.findByProperties("getDMFromUserId");
@@ -82,7 +85,7 @@ class PinDMs {
}
stop () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
let dmsscrollerinstance = BDFDB.getReactInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
if (dmsscrollerinstance) {
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
diff --git a/Plugins/PluginRepo/PluginRepo.plugin.js b/Plugins/PluginRepo/PluginRepo.plugin.js
index 581f4b15ba..adeff59ea1 100644
--- a/Plugins/PluginRepo/PluginRepo.plugin.js
+++ b/Plugins/PluginRepo/PluginRepo.plugin.js
@@ -3,7 +3,7 @@
class PluginRepo {
getName () {return "PluginRepo";}
- getVersion () {return "1.7.0";}
+ getVersion () {return "1.7.1";}
getAuthor () {return "DevilBro";}
@@ -247,11 +247,11 @@ class PluginRepo {
BDFDB.initElements(settingspanel, this);
- BDFDB.addChildEventListener(settingspanel, "click", ".btn-addplugin", () => {this.addPluginToOwnList(settingspanel);});
- BDFDB.addChildEventListener(settingspanel, "click", "#input-pluginurl", e => {if (e.which == 13) this.addPluginToOwnList(settingspanel);});
- BDFDB.addChildEventListener(settingspanel, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);});
- BDFDB.addChildEventListener(settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList();})
- BDFDB.addChildEventListener(settingspanel, "click", ".refresh-button", () => {
+ BDFDB.addEventListener(this, settingspanel, "click", ".btn-addplugin", () => {this.addPluginToOwnList(settingspanel);});
+ BDFDB.addEventListener(this, settingspanel, "click", "#input-pluginurl", e => {if (e.which == 13) this.addPluginToOwnList(settingspanel);});
+ BDFDB.addEventListener(this, settingspanel, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);});
+ BDFDB.addEventListener(this, settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);})
+ BDFDB.addEventListener(this, settingspanel, "click", ".refresh-button", () => {
this.loading = {is:false, timeout:null, amount:0};
this.loadPlugins();
});
@@ -263,22 +263,25 @@ class PluginRepo {
load () {}
start () {
- var libraryScript = null;
- if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
- libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
+ libraryScript.setAttribute("date", performance.now());
+ libraryScript.addEventListener("load", () => {
+ BDFDB.loaded = true;
+ this.initialize();
+ });
document.head.appendChild(libraryScript);
}
+ else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
- if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
- else libraryScript.addEventListener("load", () => {this.initialize();});
}
initialize () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
this.loadPlugins();
@@ -294,7 +297,7 @@ class PluginRepo {
stop () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
clearInterval(this.updateInterval);
clearTimeout(this.loading.timeout);
@@ -311,7 +314,7 @@ class PluginRepo {
let observer = new MutationObserver(changes => {
changes.forEach(change => {
if (change.addedNodes) change.addedNodes.forEach(node => {
- if (node.tagName && node.classList && node.className.includes("plugin-context-menu") && !node.querySelector(".pluginrepo-item")) {
+ if (node.tagName && BDFDB.containsClass(node, "plugin-context-menu") && !node.querySelector(".pluginrepo-item")) {
observer.disconnect();
let item = node.querySelectorAll(BDFDB.dotCN.contextmenuitem);
item = item[item.length-1];
@@ -321,7 +324,8 @@ class PluginRepo {
this.openPluginRepoModal();
});
item.parentElement.insertBefore(settingsContextEntry, item.nextElementSibling);
- node.style.setProperty("top", (menu.getBoundingClientRect().top - node.getBoundingClientRect().height + menu.getBoundingClientRect().height) + "px");
+ var menurects = BDFDB.getRects(menu);
+ node.style.setProperty("top", (menurects.top - BDFDB.getRects(node).height + menurects.height) + "px");
}
});
});
@@ -355,7 +359,9 @@ class PluginRepo {
if (!ownlist.includes(url)) {
ownlist.push(url);
BDFDB.saveData("ownlist", ownlist, this, "ownlist");
- pluginList.appendChild(BDFDB.htmlToElement(`
`));
+ let entry = BDFDB.htmlToElement(`
`);
+ BDFDB.addChildEventListener(entry, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);});
+ pluginList.appendChild(entry);
}
}
}
@@ -369,10 +375,10 @@ class PluginRepo {
BDFDB.saveData("ownlist", ownlist, this, "ownlist");
}
- removeAllFromOwnList () {
+ removeAllFromOwnList (settingspanel) {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all added Plugins from your own list?", () => {
BDFDB.saveData("ownlist", [], this, "ownlist");
- BDFDB.removeEles("." + this.getName() + "-settings " + BDFDB.dotCN.hovercard);
+ BDFDB.removeEles(settingspanel.querySelector(BDFDB.dotCN.hovercard));
});
}
@@ -412,7 +418,7 @@ class PluginRepo {
BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {this.sortEntries(pluginRepoModal);});
});
BDFDB.addChildEventListener(pluginRepoModal, "click", BDFDB.dotCN.tabbaritem + "[tab=plugins]", e => {
- if (!e.currentTarget.classList.contains(BDFDB.disCN.settingsitemselected) && pluginRepoModal.updateHidden) {
+ if (!BDFDB.containsClass(e.currentTarget, BDFDB.disCN.settingsitemselected) && pluginRepoModal.updateHidden) {
delete pluginRepoModal.updateHidden;
this.sortEntries(pluginRepoModal);
}
@@ -457,7 +463,7 @@ class PluginRepo {
entry.querySelector(BDFDB.dotCN._repoauthor).innerHTML = data.author;
entry.querySelector(BDFDB.dotCN._repodescription).innerHTML = data.description;
let favbutton = entry.querySelector(BDFDB.dotCN.giffavoritebutton);
- favbutton.classList.toggle(BDFDB.disCN.giffavoriteselected, data.fav == 0);
+ BDFDB.toggleClass(favbutton, BDFDB.disCN.giffavoriteselected, data.fav == 0);
favbutton.addEventListener("click", e => {
let favorize = data.fav == 1;
data.fav = favorize ? 0 : 1;
@@ -486,7 +492,7 @@ class PluginRepo {
});
let trashbutton = entry.querySelector(".trashIcon");
trashbutton.addEventListener("click", e => {
- if (entry.classList.contains("outdated") || entry.classList.contains("updated")) {
+ if (BDFDB.containsClass(entry, "outdated", "updated", false)) {
setEntryState(2);
this.deletePluginFile(data);
if (!BDFDB.isRestartNoMoreEnabled()) this.stopPlugin(data);
@@ -505,9 +511,9 @@ class PluginRepo {
function setEntryState (state) {
data.state = state;
- entry.classList.toggle("downloadable", state > 1);
- entry.classList.toggle("outdated", state == 1);
- entry.classList.toggle("updated", state < 1);
+ BDFDB.toggleClass(entry, "downloadable", state > 1);
+ BDFDB.toggleClass(entry, "outdated", state == 1);
+ BDFDB.toggleClass(entry, "updated", state < 1);
let downloadbutton = entry.querySelector(".btn-download");
downloadbutton.innerText = state < 1 ? "Updated" : (state > 1 ? "Download" : "Outdated");
downloadbutton.style.setProperty("background-color", "rgb(" + (state < 1 ? "67,181,129" : (state > 1 ? "114,137,218" : "241,71,71")) + ")", "important");
@@ -542,13 +548,10 @@ class PluginRepo {
li.querySelectorAll(BDFDB.dotCNC._reponame + BDFDB.dotCNC._repoversion + BDFDB.dotCNC._repoauthor + BDFDB.dotCN._repodescription).forEach(ele => {
if (searchstring && searchstring.length > 2 || ele.querySelector(BDFDB.dotCN.highlight)) ele.innerHTML = BDFDB.highlightText(ele.innerText, searchstring);
});
- li.style.removeProperty("display");
li.style.setProperty("order", pos, "important");
}
- else {
- li.style.setProperty("display", "none", "important");
- li.style.removeProperty("order");
- }
+ else li.style.removeProperty("order");
+ BDFDB.toggleEles(li, pos > -1);
}
}
diff --git a/Plugins/README.md b/Plugins/README.md
index 0d8279231e..ca2694375f 100644
--- a/Plugins/README.md
+++ b/Plugins/README.md
@@ -42,4 +42,5 @@
- [Theme Repo](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeRepo) - Allows you to preview all themes from the theme repo and download them on the fly.
- [Theme Settings](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeSettings) - Allows you to change Theme Variables within BetterDiscord.
- [Top Role Everywhere](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/TopRoleEverywhere) - Adds the highest role of a user as a tag.
+ - [User Notes](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/UserNotes) - Allows you to write your own user notes wihtout a character limit.
- [Write UpperCase](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/WriteUpperCase) - Changes the input in the textarea to uppercase.
\ No newline at end of file
diff --git a/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js b/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js
index 51a0252b13..8717e74996 100644
--- a/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js
+++ b/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js
@@ -1,6 +1,14 @@
//META{"name":"ReadAllNotificationsButton"}*//
class ReadAllNotificationsButton {
+ getName () {return "ReadAllNotificationsButton";}
+
+ getVersion () {return "1.3.8";}
+
+ getAuthor () {return "DevilBro";}
+
+ getDescription () {return "Adds a button to clear all notifications.";}
+
initConstructor () {
this.patchModules = {
"Guilds":"componentDidMount",
@@ -27,30 +35,20 @@ class ReadAllNotificationsButton {
}
};
}
-
- getName () {return "ReadAllNotificationsButton";}
-
- getDescription () {return "Adds a button to clear all notifications.";}
-
- getVersion () {return "1.3.7";}
-
- getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `
${this.getName()}
`;
for (let key in settings) {
- settingshtml += `
`;
+ settingshtml += `
`;
}
settingshtml += `
`;
- var settingspanel = $(settingshtml)[0];
+ let settingspanel = BDFDB.htmlToElement(settingshtml);
- BDFDB.initElements(settingspanel);
+ BDFDB.initElements(settingspanel, this);
- $(settingspanel)
- .on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
return settingspanel;
}
@@ -58,22 +56,25 @@ class ReadAllNotificationsButton {
load () {}
start () {
- var libraryScript = null;
- if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
- libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
+ libraryScript.setAttribute("date", performance.now());
+ libraryScript.addEventListener("load", () => {
+ BDFDB.loaded = true;
+ this.initialize();
+ });
document.head.appendChild(libraryScript);
}
+ else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
- if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
- else libraryScript.addEventListener("load", () => {this.initialize();});
}
initialize () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
BDFDB.WebModules.forceAllUpdates(this);
@@ -84,7 +85,7 @@ class ReadAllNotificationsButton {
}
stop () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".RANbutton-frame", ".RAMbutton");
BDFDB.removeClasses("RAN-added", "RAM-added");
BDFDB.unloadMessage(this);
@@ -93,29 +94,29 @@ class ReadAllNotificationsButton {
// begin of own functions
-
- updateSettings (settingspanel) {
- var settings = {};
- for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
- settings[input.value] = input.checked;
- }
- BDFDB.saveAllData(settings, this, "settings");
- }
processGuilds (instance, wrapper) {
- $(this.RANbuttonMarkup).insertBefore(wrapper.querySelector(BDFDB.dotCN.guildseparator))
- .on("click", ".RANbutton", () => {
+ let guildseparator = wrapper.querySelector(BDFDB.dotCN.guildseparator);
+ if (guildseparator) {
+ let ranbutton = BDFDB.htmlToElement(this.RANbuttonMarkup);
+ guildseparator.parentElement.insertBefore(ranbutton, guildseparator);
+ ranbutton.addEventListener("click", () => {
BDFDB.clearReadNotifications(BDFDB.getData("includeMuted", this, "settings") ? BDFDB.readServerList() : BDFDB.readUnreadServerList());
});
- wrapper.classList.add("RAN-added");
+ BDFDB.addClass(wrapper, "RAN-added");
+ }
}
processRecentMentions (instance, wrapper) {
BDFDB.removeEles(".RAMbutton");
if (instance.props && instance.props.popoutName == "RECENT_MENTIONS_POPOUT") {
- wrapper.classList.add("RAM-added");
- $(this.RAMbuttonMarkup).appendTo(wrapper.querySelector(BDFDB.dotCN.recentmentionstitle))
- .on("click", () => {this.clearMentions(instance, wrapper);});
+ let recentmentionstitle = wrapper.querySelector(BDFDB.dotCN.recentmentionstitle);
+ if (recentmentionstitle) {
+ let ranbutton = BDFDB.htmlToElement(this.RANbuttonMarkup);
+ recentmentionstitle.appendChild(ranbutton);
+ ranbutton.addEventListener("click", () => {this.clearMentions(instance, wrapper);});
+ BDFDB.addClass(wrapper, "RAM-added");
+ }
}
}
diff --git a/Plugins/RemoveNicknames/RemoveNicknames.plugin.js b/Plugins/RemoveNicknames/RemoveNicknames.plugin.js
index d85b10c25b..a0ed7251f0 100644
--- a/Plugins/RemoveNicknames/RemoveNicknames.plugin.js
+++ b/Plugins/RemoveNicknames/RemoveNicknames.plugin.js
@@ -3,7 +3,7 @@
class RemoveNicknames {
getName () {return "RemoveNicknames";}
- getVersion () {return "1.1.3";}
+ getVersion () {return "1.1.4";}
getAuthor () {return "DevilBro";}
@@ -38,8 +38,7 @@ class RemoveNicknames {
let settingspanel = BDFDB.htmlToElement(settingshtml);
- BDFDB.initElements(settingspanel, this);
-;
+ BDFDB.initElements(settingspanel, this);
;
return settingspanel;
}
@@ -47,22 +46,25 @@ class RemoveNicknames {
load () {}
start () {
- var libraryScript = null;
- if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) {
- libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
- if (libraryScript) libraryScript.remove();
- libraryScript = document.createElement("script");
- libraryScript.setAttribute("type", "text/javascript");
- libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
- document.head.appendChild(libraryScript);
- }
+ var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
+ if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
+ if (libraryScript) libraryScript.remove();
+ libraryScript = document.createElement("script");
+ libraryScript.setAttribute("type", "text/javascript");
+ libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
+ libraryScript.setAttribute("date", performance.now());
+ libraryScript.addEventListener("load", () => {
+ BDFDB.loaded = true;
+ this.initialize();
+ });
+ document.head.appendChild(libraryScript);
+ }
+ else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
- if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize();
- else libraryScript.addEventListener("load", () => {this.initialize();});
}
initialize () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
this.reseting = false;
@@ -81,7 +83,7 @@ class RemoveNicknames {
stop () {
- if (typeof BDFDB === "object") {
+ if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.reseting = true;
BDFDB.WebModules.forceAllUpdates(this);
@@ -105,7 +107,7 @@ class RemoveNicknames {
}
processNameTag (instance, wrapper) {
- let username = wrapper.parentElement.querySelector("." + (wrapper.classList && wrapper.classList.contains(BDFDB.disCN.userpopoutheadertagwithnickname) ? BDFDB.disCN.userpopoutheadernickname : instance.props.usernameClass).replace(/ /g, "."));
+ let username = wrapper.parentElement.querySelector("." + (BDFDB.containsClass(wrapper, BDFDB.disCN.userpopoutheadertagwithnickname) ? BDFDB.disCN.userpopoutheadernickname : instance.props.usernameClass).replace(/ /g, "."));
if (username) BDFDB.setInnerText(username, this.getNewName(instance.props.user));
}
@@ -127,7 +129,7 @@ class RemoveNicknames {
processClickable (instance, wrapper) {
if (!wrapper || !instance.props || !instance.props.className) return;
if (instance.props.tag == "a" && instance.props.className.indexOf(BDFDB.disCN.anchorunderlineonhover) > -1) {
- if (wrapper.parentElement.classList.contains(BDFDB.disCN.messagesystemcontent)) {
+ if (BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.messagesystemcontent)) {
let message = BDFDB.getKeyInformation({node:wrapper.parentElement, key:"message", up:true});
if (message) BDFDB.setInnerText(wrapper, this.getNewName(message.author));
}
diff --git a/Plugins/RepoControls/RepoControls.plugin.js b/Plugins/RepoControls/RepoControls.plugin.js
index 50eab9004c..c1406cd65e 100644
--- a/Plugins/RepoControls/RepoControls.plugin.js
+++ b/Plugins/RepoControls/RepoControls.plugin.js
@@ -3,7 +3,7 @@
class RepoControls {
getName () {return "RepoControls";}
- getVersion () {return "1.2.4";}
+ getVersion () {return "1.2.5";}
getAuthor () {return "DevilBro";}
@@ -37,8 +37,8 @@ class RepoControls {
@@ -66,7 +66,7 @@ class RepoControls {
`;
this.sortPopoutMarkup =
- `