CHAOS CHAAAOOOOOS

This commit is contained in:
Mirco Wittrien 2019-01-17 23:48:29 +01:00
parent 4fe77fdc43
commit 6d044f29b9
47 changed files with 2632 additions and 2907 deletions

View File

@ -3,7 +3,7 @@
class BadgesEverywhere {
getName () {return "BadgesEverywhere";}
getVersion () {return "1.2.2";}
getVersion () {return "1.2.3";}
getAuthor () {return "DevilBro";}
@ -98,22 +98,25 @@ class BadgesEverywhere {
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.APIModule = BDFDB.WebModules.findByProperties("getAPIBaseURL");
@ -130,7 +133,7 @@ class BadgesEverywhere {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".BE-badges");
BDFDB.unloadMessage(this);
}

View File

@ -3,7 +3,7 @@
class BetterFriendCount {
getName () {return "BetterFriendCount";}
getVersion () {return "1.1.0";}
getVersion () {return "1.1.1";}
getAuthor () {return "DevilBro";}
@ -32,22 +32,25 @@ class BetterFriendCount {
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.FriendUtils = BDFDB.WebModules.findByProperties("getFriendIDs", "getRelationships");
@ -63,7 +66,7 @@ class BetterFriendCount {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".betterfriendcount-badge");
BDFDB.unloadMessage(this);
}
@ -77,7 +80,7 @@ class BetterFriendCount {
}
processNameTag (instance, wrapper) {
if (wrapper.parentElement && wrapper.parentElement.classList && wrapper.parentElement.classList.contains(BDFDB.disCN.friendscolumn)) this.addCountNumbers();
if (wrapper.parentElement && BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.friendscolumn)) this.addCountNumbers();
}
addCountNumbers (wrapper = document.querySelector(BDFDB.dotCNS.friends + BDFDB.dotCN.settingstabbar)) {

View File

@ -1,48 +1,43 @@
//META{"name":"BetterNsfwTag"}*//
class BetterNsfwTag {
getName () {return "BetterNsfwTag";}
getVersion () {return "1.1.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a more noticeable tag to NSFW channels.";}
initConstructor () {
this.patchModules = {
"ChannelItem":"componentDidMount"
};
this.tagMarkup = `<span class="NSFW-tag ${BDFDB.disCNS.bottag + BDFDB.disCNS.bottagregular + BDFDB.disCN.bottagnametag}" style="background-color: rgb(241, 71, 71) !important; color: white !important;">NSFW</span>`;
this.css = `
.NSFW-tag${BDFDB.dotCN.bottag} {
top: -3px;
position: relative;
}`
}
getName () {return "BetterNsfwTag";}
getDescription () {return "Adds a more noticeable tag to NSFW channels.";}
getVersion () {return "1.1.6";}
getAuthor () {return "DevilBro";}
//legacy
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);
@ -53,7 +48,7 @@ class BetterNsfwTag {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".NSFW-tag");
BDFDB.unloadMessage(this);
}
@ -64,7 +59,8 @@ class BetterNsfwTag {
processChannelItem (instance, wrapper) {
if (instance.props && instance.props.channel && instance.props.channel.nsfw) {
$(this.tagMarkup).appendTo(wrapper.querySelector(BDFDB.dotCN.channelname));
let channelname = wrapper.querySelector(BDFDB.dotCN.channelname);
if (channelname) channelname.appendChild(BDFDB.htmlToElement(`<span class="NSFW-tag ${BDFDB.disCNS.bottag + BDFDB.disCNS.bottagregular + BDFDB.disCN.bottagnametag}" style="background-color: rgb(241, 71, 71) !important; color: white !important; top: -3px; position: relative;">NSFW</span>`));
}
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"BetterSearchPage"}*//
class BetterSearchPage {
getName () {return "BetterSearchPage";}
getVersion () {return "1.0.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds some extra controls to the search results page.";}
initConstructor () {
this.patchModules = {
"SearchResults":["componentDidMount","componentDidUpdate"]
@ -51,30 +59,19 @@ class BetterSearchPage {
}
};
}
getName () {return "BetterSearchPage";}
getDescription () {return "Adds some extra controls to the search results page.";}
getVersion () {return "1.0.4";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div></div>`;
var settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
$(settingspanel)
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
BDFDB.initElements(settingspanel, this);
return settingspanel;
}
@ -82,23 +79,26 @@ class BetterSearchPage {
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") {
BDFDB.loadMessage(this);
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
this.SearchNavigation = BDFDB.WebModules.findByProperties("searchNextPage","searchPreviousPage");
@ -110,21 +110,14 @@ class BetterSearchPage {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".BSP-pagination",".BSP-pagination-button",".BSP-pagination-jumpinput");
BDFDB.unloadMessage(this);
}
}
// 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");
}
processSearchResults (instance, wrapper) {
if (instance.props && instance.props.searchId) this.addNewControls(wrapper.querySelector(BDFDB.dotCN.searchresultspagination), instance.props.searchId);
@ -151,37 +144,21 @@ class BetterSearchPage {
if (currentpage == 201) BDFDB.showToast("Discord doesn't allow you to go further than page 201.",{type:"error"});
maxpage = 201;
}
if (currentpage == maxpage && maxpage == 201) pagination.querySelector(BDFDB.dotCN.searchresultspaginationnext).classList.add(BDFDB.disCN.searchresultspaginationdisabled);
if (currentpage == maxpage && maxpage == 201) BDFDB.addClass(pagination.querySelector(BDFDB.dotCN.searchresultspaginationnext), BDFDB.disCN.searchresultspaginationdisabled);
let settings = BDFDB.getAllData(this, "settings");
let BSPpaginatonPrevious = pagination.querySelector(BDFDB.dotCN.searchresultspaginationprevious);
if (BSPpaginatonPrevious) {
BSPpaginatonPrevious.classList.add("pagination-button");
BSPpaginatonPrevious.setAttribute("type", "Previous");
}
let BSPpaginatonNext = pagination.querySelector(BDFDB.dotCN.searchresultspaginationnext);
if (BSPpaginatonNext) {
BSPpaginatonNext.classList.add("pagination-button");
BSPpaginatonNext.setAttribute("type", "Next");
}
for (let btn of pagination.querySelectorAll(BDFDB.dotCNC.searchresultspaginationprevious + BDFDB.dotCN.searchresultspaginationnext)) BDFDB.addClass(btn, "pagination-button");
if (settings.addFirstLast) {
let BSPpaginatonFirst = document.createElement("div");
BSPpaginatonFirst.className = "pagination-button BSP-pagination-button BSP-pagination-first";
BSPpaginatonFirst.setAttribute("type", "First");
if (currentpage == 1) BSPpaginatonFirst.classList.add(BDFDB.disCN.searchresultspaginationdisabled);
pagination.insertBefore(BSPpaginatonFirst, pagination.firstElementChild);
let BSPpaginatonLast = document.createElement("div");
BSPpaginatonLast.className = "pagination-button BSP-pagination-button BSP-pagination-last";
BSPpaginatonFirst.setAttribute("type", "Last");
if (currentpage == maxpage) BSPpaginatonLast.classList.add(BDFDB.disCN.searchresultspaginationdisabled);
pagination.appendChild(BSPpaginatonLast);
pagination.insertBefore(BDFDB.htmlToElement(`<div aria-label="First" class="${currentpage == 1 ? BDFDB.disCNS.searchresultspaginationdisabled : ""}pagination-button BSP-pagination-button BSP-pagination-first"></div>`), pagination.firstElementChild);
pagination.appendChild(BDFDB.htmlToElement(`<div aria-label="Last" class="${currentpage == maxpage ? BDFDB.disCNS.searchresultspaginationdisabled : ""}pagination-button BSP-pagination-button BSP-pagination-last"></div>`));
}
if (settings.addJumpTo) {
$(`<div class="inputNumberWrapper inputNumberWrapperMini BSP-pagination-jumpinput ${BDFDB.disCN.inputwrapper}"><span class="numberinput-buttons-zone"><span class="numberinput-button-up"></span><span class="numberinput-button-down"></span></span><input type="number" min="1" max="${maxpage}" placeholder="${currentpage}" value="${currentpage}" class="${BDFDB.disCNS.inputmini + BDFDB.disCNS.input + BDFDB.disCN.size16}"></div><div type="Go To" class="pagination-button BSP-pagination-button BSP-pagination-jump"></div>`).appendTo(pagination);
pagination.appendChild(BDFDB.htmlToElement(`<div class="inputNumberWrapper inputNumberWrapperMini BSP-pagination-jumpinput ${BDFDB.disCN.inputwrapper}"><span class="numberinput-buttons-zone"><span class="numberinput-button-up"></span><span class="numberinput-button-down"></span></span><input type="number" min="1" max="${maxpage}" placeholder="${currentpage}" value="${currentpage}" class="${BDFDB.disCNS.inputmini + BDFDB.disCNS.input + BDFDB.disCN.size16}"></div>`));
pagination.appendChild(BDFDB.htmlToElement(`<div aria-label="Go To" class="pagination-button BSP-pagination-button BSP-pagination-jump"></div>`));
}
BDFDB.initElements(pagination);
if (settings.cloneToTheTop) {
let BSPpaginaton = pagination.cloneNode(true);
BSPpaginaton.classList.add("BSP-pagination");
BDFDB.addClass(BSPpaginaton, "BSP-pagination");
searchResultsWrapper.insertBefore(BSPpaginaton, searchResultsWrapper.firstElementChild);
BDFDB.initElements(BSPpaginaton);
}
@ -202,33 +179,32 @@ class BetterSearchPage {
}
}
};
$(searchResultsWrapper)
.off("click." + this.getName()).off("mouseenter." + this.getName()).off("keydown." + this.getName())
.on("click." + this.getName(), BDFDB.dotCN.searchresultspaginationdisabled, (e) => {
e.preventDefault();
e.stopPropagation();
})
.on("mouseenter." + this.getName(), ".pagination-button:not(" + BDFDB.dotCN.searchresultspaginationdisabled + ")", (e) => {
let type = e.currentTarget.getAttribute("type");
if (type) BDFDB.createTooltip(type, e.currentTarget, {type:"top"});
})
.on("click." + this.getName(), ".BSP-pagination " + BDFDB.dotCN.searchresultspaginationprevious + ":not(" + BDFDB.dotCN.searchresultspaginationdisabled + ")", () => {
this.SearchNavigation.searchPreviousPage(searchId);
})
.on("click." + this.getName(), ".BSP-pagination " + BDFDB.dotCN.searchresultspaginationnext + ":not(" + BDFDB.dotCN.searchresultspaginationdisabled + ")", () => {
this.SearchNavigation.searchNextPage(searchId);
})
.on("click." + this.getName(), ".BSP-pagination-first:not(" + BDFDB.dotCN.searchresultspaginationdisabled + ")", () => {
for (let i = 0; currentpage - 1 - i > 0; i++) this.SearchNavigation.searchPreviousPage(searchId);
})
.on("click." + this.getName(), ".BSP-pagination-last:not(" + BDFDB.dotCN.searchresultspaginationdisabled + ")", () => {
for (let i = 0; maxpage - currentpage - i > 0; i++) this.SearchNavigation.searchNextPage(searchId);
})
.on("keydown." + this.getName(), ".BSP-pagination-jumpinput " + BDFDB.dotCN.inputmini, (e) => {
if (e.which == 13) doJump(e.currentTarget);
})
.on("click." + this.getName(), ".BSP-pagination-jump:not(" + BDFDB.dotCN.searchresultspaginationdisabled + ")", (e) => {
doJump(e.currentTarget.parentElement.querySelector(".BSP-pagination-jumpinput " + BDFDB.dotCN.inputmini));
});
BDFDB.addEventListener(this, searchResultsWrapper, "click", BDFDB.dotCN.searchresultspaginationdisabled, e => {
e.preventDefault();
e.stopPropagation();
});
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination ${BDFDB.dotCN.searchresultspaginationprevious}:not(${BDFDB.dotCN.searchresultspaginationdisabled})`, () => {
this.SearchNavigation.searchPreviousPage(searchId);
});
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination ${BDFDB.dotCN.searchresultspaginationnext}:not(${BDFDB.dotCN.searchresultspaginationdisabled})`, () => {
this.SearchNavigation.searchNextPage(searchId);
});
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination-first:not(${BDFDB.dotCN.searchresultspaginationdisabled})`, () => {
for (let i = 0; currentpage - 1 - i > 0; i++) this.SearchNavigation.searchPreviousPage(searchId);
});
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination-last:not(${BDFDB.dotCN.searchresultspaginationdisabled})`, () => {
for (let i = 0; maxpage - currentpage - i > 0; i++) this.SearchNavigation.searchNextPage(searchId);
});
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination-jump:not(${BDFDB.dotCN.searchresultspaginationdisabled})`, e => {
doJump(e.currentTarget.parentElement.querySelector(`.BSP-pagination-jumpinput ${BDFDB.dotCN.inputmini}`));
});
BDFDB.addEventListener(this, searchResultsWrapper, "keydown", `.BSP-pagination-jumpinput ${BDFDB.dotCN.inputmini}`, e => {
let label = e.currentTarget.getAttribute("aria-label");
if (label) BDFDB.createTooltip(label, e.currentTarget, {type:"top"});
});
BDFDB.addEventListener(this, searchResultsWrapper, "mouseenter", `.pagination-button:not(${BDFDB.dotCN.searchresultspaginationdisabled})`, e => {
let label = e.currentTarget.getAttribute("aria-label");
if (label) BDFDB.createTooltip(label, e.currentTarget, {type:"top"});
});
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"CharCounter"}*//
class CharCounter {
getName () {return "CharCounter";}
getVersion () {return "1.3.1";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a charcounter in the chat.";}
initConstructor () {
this.patchModules = {
"ChannelTextArea":"componentDidMount",
@ -10,8 +18,6 @@ class CharCounter {
this.selecting = false;
this.counterMarkup = `<div id="charcounter" class="charcounter"></div>`;
this.maxLenghts = {
normal: 2000,
edit: 2000,
@ -73,35 +79,29 @@ class CharCounter {
}`;
}
getName () {return "CharCounter";}
getDescription () {return "Adds a charcounter in the chat.";}
getVersion () {return "1.3.0";}
getAuthor () {return "DevilBro";}
//legacy
load () {}
start () {
var libraryScript = null;
if (typeof BDFDB !== "object" || BDFDB.isLibraryOutdated()) {
if (typeof BDFDB === "object") BDFDB = "";
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") 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);
@ -113,7 +113,7 @@ class CharCounter {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".charcounter");
BDFDB.removeClasses("charcounter-added");
BDFDB.unloadMessage(this);
@ -128,7 +128,7 @@ class CharCounter {
}
processNote (instance, wrapper) {
if (wrapper.classList) this.appendCounter(wrapper.firstElementChild, wrapper.classList.contains(BDFDB.disCN.usernotepopout) ? "popout" : (wrapper.classList.contains(BDFDB.disCN.usernoteprofile) ? "profile" : null));
this.appendCounter(wrapper.firstElementChild, BDFDB.containsClass(wrapper, BDFDB.disCN.usernotepopout) ? "popout" : (BDFDB.containsClass(wrapper, BDFDB.disCN.usernoteprofile) ? "profile" : null));
}
processModal (instance, wrapper) {
@ -140,42 +140,29 @@ class CharCounter {
appendCounter (input, type) {
if (!input || !type) return;
var counter = $(this.counterMarkup);
counter.addClass(type).appendTo(input.parentElement);
var counter = BDFDB.htmlToElement(`<div id="charcounter" class="charcounter ${type}"></div>`);
input.parentElement.appendChild(counter);
var updateCounter = () => {
var selection = input.selectionEnd - input.selectionStart == 0 ? "" : " (" + (input.selectionEnd - input.selectionStart) + ")";
var maxLength = this.maxLenghts[type] || 2000;
counter.text(input.value.length + "/" + maxLength + selection);
}
var updateCounter = () => {counter.innerText = input.value.length + "/" + (this.maxLenghts[type] || 2000) + (input.selectionEnd - input.selectionStart == 0 ? "" : " (" + (input.selectionEnd - input.selectionStart) + ")");};
input.parentElement.parentElement.classList.add("charcounter-added");
BDFDB.addClass(input.parentElement.parentElement, "charcounter-added");
if (type == "nickname") input.setAttribute("maxlength", 32);
$(input)
.off("keydown." + this.getName() + " click." + this.getName())
.on("keydown." + this.getName() + " click." + this.getName(), e => {
clearTimeout(input.charcountertimeout);
input.charcountertimeout = setTimeout(() => {updateCounter();},100);
})
.off("mousedown." + this.getName())
.on("mousedown." + this.getName(), e => {
this.selecting = true;
});
$(document)
.off("mouseup." + this.getName())
.on("mouseup." + this.getName(), e => {
if (this.selecting) {
this.selecting = false;
}
})
.off("mousemove." + this.getName())
.on("mousemove." + this.getName(), e => {
if (this.selecting) {
setTimeout(() => {
updateCounter();
},10);
}
BDFDB.addEventListener(this, input, "keydown click", e => {
clearTimeout(input.charcountertimeout);
input.charcountertimeout = setTimeout(() => {updateCounter();},100);
});
BDFDB.addEventListener(this, input, "mousedown", e => {
BDFDB.addEventListener(this, document, "mouseup", () => {
BDFDB.removeEventListener(this, document);
if (input.selectionEnd - input.selectionStart) setImmediate(() => {BDFDB.addEventListener(this, document, "click", () => {
input.selectionStart = 0;
input.selectionEnd = 0;
updateCounter();
BDFDB.removeEventListener(this, document);
});});
});
BDFDB.addEventListener(this, document, "mousemove", () => {setTimeout(() => {updateCounter();},10);});
});
updateCounter();
}

View File

@ -3,13 +3,18 @@
class ChatAliases {
getName () {return "ChatAliases";}
getVersion () {return "1.9.3";}
getVersion () {return "1.9.4";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows the user to configure their own chat-aliases which will automatically be replaced before the message is being sent.";}
initConstructor () {
this.patchModules = {
"ChannelTextArea":"componentDidMount",
"StandardSidebarView":"componentWillUnmount"
};
this.configs = ["case","exact","autoc","regex","file"];
this.defaults = {
@ -24,7 +29,7 @@ class ChatAliases {
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Replace:</h3><input action="add" type="text" placeholder="Wordvalue" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} wordInputs" id="input-wordvalue" style="flex: 1 1 auto;"><button action="add" type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-add btn-addword" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">With:</h3><input action="add" type="text" placeholder="Replacevalue" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} wordInputs" id="input-replacevalue" style="flex: 1 1 auto;"><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} file-navigator" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div><input id="input-file" type="file" style="display:none!important;"></button></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto; max-width: ${560 - (this.configs.length * 33)}px;">List of Chataliases:</h3><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifycenter + BDFDB.disCNS.alignend + BDFDB.disCN.nowrap}" style="flex: 1 1 auto; max-width: ${this.configs.length * 34}px;">`;
@ -46,17 +51,15 @@ class ChatAliases {
settingshtml += `<div class="DevilBro-settings-inner-list info-container" ${infoHidden ? "style='display:none;'" : ""}><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Case: Will replace words while comparing lowercase/uppercase. apple => apple, not APPLE or AppLe</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Not Case: Will replace words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Exact: Will replace words that are exactly the replaceword. apple to pear => applepie stays applepie</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Not Exact: Will replace words anywhere they appear. apple to pear => applepieapple to pearpiepear</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Autoc: Will appear in the Autocomplete Menu (if enabled).</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Regex: Will treat the entered wordvalue as a regular expression. <a class="${BDFDB.disCNS.anchor + BDFDB.disCN.anchorunderlineonhover}" target="_blank" href="https://regexr.com/">Help</a></div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">File: If the replacevalue is a filepath it will try to upload the file located at the filepath.</div></div>`;
settingshtml += `</div>`;
var settingspanel = BDFDB.htmlToElement(settingshtml);
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);})
.on("keypress", ".wordInputs", (e) => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);})
.on("keyup", BDFDB.dotCN.gamenameinput, (e) => {this.updateWord(e.currentTarget);})
.on("click", ".btn-addword, .remove-word, .remove-all", (e) => {this.updateContainer(settingspanel, e.currentTarget);})
.on("click", BDFDB.dotCN.checkboxinput, (e) => {this.updateConfig(e.currentTarget);})
.on("click", ".toggle-info", (e) => {this.toggleInfo(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "keypress", ".wordInputs", e => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.gamenameinput, e => {this.updateWord(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addword, .remove-word, .remove-all", e => {this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {this.updateConfig(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
return settingspanel;
}
@ -64,67 +67,38 @@ class ChatAliases {
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.UploadModule = BDFDB.WebModules.findByProperties("instantBatchUpload");
this.CurrentUserPerms = BDFDB.WebModules.findByProperties("getChannelPermissions", "can");
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions;
var observer = null;
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.removedNodes) {
change.removedNodes.forEach((node) => {
if (node.tagName && node.getAttribute("layer-id") == "user-settings") {
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.layers, {name:"settingsWindowObserver",instance:observer}, {childList:true});
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.addedNodes) {
change.addedNodes.forEach((node) => {
if (node.tagName && node.querySelector(BDFDB.dotCN.textareainner + ":not(" + BDFDB.dotCN.textareainnerdisabled + ")")) {
this.bindEventToTextArea(node.querySelector("textarea"));
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"textareaObserver",instance:observer}, {childList: true, subtree:true});
this.aliases = BDFDB.loadAllData(this, "words");
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
$(document).off("click." + this.getName()).on("click." + this.getName(), (e) => {
if (!e.target.tagName === "TEXTAREA") $(".autocompleteAliases, .autocompleteAliasesRow").remove();
BDFDB.addEventListener(document, "click", e => {
if (!e.target.tagName === "TEXTAREA") BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
});
BDFDB.WebModules.forceAllUpdates(this);
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
@ -132,7 +106,7 @@ class ChatAliases {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
BDFDB.unloadMessage(this);
}
@ -141,16 +115,6 @@ class ChatAliases {
// 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");
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
}
updateContainer (settingspanel, ele) {
var update = false, wordvalue = null, replacevalue = null;
var action = ele.getAttribute("action");
@ -211,8 +175,8 @@ class ChatAliases {
}
containerhtml += `</div><div word="${word}" action="remove" class="${BDFDB.disCN.hovercardbutton} remove-word"></div></div>`;
}
$(settingspanel).find(".alias-list").html(containerhtml);
BDFDB.initElements(settingspanel);
settingspanel.querySelector(".alias-list").innerHTML = containerhtml;
BDFDB.initElements(settingspanel, this);
}
}
@ -249,27 +213,33 @@ class ChatAliases {
}
}
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);
var visible = $(settingspanel).find(".info-container").is(":visible");
$(settingspanel).find(".info-container").toggle(!visible);
BDFDB.saveData("hideInfo", visible, this, "hideInfo");
BDFDB.toggleClass(svg, BDFDB.disCN.directionright);
BDFDB.toggleClass(svg, BDFDB.disCN.categoryiconcollapsed);
BDFDB.toggleClass(svg, BDFDB.disCN.categoryicondefault);
BDFDB.toggleEles(ele.nextElementSibling);
BDFDB.saveData("hideInfo", BDFDB.isEleHidden(ele.nextElementSibling), this, "hideInfo");
}
bindEventToTextArea (textarea) {
if (!textarea) return;
var channel = BDFDB.getSelectedChannel();
if (!channel) return;
var settings = BDFDB.getAllData(this, "settings");
$(textarea)
.off("input." + this.getName())
.on("input." + this.getName(), () => {
processStandardSidebarView (instance, wrapper) {
if (this.SettingsUpdated) {
BDFDB.WebModules.forceAllUpdates(this);
delete this.SettingsUpdated;
}
}
processChannelTextArea (instance, wrapper) {
if (instance.props && instance.props.type) {
var textarea = wrapper.querySelector("textarea");
if (!textarea) return;
var channel = BDFDB.getSelectedChannel();
if (!channel) return;
var settings = BDFDB.getAllData(this, "settings");
BDFDB.addEventListener(this, textarea, "input", () => {
if (this.format) {
this.format = false;
textarea.focus();
@ -285,27 +255,26 @@ class ChatAliases {
}
}
}
})
.off("keydown." + this.getName())
.on("keydown." + this.getName(), e => {
});
BDFDB.addEventListener(this, textarea, "keydown", e => {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete);
if ((e.which == 9 || e.which == 13) && autocompletemenu) {
if (autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement.classList.contains("autocompleteAliasesRow")) {
if (autocompletemenu && (e.which == 9 || e.which == 13)) {
if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteAliasesRow")) {
e.preventDefault();
e.stopPropagation();
this.swapWordWithAlias(textarea);
}
}
else if ((e.which == 38 || e.which == 40) && autocompletemenu) {
else if (autocompletemenu && (e.which == 38 || e.which == 40)) {
let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteAliasesSelector)");
let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected);
if (selected.classList.contains("autocompleteAliasesSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) {
if (BDFDB.containsClass(selected, "autocompleteAliasesSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) {
e.preventDefault();
e.stopPropagation();
let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true);
selected.classList.remove(BDFDB.disCN.autocompleteselected);
next.classList.add(BDFDB.disCN.autocompleteselected);
if (!next.classList.contains("autocompleteAliasesSelector")) {
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(next, BDFDB.disCN.autocompleteselected);
if (!BDFDB.containsClass(next, "autocompleteAliasesSelector")) {
// if next element is a default discord autocomplete item, trigger the keypress again so the item is internally selected
var press = new KeyboardEvent("keypress", e);
Object.defineProperty(press, "keyCode", {value: e.which});
@ -316,25 +285,19 @@ class ChatAliases {
}
else if (textarea.value && !e.shiftKey && e.which == 13 && !autocompletemenu && textarea.value.indexOf("s/") != 0) {
this.format = true;
$(textarea).trigger("input");
textarea.dispatchEvent(new Event("input"));
}
else if (!e.ctrlKey && e.which != 16 && settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) {
clearTimeout(textarea.chataliastimeout);
textarea.chataliastimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea);},100);
}
if (!e.ctrlKey && e.which != 38 && e.which != 40) {
if (!(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) {
BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
}
}
})
.off("click." + this.getName())
.on("click." + this.getName(), e => {
if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) {
setImmediate(() => {this.addAutoCompleteMenu(textarea);});
}
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
});
BDFDB.addEventListener(this, textarea, "click", e => {
if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea);});
});
}
}
addAutoCompleteMenu (textarea) {
@ -377,25 +340,19 @@ class ChatAliases {
}
let autocompleterowheader = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCN.autocompleteselector} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.autocompletecontenttitle + BDFDB.disCNS.small + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCN.weightsemibold}">Aliases: <strong class="lastword">${BDFDB.encodeToHTML(lastword)}</strong></div></div></div>`);
autocompletemenu.appendChild(autocompleterowheader);
$(autocompletemenu)
.off("mouseenter." + this.getName())
.on("mouseenter." + this.getName(), BDFDB.dotCN.autocompleteselectable, (e) => {
autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected).forEach(selected => {selected.classList.remove(BDFDB.disCN.autocompleteselected);});
e.currentTarget.classList.add(BDFDB.disCN.autocompleteselected);
});
BDFDB.addEventListener(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => {
BDFDB.removeClass(autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected), BDFDB.disCN.autocompleteselected);
BDFDB.addClass(e.currentTarget, BDFDB.disCN.autocompleteselected);
});
for (let word in matchedaliases) {
if (amount-- < 1) break;
let autocompleterow = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCNS.autocompleteselector + BDFDB.disCN.autocompleteselectable} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletecontent}" style="flex: 1 1 auto;"><div class="${BDFDB.disCN.flexchild} aliasword" style="flex: 1 1 auto;">${BDFDB.encodeToHTML(word)}</div><div class="${BDFDB.disCNS.autocompletedescription + BDFDB.disCN.flexchild}">${BDFDB.encodeToHTML(matchedaliases[word].replace)}</div></div></div></div>`);
autocompleterow.querySelector(BDFDB.dotCN.autocompleteselectable).addEventListener("click", () => {this.swapWordWithAlias(textarea);});
autocompletemenu.appendChild(autocompleterow);
$(autocompleterow)
.off("click." + this.getName())
.on("click." + this.getName(), BDFDB.dotCN.autocompleteselectable, (e) => {
this.swapWordWithAlias(textarea);
});
}
if (!autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected)) {
autocompletemenu.querySelector(".autocompleteAliasesRow " + BDFDB.dotCN.autocompleteselectable).classList.add(BDFDB.disCN.autocompleteselected);
BDFDB.addClass(autocompletemenu.querySelector(".autocompleteAliasesRow " + BDFDB.dotCN.autocompleteselectable), BDFDB.disCN.autocompleteselected);
}
}
}

View File

@ -1,7 +1,20 @@
//META{"name":"ChatFilter"}*//
class ChatFilter {
getName () {return "ChatFilter";}
getVersion () {return "3.3.2";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows the user to censor words or block complete messages based on words in the chatwindow.";}
initConstructor () {
this.patchModules = {
"Message":["componentDidMount","componentDidUpdate"],
"StandardSidebarView":"componentWillUnmount"
};
this.configs = ["empty","case","exact"];
this.css = `
@ -9,11 +22,6 @@ class ChatFilter {
${BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messagemarkup}.blocked:not(.revealed) {
font-weight: bold;
font-style: italic;
}
${BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messageaccessory}.censored:not(.revealed),
${BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messagemarkup}:not(.revealed) {
}`;
this.defaults = {
@ -27,14 +35,6 @@ class ChatFilter {
}
};
}
getName () {return "ChatFilter";}
getDescription () {return "Allows the user to censor words or block complete messages based on words in the chatwindow.";}
getVersion () {return "3.3.1";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -45,7 +45,7 @@ class ChatFilter {
var words = BDFDB.loadData(rtype, this, "words");
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto; min-width:55px;">${this.defaults.replaces[rtype].title}</h3><input rtype="${rtype}" action="add" type="text" placeholder="Wordvalue" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} wordInputs" id="input-${rtype}-wordvalue" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">With:</h3><input rtype="${rtype}" action="add" type="text" placeholder="Replacevalue" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} wordInputs" id="input-${rtype}-replacevalue" style="flex: 1 1 auto;"><button rtype="${rtype}" action="add" type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-add btn-addword" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div>`;
for (let key in settings) {
settingshtml += `<div rtype="${rtype}" value="${key}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" rtype="${rtype}" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key][rtype] ? " checked" : ""}></div></div>`;
if (this.defaults.settings[key].enabled[rtype]) settingshtml += `<div value="${key}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key} ${rtype}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key][rtype] ? " checked" : ""}></div></div>`;
}
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto; min-width: 320px;">${this.defaults.replaces[rtype].description}</h3><input rtype="${rtype}" type="text" placeholder="${this.defaults.replaces[rtype].value}" value="${replaces[rtype]}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} defaultInputs" id="input-${rtype}-defaultvalue" style="flex: 1 1 auto;"></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto; max-width: ${560 - (this.configs.length * 33)}px;">List of ${rtype} Words:</h3><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifycenter + BDFDB.disCNS.alignend + BDFDB.disCN.nowrap}" style="flex: 1 1 auto; max-width: ${this.configs.length * 34}px;">`;
@ -69,23 +69,16 @@ class ChatFilter {
settingshtml += `<div class="DevilBro-settings-inner-list info-container" ${infoHidden ? "style='display:none;'" : ""}><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Case: Will block/censor words while comparing lowercase/uppercase. apple => apple, not APPLE or AppLe</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Not Case: Will block/censor words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Exact: Will block/censor words that are exactly the selected word. apple => apple, not applepie or pineapple</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Not Exact: Will block/censor all words containing the selected word. apple => apple, applepie and pineapple</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">Empty: Ignores the default and set replace word and removes the word/message instead.</div></div>`;
settingshtml += `</div>`;
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("keypress", ".wordInputs", (e) => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);})
.on("keyup", ".defaultInputs", (e) => {this.saveReplace(e.currentTarget);})
.on("click", ".btn-addword, .remove-word, .remove-all", (e) => {this.updateContainer(settingspanel, e.currentTarget);})
.on("click", BDFDB.dotCN.checkboxinput, (e) => {this.updateConfig(e.currentTarget);})
.on("click", ".toggle-info", (e) => {this.toggleInfo(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "keypress", ".wordInputs", e => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "keyup", ".defaultInputs", e => {this.saveReplace(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addword, .remove-word, .remove-all", e => {this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {this.updateConfig(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
for (let key in settings) {
for (let rtype in this.defaults.settings[key].enabled) {
if (!this.defaults.settings[key].enabled[rtype]) $(settingspanel).find(`${BDFDB.dotCN.flex}[value='${key}'][rtype='${rtype}']`).hide();
}
}
return settingspanel;
}
@ -93,74 +86,28 @@ class ChatFilter {
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.type == "characterData") {
this.hideMessage(change.target.parentElement);
}
if (change.addedNodes) {
change.addedNodes.forEach((node) => {
if (node.tagName && node.classList.contains(BDFDB.disCN.message)) this.hideMessage(node.querySelector(BDFDB.dotCN.messagemarkup));
});
}
}
);
});
BDFDB.addObserver(this, null, {name:"messageChangeObserver",instance:observer,multi:true}, {childList:true, characterData:true, subtree:true});
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.addedNodes) {
change.addedNodes.forEach((node) => {
if (node.tagName && node.querySelector(BDFDB.dotCN.message)) {
BDFDB.addObserver(this, node, {name:"messageChangeObserver",multi:true}, {childList:true, characterData:true, subtree:true});
node.querySelectorAll(BDFDB.dotCNC.messagemarkup + BDFDB.dotCN.messageaccessory).forEach(message => {
this.hideMessage(message);
});
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true});
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.removedNodes) {
change.removedNodes.forEach((node) => {
if (node && $(node).attr("layer-id") == "user-settings") this.hideAllMessages();
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.layers, {name:"settingsWindowObserver",instance:observer}, {childList:true});
this.hideAllMessages();
BDFDB.WebModules.forceAllUpdates(this);
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
@ -168,29 +115,35 @@ class ChatFilter {
}
stop () {
if (typeof BDFDB === "object") {
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.blocked, ${BDFDB.dotCN.messagemarkup}.censored, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {
this.resetMessage(message);
});
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);});
BDFDB.unloadMessage(this);
}
}
onSwitch () {
if (typeof BDFDB === "object") {
this.hideAllMessages();
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver"}, {childList:true, subtree:true});
}
}
// begin of own functions
updateContainer (settingspanel, ele) {
var update = false, wordvalue = null, replacevalue = null;
var action = ele.getAttribute("action"), rtype = ele.getAttribute("rtype");
var words = BDFDB.loadData(rtype, this, "words") || {};
var wordvalue = null, replacevalue = null, action = ele.getAttribute("action"), rtype = ele.getAttribute("rtype"), words = BDFDB.loadData(rtype, this, "words") || {};
var update = () => {
BDFDB.saveData(rtype, words, this, "words");
var containerhtml = ``;
for (let word in words) {
containerhtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis}" style="flex: 1 1 auto;">${BDFDB.encodeToHTML(word)} (${BDFDB.encodeToHTML(words[word].replace)})</div>`
for (let config of this.configs) {
containerhtml += `<div class="${BDFDB.disCNS.checkboxcontainer + BDFDB.disCN.marginreset}" style="flex: 0 0 auto;"><label class="${BDFDB.disCN.checkboxwrapper}"><input word="${word}" rtype="${rtype}" config="${config}" type="checkbox" class="${BDFDB.disCNS.checkboxinputdefault + BDFDB.disCN.checkboxinput}"${words[word][config] ? " checked" : ""}><div class="${BDFDB.disCNS.checkbox + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.checkboxround}"><svg name="Checkmark" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><polyline stroke="transparent" stroke-width="2" points="3.5 9.5 7 13 15 5"></polyline></g></svg></div></label></div>`;
}
containerhtml += `</div><div word="${word}" rtype="${rtype}" action="remove" class="${BDFDB.disCN.hovercardbutton} remove-word"></div></div>`;
}
containerhtml += `</div>`;
settingspanel.querySelector("." + rtype + "-list").innerHTML = containerhtml;
BDFDB.initElements(settingspanel, this);
this.SettingsUpdated = true;
};
if (action == "add") {
var wordinput = settingspanel.querySelector("#input-" + rtype + "-wordvalue");
@ -209,37 +162,21 @@ class ChatFilter {
};
wordinput.value = null;
replaceinput.value = null;
update = true;
update();
}
}
else if (action == "remove") {
wordvalue = ele.getAttribute("word");
if (wordvalue) {
delete words[wordvalue];
update = true;
update();
}
}
else if (action == "removeall") {
if (confirm("Are you sure you want to remove all added Words from your list?")) {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all added Words from your list?", () => {
words = {};
update = true;
}
}
if (update) {
BDFDB.saveData(rtype, words, this, "words");
words = BDFDB.loadData(rtype, this, "words");
var containerhtml = ``;
for (let word in words) {
containerhtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis}" style="flex: 1 1 auto;">${BDFDB.encodeToHTML(word)} (${BDFDB.encodeToHTML(words[word].replace)})</div>`
for (let config of this.configs) {
containerhtml += `<div class="${BDFDB.disCNS.checkboxcontainer + BDFDB.disCN.marginreset}" style="flex: 0 0 auto;"><label class="${BDFDB.disCN.checkboxwrapper}"><input word="${word}" rtype="${rtype}" config="${config}" type="checkbox" class="${BDFDB.disCNS.checkboxinputdefault + BDFDB.disCN.checkboxinput}"${words[word][config] ? " checked" : ""}><div class="${BDFDB.disCNS.checkbox + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.checkboxround}"><svg name="Checkmark" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><polyline stroke="transparent" stroke-width="2" points="3.5 9.5 7 13 15 5"></polyline></g></svg></div></label></div>`;
}
containerhtml += `</div><div word="${word}" rtype="${rtype}" action="remove" class="${BDFDB.disCN.hovercardbutton} remove-word"></div></div>`;
}
containerhtml += `</div>`;
$(settingspanel).find("." + rtype + "-list").html(containerhtml);
BDFDB.initElements(settingspanel);
update();
});
}
}
@ -251,17 +188,6 @@ class ChatFilter {
BDFDB.saveData(rtype, wordvalue.trim(), this, "replaces");
}
}
updateSettings (settingspanel) {
var settings = {};
for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
let key = input.getAttribute("value");
let rtype = input.getAttribute("rtype");
if (!settings[key]) settings[key] = {};
settings[key][rtype] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
updateConfig (ele) {
var wordvalue = ele.getAttribute("word");
@ -273,35 +199,34 @@ class ChatFilter {
BDFDB.saveData(rtype, words, this, "words");
}
}
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");
}
hideAllMessages () {
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {
this.resetMessage(message);
});
document.querySelectorAll(BDFDB.dotCN.messagegroup).forEach(messageContainer => {
BDFDB.addObserver(this, messageContainer, {name:"messageChangeObserver",multi:true}, {childList:true, characterData:true, subtree:true});
messageContainer.querySelectorAll(BDFDB.dotCNC.messagemarkup + BDFDB.dotCN.messageaccessory).forEach(message => {
this.hideMessage(message);
});
});
processMessage (instance, wrapper) {
wrapper.querySelectorAll(`${BDFDB.dotCNC.messagemarkup + BDFDB.dotCN.messageaccessory}`).forEach(message => {this.hideMessage(message);});
}
processStandardSidebarView (instance, wrapper) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);});
BDFDB.WebModules.forceAllUpdates(this);
}
}
hideMessage (message) {
if (message.tagName && !message.classList.contains("blocked") && !message.classList.contains("censored")) {
var orightml = $(message).html();
if (message.tagName && !BDFDB.containsClass(message, "blocked", "censored", false)) {
var orightml = message.innerHTML;
var newhtml = "";
if (orightml) {
@ -343,13 +268,12 @@ class ChatFilter {
if (blocked) break;
}
if (blocked) {
if (settings.hideMessage.blocked) $(message).hide();
if (settings.hideMessage.blocked) BDFDB.toggleEles(message, false);
newhtml = BDFDB.encodeToHTML(blockedReplace);
$(message)
.html(newhtml)
.addClass("blocked")
.data("newhtmlChatFilter",newhtml)
.data("orightmlChatFilter",orightml);
message.innerHTML = newhtml;
BDFDB.addClass(message, "blocked");
message.ChatFilterOriginalHTML = orightml;
message.ChatFilterNewHTML = newhtml;
this.addClickListener(message, settings.showMessageOnClick.blocked);
}
@ -396,11 +320,10 @@ class ChatFilter {
if (censored) {
newhtml = strings.join("");
$(message)
.html(newhtml)
.addClass("censored")
.data("newhtmlChatFilter",newhtml)
.data("orightmlChatFilter",orightml);
message.innerHTML = newhtml;
BDFDB.addClass(message, "censored");
message.ChatFilterOriginalHTML = orightml;
message.ChatFilterNewHTML = newhtml;
this.addClickListener(message, settings.showMessageOnClick.censored);
}
@ -422,34 +345,28 @@ class ChatFilter {
}
resetMessage (message) {
$(message)
.html($(message).data("orightmlChatFilter"))
.off("click." + this.getName())
.removeClass("blocked")
.removeClass("censored")
.removeClass("revealed");
message.innerHTML = message.ChatFilterOriginalHTML;
BDFDB.removeClass(message, "blocked", "censored", "revealed");
BDFDB.toggleEles(message, true);
delete message.ChatFilterOriginalHTML;
delete message.ChatFilterNewHTML;
message.removeEventListener("click", message.clickChatFilterListener);
}
addClickListener (message, add) {
$(message)
.off("click." + this.getName());
if (add) {
var orightml = $(message).data("orightmlChatFilter");
var newhtml = $(message).data("newhtmlChatFilter");
$(message)
.on("click." + this.getName(), () => {
if ($(message).hasClass("revealed")) {
$(message)
.html(newhtml)
.removeClass("revealed");
}
else {
$(message)
.html(orightml)
.addClass("revealed");
}
});
addClickListener (message, addListener) {
message.removeEventListener("click", message.clickChatFilterListener);
if (addListener) {
message.clickChatFilterListener = () => {
if (BDFDB.containsClass(message, "revealed")) {
BDFDB.removeClass(message, "revealed");
message.innerHTML = message.ChatFilterNewHTML;
}
else {
BDFDB.addClass(message, "revealed");
message.innerHTML = message.ChatFilterOriginalHTML;
}
};
message.addEventListener("click", message.clickChatFilterListener);
}
}
}

View File

@ -1,10 +1,21 @@
//META{"name":"CompleteTimestamps"}*//
class CompleteTimestamps {
getName () {return "CompleteTimestamps";}
getVersion () {return "1.2.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Replace all timestamps with complete timestamps.";}
initConstructor () {
this.languages;
this.patchModules = {
"MessageGroup":["componentDidMount","componentDidUpdate"],
"StandardSidebarView":"componentWillUnmount"
};
this.updateTimestamps = false;
this.languages;
this.defaults = {
settings: {
@ -25,23 +36,15 @@ class CompleteTimestamps {
}
};
}
getName () {return "CompleteTimestamps";}
getDescription () {return "Replace all timestamps with complete timestamps.";}
getVersion () {return "1.2.8";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var settings = BDFDB.getAllData(this, "settings");
var choices = BDFDB.getAllData(this, "choices");
var formats = BDFDB.getAllData(this, "formats");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
let settings = BDFDB.getAllData(this, "settings");
let choices = BDFDB.getAllData(this, "choices");
let formats = BDFDB.getAllData(this, "formats");
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in choices) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${this.defaults.choices[key].description}</h3><div class="${BDFDB.disCN.selectwrap}" style="flex: 1 1 70%;"><div class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}" option="${key}" value="${choices[key]}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal} languageName" style="flex: 1 1 42%; padding:0;">${this.languages[choices[key]].name}</div><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal} languageTimestamp" style="flex: 1 1 58%; padding:0;">${this.getTimestamp(this.languages[choices[key]].id)}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
@ -49,21 +52,20 @@ class CompleteTimestamps {
for (let key in formats) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${this.defaults.formats[key].description}</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" option="${key}" value="${formats[key]}" placeholder="${this.defaults.formats[key].value}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16}"></div></div>`;
}
var infoHidden = BDFDB.loadData("hideInfo", this, "hideInfo");
let infoHidden = BDFDB.loadData("hideInfo", this, "hideInfo");
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.cursorpointer + (infoHidden ? BDFDB.disCN.categorywrappercollapsed : BDFDB.disCN.categorywrapperdefault)} toggle-info" style="flex: 1 1 auto;"><svg class="${BDFDB.disCNS.categoryicontransition + BDFDB.disCNS.directionright + (infoHidden ? BDFDB.disCN.categoryiconcollapsed : BDFDB.disCN.categoryicondefault)}" width="12" height="12" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10"></path></svg><div class="${BDFDB.disCNS.categorycolortransition + BDFDB.disCNS.overflowellipsis + BDFDB.disCN.categorynamecollapsed}" style="flex: 1 1 auto;">Information</div></div>`;
settingshtml += `<div class="DevilBro-settings-inner-list info-container" ${infoHidden ? "style='display:none;'" : ""}>`;
settingshtml += `<div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$hour will be replaced with the current hour</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$minute will be replaced with the current minutes</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$second will be replaced with the current seconds</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$msecond will be replaced with the current milliseconds</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$timemode will change $hour to a 12h format and will be replaced with AM/PM</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$year will be replaced with the current year</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$month will be replaced with the current month</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$day will be replaced with the current day</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$monthnameL will be replaced with the monthname in long format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$monthnameS will be replaced with the monthname in short format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$weekdayL will be replaced with the weekday in long format based on the Discord Language</div><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">$weekdayS will be replaced with the weekday in short format based on the Discord Language</div>`;
settingshtml += `</div></div>`;
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 = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
for (var key in this.languages) {
var isSelected = key == choice ? ` ${BDFDB.disCN.selectselected}` : ``;
let menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
for (let key in this.languages) {
let isSelected = key == choice ? ` ${BDFDB.disCN.selectselected}` : ``;
menuhtml += `<div value="${key}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectoption + isSelected}" style="flex: 1 1 auto; display:flex;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 42%;">${this.languages[key].name}</div><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 58%;">${this.getTimestamp(this.languages[key].id)}</div></div>`
}
menuhtml += `</div></div>`;
return $(menuhtml)[0];
return BDFDB.htmlToElement(menuhtml);
}
processMessageGroup (instance, wrapper) {
for (let stamp of wrapper.querySelectorAll("time[datetime]")) this.changeTimestamp(stamp);
}
processStandardSidebarView (instance, wrapper) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this);
}
}
changeTimestamp (stamp) {
if (!stamp.className || stamp.className.toLowerCase().indexOf("timestamp") == -1 || stamp.classList.contains("complete-timestamp")) return;
if (!stamp.className || stamp.className.toLowerCase().indexOf("timestamp") == -1 || BDFDB.containsClass(stamp, "complete-timestamp")) return;
let time = stamp.getAttribute("datetime");
if (time) {
this.setMaxWidth();
let choice = BDFDB.getData("creationDateLang", this, "choices");
stamp.classList.add("complete-timestamp");
BDFDB.addClass(stamp, "complete-timestamp");
let stampdivider = document.createElement("span");
stampdivider.className = "complete-timestamp-divider arabic-fix";
stampdivider.style.setProperty("display", "inline", "important");
@ -273,24 +241,15 @@ class CompleteTimestamps {
stampdivider.style.setProperty("font-size", "0px", "important");
stampdivider.innerText = "ARABIC FIX";
stamp.parentElement.insertBefore(stampdivider, stamp);
BDFDB.setInnerText(stamp, this.getTimestamp(this.languages[choice].id, time));
BDFDB.setInnerText(stamp, this.getTimestamp(this.languages[BDFDB.getData("creationDateLang", this, "choices")].id, time));
}
}
getMessageGroup (div) {
var messagegroup = null;
while (messagegroup == null || div.parentElement) {
div = div.parentElement;
if (div.classList && div.classList.contains(BDFDB.disCN.messagegroup)) messagegroup = div;
}
return messagegroup;
}
getMessageData (div, messagegroup) {
var pos = Array.from(messagegroup.querySelectorAll("." + div.className.replace(/ /g, "."))).indexOf(div);
var instance = BDFDB.getReactInstance(messagegroup);
let pos = Array.from(messagegroup.querySelectorAll("." + div.className.replace(/ /g, "."))).indexOf(div);
let instance = BDFDB.getReactInstance(messagegroup);
if (!instance) return;
var info = instance.return.stateNode.props.messages;
let info = instance.return.stateNode.props.messages;
return info && pos > -1 ? info[pos] : null;
}
@ -299,9 +258,9 @@ class CompleteTimestamps {
if (typeof time == "string") timeobj = new Date(time);
if (timeobj.toString() == "Invalid Date") timeobj = new Date(parseInt(time));
if (timeobj.toString() == "Invalid Date") return;
var settings = BDFDB.getAllData(this, "settings"), timestring = "";
let settings = BDFDB.getAllData(this, "settings"), timestring = "";
if (languageid != "own") {
var timestamp = [];
let timestamp = [];
if (settings.displayDate) timestamp.push(timeobj.toLocaleDateString(languageid));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeobj.toLocaleTimeString(languageid)) : timeobj.toLocaleTimeString(languageid));
if (settings.otherOrder) timestamp.reverse();
@ -309,9 +268,9 @@ class CompleteTimestamps {
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
}
else {
var ownformat = BDFDB.getData("ownFormat", this, "formats");
let ownformat = BDFDB.getData("ownFormat", this, "formats");
languageid = BDFDB.getDiscordLanguage().id;
var hour = timeobj.getHours(), minute = timeobj.getMinutes(), second = timeobj.getSeconds(), msecond = timeobj.getMilliseconds(), day = timeobj.getDate(), month = timeobj.getMonth()+1, timemode = "";
let hour = timeobj.getHours(), minute = timeobj.getMinutes(), second = timeobj.getSeconds(), msecond = timeobj.getMilliseconds(), day = timeobj.getDate(), month = timeobj.getMonth()+1, timemode = "";
if (ownformat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
@ -339,9 +298,9 @@ class CompleteTimestamps {
}
addLeadingZeros (timestring) {
var chararray = timestring.split("");
var numreg = /[0-9]/;
for (var i = 0; i < chararray.length; i++) {
let chararray = timestring.split("");
let numreg = /[0-9]/;
for (let i = 0; i < chararray.length; i++) {
if (!numreg.test(chararray[i-1]) && numreg.test(chararray[i]) && !numreg.test(chararray[i+1])) chararray[i] = "0" + chararray[i];
}
@ -351,12 +310,12 @@ class CompleteTimestamps {
setMaxWidth () {
if (this.currentMode != BDFDB.getDiscordMode()) {
this.currentMode = BDFDB.getDiscordMode();
var timestamp = document.querySelector(BDFDB.dotCN.messagetimestampcompact);
let timestamp = document.querySelector(BDFDB.dotCN.messagetimestampcompact);
if (timestamp) {
var choice = BDFDB.getData("creationDateLang", this, "choices");
var testtimestamp = $(`<time class="${timestamp.className}" style="width: auto !important;">${this.getTimestamp(this.languages[choice].id, new Date(253402124399995))}</time>`);
$(testtimestamp).appendTo(document.body);
var width = testtimestamp.outerWidth() + 5;
let choice = BDFDB.getData("creationDateLang", this, "choices");
let testtimestamp = BDFDB.htmlToElement(`<time class="${timestamp.className}" style="width: auto !important;">${this.getTimestamp(this.languages[choice].id, new Date(253402124399995))}</time>`);
document.body.appendChild(testtimestamp);
let width = BDFDB.getRects(testtimestamp).width + 5;
testtimestamp.remove();
BDFDB.appendLocalStyle(this.getName() + "CompactCorrection", `
${BDFDB.dotCN.messagetimestampcompact} {
@ -374,9 +333,7 @@ class CompleteTimestamps {
}
`);
}
else {
BDFDB.removeLocalStyle(this.getName() + "CompactCorrection");
}
else BDFDB.removeLocalStyle(this.getName() + "CompactCorrection");
}
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"CreationDate"}*//
class CreationDate {
getName () {return "CreationDate";}
getVersion () {return "1.2.4";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays the Creation Date of an Account in the UserPopout and UserModal.";}
initConstructor () {
this.labels = {};
@ -46,14 +54,6 @@ class CreationDate {
}
};
}
getName () {return "CreationDate";}
getDescription () {return "Displays the Creation Date of an Account in the UserPopout and UserModal.";}
getVersion () {return "1.2.3";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -61,26 +61,22 @@ class CreationDate {
let choices = BDFDB.getAllData(this, "choices");
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in choices) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${this.defaults.choices[key].description}</h3><div class="${BDFDB.disCN.selectwrap}" style="flex: 1 1 70%;"><div class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}" type="${key}" value="${choices[key]}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal} languageName" style="flex: 1 1 42%; padding:0;">${this.languages[choices[key]].name}</div><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal} languageTimestamp" style="flex: 1 1 58%; padding:0;">${this.getCreationTime(this.languages[choices[key]].id)}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
}
settingshtml += `</div></div>`;
let settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", BDFDB.dotCN.switchinner, () => {
this.updateSettings(settingspanel);
let choices = BDFDB.getAllData(this, "choices");
for (let key in choices) {
settingspanel.querySelector(`${BDFDB.dotCN.select}[type='${key}'] .languageTimestamp`).innerText = this.getCreationTime(this.languages[choices[key]].id);
}
})
.on("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu(e);});
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {
let choices = BDFDB.getAllData(this, "choices");
for (let key in choices) settingspanel.querySelector(`${BDFDB.dotCN.select}[type='${key}'] .languageTimestamp`).innerText = this.getCreationTime(this.languages[choices[key]].id);
});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(e);});
return settingspanel;
}
@ -88,23 +84,25 @@ class CreationDate {
load () {}
start () {
let libraryScript = null;
if (typeof BDFDB !== "object" || BDFDB.isLibraryOutdated()) {
if (typeof BDFDB === "object") BDFDB = "";
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") 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.languages = Object.assign({},BDFDB.languages);
@ -118,7 +116,7 @@ class CreationDate {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".creationDate");
BDFDB.unloadMessage(this);
}
@ -126,52 +124,49 @@ class CreationDate {
// begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
openDropdownMenu (e) {
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");
let type = selectWrap.getAttribute("type");
let selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
let selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"));
selectWrap.appendChild(selectMenu);
$(selectMenu).on("mousedown." + this.getName(), BDFDB.dotCN.selectoption, (e2) => {
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.getCreationTime(language);
BDFDB.saveData(type, 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, type) {
createDropdownMenu (choice) {
let menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
for (let key in this.languages) {
let isSelected = key == choice ? ` ${BDFDB.disCN.selectselected}` : ``;
menuhtml += `<div value="${key}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectoption + isSelected}" style="flex: 1 1 auto; display:flex;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 42%;">${this.languages[key].name}</div><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 58%;">${this.getCreationTime(this.languages[key].id)}</div></div>`
}
menuhtml += `</div></div>`;
return $(menuhtml)[0];
return BDFDB.htmlToElement(menuhtml);
}
processUserPopout (instance, wrapper) {
@ -188,15 +183,14 @@ class CreationDate {
addCreationDate (info, container, popout) {
if (!info || !container || container.querySelector(".creationDate")) return;
let creationDate = $(this.creationDateMarkup);
let choice = BDFDB.getData("creationDateLang", this, "choices");
let nametag = container.querySelector(BDFDB.dotCN.nametag);
let joinedAtDate = container.querySelector(".joinedAtDate");
container.insertBefore($(`<div class="creationDate DevilBro-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container).getBoundingClientRect().width - 20}px !important;"><div class="DevilBro-textscroll">${this.labels.createdat_text + " " + this.getCreationTime(this.languages[choice].id, info.createdAt)}</div></div>`)[0], joinedAtDate ? joinedAtDate.nextSibling : (nametag ? nametag.nextSibling : null));
container.insertBefore(BDFDB.htmlToElement(`<div class="creationDate DevilBro-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important;"><div class="DevilBro-textscroll">${this.labels.createdat_text + " " + this.getCreationTime(this.languages[choice].id, info.createdAt)}</div></div>`), joinedAtDate ? joinedAtDate.nextSibling : (nametag ? nametag.nextSibling : null));
BDFDB.initElements(container.parentElement);
if (popout && popout.style.transform.indexOf("translateY(-1") == -1) {
let arect = document.querySelector(BDFDB.dotCN.appmount).getBoundingClientRect();
let prect = popout.getBoundingClientRect();
let arect = BDFDB.getRects(document.querySelector(BDFDB.dotCN.appmount));
let prect = BDFDB.getRects(popout);
popout.style.setProperty("top", (prect.y + prect.height > arect.height ? (arect.height - prect.height) : prect.y) + "px");
}
}

View File

@ -201,7 +201,7 @@ class DisplayServersAsChannels {
start () {
var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
if ((!global.BDFDB || typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) && !(libraryScript && performance.now() - libraryScript.getAttribute("date") < 600000)) {
if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");

View File

@ -1,6 +1,14 @@
//META{"name":"EditChannels"}*//
class EditChannels {
getName () {return "EditChannels";}
getVersion () {return "3.8.8";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to rename and recolor channelnames.";}
initConstructor () {
this.labels = {};
@ -96,37 +104,27 @@ class EditChannels {
}
};
}
getName () {return "EditChannels";}
getDescription () {return "Allows you to rename and recolor channelnames.";}
getVersion () {return "3.8.7";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Reset all Channels.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
settingshtml += `</div></div>`;
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("click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all channels?", () => {
BDFDB.removeAllData(this, "channels");
BDFDB.WebModules.forceAllUpdates(this);
});
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all channels?", () => {
BDFDB.removeAllData(this, "channels");
BDFDB.WebModules.forceAllUpdates(this);
});
});
return settingspanel;
}
@ -134,22 +132,25 @@ class EditChannels {
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.UserUtils = BDFDB.WebModules.findByProperties("getUsers","getUser");
@ -166,7 +167,7 @@ class EditChannels {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
let data = BDFDB.loadAllData(this, "channels");
BDFDB.removeAllData(this, "channels");
BDFDB.WebModules.forceAllUpdates(this);
@ -179,15 +180,6 @@ class EditChannels {
// 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.updateChannels = true;
}
changeLanguageStrings () {
this.channelContextEntryMarkup = this.channelContextEntryMarkup.replace("REPLACE_context_localchannelsettings_text", this.labels.context_localchannelsettings_text);
@ -202,78 +194,79 @@ class EditChannels {
onChannelContextMenu (instance, menu) {
if (instance.props && instance.props.channel && !menu.querySelector(".localchannelsettings-item")) {
$(menu).append(this.channelContextEntryMarkup)
.on("mouseenter", ".localchannelsettings-item", (e) => {
var channelContextSubMenu = $(this.channelContextSubMenuMarkup);
channelContextSubMenu
.on("click", ".channelsettings-item", () => {
$(menu).hide();
this.showChannelSettings(instance.props.channel);
});
if (BDFDB.loadData(instance.props.channel.id, this, "channels")) {
channelContextSubMenu
.find(".resetsettings-item")
.removeClass(BDFDB.disCN.contextmenuitemdisabled)
.on("click", () => {
$(menu).hide();
BDFDB.removeData(instance.props.channel.id, this, "channels");
BDFDB.WebModules.forceAllUpdates(this);
});
}
BDFDB.appendSubMenu(e.currentTarget, channelContextSubMenu);
let channelContextEntry = BDFDB.htmlToElement(this.channelContextEntryMarkup);
menu.appendChild(channelContextEntry);
let settingsitem = channelContextEntry.querySelector(".localchannelsettings-item");
settingsitem.addEventListener("mouseenter", () => {
let channelContextSubMenu = BDFDB.htmlToElement(this.channelContextSubMenuMarkup);
let channelitem = channelContextSubMenu.querySelector(".channelsettings-item");
channelitem.addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.showChannelSettings(instance.props.channel);
});
if (BDFDB.loadData(instance.props.channel.id, this, "channels")) {
let resetitem = channelContextSubMenu.querySelector(".resetsettings-item");
BDFDB.removeClass(resetitem, BDFDB.disCN.contextmenuitemdisabled);
resetitem.addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
BDFDB.removeData(instance.props.channel.id, this, "channels");
BDFDB.WebModules.forceAllUpdates(this);
});
}
BDFDB.appendSubMenu(settingsitem, channelContextSubMenu);
});
}
}
showChannelSettings (info) {
var {name,color} = BDFDB.loadData(info.id, this, "channels") || {}
var channelSettingsModal = $(this.channelSettingsModalMarkup);
channelSettingsModal.find(BDFDB.dotCN.modalguildname).text(info.name);
channelSettingsModal.find("#input-channelname").val(name);
channelSettingsModal.find("#input-channelname").attr("placeholder", info.name);
let channelSettingsModal = BDFDB.htmlToElement(this.channelSettingsModalMarkup);
let channelnameinput = channelSettingsModal.querySelector("#input-channelname");
channelSettingsModal.querySelector(BDFDB.dotCN.modalguildname).innerText = info.name;
channelnameinput.value = name || "";
channelnameinput.setAttribute("placeholder", info.name);
BDFDB.setColorSwatches(channelSettingsModal, color);
BDFDB.appendModal(channelSettingsModal);
channelSettingsModal
.on("click", ".btn-save", (event) => {
event.preventDefault();
name = null;
if (channelSettingsModal.find("#input-channelname").val()) {
if (channelSettingsModal.find("#input-channelname").val().trim().length > 0) {
name = channelSettingsModal.find("#input-channelname").val().trim();
}
}
color = BDFDB.getSwatchColor(channelSettingsModal, 1);
if (color) {
if (color[0] < 30 && color[1] < 30 && color[2] < 30) BDFDB.colorCHANGE(color, 30);
else if (color[0] > 225 && color[1] > 225 && color[2] > 225) BDFDB.colorCHANGE(color, -30);
}
if (name == null && color == null) {
BDFDB.removeData(info.id, this, "channels");
}
else {
BDFDB.saveData(info.id, {name,color}, this, "channels");
}
BDFDB.WebModules.forceAllUpdates(this);
});
BDFDB.addChildEventListener(channelSettingsModal, "click", ".btn-save", e => {
e.preventDefault();
channelSettingsModal.find("#input-channelname").focus();
name = channelnameinput.value.trim();
name = name ? name : null;
color = BDFDB.getSwatchColor(channelSettingsModal, 1);
if (color) {
if (color[0] < 30 && color[1] < 30 && color[2] < 30) color = BDFDB.colorCHANGE(color, 30);
else if (color[0] > 225 && color[1] > 225 && color[2] > 225) color = BDFDB.colorCHANGE(color, -30);
}
if (name == null && color == null) {
BDFDB.removeData(info.id, this, "channels");
}
else {
BDFDB.saveData(info.id, {name,color}, this, "channels");
}
BDFDB.WebModules.forceAllUpdates(this);
});
channelnameinput.focus();
}
processChannelTextArea (instance, wrapper) {
if (instance.props && instance.props.type == "normal" && instance.props.channel && instance.props.channel.type == 0) {
let channel = instance.props.channel;
let channel = BDFDB.getReactValue(instance, "props.channel");
if (channel && channel.type == 0 && instance.props.type == "normal") {
let data = BDFDB.loadData(channel.id, this, "channels") || {};
wrapper.querySelector("textarea").setAttribute("placeholder", BDFDB.LanguageStrings.TEXTAREA_PLACEHOLDER.replace("{{channel}}", "#" + (data.name || channel.name)));
}
}
processAuditLog (instance, wrapper) {
if (instance.props && instance.props.log && instance.props.log.options && instance.props.log.options.channel) {
let channel = BDFDB.getReactValue(instance, "props.log.options.channel");
if (channel) {
let hooks = wrapper.querySelectorAll(BDFDB.dotCN.flexchild + " > span:not(" + BDFDB.dotCN.auditloguserhook + ")");
if (hooks.length > 0) this.changeChannel2(instance.props.log.options.channel, hooks[0].firstChild);
if (hooks.length > 0) this.changeChannel2(channel, hooks[0].firstChild);
}
}
@ -290,11 +283,11 @@ class EditChannels {
}
processHeaderBar (instance, wrapper) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.memoizedProps && fiber.return.memoizedProps.channelId) {
let channel_id = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channelId");
if (channel_id) {
let channelname = wrapper.querySelector(BDFDB.dotCN.channelheaderchannelname);
if (channelname) {
let channel = this.ChannelUtils.getChannel(fiber.return.memoizedProps.channelId);
let channel = this.ChannelUtils.getChannel(channel_id);
if (channel) {
if (channel.type == 0) this.changeChannel(channel, wrapper.querySelector(BDFDB.dotCN.channelheaderchannelname));
else {
@ -312,10 +305,10 @@ class EditChannels {
processClickable (instance, wrapper) {
if (!instance.props || !instance.props.className) return;
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mentionwrapper) > -1 && instance.props.className.indexOf(BDFDB.disCN.mention) == -1) {
let fiber = instance._reactInternalFiber;
if (fiber.memoizedProps && fiber.memoizedProps.children && typeof fiber.memoizedProps.children[0] == "string") {
let channelname = fiber.memoizedProps.children[0].slice(1);
let categoryname = fiber.return && fiber.return.return && fiber.return.return.type && fiber.return.return.type.displayName == "Tooltip" ? fiber.return.return.memoizedProps.text : null;
let children = BDFDB.getReactValue(instance, "_reactInternalFiber.memoizedProps.children");
if (children && typeof children[0] == "string") {
let channelname = children[0].slice(1);
let categoryname = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.type.displayName") == "Tooltip" ? BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.text") : null;
for (let channel of this.CurrentChannelUtils.getChannels(this.LastGuildStore.getGuildId())[0]) {
if (channelname == channel.channel.name) {
let category = categoryname ? this.ChannelUtils.getChannel(channel.channel.parent_id) : null;
@ -328,32 +321,31 @@ class EditChannels {
}
}
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.memoizedProps && fiber.return.memoizedProps.result && fiber.return.memoizedProps.result.type.indexOf("_CHANNEL") != -1) {
this.changeChannel(fiber.return.memoizedProps.result.record, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
if (fiber.return.memoizedProps.result.record.parent_id) {
this.changeChannel(this.ChannelUtils.getChannel(fiber.return.memoizedProps.result.record.parent_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultnote));
let result = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.result");
if (result && result.type.indexOf("_CHANNEL") != -1) {
this.changeChannel(result.record, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
if (result.record.parent_id) {
this.changeChannel(this.ChannelUtils.getChannel(result.record.parent_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultnote));
}
}
}
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.memoizedProps && fiber.return.memoizedProps.channel) {
this.changeChannel(fiber.return.memoizedProps.channel, wrapper.querySelector(BDFDB.dotCN.marginleft4));
if (fiber.return.memoizedProps.category) this.changeChannel(fiber.return.memoizedProps.category, wrapper.querySelector(BDFDB.dotCN.autocompletedescription));
let channel = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channel");
if (channel) {
this.changeChannel(channel, wrapper.querySelector(BDFDB.dotCN.marginleft4));
let category = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.category");
if (category) this.changeChannel(category, wrapper.querySelector(BDFDB.dotCN.autocompletedescription));
}
}
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.messagespopoutchannelname) > -1) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.sibling && fiber.return.sibling.child && fiber.return.sibling.child.child && fiber.return.sibling.child.child.memoizedProps) {
this.changeChannel2(fiber.return.sibling.child.child.memoizedProps.channel, wrapper);
}
let channel = BDFDB.getReactValue(instance, "_reactInternalFiber.return.sibling.child.child.memoizedProps.channel");
if (channel) this.changeChannel2(channel, wrapper);
}
}
processStandardSidebarView (instance, wrapper) {
if (this.updateChannels) {
this.updateChannels = false;
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this);
}
}
@ -366,8 +358,8 @@ class EditChannels {
let color = this.chooseColor(channelname, data.color);
channelname.style.setProperty("color", color, "important");
BDFDB.setInnerText(channelname, data.name || info.name);
let iconparent = channelname.classList && channelname.classList.contains(BDFDB.disCN.quickswitchresultmatch) ? channelname.parentElement.parentElement : channelname.parentElement;
if (channelname.classList && !channelname.classList.contains(BDFDB.disCN.autocompletedescription)) {
let iconparent = BDFDB.containsClass(channelname, BDFDB.disCN.quickswitchresultmatch) ? channelname.parentElement.parentElement : channelname.parentElement;
if (!BDFDB.containsClass(channelname, BDFDB.disCN.autocompletedescription)) {
iconparent.querySelectorAll('svg [stroke]:not([stroke="none"]').forEach(icon => {
if (!icon.getAttribute("oldstroke")) icon.setAttribute("oldstroke", icon.getAttribute("stroke"));
icon.setAttribute("stroke", color && settings.changeChannelIcon ? color : icon.getAttribute("oldstroke"), "important");
@ -385,7 +377,7 @@ class EditChannels {
channelname.EditChannelsChangeObserver = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.type == "childList" && change.addedNodes.length && change.target.tagName && (change.target.tagName == "SVG" || change.target.querySelector("svg")) || change.type == "attributes" && change.attributeName == "class" && change.target.className.length && change.target.className.indexOf("name") > -1 || change.type == "attributes" && change.attributeName == "style" && change.target.classList && change.target.classList.contains(BDFDB.disCN.channelheaderchannelname)) {
if (change.type == "childList" && change.addedNodes.length && change.target.tagName && (change.target.tagName == "SVG" || change.target.querySelector("svg")) || change.type == "attributes" && change.attributeName == "class" && change.target.className.length && change.target.className.indexOf("name") > -1 || change.type == "attributes" && change.attributeName == "style" && BDFDB.containsClass(change.target, BDFDB.disCN.channelheaderchannelname)) {
channelname.EditChannelsChangeObserver.disconnect();
this.changeChannel(info, channelname);
}
@ -421,23 +413,25 @@ class EditChannels {
changeMention (info, mention, categoryinfo) {
if (!info || !mention || !mention.parentElement) return;
if (mention.EditChannelsChangeObserver && typeof mention.EditChannelsChangeObserver.disconnect == "function") mention.EditChannelsChangeObserver.disconnect();
mention.removeEventListener("mouseover", mention.mouseoverListenerEditChannels);
mention.removeEventListener("mouseout", mention.mouseoutListenerEditChannels);
let data = BDFDB.loadData(info.id, this, "channels") || {};
let color = BDFDB.colorCONVERT(data.color, "RGBCOMP");
BDFDB.setInnerText(mention, "#" + (data.name || info.name));
if (mention.EditChannelsHovered) colorHover();
else colorDefault();
$(mention)
.off("mouseenter." + this.getName()).off("mouseleave." + this.getName())
.on("mouseenter." + this.getName(), (e) => {
mention.EditChannelsHovered = true;
colorHover();
let categorydata = BDFDB.loadData(categoryinfo.id, this, "channels") || {};
if (categorydata.name) BDFDB.createTooltip(categorydata.name, mention, {type:"top",selector:"EditChannels-tooltip",css:`body ${BDFDB.dotCN.tooltip}:not(.EditChannels-tooltip) {display: none !important;}`});
})
.on("mouseleave." + this.getName(), (e) => {
mention.EditChannelsHovered = false;
colorDefault();
});
mention.mouseoverListenerEditChannels = () => {
mention.EditChannelsHovered = true;
colorHover();
let categorydata = BDFDB.loadData(categoryinfo.id, this, "channels") || {};
if (categorydata.name) BDFDB.createTooltip(categorydata.name, mention, {type:"top",selector:"EditChannels-tooltip",css:`body ${BDFDB.dotCN.tooltip}:not(.EditChannels-tooltip) {display: none !important;}`});
};
mention.mouseoutListenerEditChannels = () => {
delete mention.EditChannelsHovered;
colorDefault();
};
mention.addEventListener("mouseover", mention.mouseoverListenerEditChannels);
mention.addEventListener("mouseout", mention.mouseoutListenerEditChannels);
mention.EditChannelsChangeObserver = new MutationObserver((changes, _) => {
mention.EditChannelsChangeObserver.disconnect();
this.changeMention(info, mention, categoryinfo);

View File

@ -1,6 +1,14 @@
//META{"name":"EditServers"}*//
class EditServers {
getName () {return "EditServers";}
getVersion () {return "1.9.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to change the icon, name and color of servers.";}
initConstructor () {
this.labels = {};
@ -38,7 +46,7 @@ class EditServers {
<div class="${BDFDB.disCN.modal}">
<div class="${BDFDB.disCN.modalinner}">
<div class="${BDFDB.disCNS.modalsub + BDFDB.disCN.modalsizemedium}">
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto;">
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto; padding-bottom: 10px;">
<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">
<h4 class="${BDFDB.disCNS.h4 + BDFDB.disCNS.headertitle + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.defaultcolor + BDFDB.disCNS.h4defaultmargin + BDFDB.disCN.marginreset}">REPLACE_modal_header_text</h4>
<div class="${BDFDB.disCNS.modalguildname + BDFDB.disCNS.small + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCN.primary}"></div>
@ -50,10 +58,12 @@ class EditServers {
</g>
</svg>
</div>
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.marginbottom8 + BDFDB.disCN.modalsubinner}" style="flex: 0 0 auto;">
<div tab="server" class="tab">REPLACE_modal_tabheader1_text</div>
<div tab="icon" class="tab">REPLACE_modal_tabheader2_text</div>
<div tab="tooltip" class="tab">REPLACE_modal_tabheader3_text</div>
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.marginbottom8 + BDFDB.disCN.tabbarcontainer}" style="flex: 0 0 auto; padding-right: 12px;">
<div class="${BDFDB.disCNS.tabbar + BDFDB.disCN.tabbartop}">
<div tab="server" class="${BDFDB.disCNS.settingsitemdefault + BDFDB.disCNS.settingsitem + BDFDB.disCNS.settingsnotselected + BDFDB.disCN.tabbaritem}">REPLACE_modal_tabheader1_text</div>
<div tab="icon" class="${BDFDB.disCNS.settingsitemdefault + BDFDB.disCNS.settingsitem + BDFDB.disCNS.settingsnotselected + BDFDB.disCN.tabbaritem}">REPLACE_modal_tabheader2_text</div>
<div tab="tooltip" class="${BDFDB.disCNS.settingsitemdefault + BDFDB.disCNS.settingsitem + BDFDB.disCNS.settingsnotselected + BDFDB.disCN.tabbaritem}">REPLACE_modal_tabheader3_text</div>
</div>
</div>
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.themeghosthairline}">
<div class="${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner}">
@ -115,14 +125,6 @@ class EditServers {
</div>
</span>`;
}
getName () {return "EditServers";}
getDescription () {return "Allows you to change the icon, name and color of servers.";}
getVersion () {return "1.8.9";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -130,17 +132,16 @@ class EditServers {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Reset all Servers.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
settingshtml += `</div></div>`;
var settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all servers?", () => {
BDFDB.removeAllData(this, "servers");
BDFDB.WebModules.forceAllUpdates(this);
});
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all servers?", () => {
BDFDB.removeAllData(this, "servers");
BDFDB.WebModules.forceAllUpdates(this);
});
});
return settingspanel;
}
@ -148,22 +149,25 @@ class EditServers {
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.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
@ -176,7 +180,7 @@ class EditServers {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
let data = BDFDB.loadAllData(this, "servers");
BDFDB.removeAllData(this, "servers");
BDFDB.WebModules.forceAllUpdates(this);
@ -212,160 +216,133 @@ class EditServers {
onGuildContextMenu (instance, menu) {
if (instance.props && instance.props.target && instance.props.guild && !menu.querySelector(".localserversettings-item")) {
$(this.serverContextEntryMarkup).appendTo(menu)
.on("mouseenter", ".localserversettings-item", (e) => {
var serverContextSubMenu = $(this.serverContextSubMenuMarkup);
serverContextSubMenu
.on("click", ".serversettings-item", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.showServerSettings(instance.props.guild);
});
if (BDFDB.loadData(instance.props.guild.id, this, "servers")) {
serverContextSubMenu
.find(".resetsettings-item")
.removeClass(BDFDB.disCN.contextmenuitemdisabled)
.on("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
BDFDB.removeData(instance.props.guild.id, this, "servers");
BDFDB.WebModules.forceAllUpdates(this);
});
}
BDFDB.appendSubMenu(e.currentTarget, serverContextSubMenu);
let serverContextEntry = BDFDB.htmlToElement(this.serverContextEntryMarkup);
menu.appendChild(serverContextEntry);
let settingsitem = serverContextEntry.querySelector(".localserversettings-item");
settingsitem.addEventListener("mouseenter", () => {
let serverContextSubMenu = BDFDB.htmlToElement(this.serverContextSubMenuMarkup);
let serveritem = serverContextSubMenu.querySelector(".serversettings-item");
serveritem.addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.showServerSettings(instance.props.guild);
});
if (BDFDB.loadData(instance.props.guild.id, this, "servers")) {
let resetitem = serverContextSubMenu.querySelector(".resetsettings-item");
BDFDB.removeClass(resetitem, BDFDB.disCN.contextmenuitemdisabled);
resetitem.addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
BDFDB.removeData(instance.props.guild.id, this, "servers");
BDFDB.WebModules.forceAllUpdates(this);
});
}
BDFDB.appendSubMenu(settingsitem, serverContextSubMenu);
});
}
}
showServerSettings (info) {
var {name,shortName,url,removeIcon,color1,color2,color3,color4} = BDFDB.loadData(info.id, this, "servers") || {};
var serverSettingsModal = $(this.serverSettingsModalMarkup);
serverSettingsModal.find(BDFDB.dotCN.modalguildname).text(info.name);
serverSettingsModal.find("#input-servername").val(name);
serverSettingsModal.find("#input-servername").attr("placeholder", info.name);
serverSettingsModal.find("#input-servershortname").val(shortName || (info.icon ? "" : info.acronym));
serverSettingsModal.find("#input-servershortname").attr("placeholder", info.acronym);
serverSettingsModal.find("#input-serverurl").val(url);
serverSettingsModal.find("#input-serverurl").attr("placeholder", info.icon ? "https://cdn.discordapp.com/icons/" + info.id + "/" + info.icon + ".png" : null);
serverSettingsModal.find("#input-serverurl").addClass(url ? "valid" : "");
serverSettingsModal.find("#input-serverurl").prop("disabled", removeIcon);
serverSettingsModal.find("#input-removeicon").prop("checked", removeIcon);
let serverSettingsModal = BDFDB.htmlToElement(this.serverSettingsModalMarkup);
let servernameinput = serverSettingsModal.querySelector("#input-servername");
let servershortnameinput = serverSettingsModal.querySelector("#input-servershortname");
let serverurlinput = serverSettingsModal.querySelector("#input-serverurl");
let removeiconinput = serverSettingsModal.querySelector("#input-removeicon");
serverSettingsModal.querySelector(BDFDB.dotCN.modalguildname).innerText = info.name;
servernameinput.value = name || "";
servernameinput.setAttribute("placeholder", info.name);
servershortnameinput.value = shortName || (info.icon ? "" : info.acronym);
servershortnameinput.setAttribute("placeholder", info.acronym);
serverurlinput.value = url || "";
serverurlinput.setAttribute("placeholder", BDFDB.getGuildIcon(info.id) || "");
BDFDB.toggleClass(serverurlinput, "valid", serverurlinput.value.length > 0);
serverurlinput.disabled = removeIcon;
removeiconinput.checked = removeIcon;
BDFDB.setColorSwatches(serverSettingsModal, color1);
BDFDB.setColorSwatches(serverSettingsModal, color2);
BDFDB.setColorSwatches(serverSettingsModal, color3);
BDFDB.setColorSwatches(serverSettingsModal, color4);
BDFDB.appendModal(serverSettingsModal);
serverSettingsModal
.on("click", "#input-removeicon", (e) => {
serverSettingsModal.find("#input-serverurl").prop("disabled", e.currentTarget.checked);
})
.on("change keyup paste", "#input-serverurl", (e) => {
this.checkUrl(e.currentTarget);
})
.on("mouseenter", "#input-serverurl", (e) => {
e.currentTarget.classList.add("hovering");
this.createNoticeTooltip(e.currentTarget);
})
.on("mouseleave", "#input-serverurl", (e) => {
e.currentTarget.classList.remove("hovering");
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
})
.on("click", ".btn-save", (e) => {
e.preventDefault();
name = null;
if (serverSettingsModal.find("#input-servername").val() && serverSettingsModal.find("#input-servername").val().trim().length > 0) {
name = serverSettingsModal.find("#input-servername").val().trim();
}
shortName = null;
if (serverSettingsModal.find("#input-servershortname").val() && serverSettingsModal.find("#input-servershortname").val().trim().length > 0) {
shortName = serverSettingsModal.find("#input-servershortname").val().trim();
shortName = shortName == info.acronym ? null : shortName;
}
removeIcon = serverSettingsModal.find("#input-removeicon").prop("checked");
if (serverSettingsModal.find("#input-serverurl:not('.invalid')").length > 0) {
url = null;
if (!removeIcon && serverSettingsModal.find("#input-serverurl").val() && serverSettingsModal.find("#input-serverurl").val().trim().length > 0) {
url = serverSettingsModal.find("#input-serverurl").val().trim();
}
}
color1 = BDFDB.getSwatchColor(serverSettingsModal, 1);
color2 = BDFDB.getSwatchColor(serverSettingsModal, 2);
color3 = BDFDB.getSwatchColor(serverSettingsModal, 3);
color4 = BDFDB.getSwatchColor(serverSettingsModal, 4);
if (name == null && shortName == null && url == null && !removeIcon && color1 == null && color2 == null && color3 == null && color4 == null) {
BDFDB.removeData(info.id, this, "servers");
}
else {
BDFDB.saveData(info.id, {name,shortName,url,removeIcon,color1,color2,color3,color4}, this, "servers");
}
BDFDB.WebModules.forceAllUpdates(this);
});
serverSettingsModal.find("#input-servername").focus();
removeiconinput.addEventListener("click", e => {
serverurlinput.disabled = e.currentTarget.checked;
});
serverurlinput.addEventListener("change keyup paste", e => {
this.checkUrl(e.currentTarget);
});
serverurlinput.addEventListener("mouseenter", e => {
BDFDB.addClass(e.currentTarget, "hovering");
this.createNoticeTooltip(e.currentTarget);
});
serverurlinput.addEventListener("mouseleave", e => {
BDFDB.removeClass(e.currentTarget, "hovering");
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
});
BDFDB.addChildEventListener(serverSettingsModal, "click", ".btn-save", e => {
e.preventDefault();
name = servernameinput.value.trim();
name = name ? name : null;
shortName = servershortnameinput.value.trim();
shortName = shortName && shortName != info.acronym ? shortName : null;
removeIcon = removeiconinput.checked;
url = !removeIcon && BDFDB.containsClass(serverurlinput, "valid") ? serverurlinput.value.trim() : null;
url = url ? url : null;
color1 = BDFDB.getSwatchColor(serverSettingsModal, 1);
color2 = BDFDB.getSwatchColor(serverSettingsModal, 2);
color3 = BDFDB.getSwatchColor(serverSettingsModal, 3);
color4 = BDFDB.getSwatchColor(serverSettingsModal, 4);
if (name == null && shortName == null && url == null && !removeIcon && color1 == null && color2 == null && color3 == null && color4 == null) {
BDFDB.removeData(info.id, this, "servers");
}
else {
BDFDB.saveData(info.id, {name,shortName,url,removeIcon,color1,color2,color3,color4}, this, "servers");
}
BDFDB.WebModules.forceAllUpdates(this);
});
servernameinput.focus();
}
checkUrl (input) {
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
if (!input.value) {
input.classList.remove("valid");
input.classList.remove("invalid");
BDFDB.removeClass(input, "valid");
BDFDB.removeClass(input, "invalid");
}
else {
require("request")(input.value, (error, response, result) => {
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
input.classList.add("valid");
input.classList.remove("invalid");
BDFDB.addClass(input, "valid");
BDFDB.removeClass(input, "invalid");
}
else {
input.classList.remove("valid");
input.classList.add("invalid");
BDFDB.removeClass(input, "valid");
BDFDB.addClass(input, "invalid");
}
if (input.classList.contains("hovering")) this.createNoticeTooltip(input);
if (BDFDB.containsClass(input, "hovering")) this.createNoticeTooltip(input);
});
}
}
createNoticeTooltip (input) {
var disabled = input.disabled;
var valid = input.classList.contains("valid");
var invalid = input.classList.contains("invalid");
var valid = BDFDB.containsClass(input, "valid");
var invalid = BDFDB.containsClass(input, "invalid");
if (disabled || valid || invalid) {
BDFDB.createTooltip(disabled ? this.labels.modal_ignoreurl_text : valid ? this.labels.modal_validurl_text : this.labels.modal_invalidurl_text, input, {type:"right",selector:"notice-tooltip",color: disabled ? "black" : invalid ? "red" : "green"});
}
}
loadServer (serverObj) {
if (typeof serverObj !== "object" || !serverObj) return;
var data = BDFDB.loadData(serverObj.id, this, "servers");
if (data) {
var name = data.name ? data.name : serverObj.name;
var bgImage = data.url ? ("url(" + data.url + ")") : (serverObj.icon ? "url('https://cdn.discordapp.com/icons/" + serverObj.id + "/" + serverObj.icon + ".png')" : "");
var removeIcon = data.removeIcon;
var shortName = data.shortName ? data.shortName : (serverObj.icon && !removeIcon ? "" : serverObj.data.acronym);
var color1 = data.color1 ? BDFDB.colorCONVERT(data.color1, "RGB") : "";
var color2 = data.color2 ? BDFDB.colorCONVERT(data.color2, "RGB") : "";
$(serverObj.div)
.off("mouseenter." + this.getName())
.on("mouseenter." + this.getName(), () => {this.createServerToolTip(serverObj);})
.attr("custom-editservers", true)
.find(BDFDB.dotCN.avataricon)
.text(bgImage && !removeIcon ? "" : shortName)
.addClass(removeIcon || !bgImage ? BDFDB.disCN.avatarnoicon : "")
.removeClass(!removeIcon && bgImage ? BDFDB.disCN.avatarnoicon : "")
.css("font-size", removeIcon || !bgImage ? "10px" : "")
.css("background-image", removeIcon ? "" : bgImage)
.css("background-color", color1)
.css("color", color2);
}
}
processGuildIcon (instance, wrapper) {
if (instance.props && instance.props.guild) {
let icon = wrapper.classList && wrapper.classList.contains(BDFDB.disCN.avataricon) ? wrapper : wrapper.querySelector(BDFDB.dotCN.avataricon);
let icon = wrapper.classList && BDFDB.containsClass(wrapper, BDFDB.disCN.avataricon) ? wrapper : wrapper.querySelector(BDFDB.dotCN.avataricon);
if (!icon) return;
this.changeGuildIcon(instance.props.guild, icon);
if (BDFDB.getParentEle(BDFDB.dotCN.guild, icon)) this.changeTooltip(instance.props.guild, wrapper, "right");
@ -382,18 +359,18 @@ class EditServers {
processClickable (instance, wrapper) {
if (!wrapper || !instance.props || !instance.props.className) return;
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.userprofilelistrow) > -1) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.type && fiber.return.type.displayName == "GuildRow" && fiber.return.memoizedProps && fiber.return.memoizedProps.guild) {
this.changeGuildName(fiber.return.memoizedProps.guild, wrapper.querySelector(BDFDB.dotCN.userprofilelistname));
let guild = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.guild");
if (guild && BDFDB.getReactValue(instance, "_reactInternalFiber.return.type.displayName") == "GuildRow") {
this.changeGuildName(guild, wrapper.querySelector(BDFDB.dotCN.userprofilelistname));
}
}
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.memoizedProps && fiber.return.memoizedProps.result && fiber.return.memoizedProps.result.type == "GUILD") {
this.changeGuildName(fiber.return.memoizedProps.result.record, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
let result = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.result");
if (result && result.type == "GUILD") {
this.changeGuildName(result.record, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
}
else if (fiber.return && fiber.return.memoizedProps && fiber.return.memoizedProps.result && fiber.return.memoizedProps.result.type.indexOf("_CHANNEL") != -1 && fiber.return.memoizedProps.result.record && fiber.return.memoizedProps.result.record.guild_id) {
this.changeGuildName(this.GuildUtils.getGuild(fiber.return.memoizedProps.result.record.guild_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultmisccontainer));
else if (result && result.type.indexOf("_CHANNEL") != -1 && result.record && result.record.guild_id) {
this.changeGuildName(this.GuildUtils.getGuild(result.record.guild_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultmisccontainer));
}
}
}
@ -402,14 +379,18 @@ class EditServers {
if (!info || !guildname || !guildname.parentElement) return;
if (guildname.EditServersChangeObserver && typeof guildname.EditServersChangeObserver.disconnect == "function") guildname.EditServersChangeObserver.disconnect();
let data = BDFDB.loadData(info.id, this, "servers") || {};
guildname.style.setProperty("color", BDFDB.colorCONVERT(data.color2, "RGB"), "important");
BDFDB.setInnerText(guildname, data.name || info.name);
if (!BDFDB.isObjectEmpty(data)) {
guildname.EditServersChangeObserver = new MutationObserver((changes, _) => {
guildname.EditServersChangeObserver.disconnect();
this.changeName(info, guildname);
});
guildname.EditServersChangeObserver.observe(guildname, {attributes:true});
if (data.name || data.color2 || guildname.getAttribute("changed-by-editservers")) {
guildname.style.setProperty("color", BDFDB.colorCONVERT(data.color2, "RGB"), "important");
BDFDB.setInnerText(guildname, data.name || info.name);
if (data.name || data.color2) {
guildname.setAttribute("changed-by-editservers", true);
guildname.EditServersChangeObserver = new MutationObserver((changes, _) => {
guildname.EditServersChangeObserver.disconnect();
this.changeName(info, guildname);
});
guildname.EditServersChangeObserver.observe(guildname, {attributes:true});
}
else guildname.removeAttribute("changed-by-editservers");
}
}
@ -417,65 +398,65 @@ class EditServers {
if (!info || !icon || !icon.parentElement) return;
if (icon.EditServersChangeObserver && typeof icon.EditServersChangeObserver.disconnect == "function") icon.EditServersChangeObserver.disconnect();
let data = BDFDB.loadData(info.id, this, "servers") || {};
let url = data.url || BDFDB.getGuildIcon(info.id);
if (icon.tagName == "IMG") icon.setAttribute("src", data.removeIcon || data.shortName ? null : url);
else {
BDFDB.setInnerText(icon, data.url ? "" : (data.shortName || (info.icon && !data.removeIcon ? "" : info.acronym)));
icon.style.setProperty("background-image", data.removeIcon || data.shortName ? null : (url ? `url(${url})` : null), "important");
icon.style.setProperty("background-color", BDFDB.colorCONVERT(data.color1, "RGB"), "important");
icon.style.setProperty("color", BDFDB.colorCONVERT(data.color2, "RGB", "important"));
icon.style.setProperty("font-size", this.getFontSize(icon));
let hasicon = icon.style.getPropertyValue("background-image");
for (let noiconclass of this.getNoIconClasses(icon)) {
if (hasicon) icon.classList.remove(noiconclass);
else icon.classList.add(noiconclass);
}
if (data.url && !data.removeIcon) {
icon.style.setProperty("background-position", "center");
icon.style.setProperty("background-size", "cover");
}
if (data.url || data.removeIcon || icon.getAttribute("changed-by-editservers")) {
if (icon.tagName == "IMG") icon.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.getGuildIcon(info.id)));
else {
icon.style.removeProperty("background-position");
icon.style.removeProperty("background-size");
BDFDB.setInnerText(icon, data.url ? "" : (data.shortName || (info.icon && !data.removeIcon ? "" : info.acronym)));
icon.style.setProperty("background-image", data.removeIcon || data.shortName ? null : (url ? `url(${data.url || BDFDB.getUserAvatar(info.id)})` : null));
icon.style.setProperty("background-color", BDFDB.colorCONVERT(data.color1, "RGB"), "important");
icon.style.setProperty("color", BDFDB.colorCONVERT(data.color2, "RGB", "important"));
icon.style.setProperty("font-size", this.getFontSize(icon));
let hasicon = icon.style.getPropertyValue("background-image");
if (hasicon) BDFDB.removeClass(icon, this.getNoIconClasses(icon));
else BDFDB.addClass(icon, this.getNoIconClasses(icon));
if (data.url && !data.removeIcon) {
icon.style.setProperty("background-position", "center");
icon.style.setProperty("background-size", "cover");
}
}
}
if (!BDFDB.isObjectEmpty(data)) {
icon.EditServersChangeObserver = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
icon.EditServersChangeObserver.disconnect();
this.changeGuildIcon(info, icon);
}
);
});
icon.EditServersChangeObserver.observe(icon, {attributes:true});
if (data.url || data.removeIcon) {
icon.setAttribute("changed-by-editservers", true);
icon.EditServersChangeObserver = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
icon.EditServersChangeObserver.disconnect();
this.changeGuildIcon(info, icon);
}
);
});
icon.EditServersChangeObserver.observe(icon, {attributes:true});
}
else icon.removeAttribute("changed-by-editservers");
}
}
changeTooltip (info, wrapper, type) {
if (!info || !wrapper || !wrapper.parentElement) return;
let data = BDFDB.loadData(info.id, this, "servers") || {};
$(wrapper).off("mouseenter." + this.getName());
if (data.name || data.color3 || data.color4) $(wrapper).on("mouseenter." + this.getName(), () => {
wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditServers);
if (data.name || data.color3 || data.color4) {
var bgColor = data.color3 ? BDFDB.colorCONVERT(data.color3, "RGB") : "";
var fontColor = data.color4 ? BDFDB.colorCONVERT(data.color4, "RGB") : "";
BDFDB.createTooltip(data.name || info.name, wrapper, {type,selector:"EditServers-tooltip",style:`color: ${fontColor} !important; background-color: ${bgColor} !important; border-color: ${bgColor} !important;`,css:`body ${BDFDB.dotCN.tooltip}:not(.EditServers-tooltip) {display: none !important;}`});
});
wrapper.tooltipListenerEditServers = () => {
BDFDB.createTooltip(data.name || info.name, wrapper, {type,selector:"EditServers-tooltip",style:`color: ${fontColor} !important; background-color: ${bgColor} !important; border-color: ${bgColor} !important;`,css:`body ${BDFDB.dotCN.tooltip}:not(.EditServers-tooltip) {display: none !important;}`});
};
wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditServers);
}
}
getFontSize (icon) {
if (icon.style.getPropertyValue("background-image")) return null;
else if (icon.classList.contains(BDFDB.disCN.avatariconsizexlarge)) return "12px";
else if (icon.classList.contains(BDFDB.disCN.avatariconsizelarge)) return "10px";
else if (icon.classList.contains(BDFDB.disCN.avatariconsizemedium)) return "8px";
else if (icon.classList.contains(BDFDB.disCN.avatariconsizesmall)) return "4.8px";
else if (icon.classList.contains(BDFDB.disCN.avatariconsizemini)) return "4px";
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizexlarge)) return "12px";
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizelarge)) return "10px";
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizemedium)) return "8px";
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizesmall)) return "4.8px";
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizemini)) return "4px";
else return "10px";
}
getNoIconClasses (icon) {
let noiconclasses = [BDFDB.disCN.avatarnoicon];
if (icon.classList.contains(BDFDB.disCN.userprofilelistavatar)) noiconclasses.push(BDFDB.disCN.userprofilelistguildavatarwithouticon);
if (BDFDB.containsClass(icon, BDFDB.disCN.userprofilelistavatar)) noiconclasses.push(BDFDB.disCN.userprofilelistguildavatarwithouticon);
return noiconclasses;
}

View File

@ -3,11 +3,11 @@
class EditUsers {
getName () {return "EditUsers";}
getVersion () {return "3.2.2";}
getVersion () {return "3.2.3";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to change the icon, name, tag and color of users. Does not work in compact mode.";}
getDescription () {return "Allows you to change the icon, name, tag and color of users.";}
initConstructor () {
this.labels = {};
@ -196,13 +196,12 @@ class EditUsers {
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all users?", () => {
BDFDB.removeAllData(this, "users");
BDFDB.WebModules.forceAllUpdates(this);
});
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all users?", () => {
BDFDB.removeAllData(this, "users");
BDFDB.WebModules.forceAllUpdates(this);
});
});
return settingspanel;
}
@ -210,22 +209,25 @@ class EditUsers {
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.RelationshipUtils = BDFDB.WebModules.findByProperties("isBlocked", "isFriend");
@ -244,7 +246,7 @@ class EditUsers {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
let data = BDFDB.loadAllData(this, "users");
BDFDB.removeAllData(this, "users");
BDFDB.WebModules.forceAllUpdates(this);
@ -284,26 +286,25 @@ class EditUsers {
if (instance.props && instance.props.user && !menu.querySelector(".localusersettings-item")) {
let userContextEntry = BDFDB.htmlToElement(this.userContextEntryMarkup);
menu.appendChild(userContextEntry);
$(userContextEntry)
.on("mouseenter." + this.getName(), ".localusersettings-item", e => {
var userContextSubMenu = BDFDB.htmlToElement(this.userContextSubMenuMarkup);
$(userContextSubMenu)
.on("click", ".usersettings-item", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.showUserSettings(instance.props.user);
});
if (BDFDB.loadData(instance.props.user.id, this, "users")) {
$(userContextSubMenu)
.find(".resetsettings-item")
.removeClass(BDFDB.disCN.contextmenuitemdisabled)
.on("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
BDFDB.removeData(instance.props.user.id, this, "users");
BDFDB.WebModules.forceAllUpdates(this);
});
}
BDFDB.appendSubMenu(e.currentTarget, userContextSubMenu);
let settingsitem = userContextEntry.querySelector(".localusersettings-item");
settingsitem.addEventListener("mouseenter", () => {
let userContextSubMenu = BDFDB.htmlToElement(this.userContextSubMenuMarkup);
let useritem = userContextSubMenu.querySelector(".usersettings-item");
useritem.addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.showUserSettings(instance.props.user);
});
if (BDFDB.loadData(instance.props.user.id, this, "users")) {
let resetitem = userContextSubMenu.querySelector(".resetsettings-item");
BDFDB.removeClass(resetitem, BDFDB.disCN.contextmenuitemdisabled);
resetitem.addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
BDFDB.removeData(instance.props.user.id, this, "users");
BDFDB.WebModules.forceAllUpdates(this);
});
}
BDFDB.appendSubMenu(settingsitem, userContextSubMenu);
});
}
}
@ -325,7 +326,7 @@ class EditUsers {
usertaginput.value = tag || "";
userurlinput.value = url || "";
userurlinput.setAttribute("placeholder", BDFDB.getUserAvatar(info.id) || "");
userurlinput.classList.toggle("valid", userurlinput.value);
BDFDB.toggleClass(userurlinput, "valid", userurlinput.value.length > 0);
userurlinput.disabled = removeIcon;
removeiconinput.checked = removeIcon;
ignoretagcolorinput.checked = ignoreTagColor;
@ -336,86 +337,84 @@ class EditUsers {
let ignoredswatches = userSettingsModal.querySelectorAll(".swatches[swatchnr='3'], .swatches[swatchnr='4']");
ignoredswatches.forEach(swatches => {swatches.classList.toggle("disabled", ignoretagcolorinput.checked);});
BDFDB.toggleClass(ignoredswatches, "disabled", ignoretagcolorinput.checked);
BDFDB.appendModal(userSettingsModal);
$(userSettingsModal)
.on("click", "#input-removeicon", e => {
userurlinput.disabled = e.currentTarget.checked;
})
.on("click", "#input-ignoretagcolor", e => {
ignoredswatches.forEach(swatches => {swatches.classList.toggle("disabled", e.currentTarget.checked);});
})
.on("change keyup paste", "#input-userurl", e => {
this.checkUrl(e.currentTarget);
})
.on("mouseenter", "#input-userurl", e => {
e.currentTarget.classList.add("hovering");
this.createNoticeTooltip(e.currentTarget);
})
.on("mouseleave", "#input-userurl", e => {
e.currentTarget.classList.remove("hovering");
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
})
.on("click", ".btn-save", e => {
e.preventDefault();
name = usernameinput.value.trim();
name = name ? name : null;
tag = usertaginput.value.trim();
tag = tag ? tag : null;
removeIcon = removeiconinput.checked;
ignoreTagColor = ignoretagcolorinput.checked;
url = !removeIcon && userurlinput.classList.contains("valid") ? userurlinput.value.trim() : null;
url = url ? url : null;
color1 = BDFDB.getSwatchColor(userSettingsModal, 1);
color2 = BDFDB.getSwatchColor(userSettingsModal, 2);
color3 = BDFDB.getSwatchColor(userSettingsModal, 3);
color4 = BDFDB.getSwatchColor(userSettingsModal, 4);
if (name == null && tag == null && url == null && !removeIcon && !ignoreTagColor && color1 == null && color2 == null && color3 == null && color4 == null) {
BDFDB.removeData(info.id, this, "users")
}
else {
BDFDB.saveData(info.id, {name,tag,url,removeIcon,ignoreTagColor,color1,color2,color3,color4}, this, "users");
}
BDFDB.WebModules.forceAllUpdates(this);
});
removeiconinput.addEventListener("click", e => {
userurlinput.disabled = e.currentTarget.checked;
});
ignoretagcolorinput.addEventListener("click", e => {
BDFDB.toggleClass(ignoredswatches, "disabled", e.currentTarget.checked);
});
userurlinput.addEventListener("change keyup paste", e => {
this.checkUrl(e.currentTarget);
});
userurlinput.addEventListener("mouseenter", e => {
BDFDB.addClass(e.currentTarget, "hovering");
this.createNoticeTooltip(e.currentTarget);
});
userurlinput.addEventListener("mouseleave", e => {
BDFDB.removeClass(e.currentTarget, "hovering");
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
});
BDFDB.addChildEventListener(userSettingsModal, "click", ".btn-save", e => {
e.preventDefault();
name = usernameinput.value.trim();
name = name ? name : null;
tag = usertaginput.value.trim();
tag = tag ? tag : null;
removeIcon = removeiconinput.checked;
ignoreTagColor = ignoretagcolorinput.checked;
url = !removeIcon && BDFDB.containsClass(userurlinput, "valid") ? userurlinput.value.trim() : null;
url = url ? url : null;
color1 = BDFDB.getSwatchColor(userSettingsModal, 1);
color2 = BDFDB.getSwatchColor(userSettingsModal, 2);
color3 = BDFDB.getSwatchColor(userSettingsModal, 3);
color4 = BDFDB.getSwatchColor(userSettingsModal, 4);
if (name == null && tag == null && url == null && !removeIcon && !ignoreTagColor && color1 == null && color2 == null && color3 == null && color4 == null) {
BDFDB.removeData(info.id, this, "users")
}
else {
BDFDB.saveData(info.id, {name,tag,url,removeIcon,ignoreTagColor,color1,color2,color3,color4}, this, "users");
}
BDFDB.WebModules.forceAllUpdates(this);
});
usernameinput.focus();
}
checkUrl (input) {
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
if (!input.value) {
input.classList.remove("valid");
input.classList.remove("invalid");
BDFDB.removeClass(input, "valid");
BDFDB.removeClass(input, "invalid");
}
else {
require("request")(input.value, (error, response, result) => {
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
input.classList.add("valid");
input.classList.remove("invalid");
BDFDB.addClass(input, "valid");
BDFDB.removeClass(input, "invalid");
}
else {
input.classList.remove("valid");
input.classList.add("invalid");
BDFDB.removeClass(input, "valid");
BDFDB.addClass(input, "invalid");
}
if (input.classList.contains("hovering")) this.createNoticeTooltip(input);
if (BDFDB.containsClass(input, "hovering")) this.createNoticeTooltip(input);
});
}
}
createNoticeTooltip (input) {
var disabled = input.disabled;
var valid = input.classList.contains("valid");
var invalid = input.classList.contains("invalid");
var valid = BDFDB.containsClass(input, "valid");
var invalid = BDFDB.containsClass(input, "invalid");
if (disabled || valid || invalid) {
BDFDB.createTooltip(disabled ? this.labels.modal_ignoreurl_text : valid ? this.labels.modal_validurl_text : this.labels.modal_invalidurl_text, input, {type:"right",selector:"notice-tooltip",color: disabled ? "black" : invalid ? "red" : "green"});
}
@ -432,7 +431,7 @@ class EditUsers {
}
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, "."));
this.changeName(instance.props.user, username);
this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper));
this.addTag(instance.props.user, username.parentElement, BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""));
@ -445,11 +444,11 @@ class EditUsers {
if (username) {
let channel = this.ChannelUtils.getChannel(message.channel_id) || {};
this.changeName(message.author, username, channel.guild_id);
if (wrapper.parentElement && wrapper.parentElement.classList && !wrapper.parentElement.classList.contains(BDFDB.disCN.messageheadercompact)) {
if (!BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.messageheadercompact)) {
this.changeAvatar(message.author, this.getAvatarDiv(wrapper));
}
let messagegroup = BDFDB.getParentEle(BDFDB.dotCN.messagegroup, wrapper);
this.addTag(message.author, wrapper, BDFDB.disCN.bottagmessage + " " + (messagegroup.classList.contains(BDFDB.disCN.messagegroupcozy) ? BDFDB.disCN.bottagmessagecozy : BDFDB.disCN.bottagmessagecompact));
this.addTag(message.author, wrapper, BDFDB.disCN.bottagmessage + " " + (BDFDB.containsClass(messagegroup, BDFDB.disCN.messagegroupcozy) ? BDFDB.disCN.bottagmessagecozy : BDFDB.disCN.bottagmessagecompact));
}
}
}
@ -496,7 +495,7 @@ class EditUsers {
let avatar = wrapper.querySelector(BDFDB.dotCN.callavatar);
this.changeName2(user, wrapper.parentElement.querySelector(BDFDB.dotCN.callmembers));
this.changeAvatar(user, avatar);
if (avatar.classList.contains(BDFDB.disCN.callvideo)) this.changeTooltip(user, avatar, "left");
if (BDFDB.containsClass(avatar, BDFDB.disCN.callvideo)) this.changeTooltip(user, avatar, "left");
}
}
}
@ -531,7 +530,7 @@ class EditUsers {
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) && wrapper.parentElement.querySelector("a") == wrapper) {
if (BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.messagesystemcontent) && wrapper.parentElement.querySelector("a") == wrapper) {
let message = BDFDB.getKeyInformation({node:wrapper.parentElement, key:"message", up:true});
if (message) this.changeName(message.author, wrapper);
}
@ -611,14 +610,14 @@ class EditUsers {
if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) {
let member = this.MemberUtils.getMember(guildid, info.id) || {};
let isBRCenabled = BDFDB.isPluginEnabled("BetterRoleColors");
let usenick = !username.parentElement.classList.contains(BDFDB.disCN.userprofilelistname) && !username.classList.contains(BDFDB.disCN.userprofileusername) && !username.parentElement.classList.contains(BDFDB.disCN.accountinfodetails) && member.nick;
let usemembercolor = !username.parentElement.classList.contains(BDFDB.disCN.userprofilelistname) && (username.classList.contains(BDFDB.disCN.memberusername) || username.classList.contains(BDFDB.disCN.messageusername) || isBRCenabled);
let usenick = !BDFDB.containsClass(username, BDFDB.disCN.userprofileusername) && !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname, BDFDB.disCN.accountinfodetails, false) && member.nick;
let usemembercolor = !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname) && (BDFDB.containsClass(username, BDFDB.disCN.memberusername, BDFDB.disCN.messageusername, false) || isBRCenabled);
username.style.setProperty("color", BDFDB.colorCONVERT(data.color1 || (usemembercolor ? member.colorString : null), "RGB"), "important");
username.style.setProperty("background-color", BDFDB.colorCONVERT(data.color2, "RGB"), "important");
BDFDB.setInnerText(username, data.name || (usenick ? member.nick : info.username));
for (let tag of username.parentElement.querySelectorAll(BDFDB.dotCN.bottag)) {
let invert = tag.className.indexOf(BDFDB.disCN.bottaginvert) > -1;
let tagcolor = BDFDB.colorCONVERT(data.color1 || (isBRCenabled || tag.classList.contains("owner-tag-rolecolor") ? member.colorString : null), "RGB");
let tagcolor = BDFDB.colorCONVERT(data.color1 || (isBRCenabled || BDFDB.containsClass(tag, "owner-tag-rolecolor") ? member.colorString : null), "RGB");
tagcolor = BDFDB.colorISBRIGHT(tagcolor) ? BDFDB.colorCHANGE(tagcolor, -0.3) : tagcolor;
tag.style.setProperty(invert ? "color" : "background-color", tagcolor, "important");
}
@ -687,7 +686,7 @@ class EditUsers {
if (avatar.tagName == "IMG") avatar.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.getUserAvatar(info.id)));
else {
let url = data.removeIcon ? null : ("url(" + (data.url || BDFDB.getUserAvatar(info.id)) + ")");
if (url && avatar.classList.contains(BDFDB.disCN.avatarmaskprofile) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)");
if (url && BDFDB.containsClass(avatar, BDFDB.disCN.avatarmaskprofile) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)");
avatar.style.setProperty("background-image", url);
if (data.url && !data.removeIcon) {
avatar.style.setProperty("background-position", "center");
@ -713,14 +712,17 @@ class EditUsers {
changeTooltip (info, wrapper, type) {
if (!info || !wrapper || !wrapper.parentElement) return;
let data = this.getUserData(info.id, wrapper);
$(wrapper).off("mouseenter." + this.getName());
if (data.name) $(wrapper).on("mouseenter." + this.getName(), () => {
BDFDB.createTooltip(data.name, wrapper, {type,selector:"EditUsers-tooltip",css:`body ${BDFDB.dotCN.tooltip}:not(.EditUsers-tooltip) {display: none !important;}`});
});
wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditUsers);
if (data.name) {
wrapper.tooltipListenerEditUsers = () => {
BDFDB.createTooltip(data.name, wrapper, {type,selector:"EditUsers-tooltip",css:`body ${BDFDB.dotCN.tooltip}:not(.EditUsers-tooltip) {display: none !important;}`});
};
wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditUsers);
}
}
addTag (info, wrapper, selector = "") {
if (!info || !wrapper || !wrapper.parentElement || wrapper.classList.contains(BDFDB.disCN.accountinfodetails) || wrapper.classList.contains("discord-tag")) return;
if (!info || !wrapper || !wrapper.parentElement || BDFDB.containsClass(wrapper, BDFDB.disCN.accountinfodetails) || BDFDB.containsClass(wrapper, "discord-tag")) return;
BDFDB.removeEles(wrapper.querySelectorAll(".EditUsers-tag"));
let data = this.getUserData(info.id, wrapper);
if (data.tag) {
@ -741,25 +743,27 @@ class EditUsers {
let dmchannel = BDFDB.getParentEle(BDFDB.dotCN.dmchannel, username);
if (!dmchannel) return;
if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect();
$(dmchannel).off("." + this.getName())
dmchannel.removeEventListener("mouseenter", dmchannel.mouseenterListenerEditUsers);
dmchannel.removeEventListener("mouseleave", dmchannel.mouseleaveListenerEditUsers);
let data = this.getUserData(info.id, username);
if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) {
let color1 = BDFDB.colorCONVERT(data.color1, "RGB");
let color2 = BDFDB.colorCONVERT(data.color2, "RGB");
BDFDB.setInnerText(username, data.name || info.username);
if (username.EditUsersHovered || dmchannel.classList.contains(BDFDB.disCN.dmchannelselected)) colorHover();
if (username.EditUsersHovered || BDFDB.containsClass(dmchannel, BDFDB.disCN.dmchannelselected)) colorHover();
else colorDefault();
if (data.name || data.color1 || data.color2) {
$(dmchannel)
.on("mouseenter." + this.getName(), () => {
username.EditUsersHovered = true;
colorHover();
})
.on("mouseleave." + this.getName(), () => {
delete username.EditUsersHovered;
colorDefault();
});
dmchannel.mouseenterListenerEditUsers = () => {
username.EditUsersHovered = true;
colorHover();
};
dmchannel.mouseleaveListenerEditUsers = () => {
delete username.EditUsersHovered;
colorDefault();
};
dmchannel.addEventListener("mouseenter", dmchannel.mouseenterListenerEditUsers);
dmchannel.addEventListener("mouseleave", dmchannel.mouseleaveListenerEditUsers);
username.setAttribute("changed-by-editusers", true);
username.EditUsersChangeObserver = new MutationObserver((changes, _) => {
username.EditUsersChangeObserver.disconnect();
@ -782,6 +786,8 @@ class EditUsers {
changeMention (info, mention) {
if (!info || !mention || !mention.parentElement) return;
if (mention.EditUsersChangeObserver && typeof mention.EditUsersChangeObserver.disconnect == "function") mention.EditUsersChangeObserver.disconnect();
mention.removeEventListener("mouseover", mention.mouseoverListenerEditUsers);
mention.removeEventListener("mouseout", mention.mouseoutListenerEditUsers);
let data = this.getUserData(info.id, mention);
let member = this.MemberUtils.getMember(this.LastGuildStore.getGuildId(), info.id) || {};
let color1 = BDFDB.colorCONVERT(data.color1 || (BDFDB.isPluginEnabled("BetterRoleColors") ? member.colorString : null), "RGBCOMP");
@ -789,16 +795,16 @@ class EditUsers {
BDFDB.setInnerText(mention, "@" + name);
if (mention.EditUsersHovered) colorHover();
else colorDefault();
$(mention)
.off("." + this.getName())
.on("mouseenter." + this.getName(), () => {
mention.EditUsersHovered = true;
colorHover();
})
.on("mouseleave." + this.getName(), () => {
delete mention.EditUsersHovered;
colorDefault();
});
mention.mouseoverListenerEditUsers = () => {
mention.EditUsersHovered = true;
colorHover();
};
mention.mouseoutListenerEditUsers = () => {
delete mention.EditUsersHovered;
colorDefault();
};
mention.addEventListener("mouseover", mention.mouseoverListenerEditUsers);
mention.addEventListener("mouseout", mention.mouseoutListenerEditUsers);
mention.EditUsersChangeObserver = new MutationObserver((changes, _) => {
mention.EditUsersChangeObserver.disconnect();
this.changeMention(info, mention);
@ -822,7 +828,7 @@ class EditUsers {
let member = this.MemberUtils.getMember(this.LastGuildStore.getGuildId(), info.id) || {};
let color1 = BDFDB.colorCONVERT(data.color1 || (BDFDB.isPluginEnabled("BetterRoleColors") ? member.colorString : ""), "RGB");
BDFDB.setInnerText(username, data.name || member.nick || info.username);
username.style.setProperty("color", username.classList.contains(BDFDB.disCN.voicenamedefault) ? BDFDB.colorCHANGE(color1, -50) : color1, "important");
username.style.setProperty("color", BDFDB.containsClass(username, BDFDB.disCN.voicenamedefault) ? BDFDB.colorCHANGE(color1, -50) : color1, "important");
if (data.name || data.color1) {
username.EditUsersChangeObserver = new MutationObserver((changes, _) => {
username.EditUsersChangeObserver.disconnect();
@ -850,8 +856,8 @@ class EditUsers {
for (let i in settings) if (!settings[i]) allenabled = false;
if (allenabled) return data;
let key = null, ele = null;
if (!wrapper.classList.contains(BDFDB.disCN.mention) && BDFDB.getParentEle(BDFDB.dotCN.messagegroup, wrapper)) key = "changeInChatWindow";
else if (wrapper.classList.contains(BDFDB.disCN.mention)) key = "changeInMentions";
if (!BDFDB.containsClass(wrapper, BDFDB.disCN.mention) && BDFDB.getParentEle(BDFDB.dotCN.messagegroup, wrapper)) key = "changeInChatWindow";
else if (BDFDB.containsClass(wrapper, BDFDB.disCN.mention)) key = "changeInMentions";
else if (BDFDB.getParentEle(BDFDB.dotCN.textareawrapchat, wrapper)) key = "changeInChatTextarea";
else if (BDFDB.getParentEle(BDFDB.dotCN.voiceuser, wrapper)) key = "changeInVoiceChat";
else if (BDFDB.getParentEle(BDFDB.dotCN.members, wrapper)) key = "changeInMemberList";

View File

@ -1,6 +1,14 @@
//META{"name":"EmojiStatistics"}*//
class EmojiStatistics {
getName () {return "EmojiStatistics";}
getVersion () {return "2.7.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds some helpful options to show you more information about emojis and emojiservers.";}
initConstructor () {
this.labels = {};
@ -9,6 +17,7 @@ class EmojiStatistics {
};
this.css = `
.emojistatistics-tooltip,
.emoji-tooltip {
z-index: 2002;
}
@ -24,19 +33,7 @@ class EmojiStatistics {
}
.${this.getName()}-modal .emojiserver-entry .modal-emojiserver-icon {
background-color: #484B51;
background-size: cover;
border-radius: 25px;
color: #b9bbbe;
display: inline-block;
font-size: 16px;
font-weight: 600;
height: 35px;
letter-spacing: .5px;
overflow: hidden;
padding-top: 15px;
text-align: center;
width: 50px;
}
.${this.getName()}-modal .titles-entry label,
@ -151,10 +148,6 @@ class EmojiStatistics {
<label class="modal-emojicopies-label">modal-emojicopies-label</label>
</div>`;
this.dividerMarkup = `<div class="${BDFDB.disCN.modaldivider}"></div>`;
this.emojiButtonMarkup = `<div class="emojistatistics-button"></div>`;
this.defaults = {
settings: {
enableEmojiHovering: {value:true, description:"Show Information about Emojis on hover over an Emoji in the Emojipicker."},
@ -166,37 +159,27 @@ class EmojiStatistics {
};
}
getName () {return "EmojiStatistics";}
getDescription () {return "Adds some helpful options to show you more information about emojis and emojiservers.";}
getVersion () {return "2.7.8";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var settings = BDFDB.getAllData(this, "settings");
var amounts = BDFDB.getAllData(this, "amounts");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in amounts) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">${this.defaults.amounts[key].description}</h3><div class="${BDFDB.disCN.inputwrapper} inputNumberWrapper ${BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCNS.directioncolumn}" style="flex: 1 1 auto;"><span class="numberinput-buttons-zone"><span class="numberinput-button-up"></span><span class="numberinput-button-down"></span></span><input type="number" min="0" option="${key}" value="${amounts[key]}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} amountInput"></div></div>`;
}
settingshtml += `</div></div>`;
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("input", ".amountInput", (e) => {
var input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => {
var input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
return settingspanel;
}
@ -205,22 +188,25 @@ class EmojiStatistics {
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.GuildEmojis = BDFDB.WebModules.findByProperties("getGuildEmoji", "getDisambiguatedEmojiContext");
@ -233,7 +219,7 @@ class EmojiStatistics {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".emoji-tooltip",".emojistatistics-button");
BDFDB.unloadMessage(this);
}
@ -241,14 +227,6 @@ class EmojiStatistics {
// 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");
}
changeLanguageStrings () {
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
@ -265,24 +243,26 @@ class EmojiStatistics {
processEmojiPicker (instance, wrapper) {
if (!wrapper.querySelector(".emojistatistics-button")) {
let emojipickerdiversityselector = document.querySelector(BDFDB.dotCN.emojipickerdiversityselector);
if (!emojipickerdiversityselector) return;
this.loadEmojiList();
let settings = BDFDB.getAllData(this, "settings");
if (settings.enableEmojiStatisticsButton) {
$(this.emojiButtonMarkup)
.insertBefore(BDFDB.dotCN.emojipickerdiversityselector, wrapper)
.off("click." + this.getName())
.on("click." + this.getName(), () => {
instance._reactInternalFiber.return.return.return.return.stateNode.close();
this.showEmojiInformationModal();
});
let emojiStatisticsButton = BDFDB.htmlToElement(`<div class="emojistatistics-button"></div>`);
emojipickerdiversityselector.parentElement.insertBefore(emojiStatisticsButton, emojipickerdiversityselector);
emojiStatisticsButton.addEventListener("click", () => {
instance._reactInternalFiber.return.return.return.return.stateNode.close();
this.showEmojiInformationModal();
});
emojiStatisticsButton.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Emoji Statistics", emojiStatisticsButton, {type:"top",selector:"emojistatistics-tooltip"});
});
}
if (settings.enableEmojiHovering) {
$(wrapper)
.off("mouseenter." + this.getName())
.on("mouseenter." + this.getName(), BDFDB.dotCN.emojipickeremojiitem, e => {
let data = this.emojiToServerList[e.target.style.getPropertyValue("background-image").replace('url("',"").replace('")',"")];
if (data) BDFDB.createTooltip(`${BDFDB.encodeToHTML(data.emoji)}\n${BDFDB.encodeToHTML(data.server)}`, e.target, {type:"right",selector:"emoji-tooltip",delay:BDFDB.getData("hoverDelay", this, "amounts")});
});
BDFDB.addEventListener(this, wrapper, "mouseenter", BDFDB.dotCN.emojipickeremojiitem, e => {
let data = this.emojiToServerList[e.target.style.getPropertyValue("background-image").replace('url("',"").replace('")',"")];
if (data) BDFDB.createTooltip(`${BDFDB.encodeToHTML(data.emoji)}\n${BDFDB.encodeToHTML(data.server)}`, e.target, {type:"right",selector:"emoji-tooltip",delay:BDFDB.getData("hoverDelay", this, "amounts")});
});
}
}
}
@ -299,13 +279,43 @@ class EmojiStatistics {
}
showEmojiInformationModal () {
var emojiInformationModal = $(this.emojiInformationModalMarkup);
BDFDB.appendModal(emojiInformationModal);
var emojiInformationModal = BDFDB.htmlToElement(this.emojiInformationModalMarkup);
let titlescontainer = emojiInformationModal.querySelector(".titles");
let entriescontainer = emojiInformationModal.querySelector(".entries");
if (!titlescontainer || !entriescontainer) return;
var titleEntry = BDFDB.htmlToElement(this.emojiserverTitlesMarkup);
titlescontainer.appendChild(titleEntry);
BDFDB.addChildEventListener(titleEntry, "click", ".modal-sorttitle-label ", e => {
var oldTitle = e.currentTarget.innerText;
var reverse = oldTitle.indexOf("▼") < 0 ? false : true;
titleEntry.querySelector(".modal-titlesname-label").innerText = this.labels.modal_titlesname_text;
titleEntry.querySelector(".modal-titlestotal-label").innerText = this.labels.modal_titlestotal_text;
titleEntry.querySelector(".modal-titlesglobal-label").innerText = this.labels.modal_titlesglobal_text;
titleEntry.querySelector(".modal-titleslocal-label").innerText = this.labels.modal_titleslocal_text;
titleEntry.querySelector(".modal-titlescopies-label").innerText = this.labels.modal_titlescopies_text;
var sortKey = "index";
if (oldTitle.indexOf("▲") < 0) {
sortKey = e.currentTarget.getAttribute("sortkey");
var title = this.labels["modal_titles" + sortKey + "_text"];
e.currentTarget.innerText = oldTitle.indexOf("▼") < 0 ? title + "▼" : title + "▲";
}
BDFDB.sortArrayByKey(entries, sortKey);
if (reverse) entries.reverse();
this.updateAllEntries(entriescontainer, entries);
});
var entries = [], index = 0;
for (let serverObj of BDFDB.readServerList()) {
for (let info of BDFDB.readServerList()) {
let amountGlobal = 0, amountLocal = 0, amountCopies = 0;
for (let emoji of this.GuildEmojis.getGuildEmoji(serverObj.id)) {
for (let emoji of this.GuildEmojis.getGuildEmoji(info.id)) {
if (emoji.managed) {
amountGlobal++;
if (this.emojiReplicaList[emoji.name]) amountCopies++;
@ -314,59 +324,36 @@ class EmojiStatistics {
amountLocal++;
}
}
var entry = $(this.emojiserverEntryMarkup);
if (serverObj.icon) {
entry.find(".modal-emojiserver-icon").css("background-image", "url('https://cdn.discordapp.com/icons/" + serverObj.id + "/" + serverObj.icon + ".png')");
}
else {
entry.find(".modal-emojiserver-icon").text(serverObj.div.querySelector("a").innerText);
}
entry.find(".modal-emojiname-label").text(serverObj.name);
entry.find(".modal-emojitotal-label").text(amountGlobal+amountLocal);
entry.find(".modal-emojiglobal-label").text(amountGlobal);
entry.find(".modal-emojilocal-label").text(amountLocal);
entry.find(".modal-emojicopies-label").text(amountCopies);
entries.push({entry:entry, index:index++, name:serverObj.name, total:amountGlobal+amountLocal, global:amountGlobal, local:amountLocal, copies:amountCopies});
var emojiEntry = BDFDB.htmlToElement(this.emojiserverEntryMarkup);
emojiEntry.querySelector(".modal-emojiserver-icon").innerHTML = this.createCopyOfServer(info).outerHTML;
emojiEntry.querySelector(".modal-emojiname-label").innerText = info.name || "";
emojiEntry.querySelector(".modal-emojitotal-label").innerText = amountGlobal + amountLocal;
emojiEntry.querySelector(".modal-emojiglobal-label").innerText = amountGlobal;
emojiEntry.querySelector(".modal-emojilocal-label").innerText = amountLocal;
emojiEntry.querySelector(".modal-emojicopies-label").innerText = amountCopies;
entries.push({div:emojiEntry, index:index++, name:info.name || "", total:amountGlobal+amountLocal, global:amountGlobal, local:amountLocal, copies:amountCopies});
}
var titleentry = $(this.emojiserverTitlesMarkup)
.appendTo(".titles", emojiInformationModal)
.on("click", ".modal-sorttitle-label ", (e2) => {
var oldTitle = e2.target.innerText;
BDFDB.appendModal(emojiInformationModal);
var reverse = oldTitle.indexOf("▼") < 0 ? false : true;
titleentry.find(".modal-titlesname-label").text(this.labels.modal_titlesname_text);
titleentry.find(".modal-titlestotal-label").text(this.labels.modal_titlestotal_text);
titleentry.find(".modal-titlesglobal-label").text(this.labels.modal_titlesglobal_text);
titleentry.find(".modal-titleslocal-label").text(this.labels.modal_titleslocal_text);
titleentry.find(".modal-titlescopies-label").text(this.labels.modal_titlescopies_text);
var sortKey = "index";
if (oldTitle.indexOf("▲") < 0) {
sortKey = e2.target.getAttribute("sortkey");
var title = this.labels["modal_titles" + sortKey + "_text"];
e2.target.innerText = oldTitle.indexOf("▼") < 0 ? title + "▼" : title + "▲";
}
BDFDB.sortArrayByKey(entries, sortKey);
if (reverse) entries.reverse();
this.updateAllEntries(emojiInformationModal, entries);
});
this.updateAllEntries(emojiInformationModal, entries);
this.updateAllEntries(entriescontainer, entries);
}
updateAllEntries (modal, entries) {
var container = modal.find(".entries");
container.children().remove();
for (let i = 0; entries.length > i; i++) {
if (i > 0) container.append(this.dividerMarkup);
container.append(entries[i].entry);
updateAllEntries (entriescontainer, entries) {
BDFDB.removeEles(entriescontainer.childNodes);
for (let entry of entries) {
if (entriescontainer.childElementCount) entriescontainer.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.modaldivider}"></div>`));
entriescontainer.appendChild(entry.div);
}
}
createCopyOfServer (info) {
let serverCopy = info.div.cloneNode(true);
BDFDB.toggleEles(serverCopy, true);
BDFDB.removeClass(serverCopy, BDFDB.disCN.guildunread, BDFDB.disCN.guildselected);
return serverCopy;
}
setLabelsByLanguage () {
switch (BDFDB.getDiscordLanguage().id) {
case "hr": //croatian

View File

@ -1,40 +1,43 @@
//META{"name":"ForceImagePreviews"}*//
class ForceImagePreviews {
getName () {return "ForceImagePreviews";}
getVersion () {return "1.0.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Forces embedded Image Previews, if Discord doesn't do it itself. Caution: Externals Images can contain malicious code and reveal your IP!";}
initConstructor () {
this.patchModules = {
"Message":"componentDidMount"
};
}
getName () {return "ForceImagePreviews";}
getDescription () {return "Forces embedded Image Previews, if Discord doesn't do it itself. Caution: Externals Images can contain malicious code and reveal your IP!";}
getVersion () {return "1.0.8";}
getAuthor () {return "DevilBro";}
//legacy
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);
@ -45,7 +48,7 @@ class ForceImagePreviews {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".FIP-embed");
BDFDB.unloadMessage(this);
}
@ -93,7 +96,7 @@ class ForceImagePreviews {
}
let checkedsrc = itemsrc.indexOf("imgur.com/") > -1 ? ("imgur.com/" + itemsrc.split("/")[3].split(".")[0]) : itemsrc;
if (!accessory.querySelector(`${BDFDB.dotCN.embedimage}[href*="${checkedsrc}"]`)) {
let embed = $(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCNS.flex + BDFDB.disCN.embedold}"><a class="${BDFDB.disCNS.imagewrapper + BDFDB.disCNS.imagezoom + BDFDB.disCN.embedimage}" href="${itemsrc}" rel="noreferrer noopener" target="_blank" style="width: ${width}px; height: ${height}px;"><img src="${itemsrc}" style="width: ${width}px; height: ${height}px;"></a></div>`)[0];
let embed = BDFDB.htmlToElement(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCNS.flex + BDFDB.disCN.embedold}"><a class="${BDFDB.disCNS.imagewrapper + BDFDB.disCNS.imagezoom + BDFDB.disCN.embedimage}" href="${itemsrc}" rel="noreferrer noopener" target="_blank" style="width: ${width}px; height: ${height}px;"><img src="${itemsrc}" style="width: ${width}px; height: ${height}px;"></a></div>`);
this.insertEmbed(embed, previmage, links, accessory);
}
this.addItemToAccessory(item, links, accessory);
@ -104,11 +107,11 @@ class ForceImagePreviews {
result = result.replace(new RegExp("[\\r|\\n|\\t]|[\\s]{2,}", "g"), "");
let width = 400;
let height = Math.round(width*(result.split('<meta itemprop="height" content="')[1].split('"')[0]/result.split('<meta itemprop="width" content="')[1].split('"')[0]));
let embed = $(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCNS.flex + BDFDB.disCN.embedold}" style="max-width: 426px;"><div class="${BDFDB.disCN.embedpill}" style="background-color: rgb(255, 0, 0);"></div><div class="${BDFDB.disCN.embedinner}"><div class="${BDFDB.disCNS.embedcontent + BDFDB.disCN.flex}"><div class="${BDFDB.disCN.embedcontentinner}"><div class=""><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedproviderlink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedprovider + BDFDB.disCNS.size12 + BDFDB.disCN.weightnormal}" href="https://www.youtube.com/" rel="noreferrer noopener" target="_blank">YouTube</a></div><div class="${BDFDB.disCNS.embedauthor + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedauthornamelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedauthorname + BDFDB.disCNS.weightmedium + BDFDB.disCN.size14}" href="https://www.youtube.com${result.split('<div class="yt-user-info"><a href="')[1].split('"')[0]}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<div class="yt-user-info"><a href="')[1].split('>')[1].split('<')[0])}</a></div><div class="${BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedtitlelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedtitle + BDFDB.disCNS.size14 + BDFDB.disCN.weightmedium}" href="${itemsrc}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<meta property="og:title" content="')[1].split('"')[0])}</a></div></div></div><div class="${BDFDB.disCNS.embedvideo + BDFDB.disCNS.embedimage + BDFDB.disCNS.embedmarginlarge + BDFDB.disCN.margintop8}" style="width: ${width}px; height: ${height}px;"><div class="${BDFDB.disCNS.imagewrapper + BDFDB.disCN.imagezoom}" style="width: ${width}px; height: ${height}px;"><img alt="" src="${result.split('<link itemprop="thumbnailUrl" href="')[1].split('"')[0]}" style="width: ${width}px; height: ${height}px;"></div><div class="${BDFDB.disCNS.embedvideoactions + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifycenter + BDFDB.disCN.aligncenter}"><div class="${BDFDB.disCNS.embedvideoactionsinner + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifycenter + BDFDB.disCN.aligncenter}"><div class="${BDFDB.disCN.iconactionswrapper}"><div tabindex="0" class="${BDFDB.disCN.iconwrapper}" role="button"><svg name="Play" class="${BDFDB.disCNS.iconplay + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><polygon fill="currentColor" points="0 0 0 14 11 7" transform="translate(7 5)"></polygon></svg></div><a class="${BDFDB.disCNS.anchor + BDFDB.disCN.iconwrapper}" href="${itemsrc}" rel="noreferrer noopener" target="_blank"><svg name="OpenExternal" class="${BDFDB.disCNS.iconexternalmargins + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" transform="translate(3.000000, 4.000000)" d="M16 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4v-2H2V4h14v10h-4v2h4c1.1 0 2-.9 2-2V2a2 2 0 0 0-2-2zM9 6l-4 4h3v6h2v-6h3L9 6z"></path></svg></a></div></div></div></div></div></div>`)[0];
$(embed).on("click." + this.getName(), BDFDB.dotCN.iconplay, (e) => {
let embed = BDFDB.htmlToElement(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCNS.flex + BDFDB.disCN.embedold}" style="max-width: 426px;"><div class="${BDFDB.disCN.embedpill}" style="background-color: rgb(255, 0, 0);"></div><div class="${BDFDB.disCN.embedinner}"><div class="${BDFDB.disCNS.embedcontent + BDFDB.disCN.flex}"><div class="${BDFDB.disCN.embedcontentinner}"><div class=""><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedproviderlink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedprovider + BDFDB.disCNS.size12 + BDFDB.disCN.weightnormal}" href="https://www.youtube.com/" rel="noreferrer noopener" target="_blank">YouTube</a></div><div class="${BDFDB.disCNS.embedauthor + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedauthornamelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedauthorname + BDFDB.disCNS.weightmedium + BDFDB.disCN.size14}" href="https://www.youtube.com${result.split('<div class="yt-user-info"><a href="')[1].split('"')[0]}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<div class="yt-user-info"><a href="')[1].split('>')[1].split('<')[0])}</a></div><div class="${BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedtitlelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedtitle + BDFDB.disCNS.size14 + BDFDB.disCN.weightmedium}" href="${itemsrc}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<meta property="og:title" content="')[1].split('"')[0])}</a></div></div></div><div class="${BDFDB.disCNS.embedvideo + BDFDB.disCNS.embedimage + BDFDB.disCNS.embedmarginlarge + BDFDB.disCN.margintop8}" style="width: ${width}px; height: ${height}px;"><div class="${BDFDB.disCNS.imagewrapper + BDFDB.disCN.imagezoom}" style="width: ${width}px; height: ${height}px;"><img alt="" src="${result.split('<link itemprop="thumbnailUrl" href="')[1].split('"')[0]}" style="width: ${width}px; height: ${height}px;"></div><div class="${BDFDB.disCNS.embedvideoactions + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifycenter + BDFDB.disCN.aligncenter}"><div class="${BDFDB.disCNS.embedvideoactionsinner + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifycenter + BDFDB.disCN.aligncenter}"><div class="${BDFDB.disCN.iconactionswrapper}"><div tabindex="0" class="${BDFDB.disCN.iconwrapper}" role="button"><svg name="Play" class="${BDFDB.disCNS.iconplay + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><polygon fill="currentColor" points="0 0 0 14 11 7" transform="translate(7 5)"></polygon></svg></div><a class="${BDFDB.disCNS.anchor + BDFDB.disCN.iconwrapper}" href="${itemsrc}" rel="noreferrer noopener" target="_blank"><svg name="OpenExternal" class="${BDFDB.disCNS.iconexternalmargins + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" transform="translate(3.000000, 4.000000)" d="M16 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4v-2H2V4h14v10h-4v2h4c1.1 0 2-.9 2-2V2a2 2 0 0 0-2-2zM9 6l-4 4h3v6h2v-6h3L9 6z"></path></svg></a></div></div></div></div></div></div>`);
BDFDB.addChildEventListener(embed, "click", BDFDB.dotCN.iconplay, () => {
let videowrapper = embed.querySelector(BDFDB.dotCN.embedvideo);
while (videowrapper.firstChild) videowrapper.firstChild.remove();
$(`<iframe src="${result.split('<link itemprop="embedURL" href="')[1].split('"')[0]}?start=0&amp;autoplay=1&amp;auto_play=1" width="${width}" height="${height}" frameborder="0" allowfullscreen=""></iframe>`).appendTo(videowrapper);
BDFDB.removeEles(videowrapper.childNodes);
videowrapper.appendChild(BDFDB.htmlToElement(`<iframe src="${result.split('<link itemprop="embedURL" href="')[1].split('"')[0]}?start=0&amp;autoplay=1&amp;auto_play=1" width="${width}" height="${height}" frameborder="0" allowfullscreen=""></iframe>`));
});
this.insertEmbed(embed, previmage, links, accessory);
}
@ -125,10 +128,10 @@ class ForceImagePreviews {
prev = prev ? prev : accessory.querySelector(`${BDFDB.dotCNS.embed + BDFDB.dotCN.embedtitlelink}[href="${previmage ? this.parseSrc(previmage.src) : void 0}"]`);
next = next ? next : accessory.querySelector(`${BDFDB.dotCNS.embed + BDFDB.dotCN.embedtitlelink}[href="${links[0] ? this.parseSrc(links[0].src) : void 0}"]`);
let isempty = accessory.childElementCount == 0;
if (embed.firstElementChild.classList.contains(BDFDB.disCN.embedimage)) embed.style.setProperty("pointer-events", "none", "important");
if (BDFDB.containsClass(embed.firstElementChild, BDFDB.disCN.embedimage)) embed.style.setProperty("pointer-events", "none", "important");
accessory.insertBefore(embed, prev ? prev.nextSibling : next);
let scroller = document.querySelector(BDFDB.dotCNS.chat + BDFDB.dotCN.messages);
if (scroller) scroller.scrollTop += (embed.getBoundingClientRect().height + (isempty ? 15 : 0));
if (scroller) scroller.scrollTop += (BDFDB.getRects(embed).height + (isempty ? 15 : 0));
}
parseSrc (src) {

View File

@ -1,6 +1,14 @@
//META{"name":"FriendNotifications"}*//
class FriendNotifications {
getName () {return "FriendNotifications";}
getVersion () {return "1.1.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Notifies you when a friend either logs in or out. Click the Online Friend-Counter to display a timelog of the current session.";}
initConstructor () {
this.patchModules = {
"FluxContainer(FriendsOnline)":["componentDidMount","componentDidUpdate"]
@ -47,8 +55,6 @@ class FriendNotifications {
<div class="log-avatar"></div>
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCNS.overflowellipsis} log-description" style="flex: 1 1 auto;"></h3>
</div>`;
this.dividerMarkup = `<div class="${BDFDB.disCN.modaldivider}"></div>`;
this.css = `
${BDFDB.dotCN.guilds} > ${BDFDB.dotCN.friendsonline} {
@ -115,14 +121,6 @@ class FriendNotifications {
}
};
}
getName () {return "FriendNotifications";}
getDescription () {return "Notifies you when a friend either logs in or out. Click the Online Friend-Counter to display a timelog of the current session.";}
getVersion () {return "1.1.6";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -133,7 +131,7 @@ class FriendNotifications {
let disabled = BDFDB.loadAllData(this, "disabled");
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-checkbox"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in notificationsounds) {
if (key.indexOf("desktop") == -1 || "Notification" in window) settingshtml += `<div class="${BDFDB.disCNS.flexchild + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 1 1 auto;">${key} notification sound:</h5><h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Mute:</h5><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" option="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} mute-checkbox"${notificationsounds[key].mute ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCNS.directioncolumn + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;"><input type="text" option="${key}" value="${notificationsounds[key].url ? notificationsounds[key].url : ""}" placeholder="Url or Filepath" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} songInput"></div><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} file-navigator" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div><input type="file" accept="audio/*,video/*" style="display:none!important;"></button><button type="button" option="${key}" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-save btn-savesong" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div></div>`;
@ -152,57 +150,54 @@ class FriendNotifications {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Batch set Users:</h3><button type="button" do-disable=true class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttoncolorprimary + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} disable-all" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Disable</div></button><button type="button" do-toast=true class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} toast-all" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Toast</div></button>${"Notification" in window ? `<button type="button" do-desktop=true class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorgreen + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} desktop-all" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Desktop</div></button>` : ``}</div>`;
settingshtml += `</div></div>`;
let settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", ".settings-checkbox", () => {this.updateSettings(settingspanel);})
.on("click", ".btn-savesong", (e) => {this.saveAudio(settingspanel, e.currentTarget.getAttribute("option"));})
.on("click", ".mute-checkbox", (e) => {
let option = e.currentTarget.getAttribute("option");
let notificationsound = BDFDB.getData(option, this, "notificationsounds");
notificationsound.mute = e.currentTarget.checked;
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
})
.on("mouseenter", ".settings-avatar", (e) => {
let user = this.UserUtils.getUser(e.currentTarget.getAttribute("user-id"));
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
BDFDB.createTooltip(data.name ? data.name : user.username, e.currentTarget, {type:"top"});
})
.on("contextmenu", ".settings-avatar", (e) => {
if (!("Notification" in window)) return;
let desktopoff = !e.currentTarget.classList.contains("desktop");
let id = e.currentTarget.getAttribute("user-id");
e.currentTarget.classList.remove("disabled");
e.currentTarget.classList.toggle("desktop", desktopoff);
BDFDB.saveData(id, desktopoff, this, "desktop");
BDFDB.removeData(id, this, "disabled");
})
.on("click", ".settings-avatar", (e) => {
let disableoff = !e.currentTarget.classList.contains("disabled");
let id = e.currentTarget.getAttribute("user-id");
e.currentTarget.classList.remove("desktop");
e.currentTarget.classList.toggle("disabled", disableoff);
BDFDB.saveData(id, disableoff, this, "disabled");
BDFDB.removeData(id, this, "desktop");
})
.on("click", ".disable-all, .toast-all, .desktop-all", (e) => {
let button = e.currentTarget;
let disableon = button.getAttribute("do-disable");
let desktopon = button.getAttribute("do-desktop");
let disabledata = BDFDB.loadAllData(this, "disabled");
let desktopdata = BDFDB.loadAllData(this, "desktop");
settingspanel.querySelectorAll(".settings-avatar").forEach(avatar => {
let id = avatar.getAttribute("user-id");
avatar.classList.toggle("disabled", disableon);
avatar.classList.toggle("desktop", desktopon);
disableon ? disabledata[id] = true : delete disabledata[id];
desktopon ? desktopdata[id] = true : delete desktopdata[id];
});
BDFDB.saveAllData(disabledata, this, "disabled");
BDFDB.saveAllData(desktopdata, this, "desktop");
BDFDB.addEventListener(this, settingspanel, "click", ".btn-savesong", e => {this.saveAudio(settingspanel, e.currentTarget.getAttribute("option"));});
BDFDB.addEventListener(this, settingspanel, "click", ".mute-checkbox", e => {
let option = e.currentTarget.getAttribute("option");
let notificationsound = BDFDB.getData(option, this, "notificationsounds");
notificationsound.mute = e.currentTarget.checked;
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
});
BDFDB.addEventListener(this, settingspanel, "mouseenter", ".settings-avatar", e => {
let user = this.UserUtils.getUser(e.currentTarget.getAttribute("user-id"));
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
BDFDB.createTooltip(data.name ? data.name : user.username, e.currentTarget, {type:"top"});
});
BDFDB.addEventListener(this, settingspanel, "contextmenu", ".settings-avatar", e => {
if (!("Notification" in window)) return;
let desktopoff = !BDFDB.containsClass(e.currentTarget, "desktop");
let id = e.currentTarget.getAttribute("user-id");
BDFDB.removeClass(e.currentTarget, "disabled");
BDFDB.toggleClass(e.currentTarget, "desktop", desktopoff);
BDFDB.saveData(id, desktopoff, this, "desktop");
BDFDB.removeData(id, this, "disabled");
});
BDFDB.addEventListener(this, settingspanel, "click", ".settings-avatar", e => {
let disableoff = !BDFDB.containsClass(e.currentTarget, "disabled");
let id = e.currentTarget.getAttribute("user-id");
BDFDB.removeClass(e.currentTarget, "desktop");
BDFDB.toggleClass(e.currentTarget, "disabled", disableoff);
BDFDB.saveData(id, disableoff, this, "disabled");
BDFDB.removeData(id, this, "desktop");
});
BDFDB.addEventListener(this, settingspanel, "click", ".disable-all, .toast-all, .desktop-all", e => {
let disableon = e.currentTarget.getAttribute("do-disable");
let desktopon = e.currentTarget.getAttribute("do-desktop");
let disabledata = BDFDB.loadAllData(this, "disabled");
let desktopdata = BDFDB.loadAllData(this, "desktop");
settingspanel.querySelectorAll(".settings-avatar").forEach(avatar => {
let id = avatar.getAttribute("user-id");
BDFDB.toggleClass(avatar, "disabled", disableon);
BDFDB.toggleClass(avatar, "desktop", desktopon);
disableon ? disabledata[id] = true : delete disabledata[id];
desktopon ? desktopdata[id] = true : delete desktopdata[id];
});
BDFDB.saveAllData(disabledata, this, "disabled");
BDFDB.saveAllData(desktopdata, this, "desktop");
});
return settingspanel;
}
@ -211,22 +206,25 @@ class FriendNotifications {
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.FriendUtils = BDFDB.WebModules.findByProperties("getFriendIDs", "getRelationships");
@ -248,21 +246,13 @@ class FriendNotifications {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
// begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner + ".settings-checkbox")) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
saveAudio (settingspanel, option) {
let successSavedAudio = (parsedurl, parseddata) => {
@ -299,14 +289,8 @@ class FriendNotifications {
}
processFluxContainerFriendsOnline (instance, wrapper) {
$(wrapper)
.off("." + this.getName())
.on("mouseenter." + this.getName(), (e) => {
BDFDB.createTooltip("Timelog", e.currentTarget, {type:"right"});
})
.on("click." + this.getName(), (e) => {
this.showTimeLog();
});
BDFDB.addEventListener(this, wrapper, "mouseenter", () => {BDFDB.createTooltip("Timelog", wrapper, {type:"right"});});
BDFDB.addEventListener(this, wrapper, "click", () => {this.showTimeLog();});
let settings = BDFDB.getAllData(this, "settings");
for (let id of this.FriendUtils.getFriendIDs()) {
@ -328,7 +312,7 @@ class FriendNotifications {
};
if (!BDFDB.loadData(id, this, "desktop")) {
let toast = BDFDB.showToast(`<div class="toast-inner"><div class="toast-avatar" style="background-image:url(${avatar});"></div><div>${string}</div></div>`, {html:true, timeout:5000, type:(online ? "success" : null), icon:false, selector:`friendnotifications-${online ? "online" : "offline"}-toast`});
$(toast).on("click." + this.getName(), openChannel);
toast.addEventListener("click", openChannel);
let notificationsound = BDFDB.getData(online ? "toastonline" : "toastoffline", this, "notificationsounds");
if (!notificationsound.mute && notificationsound.song) {
let audio = new Audio();
@ -346,19 +330,20 @@ class FriendNotifications {
}
}
showTimeLog () {
let timeLogModal = $(this.timeLogModalMarkup);
showTimeLog () {
let timeLogModal = BDFDB.htmlToElement(this.timeLogModalMarkup);
let container = timeLogModal.querySelector(".entries");
if (!container) return;
let logs = this.timeLog.slice(0).reverse();
for (let log of logs) {
let entry = $(this.logEntryMarkup);
let divider = $(this.dividerMarkup);
if (container.childElementCount) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.modaldivider}"></div>`));
let data = BDFDB.loadData(log.user.id, "EditUsers", "users") || {};
entry.find(".log-time").text(`[${log.time.toLocaleTimeString()}]`);
entry.find(".log-avatar").css("background-image", `url(${data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(log.user.id))})`);
entry.find(".log-description").text(`${data.name ? data.name : log.user.username} is ${log.online ? "online" : "offline"}.`);
timeLogModal.find(".entries").append(entry).append(divider);
let entry = BDFDB.htmlToElement(this.logEntryMarkup);
entry.querySelector(".log-time").innerText = `[${log.time.toLocaleTimeString()}]`;
entry.querySelector(".log-avatar").style.setProperty("background-image", `url(${data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(log.user.id))})`);
entry.querySelector(".log-description").innerText = `${data.name || log.user.username} is ${log.online ? "online" : "offline"}.`;
container.appendChild(entry)
}
BDFDB.removeEles("." + this.getName() + "-modal " + BDFDB.dotCN.modaldivider + ":last-of-type");
BDFDB.appendModal(timeLogModal);
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"GoogleSearchReplace"}*//
class GoogleSearchReplace {
getName () {return "GoogleSearchReplace";}
getVersion () {return "1.1.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Replaces the default Google Text Search with a selection menu of several search engines.";}
initConstructor () {
this.labels = {};
@ -42,14 +50,6 @@ class GoogleSearchReplace {
</div>
</div>`;
}
getName () {return "GoogleSearchReplace";}
getDescription () {return "Replaces the default Google Text Search with a selection menu of several search engines.";}
getVersion () {return "1.1.6";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -57,17 +57,14 @@ class GoogleSearchReplace {
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Search Engines:</h3></div><div class="DevilBro-settings-inner-list">`;
for (let key in engines) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.engines[key].name}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${engines[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.engines[key].name}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="engines ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${engines[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div>`;
settingshtml += `</div></div>`;
let settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
$(settingspanel)
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
BDFDB.initElements(settingspanel, this);
return settingspanel;
}
@ -76,22 +73,25 @@ class GoogleSearchReplace {
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);
}
else {
@ -100,20 +100,13 @@ class GoogleSearchReplace {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
// begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "engines");
}
changeLanguageStrings () {
this.messageContextEntryMarkup = this.messageContextEntryMarkup.replace("REPLACE_context_googlesearchreplace_text", this.labels.context_googlesearchreplace_text);
@ -123,46 +116,40 @@ class GoogleSearchReplace {
onNativeContextMenu (instance, menu) {
if (instance.props && instance.props.type == "NATIVE_TEXT" && instance.props.value && !menu.querySelector(".reverseimagesearch-item")) {
let searchinstance = BDFDB.getOwnerInstance({node:menu,props:["handleSearchWithGoogle"]});
if (searchinstance && searchinstance._reactInternalFiber && searchinstance._reactInternalFiber.return && searchinstance._reactInternalFiber.return.stateNode) {
this.appendItem(instance, searchinstance._reactInternalFiber.return.stateNode, instance.props.value);
}
let searchentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleSearchWithGoogle"]}));
if (searchentry) this.appendItem(instance, searchentry, instance.props.value);
}
}
onMessageContextMenu (instance, menu) {
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".googlereplacesearch-item")) {
let text = document.getSelection().toString();
let searchinstance = BDFDB.getOwnerInstance({node:menu,props:["handleSearchWithGoogle"]});
if (text && searchinstance && searchinstance._reactInternalFiber && searchinstance._reactInternalFiber.return && searchinstance._reactInternalFiber.return.stateNode) {
this.appendItem(instance, searchinstance._reactInternalFiber.return.stateNode, text);
if (text) {
let searchentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleSearchWithGoogle"]}));
if (searchentry) this.appendItem(instance, searchentry, text);
}
}
}
appendItem (instance, target, text) {
$(this.messageContextEntryMarkup).appendTo(target)
.on("mouseenter", (e) => {
let messageContextSubMenu = $(this.messageContextSubMenuMarkup)[0];
let engines = BDFDB.getAllData(this, "engines");
$(messageContextSubMenu)
.on("click", ".GRS-item", (e2) => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
let engine = e2.currentTarget.getAttribute("engine");
if (engine == "_all") {
for (let key in engines) {
if (key != "_all" && engines[key]) {
window.open(this.defaults.engines[key].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
}
}
}
else window.open(this.defaults.engines[engine].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
});
for (let key in engines) if (!engines[key]) BDFDB.removeEles(messageContextSubMenu.querySelector("[engine='" + key + "']"));
if (messageContextSubMenu.querySelector(".GRS-item")) BDFDB.removeEles(messageContextSubMenu.querySelector(".alldisabled-item"));
BDFDB.appendSubMenu(e.currentTarget, messageContextSubMenu);
let messageContextEntry = BDFDB.htmlToElement(this.messageContextEntryMarkup);
target.parentElement.insertBefore(messageContextEntry, target.nextElementSibling);
messageContextEntry.addEventListener("mouseenter", () => {
let messageContextSubMenu = BDFDB.htmlToElement(this.messageContextSubMenuMarkup);
let engines = BDFDB.getAllData(this, "engines");
for (let key in engines) if (!engines[key]) BDFDB.removeEles(messageContextSubMenu.querySelector("[engine='" + key + "']"));
if (messageContextSubMenu.querySelector(".GRS-item")) BDFDB.removeEles(messageContextSubMenu.querySelector(".alldisabled-item"));
BDFDB.addChildEventListener(messageContextSubMenu, "click", ".GRS-item", e => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
let engine = e.currentTarget.getAttribute("engine");
if (engine == "_all") {
for (let key in engines) if (key != "_all" && engines[key]) window.open(this.defaults.engines[key].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
}
else window.open(this.defaults.engines[engine].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
});
target.firstElementChild.style.setProperty("display", "none", "important");
BDFDB.appendSubMenu(messageContextEntry, messageContextSubMenu);
});
BDFDB.toggleEles(target, false);
}
setLabelsByLanguage () {

View File

@ -3,7 +3,7 @@
class GoogleTranslateOption {
getName () {return "GoogleTranslateOption";}
getVersion () {return "1.6.3";}
getVersion () {return "1.6.4";}
getAuthor () {return "DevilBro, square";}
@ -412,7 +412,7 @@ class GoogleTranslateOption {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu("inSettings", e);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu("inSettings", e);});
return settingspanel;
}
@ -421,22 +421,25 @@ class GoogleTranslateOption {
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.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
@ -454,7 +457,7 @@ class GoogleTranslateOption {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopDeepL();
document.querySelectorAll(BDFDB.dotCN.message + ".translated").forEach(message => {
@ -522,7 +525,7 @@ class GoogleTranslateOption {
};
searchitem.removeEventListener("click", openGoogleSearch);
searchitem.addEventListener("click", openGoogleSearch);
let rects = searchitem.getBoundingClientRect();
let rects = BDFDB.getRects(searchitem);
BDFDB.createTooltip(`From ${input.name}:\n${text}\n\nTo ${output.name}:\n${translation}`, searchitem, {type: "right",selector:"googletranslate-tooltip",style:`max-width: ${window.outerWidth - rects.left - rects.width}px !important;`});
}
});
@ -633,7 +636,7 @@ class GoogleTranslateOption {
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};
}
@ -764,7 +767,7 @@ class GoogleTranslateOption {
BDFDB.addClass(button, "popout-open");
let translatepopout = BDFDB.htmlToElement(this.translatePopoutMarkup);
container.appendChild(translatepopout);
let buttonrects = button.getBoundingClientRect();
let buttonrects = BDFDB.getRects(button);
translatepopout.style.setProperty("left", buttonrects.left + buttonrects.width + "px");
translatepopout.style.setProperty("top", buttonrects.top - buttonrects.height/2 + "px")

View File

@ -3,7 +3,7 @@
class ImageGallery {
getName () {return "ImageGallery";}
getVersion () {return "1.5.6";}
getVersion () {return "1.5.7";}
getAuthor () {return "DevilBro";}
@ -36,22 +36,25 @@ class ImageGallery {
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);
@ -62,13 +65,16 @@ class ImageGallery {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.closemodal = true;
BDFDB.WebModules.forceAllUpdates(this, "ImageModal");
delete this.closemodal;
document.removeEventListener("keydown", document.keydownImageGalleryListener);
document.removeEventListener("keyup", document.keyupImageGalleryListener);
BDFDB.unloadMessage(this);
}
}
@ -88,7 +94,7 @@ class ImageGallery {
clearInterval(waitForImg);
let message = this.getMessageGroupOfImage(img);
if (message) {
modal.classList.add("image-gallery");
BDFDB.addClass(modal, "image-gallery");
this.addImages(modal, message.querySelectorAll(BDFDB.dotCNS.imagewrapper + "img"), img);
}
}
@ -97,7 +103,10 @@ class ImageGallery {
}
}, 100);
}
else if (methodnames.includes("componentWillUnmount")) $(document).off("keyup." + this.getName()).off("keydown." + this.getName());
else if (methodnames.includes("componentWillUnmount")) {
document.removeEventListener("keydown", document.keydownImageGalleryListener);
document.removeEventListener("keyup", document.keyupImageGalleryListener);
}
}
getMessageGroupOfImage (thisimg) {
@ -118,7 +127,11 @@ class ImageGallery {
}
addImages (modal, imgs, img) {
BDFDB.removeEles(`${BDFDB.dotCN.imagewrapper}.prev`,`${BDFDB.dotCN.imagewrapper}.next`);
BDFDB.removeEles(modal.querySelector(`${BDFDB.dotCN.imagewrapper}.prev, ${BDFDB.dotCN.imagewrapper}.next`));
let inner = modal.querySelector(BDFDB.dotCN.modalinner);
if (!inner) return;
var prevImg, nextImg, index;
for (index = 0; index < imgs.length; index++) {
@ -130,46 +143,39 @@ class ImageGallery {
}
}
$(modal).find(BDFDB.dotCN.imagewrapper)
.addClass("current")
.find("img").attr("src", this.getSrcOfImage(img));
$(modal.querySelector(BDFDB.dotCN.downloadlink))
.attr("href", this.getSrcOfImage(img));
this.resizeImage(modal, img, modal.querySelector(BDFDB.dotCN.imagewrapper + ".current img"));
if (prevImg) {
$(this.imageMarkup)
.appendTo(modal.querySelector(BDFDB.dotCN.modalinner))
.addClass("prev")
.off("click." + this.getName()).on("click." + this.getName(), () => {
this.addImages(modal, imgs, prevImg);
})
.find("img").attr("src", this.getSrcOfImage(prevImg));
this.resizeImage(modal, prevImg, modal.querySelector(BDFDB.dotCN.imagewrapper + ".prev img"));
}
if (nextImg) {
$(this.imageMarkup)
.appendTo(modal.querySelector(BDFDB.dotCN.modalinner))
.addClass("next")
.off("click." + this.getName()).on("click." + this.getName(), () => {
this.addImages(modal, imgs, nextImg);
})
.find("img").attr("src", this.getSrcOfImage(nextImg));
this.resizeImage(modal, nextImg, modal.querySelector(BDFDB.dotCN.imagewrapper + ".next img"));
}
var imagesrc = this.getSrcOfImage(img);
modal.querySelector(BDFDB.dotCN.downloadlink).setAttribute("href", imagesrc);
$(document).off("keydown." + this.getName()).off("keyup." + this.getName())
.on("keydown." + this.getName(), (e) => {
this.keyPressed({modal, imgs, prevImg, nextImg}, e);
})
.on("keyup." + this.getName(), () => {
this.eventFired = false;
});
var imagewrapper = modal.querySelector(BDFDB.dotCN.imagewrapper);
BDFDB.addClass(imagewrapper, "current");
var imagewrapperimage = imagewrapper.querySelector("img");
imagewrapperimage.setAttribute("src", imagesrc);
this.resizeImage(modal, img, imagewrapperimage);
if (prevImg) inner.appendChild(this.createImage(modal, imgs, prevImg, "prev"));
if (nextImg) inner.appendChild(this.createImage(modal, imgs, nextImg, "next"));
document.removeEventListener("keydown", document.keydownImageGalleryListener);
document.removeEventListener("keyup", document.keyupImageGalleryListener);
document.keydownImageGalleryListener = e => {this.keyPressed({modal, imgs, prevImg, nextImg}, e);};
document.keyupImageGalleryListener = e => {this.eventFired = false;};
document.addEventListener("keydown", document.keydownImageGalleryListener);
document.addEventListener("keyup", document.keyupImageGalleryListener);
}
createImage (modal, imgs, img, type) {
var imagewrapper = BDFDB.htmlToElement(this.imageMarkup);
BDFDB.addClass(imagewrapper, type);
imagewrapper.addEventListener("click", () => {this.addImages(modal, imgs, img);});
var imagewrapperimage = imagewrapper.querySelector("img");
imagewrapperimage.setAttribute("src", this.getSrcOfImage(img));
this.resizeImage(modal, img, imagewrapperimage);
return imagewrapper;
}
resizeImage (container, src, img) {
$(img).hide();
BDFDB.toggleEles(img, false);
var temp = new Image();
temp.src = src.src.split("?width=")[0];
temp.onload = function () {
@ -182,28 +188,22 @@ class ImageGallery {
newHeight = temp.height > newHeight ? newHeight : temp.height;
var wrapper = img.parentElement;
if (!BDFDB.containsClass(wrapper, "current")) wrapper.style.setProperty("top", (container.clientHeight - newHeight) / 2 + "px");
wrapper.style.setProperty("width", newWidth + "px");
wrapper.style.setProperty("height", newHeight + "px");
$(wrapper)
.css("top", !wrapper.classList.contains("current") ? (container.clientHeight - newHeight) / 2 : "")
.css("width", newWidth)
.css("height", newHeight);
$(img)
.css("width", newWidth)
.css("height", newHeight)
.show();
img.style.setProperty("width", newWidth + "px");
img.style.setProperty("height", newHeight + "px");
BDFDB.toggleEles(img, true);
};
}
keyPressed (data, e) {
keyPressed ({modal, imgs, prevImg, nextImg}, e) {
if (!this.eventFired) {
this.eventFired = true;
if (e.keyCode == 37 && data.prevImg) {
this.addImages(data.modal, data.imgs, data.prevImg);
}
else if (e.keyCode == 39 && data.nextImg) {
this.addImages(data.modal, data.imgs, data.nextImg);
}
if (e.keyCode == 37 && prevImg) this.addImages(modal, imgs, prevImg);
else if (e.keyCode == 39 && nextImg) this.addImages(modal, imgs, nextImg);
}
}
}

View File

@ -3,7 +3,7 @@
class JoinedAtDate {
getName () {return "JoinedAtDate";}
getVersion () {return "1.0.6";}
getVersion () {return "1.0.7";}
getAuthor () {return "DevilBro";}
@ -74,15 +74,11 @@ class JoinedAtDate {
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", BDFDB.dotCN.switchinner, () => {
this.updateSettings(settingspanel);
let choices = BDFDB.getAllData(this, "choices");
for (let key in choices) {
settingspanel.querySelector(`${BDFDB.dotCN.select}[type='${key}'] .languageTimestamp`).innerText = this.getJoinedTime(this.languages[choices[key]].id);
}
})
.on("click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(e);});
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {
let choices = BDFDB.getAllData(this, "choices");
for (let key in choices) settingspanel.querySelector(`${BDFDB.dotCN.select}[type='${key}'] .languageTimestamp`).innerText = this.getJoinedTime(this.languages[choices[key]].id);
});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(e);});
return settingspanel;
}
@ -90,23 +86,25 @@ class JoinedAtDate {
load () {}
start () {
let libraryScript = null;
if (typeof BDFDB !== "object" || BDFDB.isLibraryOutdated()) {
if (typeof BDFDB === "object") BDFDB = "";
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") 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.CurrentGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
@ -124,7 +122,7 @@ class JoinedAtDate {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".joinedAtDate");
BDFDB.unloadMessage(this);
}
@ -132,45 +130,39 @@ class JoinedAtDate {
// begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
openDropdownMenu (e) {
let selectControl = e.currentTarget;
let selectWrap = selectControl.parentElement;
let plugincard = BDFDB.getParentEle("li", selectWrap);
if (!plugincard || selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
selectWrap.classList.add(BDFDB.disCN.selectisopen);
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
plugincard.style.setProperty("overflow", "visible", "important");
let type = selectWrap.getAttribute("type");
let selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
selectWrap.appendChild(selectMenu);
$(selectMenu)
.on("mousedown." + this.getName(), 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.getJoinedTime(language);
BDFDB.saveData(type, language, this, "choices");
});
$(document)
.on("mousedown.select" + this.getName(), e2 => {
if (e2.target.parentElement == selectMenu) return;
$(document).off("mousedown.select" + this.getName());
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.getJoinedTime(language);
BDFDB.saveData(type, language, this, "choices");
});
var removeMenu = e2 => {
if (e2.target.parentElement != selectMenu) {
document.removeEventListener("mousedown", removeMenu);
selectMenu.remove();
plugincard.style.removeProperty("overflow");
setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
});
setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
}
};
document.addEventListener("mousedown", removeMenu);
}
createDropdownMenu (choice, type) {
@ -205,11 +197,11 @@ class JoinedAtDate {
let choice = BDFDB.getData("joinedAtDateLang", this, "choices");
let nametag = container.querySelector(BDFDB.dotCN.nametag);
let creationDate = container.querySelector(".creationDate");
container.insertBefore(BDFDB.htmlToElement(`<div class="joinedAtDate DevilBro-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container).getBoundingClientRect().width - 20}px !important;"><div class="DevilBro-textscroll">${this.labels.joinedat_text + " " + this.getJoinedTime(this.languages[choice].id, timestamp)}</div></div>`), creationDate ? creationDate : (nametag ? nametag.nextSibling : null));
container.insertBefore(BDFDB.htmlToElement(`<div class="joinedAtDate DevilBro-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important;"><div class="DevilBro-textscroll">${this.labels.joinedat_text + " " + this.getJoinedTime(this.languages[choice].id, timestamp)}</div></div>`), creationDate ? creationDate : (nametag ? nametag.nextSibling : null));
BDFDB.initElements(container.parentElement);
if (popout && popout.style.transform.indexOf("translateY(-1") == -1) {
let arect = document.querySelector(BDFDB.dotCN.appmount).getBoundingClientRect();
let prect = popout.getBoundingClientRect();
let arect = BDFDB.getRects(document.querySelector(BDFDB.dotCN.appmount));
let prect = BDFDB.getRects(popout);
popout.style.setProperty("top", (prect.y + prect.height > arect.height ? (arect.height - prect.height) : prect.y) + "px");
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"MessageUtilities"}*//
class MessageUtilities {
getName () {return "MessageUtilities";}
getVersion () {return "1.4.4";}
getAuthor () {return "DevilBro";}
getDescription () {return "Offers a number of useful message options. Remap the keybindings in the settings.";}
initConstructor () {
this.bindings = {};
@ -31,21 +39,13 @@ class MessageUtilities {
"Delete_Message": {name:"Delete Message", func:this.doDelete, value:{click:0, key1:46, key2:0}},
"Pin/Unpin_Message": {name:"Pin/Unpin Message", func:this.doPinUnPin, value:{click:0, key1:17, key2:0}},
"React_to_Message": {name:"React to Message", func:this.doOpenReact, value:{click:0, key1:9, key2:0}},
"__Note_Message": {name:"Note Message (Pesonal Pins)", func:this.doNote, value:{click:0, key1:16, key2:0}},
"__Translate_Message": {name:"Translate Message (Google Translate Option)", func:this.doTranslate, value:{click:0, key1:20, key2:0}},
"__Quote_Message": {name:"Quote Message (Quoter)", func:this.doQuote, value:{click:0, key1:113, key2:0}},
"__Citate_Message": {name:"Quote Message (Citador)", func:this.doCitate, value:{click:0, key1:114, key2:0}}
"__Note_Message": {name:"Note Message (Pesonal Pins)", func:this.doNote, value:{click:0, key1:16, key2:0}, plugin:"PersonalPins"},
"__Translate_Message": {name:"Translate Message (Google Translate Option)", func:this.doTranslate, value:{click:0, key1:20, key2:0}, plugin:"GoogleTranslateOption"},
"__Quote_Message": {name:"Quote Message (Quoter)", func:this.doQuote, value:{click:0, key1:113, key2:0}, plugin:"Quoter"},
"__Citate_Message": {name:"Quote Message (Citador)", func:this.doCitate, value:{click:0, key1:114, key2:0}, plugin:"Citador"}
}
};
}
getName () {return "MessageUtilities";}
getDescription () {return "Offers a number of useful message options. Remap the keybindings in the settings.";}
getVersion () {return "1.4.3";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -53,36 +53,31 @@ class MessageUtilities {
let bindings = BDFDB.getAllData(this, "bindings");
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
if (this.defaults.settings[key].description) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
if (this.defaults.settings[key].description) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let action in bindings) {
settingshtml += `<div class="${action}-key-settings"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.bindings[action].name}:</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[action] ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
for (let click of this.clicks) {
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 20%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">${click}:</h5><div class="${BDFDB.disCN.selectwrap}"><div type="${action}" option="${click}" value="${bindings[action][click]}" class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="padding:0;">${this.clickMap[bindings[action][click]]}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
if (!this.defaults.bindings[action].plugin || BDFDB.isPluginEnabled(this.defaults.bindings[action].plugin)) {
settingshtml += `<div class="${action}-key-settings"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.bindings[action].name}:</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[action] ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
for (let click of this.clicks) {
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 20%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">${click}:</h5><div class="${BDFDB.disCN.selectwrap}"><div type="${action}" option="${click}" value="${bindings[action][click]}" class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="padding:0;">${this.clickMap[bindings[action][click]]}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
}
for (let key of this.keys) {
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 40%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">${key}:<label class="reset-recorder" style="float: right; padding-right: 5px; cursor: pointer;">✖</label></h5><div type="${action}" option="${key}" value="${bindings[action][key]}" class="${BDFDB.disCNS.hotkeycontainer + BDFDB.disCNS.hotkeycontainer2 + BDFDB.disCN.hotkeyhasvalue}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.hotkeylayout + BDFDB.disCN.hotkeylayout2}" style="flex: 1 1 auto;"><input type="text" placeholder="${this.keyboardMap[bindings[action][key]]}" readonly="" value="${this.keyboardMap[bindings[action][key]]}" class="${BDFDB.disCNS.hotkeyinput + BDFDB.disCNS.hotkeyinput2 + BDFDB.disCN.hotkeybase}" style="flex: 1 1 auto;"></input><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCN.nowrap}" style="flex: 0 1 auto; margin: 0px;"><button type="button" class="${BDFDB.disCNS.hotkeybutton + BDFDB.disCNS.hotkeybutton2 + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookghost + BDFDB.disCNS.buttoncolorgrey + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow}"><div class="${BDFDB.disCN.buttoncontents}"><span class="${BDFDB.disCN.hotkeytext}">${BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_EDIT}</span><span class="${BDFDB.disCN.hotkeyediticon}"/></div></button></div></div></div></div>`;
}
settingshtml += `</div></div>`;
}
for (let key of this.keys) {
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 40%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">${key}:<label class="reset-recorder" style="float:right;padding-right:5px;cursor:pointer;">✖</label></h5><div type="${action}" option="${key}" value="${bindings[action][key]}" class="${BDFDB.disCNS.hotkeycontainer + BDFDB.disCNS.hotkeycontainer2 + BDFDB.disCN.hotkeyhasvalue}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.hotkeylayout + BDFDB.disCN.hotkeylayout2}" style="flex: 1 1 auto;"><input type="text" placeholder="${this.keyboardMap[bindings[action][key]]}" readonly="" value="${this.keyboardMap[bindings[action][key]]}" class="${BDFDB.disCNS.hotkeyinput + BDFDB.disCNS.hotkeyinput2 + BDFDB.disCN.hotkeybase}" style="flex: 1 1 auto;"></input><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCN.nowrap}" style="flex: 0 1 auto; margin: 0px;"><button type="button" class="${BDFDB.disCNS.hotkeybutton + BDFDB.disCNS.hotkeybutton2 + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookghost + BDFDB.disCNS.buttoncolorgrey + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow}"><div class="${BDFDB.disCN.buttoncontents}"><span class="${BDFDB.disCN.hotkeytext}">${BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_EDIT}</span><span class="${BDFDB.disCN.hotkeyediticon}"/></div></button></div></div></div></div>`;
}
settingshtml += `</div></div>`;
}
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Reset all key bindings.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
settingshtml += `</div></div>`;
let 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("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu(settingspanel, e);})
.on("click", BDFDB.dotCN.hotkeycontainer, (e) => {this.startRecording(settingspanel, e);})
.on("click", ".reset-recorder", (e) => {this.resetRecorder(settingspanel, e);})
.on("click", ".reset-button", () => {this.resetAll(settingspanel);});
$(settingspanel).find(".__Note_Message-key-settings").toggle(BDFDB.isPluginEnabled("PersonalPins") == true);
$(settingspanel).find(".__Translate_Message-key-settings").toggle(BDFDB.isPluginEnabled("GoogleTranslateOption") == true);
$(settingspanel).find(".__Quote_Message-key-settings").toggle(BDFDB.isPluginEnabled("Quoter") == true);
$(settingspanel).find(".__Citate_Message-key-settings").toggle(BDFDB.isPluginEnabled("Citador") == true);
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(e);})
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.hotkeycontainer, e => {this.startRecording(settingspanel, e);})
BDFDB.addEventListener(this, settingspanel, "click", ".reset-recorder", e => {this.resetRecorder(settingspanel, e);})
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {this.resetAll(settingspanel);});
return settingspanel;
}
@ -91,22 +86,25 @@ class MessageUtilities {
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.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
@ -115,16 +113,15 @@ class MessageUtilities {
this.CurrentUserPerms = BDFDB.WebModules.findByProperties("getChannelPermissions", "can");
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions
$(document)
.on("click." + this.getName(), BDFDB.dotCNC.message + BDFDB.dotCN.messagesystem, (e) => {
this.onClick(e.currentTarget, 0, "onSglClick");
})
.on("dblclick." + this.getName(), BDFDB.dotCNC.message + BDFDB.dotCN.messagesystem, (e) => {
this.onClick(e.currentTarget, 1, "onDblClick");
})
.on("keydown." + this.getName(), BDFDB.dotCN.textareawrapchat, (e) => {
this.onKeyDown(e.currentTarget, e.which, "onKeyDown");
});
BDFDB.addEventListener(this, document, "click", BDFDB.dotCNC.message + BDFDB.dotCN.messagesystem, e => {
this.onClick(e.currentTarget, 0, "onSglClick");
})
BDFDB.addEventListener(this, document, "dblclick", BDFDB.dotCNC.message + BDFDB.dotCN.messagesystem, e => {
this.onClick(e.currentTarget, 1, "onDblClick");
});
BDFDB.addEventListener(this, document, "keydown", BDFDB.dotCN.textareawrapchat, e => {
this.onKeyDown(e.currentTarget, e.which, "onKeyDown");
});
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
@ -132,21 +129,13 @@ class MessageUtilities {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
//begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
resetAll (settingspanel) {
BDFDB.openConfirmModal(this, "Are you sure you want to delete all key bindings?", () => {
@ -167,13 +156,15 @@ class MessageUtilities {
});
}
openDropdownMenu (settingspanel, e) {
openDropdownMenu (e) {
let selectControl = e.currentTarget;
let selectWrap = e.currentTarget.parentElement;
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);
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
plugincard.style.setProperty("overflow", "visible", "important");
let action = selectWrap.getAttribute("type");
let option = selectWrap.getAttribute("option");
@ -181,8 +172,8 @@ class MessageUtilities {
let selectMenu = this.createDropdownMenu(action, value);
selectWrap.appendChild(selectMenu);
$(selectMenu).on("mousedown." + this.getName(), BDFDB.dotCN.selectoption, (e2) => {
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
let binding = BDFDB.getData(action, this, "bindings");
let selection = e2.currentTarget.getAttribute("value");
selectWrap.setAttribute("value", selection);
@ -190,12 +181,16 @@ class MessageUtilities {
binding[option] = parseInt(selection);
BDFDB.saveData(action, binding, this, "bindings");
});
$(document).on("mousedown.select" + this.getName(), (e2) => {
if (e2.target.parentElement == selectMenu) return;
$(document).off("mousedown.select" + this.getName());
selectMenu.remove()
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 (action, value) {
@ -205,40 +200,43 @@ class MessageUtilities {
menuhtml += `<div value="${i}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectoption + isSelected}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}">${this.clickMap[i]}</div></div>`
}
menuhtml += `</div></div>`;
return $(menuhtml)[0];
return BDFDB.htmlToElement(menuhtml);
}
startRecording (settingspanel, e) {
let recorderWrap = e.currentTarget;
if (recorderWrap.classList.contains(BDFDB.disCN.hotkeyrecording)) return;
if (BDFDB.containsClass(recorderWrap, BDFDB.disCN.hotkeyrecording)) return;
let recorderInput = recorderWrap.querySelector("input");
let recorderText = recorderWrap.querySelector(BDFDB.dotCN.hotkeytext);
let action = recorderWrap.getAttribute("type");
let option = recorderWrap.getAttribute("option");
recorderWrap.classList.add(BDFDB.disCN.hotkeyrecording);
recorderWrap.classList.remove(BDFDB.disCN.hotkeyhasvalue);
BDFDB.addClass(recorderWrap, BDFDB.disCN.hotkeyrecording);
BDFDB.removeClass(recorderWrap, BDFDB.disCN.hotkeyhasvalue);
recorderText.innerText = BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_RECORDING;
$(document).on("keydown.recorder" + this.getName(), (e) => {
var saveRecording = e => {
recorderWrap.setAttribute("value", e.which);
recorderInput.setAttribute("value", this.keyboardMap[e.which]);
});
};
$(document).on("mousedown.recorder" + this.getName(), () => {
$(document).off("mousedown.recorder" + this.getName());
$(document).off("keydown.recorder" + this.getName());
var stopRecording = e => {
document.removeEventListener("mousedown", stopRecording);
document.removeEventListener("keydown", saveRecording);
let binding = BDFDB.getData(action, this, "bindings");
binding[option] = parseInt(recorderWrap.getAttribute("value"));
BDFDB.saveData(action, binding, this, "bindings");
setTimeout(() => {
recorderWrap.classList.remove(BDFDB.disCN.hotkeyrecording);
recorderWrap.classList.add(BDFDB.disCN.hotkeyhasvalue);
BDFDB.removeClass(recorderWrap, BDFDB.disCN.hotkeyrecording);
BDFDB.addClass(recorderWrap, BDFDB.disCN.hotkeyhasvalue);
recorderText.innerText = BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_EDIT;
},100);
});
};
document.addEventListener("mousedown", stopRecording);
document.addEventListener("keydown", saveRecording);
}
resetRecorder (settingspanel, e) {
@ -308,31 +306,28 @@ class MessageUtilities {
}
doNote ({messagediv, pos, message}) {
if (BDFDB.isPluginEnabled("PersonalPins") == true) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
let channel = this.ChannelUtils.getChannel(message.channel_id);
if (channel) {
if (bdplugins.PersonalPins.plugin.getNoteData(message, channel, pos)) bdplugins.PersonalPins.plugin.removeNoteData(message, channel, pos);
else bdplugins.PersonalPins.plugin.addMessageToNotes(message, messagediv, channel);
}
if (channel) bdplugins[this.defaults.bindings.__Note_Message.plugin].plugin.addMessageToNotes(message, messagediv, channel);
}
}
doTranslate ({messagediv, pos, message}) {
if (BDFDB.isPluginEnabled("GoogleTranslateOption") == true) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
let channel = this.ChannelUtils.getChannel(message.channel_id);
if (channel) bdplugins.GoogleTranslateOption.plugin.translateMessage(message, messagediv, channel);
if (channel) bdplugins[this.defaults.bindings.__Translate_Message.plugin].plugin.translateMessage(message, messagediv, channel);
}
}
doQuote ({messagediv, pos, message}) {
if (BDFDB.isPluginEnabled("Quoter") == true) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Quote_Message.plugin)) {
let quoteButton = messagediv.querySelector(".btn-quote");
if (quoteButton) quoteButton.click();
}
}
doCitate ({messagediv, pos, message}) {
if (BDFDB.isPluginEnabled("Citador") == true) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Citate_Message.plugin)) {
let citarButton = messagediv.parentElement.querySelector(".citar-btn");
if (citarButton) citarButton.click();
}

View File

@ -3,7 +3,7 @@
class MoveablePopups {
getName () {return "MoveablePopups";}
getVersion () {return "1.1.1";}
getVersion () {return "1.1.2";}
getAuthor () {return "DevilBro";}
@ -13,22 +13,25 @@ class MoveablePopups {
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;
@ -73,7 +76,7 @@ class MoveablePopups {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
@ -94,7 +97,7 @@ class MoveablePopups {
if (!e.ctrlKey) return;
div.style.setProperty("position", "fixed", "important");
this.dragging = true;
var rects = div.getBoundingClientRect();
var rects = BDFDB.getRects(div);
var transform = getComputedStyle(div,null).getPropertyValue("transform").replace(/[^0-9,-]/g,"").split(",");
var left = rects.left - (transform.length > 4 ? parseFloat(transform[4]) : 0);
var top = rects.top - (transform.length > 4 ? parseFloat(transform[5]) : 0);

View File

@ -1,6 +1,14 @@
//META{"name":"NotificationSounds"}*//
class NotificationSounds {
getName () {return "NotificationSounds";}
getVersion () {return "3.2.4";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to replace the native sounds of Discord with your own";}
initConstructor () {
this.patchModules = {
"IncomingCalls":"componentDidMount",
@ -91,14 +99,6 @@ class NotificationSounds {
this.firedEvents = {};
}
getName () {return "NotificationSounds";}
getDescription () {return "Allows you to replace the native sounds of Discord with your own";}
getVersion () {return "3.2.3";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -119,8 +119,7 @@ class NotificationSounds {
for (var type in this.types) {
var choice = BDFDB.loadData(type, this, "choices");
var unimplemented = this.types[type].implemented ? "" : " unimplemented";
settingshtml += `<div class="${type}-song-settings ${unimplemented}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.types[type].name}:</h3><h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Mute in DnD:</h5><div type="${type}" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} mute-checkbox"${choice.mute ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
settingshtml += `<div class="${type}-song-settings${this.types[type].implemented ? '"' : ' unimplemented" style="display: none !important;"'}><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.types[type].name}:</h3><h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Mute in DnD:</h5><div type="${type}" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} mute-checkbox"${choice.mute ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
for (var key of fields) {
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 33%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">${key}:</h5><div class="${BDFDB.disCN.selectwrap}"><div type="${type}" option="${key}" value="${choice[key]}" class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="padding:0;">${choice[key]}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
}
@ -131,47 +130,44 @@ class NotificationSounds {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Remove all added songs.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
settingshtml += `</div></div>`;
var settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu(settingspanel, e);})
.on("click", ".btn-addsong", (e) => {this.saveAudio(settingspanel);})
.on("keyup", ".songInput", (e) => {if (e.which == 13) this.saveAudio(settingspanel);})
.on("click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to delete all added songs?", () => {
BDFDB.removeAllData(this, "choices");
BDFDB.removeAllData(this, "audios");
this.loadAudios();
this.loadChoices();
settingspanel.querySelectorAll(BDFDB.dotCN.select).forEach((wrap) => {
wrap.setAttribute("value", "---");
wrap.querySelector(BDFDB.dotCN.title).innerText = "---";
});
settingspanel.querySelectorAll(BDFDB.dotCN.slidergrabber).forEach((grabber) => {
grabber.style.left = "100%";
});
settingspanel.querySelectorAll(BDFDB.dotCN.sliderbarfill).forEach((bar) => {
bar.style.width = "100%";
});
settingspanel.querySelectorAll(".volumeInput").forEach((input) => {
input.value = 100;
});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(settingspanel, e);});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addsong", e => {this.saveAudio(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "keyup", ".songInput", e => {if (e.which == 13) this.saveAudio(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to delete all added songs?", () => {
BDFDB.removeAllData(this, "choices");
BDFDB.removeAllData(this, "audios");
this.loadAudios();
this.loadChoices();
settingspanel.querySelectorAll(BDFDB.dotCN.select).forEach(wrap => {
wrap.setAttribute("value", "---");
wrap.querySelector(BDFDB.dotCN.title).innerText = "---";
});
})
.on("click", ".mute-checkbox", (e) => {
var checkbox = e.currentTarget;
var type = checkbox.parentElement.getAttribute("type");
var choice = BDFDB.loadData(type, this, "choices");
choice.mute = checkbox.checked;
this.saveChoice(type, choice, false);
})
.on("click", "#input-unimplemented", (e) => {
$(settingspanel).find(".unimplemented").toggle(e.currentTarget.checked);
})
.on("mousedown", BDFDB.dotCN.slidergrabber, (e) => {this.dragSlider(settingspanel,e);})
.find(".unimplemented").hide();
settingspanel.querySelectorAll(BDFDB.dotCN.slidergrabber).forEach(grabber => {
grabber.style.left = "100%";
});
settingspanel.querySelectorAll(BDFDB.dotCN.sliderbarfill).forEach(bar => {
bar.style.width = "100%";
});
settingspanel.querySelectorAll(".volumeInput").forEach(input => {
input.value = 100;
});
});
});
BDFDB.addEventListener(this, settingspanel, "click", ".mute-checkbox", e => {
var type = e.currentTarget.parentElement.getAttribute("type");
var choice = BDFDB.loadData(type, this, "choices");
choice.mute = e.currentTarget.checked;
this.saveChoice(type, choice, false);
});
BDFDB.addEventListener(this, settingspanel, "click", "#input-unimplemented", e => {
BDFDB.toggleEles(settingspanel.querySelectorAll(".unimplemented"), e.currentTarget.checked);
});
BDFDB.addEventListener(this, settingspanel, "mousedown", BDFDB.dotCN.slidergrabber, e => {this.dragSlider(settingspanel,e);});
return settingspanel;
}
@ -180,27 +176,30 @@ class NotificationSounds {
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.ChannelSettingsUtils = BDFDB.WebModules.findByProperties("isGuildOrCategoryOrChannelMuted");
BDFDB.WebModules.patch(BDFDB.WebModules.findByProperties("receiveMessage"), "receiveMessage", this, {before: (e) => {
BDFDB.WebModules.patch(BDFDB.WebModules.findByProperties("receiveMessage"), "receiveMessage", this, {before: e => {
let message = e.methodArguments[1];
let guildid = message.guild_id ? message.guild_id : null;
if (!this.ChannelSettingsUtils.isGuildOrCategoryOrChannelMuted(guildid, message.channel_id) && message.author.id != BDFDB.myData.id) {
@ -218,7 +217,7 @@ class NotificationSounds {
}
}});
BDFDB.WebModules.patch(BDFDB.WebModules.findByProperties("playSound"), "playSound", this, {instead: (e) => {
BDFDB.WebModules.patch(BDFDB.WebModules.findByProperties("playSound"), "playSound", this, {instead: e => {
setImmediate(() => {
var type = e.methodArguments[0];
if (type == "message1") {
@ -242,7 +241,7 @@ class NotificationSounds {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
@ -251,12 +250,14 @@ class NotificationSounds {
// begin of own functions
openDropdownMenu (settingspanel, 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);
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
plugincard.style.setProperty("overflow", "visible", "important");
var type = selectWrap.getAttribute("type");
var option = selectWrap.getAttribute("option");
@ -269,7 +270,7 @@ class NotificationSounds {
var selectMenu = this.createDropdownMenu({type, option, category, song});
selectWrap.appendChild(selectMenu);
$(selectMenu).on("mousedown." + this.getName(), BDFDB.dotCN.selectoption, (e2) => {
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
var choice = BDFDB.loadData(type, this, "choices");
var selection = e2.currentTarget.textContent;
selectWrap.setAttribute("value", selection);
@ -283,12 +284,17 @@ class NotificationSounds {
choice.src = choice.src ? choice.src : this.types[type].src;
this.saveChoice(type, choice, true);
});
$(document).on("mousedown.select" + this.getName(), (e2) => {
if (e2.target.parentElement == selectMenu) return;
$(document).off("mousedown.select" + this.getName());
selectMenu.remove()
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 ({type, option, category, song} = data) {
@ -300,7 +306,7 @@ class NotificationSounds {
menuhtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectoption + isSelected}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}">${ele}</div></div>`
}
menuhtml += `</div></div>`;
return $(menuhtml)[0];
return BDFDB.htmlToElement(menuhtml);
}
dragSlider (settingspanel, e) {
@ -309,36 +315,32 @@ class NotificationSounds {
var slider = track.parentNode;
var input = slider.querySelector(".volumeInput");
var bar = slider.querySelector(BDFDB.dotCN.sliderbarfill);
var disableTextSelectionCSS = `
* {
user-select: none !important;
}`;
BDFDB.appendLocalStyle("disableTextSelection", disableTextSelectionCSS);
BDFDB.appendLocalStyle("disableTextSelection", `*{user-select: none !important;}`);
var volume = 0;
var sY = 0;
var sHalfW = grabber.offsetWidth/2;
var sMinX = $(track).offset().left;
var sMaxX = sMinX + track.offsetWidth;
$(document)
.off("mouseup.slider" + this.getName()).off("mousemove.slider" + this.getName())
.on("mouseup.slider" + this.getName(), () => {
$(document).off("mouseup.slider" + this.getName()).off("mousemove.slider" + this.getName());
BDFDB.removeLocalStyle("disableTextSelection");
var type = slider.getAttribute("type");
var choice = this.choices[type];
choice.volume = volume;
this.saveChoice(type, choice, true);
})
.on("mousemove.slider" + this.getName(), (e2) => {
sY = e2.clientX > sMaxX ? sMaxX - sHalfW : (e2.clientX < sMinX ? sMinX - sHalfW : e2.clientX - sHalfW);
volume = BDFDB.mapRange([sMinX - sHalfW, sMaxX - sHalfW], [0, 100], sY);
grabber.style.left = volume + "%";
bar.style.width = volume + "%";
input.value = volume;
});
var sHalfW = BDFDB.getRects(grabber).width/2;
var sMinX = BDFDB.getRects(track).left;
var sMaxX = sMinX + BDFDB.getRects(track).width;
var mouseup = () => {
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("mousemove", mousemove);
BDFDB.removeLocalStyle("disableTextSelection");
var type = slider.getAttribute("type");
var choice = this.choices[type];
choice.volume = volume;
this.saveChoice(type, choice, true);
};
var mousemove = e2 => {
sY = e2.clientX > sMaxX ? sMaxX - sHalfW : (e2.clientX < sMinX ? sMinX - sHalfW : e2.clientX - sHalfW);
volume = BDFDB.mapRange([sMinX - sHalfW, sMaxX - sHalfW], [0, 100], sY);
grabber.style.setProperty("left", volume + "%");
bar.style.setProperty("width", volume + "%");
input.value = volume;
};
document.addEventListener("mouseup", mouseup);
document.addEventListener("mousemove", mousemove);
}
loadAudios () {

View File

@ -3,7 +3,7 @@
class OldTitleBar {
getName () {return "OldTitleBar";}
getVersion () {return "1.5.2";}
getVersion () {return "1.5.3";}
getAuthor () {return "DevilBro";}
@ -94,7 +94,7 @@ class OldTitleBar {
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch${key == "displayNative" ? " nativetitlebar-switch" : ""}"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div></div>`;
@ -102,7 +102,21 @@ class OldTitleBar {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "click", BDFDB.dotCN.switchinner, e => {this.updateSettings(settingspanel, e.currentTarget.value);});
BDFDB.addEventListener(this, settingspanel, "click", ".nativetitlebar-switch", e => {
if (this.patchMainScreen(e.currentTarget.checked)) {
this.patched = !this.patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (this.patched) {
notifybar = BDFDB.createNotificationsBar("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", () => {
let app = require("electron").remote.app;
app.relaunch();
app.quit();
});
}
}
});
return settingspanel;
}
@ -111,21 +125,21 @@ class OldTitleBar {
load () {}
start () {
var libraryScript = null;
if (!global.BDFDB || 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 (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
else if (libraryScript) libraryScript.addEventListener("load", () => {
BDFDB.loaded = true;
this.initialize();
});
}
initialize () {
@ -160,29 +174,6 @@ class OldTitleBar {
// begin of own functions
updateSettings (settingspanel, key) {
var settings = {};
for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
if (key == "displayNative") {
if (this.patchMainScreen(settings[key])) {
this.patched = !this.patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (this.patched) {
notifybar = BDFDB.createNotificationsBar("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
let app = require("electron").remote.app;
app.relaunch();
app.quit();
});
}
}
}
}
processHeaderBar (instance, wrapper) {
this.addTitleBar();

View File

@ -3,7 +3,7 @@
class OwnerTag {
getName () {return "OwnerTag";}
getVersion () {return "1.0.6";}
getVersion () {return "1.0.7";}
getAuthor () {return "DevilBro";}
@ -53,7 +53,7 @@ class OwnerTag {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
return settingspanel;
}
@ -62,22 +62,25 @@ class OwnerTag {
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.MemberUtils = BDFDB.WebModules.findByProperties("getMembers", "getMember");
@ -92,7 +95,7 @@ class OwnerTag {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".owner-tag");
BDFDB.unloadMessage(this);
}
@ -107,7 +110,7 @@ class OwnerTag {
inputs[input.getAttribute("option")] = input.value;
}
BDFDB.saveAllData(inputs, this, "inputs");
this.updateTags = true;
this.SettingsUpdated = true;
}
processNameTag (instance, wrapper) {

View File

@ -1,6 +1,14 @@
//META{"name":"PersonalPins"}*//
class PersonalPins {
getName () {return "PersonalPins";}
getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";}
getVersion () {return "1.7.3";}
getAuthor () {return "DevilBro";}
initConstructor () {
this.labels = {};
@ -146,14 +154,6 @@ class PersonalPins {
</div>
</div>`;
}
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 = `<a class="${BDFDB.disCNS.imagewrapper + BDFDB.disCN.imagezoom}" href="" rel="noreferrer noopener" target="_blank" style="width: 400px; height: 225px;"><img alt="" src="${result.split('<link itemprop="thumbnailUrl" href="')[1].split('"')[0]}" style="width: 400px; height: 225px;"></a><div class="${BDFDB.disCNS.embedvideoactions + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifycenter + BDFDB.disCN.aligncenter}"><div class="${BDFDB.disCNS.embedvideoactionsinner + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex + BDFDB.disCNS.justifycenter + BDFDB.disCN.aligncenter}"><div class="${BDFDB.disCN.iconactionswrapper}"><div tabindex="0" class="${BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" role="button"><svg name="Play" class="${BDFDB.disCNS.iconplay + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><polygon fill="currentColor" points="0 0 0 14 11 7" transform="translate(7 5)"></polygon></svg></div><a class="${BDFDB.disCNS.anchor + BDFDB.disCN.iconwrapper}" href="${ytlink}" rel="noreferrer noopener" target="_blank"><svg name="OpenExternal" class="${BDFDB.disCNS.iconexternalmargins + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" transform="translate(3.000000, 4.000000)" d="M16 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4v-2H2V4h14v10h-4v2h4c1.1 0 2-.9 2-2V2a2 2 0 0 0-2-2zM9 6l-4 4h3v6h2v-6h3L9 6z"></path></svg></a></div></div></div></div>`;
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('<meta itemprop="height" content="')[1].split('"')[0]/result.split('<meta itemprop="width" content="')[1].split('"')[0]));
@ -466,23 +470,22 @@ class PersonalPins {
});
}
}
messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname).addEventListener("click", (e) => {
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};
}

View File

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

View File

@ -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(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-plugin"></div></div>`));
let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-plugin"></div></div>`);
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);
}
}

View File

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

View File

@ -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 = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div></div>`;
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");
}
}
}

View File

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

View File

@ -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 {
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.searchbar + BDFDB.disCN.size14}" style="flex: 1 1 auto;">
<input class="${BDFDB.disCN.searchbarinput}" value="" placeholder="Search for ..." style="flex: 1 1 auto;">
<div class="${BDFDB.disCN.searchbariconwrap}">
<i class="${BDFDB.disCNS.searchbaricon + BDFDB.disCNS.searchbareyeglass + BDFDB.disCN.searchbarvisible}"/>
<i class="${BDFDB.disCNS.searchbaricon + BDFDB.disCN.searchbarclear}"/>
<i class="${BDFDB.disCNS.searchbaricon + BDFDB.disCNS.searchbareyeglass + BDFDB.disCN.searchbarvisible}"></i>
<i class="${BDFDB.disCNS.searchbaricon + BDFDB.disCN.searchbarclear}"></i>
</div>
</div>
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}" style="flex: 0 1 auto;">
@ -66,7 +66,7 @@ class RepoControls {
</div>`;
this.sortPopoutMarkup =
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} repocontrols-sort-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);" option="sort">
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} repocontrols-sort-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
<div>
<div class="${BDFDB.disCN.contextmenu} quickSelectPopout">
<div class="${BDFDB.disCN.contextmenuitemgroup}">
@ -77,7 +77,7 @@ class RepoControls {
</div>`;
this.orderPopoutMarkup =
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} repocontrols-order-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);" option="order">
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} repocontrols-order-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
<div>
<div class="${BDFDB.disCN.contextmenu} quickSelectPopout">
<div class="${BDFDB.disCN.contextmenuitemgroup}">
@ -121,17 +121,14 @@ class RepoControls {
let settings = BDFDB.getAllData(this, "settings");
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div></div>`;
let 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;
}
@ -139,22 +136,25 @@ class RepoControls {
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.fs = require("fs");
@ -170,7 +170,7 @@ class RepoControls {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".repo-controls","#bd-settingspane-container .trashIcon");
BDFDB.removeClasses("repocontrols-added");
@ -180,6 +180,8 @@ class RepoControls {
for (let li of list.querySelectorAll("li")) {
li.style.removeProperty("display");
li.style.removeProperty("order");
var checkbox = li.querySelector(BDFDB.dotCN._repocheckbox);
if (checkbox) checkbox.removeEventListener("change", checkbox.changeRepoControlsListener);
}
}
@ -189,14 +191,6 @@ class RepoControls {
// begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
processV2CList (instance, container) {
if (instance._reactInternalFiber.key) this.addControls(instance._reactInternalFiber.key.split("-")[0], container);
@ -222,7 +216,7 @@ class RepoControls {
if (!name) return;
let path = global[`bd${type}s`] && global[`bd${type}s`][name] ? this.path.join(this.dirs[type], global[`bd${type}s`][name].filename) : null;
if (!path) return;
let button = $(this.deleteButtonMarkup)[0];
let button = BDFDB.htmlToElement(this.deleteButtonMarkup);
button.addEventListener("click", () => {
let deleteFile = () => {
this.fs.unlink(path, (error) => {
@ -235,7 +229,7 @@ class RepoControls {
deleteFile();
});
});
button.addEventListener("mouseenter", (e) => {
button.addEventListener("mouseenter", e => {
BDFDB.createTooltip(`Delete ${type[0].toUpperCase() + type.slice(1)}`, e.currentTarget, {type:"top",selector:"repocontrols-trashicon-tooltip"});
});
let controls = wrapper.querySelector(BDFDB.dotCN._repocontrols);
@ -246,38 +240,49 @@ class RepoControls {
if (!type || !container) return;
BDFDB.removeEles(".repo-controls");
container.style.setProperty("display","flex","important");
container.style.setProperty("flex-direction","column","important");
container.style.setProperty("display", "flex", "important");
container.style.setProperty("flex-direction", "column", "important");
let sortings = BDFDB.getAllData(this, "sortings");
let repoControls = $(this.repoControlsMarkup);
BDFDB.initElements(repoControls);
repoControls.find(".sort-filter " + BDFDB.dotCN.quickselectvalue).attr("option", sortings.sort).text(this.sortings.sort[sortings.sort]);
repoControls.find(".order-filter " + BDFDB.dotCN.quickselectvalue).attr("option", sortings.order).text(this.sortings.order[sortings.order]);
repoControls
.on("keyup." + this.getName(), BDFDB.dotCN.searchbarinput, () => {
clearTimeout(repoControls.searchTimeout);
repoControls.searchTimeout = setTimeout(() => {this.sortEntries(container, repoControls);},1000);
})
.on("click." + this.getName(), BDFDB.dotCN.searchbarclear + BDFDB.dotCN.searchbarvisible, () => {
this.sortEntries(container, repoControls);
})
.on("click." + this.getName(), ".btn-enableall", (e) => {
this.toggleAll(type, container, true);
})
.on("click." + this.getName(), ".btn-disableall", (e) => {
this.toggleAll(type, container, false);
})
.on("click." + this.getName(), ".sort-filter", (e) => {
this.openSortPopout(e, this.sortPopoutMarkup, container, repoControls);
})
.on("click." + this.getName(), ".order-filter", (e) => {
this.openSortPopout(e, this.orderPopoutMarkup, container, repoControls);
})
.insertBefore(container);
let repocontrols = BDFDB.htmlToElement(this.repoControlsMarkup);
BDFDB.initElements(repocontrols);
container.parentElement.insertBefore(repocontrols, container);
container.classList.add("repocontrols-added");
let sortfilter = repocontrols.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue);
sortfilter.setAttribute("option", sortings.sort);
sortfilter.innerText = this.sortings.sort[sortings.sort];
let orderfilter = repocontrols.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue);
orderfilter.setAttribute("option", sortings.order);
orderfilter.innerText = this.sortings.order[sortings.order];
BDFDB.addChildEventListener(repocontrols, "keyup", BDFDB.dotCN.searchbarinput, () => {
clearTimeout(repocontrols.searchTimeout);
repocontrols.searchTimeout = setTimeout(() => {this.sortEntries(container, repocontrols);},1000);
});
BDFDB.addChildEventListener(repocontrols, "click", BDFDB.dotCN.searchbarclear + BDFDB.dotCN.searchbarvisible, () => {
this.sortEntries(container, repocontrols);
});
BDFDB.addChildEventListener(repocontrols, "click", ".btn-enableall", e => {
this.toggleAll(type, container, true);
});
BDFDB.addChildEventListener(repocontrols, "click", ".btn-disableall", e => {
this.toggleAll(type, container, false);
});
BDFDB.addChildEventListener(repocontrols, "click", ".sort-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {
BDFDB.saveData("sort", sortfilter.getAttribute("option"), this, "sortings");
this.sortEntries(container, repocontrols);
});
});
BDFDB.addChildEventListener(repocontrols, "click", ".order-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {
BDFDB.saveData("order", orderfilter.getAttribute("option"), this, "sortings");
this.sortEntries(container, repocontrols);
});
});
BDFDB.addClass(container, "repocontrols-added");
container.entries = {};
for (let li of container.children) {
@ -304,12 +309,12 @@ class RepoControls {
};
}
}
this.sortEntries(container, repoControls);
this.sortEntries(container, repocontrols);
}
sortEntries (container, repoControls) {
sortEntries (container, repocontrols) {
if (typeof container.entries != "object") return;
let searchstring = repoControls.find(BDFDB.dotCN.searchbarinput).val().replace(/[<|>]/g, "").toUpperCase();
let searchstring = repocontrols.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase();
let sortings = BDFDB.getAllData(this, "sortings");
let entries = BDFDB.filterObject(container.entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;});
@ -321,26 +326,23 @@ class RepoControls {
let pos = entrypositions.indexOf(name);
if (pos > -1) {
this.changeTextToHTML(li, searchstring);
li.style.removeProperty("display");
li.style.setProperty("order", pos, "important");
$(li)
.find(BDFDB.dotCN._repocheckbox)
.off("change." + this.getName())
.on("change." + this.getName(), (e) => {
entries[name].enabled = e.checked ? 0 : 1
});
}
else {
li.style.setProperty("display", "none", "important");
li.style.removeProperty("order");
var checkbox = li.querySelector(BDFDB.dotCN._repocheckbox);
if (checkbox) {
checkbox.removeEventListener("change", checkbox.changeRepoControlsListener);
checkbox.changeRepoControlsListener = () => {entries[name].enabled = checkbox.checked ? 0 : 1};
checkbox.addEventListener("change", checkbox.changeRepoControlsListener);
}
}
else li.style.removeProperty("order");
BDFDB.toggleEles(li, pos > -1)
}
}
changeTextToHTML (wrapper, searchstring) {
if (!wrapper || !wrapper.tagName) return;
for (let ele of wrapper.querySelectorAll(BDFDB.dotCNC._reponame + BDFDB.dotCNC._repoversion + BDFDB.dotCNC._repoauthor + BDFDB.dotCN._repodescription)) {
if (ele.classList.contains(BDFDB.disCN._repodescription)) {
if (BDFDB.containsClass(ele, BDFDB.disCN._repodescription)) {
ele.style.display = "block";
if (searchstring && searchstring.length > 2) ele.innerHTML = BDFDB.highlightText(ele.innerText, searchstring);
else ele.innerHTML = ele.innerText;
@ -358,45 +360,12 @@ class RepoControls {
let switchinner = switchwrap.querySelector(BDFDB.dotCN._repocheckboxinner);
let switchinput = switchwrap.querySelector(BDFDB.dotCN._repocheckbox);
if (switchinner && switchinput) {
if (switchinner.classList.contains("checked") && !enable) switchinput.click();
else if (!switchinner.classList.contains("checked") && enable) switchinput.click();
if (BDFDB.containsClass(switchinner, BDFDB.disCN._repocheckboxchecked) && !enable) switchinput.click();
else if (!BDFDB.containsClass(switchinner, BDFDB.disCN._repocheckboxchecked) && enable) switchinput.click();
}
}
}
}
});
}
openSortPopout (e, markup, container, repoControls) {
let wrapper = e.currentTarget;
if (wrapper.classList.contains("popout-open")) return;
wrapper.classList.add("popout-open");
let value = $(wrapper).find(BDFDB.dotCN.quickselectvalue);
let popout = $(markup);
$(BDFDB.dotCN.popouts).append(popout)
.off("click", BDFDB.dotCN.contextmenuitem)
.on("click", BDFDB.dotCN.contextmenuitem, (e2) => {
let option = $(e2.currentTarget).attr("option");
value.text($(e2.currentTarget).text());
value.attr("option", option);
$(document).off("mousedown.sortpopout" + this.getName());
popout.remove();
BDFDB.saveData(popout.attr("option"), option, this, "sortings");
this.sortEntries(container, repoControls);
setTimeout(() => {wrapper.classList.remove("popout-open");},300);
});
popout
.css("left", $(wrapper).offset().left + $(wrapper).outerWidth() + "px")
.css("top", $(wrapper).offset().top + value.outerHeight() + "px")
.find(BDFDB.dotCN.contextmenu).addClass(BDFDB.getDiscordTheme());
$(document).on("mousedown.sortpopout" + this.getName(), (e2) => {
if (popout.has(e2.target).length == 0) {
$(document).off("mousedown.sortpopout" + this.getName());
popout.remove();
setTimeout(() => {wrapper.classList.remove("popout-open");},300);
}
});
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"ReverseImageSearch"}*//
class ReverseImageSearch {
getName () {return "ReverseImageSearch";}
getVersion () {return "3.4.1";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a reverse image search option to the context menu.";}
initConstructor () {
this.imgUrlReplaceString = "DEVILBRO_BD_REVERSEIMAGESEARCH_REPLACE_IMAGEURL";
@ -40,14 +48,6 @@ class ReverseImageSearch {
</div>
</div>`;
}
getName () {return "ReverseImageSearch";}
getDescription () {return "Adds a reverse image search option to the context menu.";}
getVersion () {return "3.4.0";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -55,17 +55,14 @@ class ReverseImageSearch {
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Search Engines:</h3></div><div class="DevilBro-settings-inner-list">`;
for (let key in engines) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.engines[key].name}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${engines[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.engines[key].name}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="engines ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${engines[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div>`;
settingshtml += `</div></div>`;
let settingspanel = $(settingshtml)[0];
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel);
$(settingspanel)
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
BDFDB.initElements(settingspanel, this);
return settingspanel;
}
@ -74,22 +71,25 @@ class ReverseImageSearch {
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);
}
else {
@ -98,7 +98,7 @@ class ReverseImageSearch {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
@ -110,14 +110,6 @@ class ReverseImageSearch {
this.messageContextSubMenuMarkup = this.messageContextSubMenuMarkup.replace("REPLACE_submenu_disabled_text", this.labels.submenu_disabled_text);
}
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "engines");
}
onNativeContextMenu (instance, menu) {
if (instance.props && instance.props.type == "NATIVE_IMAGE" && instance.props.href && !menu.querySelector(".reverseimagesearch-item")) {
this.appendItem(instance, menu, instance.props.href);
@ -130,12 +122,12 @@ class ReverseImageSearch {
this.appendItem(instance, menu, instance.props.attachment.url);
}
if (instance.props.target.tagName == "A") {
menu.style.setProperty("display","none","important");
BDFDB.toggleEles(menu, false);
require("request")(instance.props.target.href, (error, response, result) => {
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) {
this.appendItem(instance, menu, instance.props.target.href);
}
menu.style.removeProperty("display");
BDFDB.toggleEles(menu, true);
BDFDB.updateContextPosition(menu);
});
}
@ -149,28 +141,24 @@ class ReverseImageSearch {
if (url.split("/https/").length != 1) url = "https://" + url.split("/https/")[url.split("/https/").length-1];
else if (url.split("/http/").length != 1) url = "http://" + url.split("/http/")[url.split("/http/").length-1];
}
$(menu)
.append(this.messageContextEntryMarkup)
.on("mouseenter", ".reverseimagesearch-item", (e) => {
let messageContextSubMenu = $(this.messageContextSubMenuMarkup)[0];
let engines = BDFDB.getAllData(this, "engines");
$(messageContextSubMenu)
.on("click", ".RIS-item", (e2) => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
let engine = e2.currentTarget.getAttribute("engine");
if (engine == "_all") {
for (let key in engines) {
if (key != "_all" && engines[key]) {
window.open(this.defaults.engines[key].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
}
}
}
else window.open(this.defaults.engines[engine].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
});
for (let key in engines) if (!engines[key]) BDFDB.removeEles(messageContextSubMenu.querySelector("[engine='" + key + "']"));
if (messageContextSubMenu.querySelector(".RIS-item")) BDFDB.removeEles(messageContextSubMenu.querySelector(".alldisabled-item"));
BDFDB.appendSubMenu(e.currentTarget, messageContextSubMenu);
let messageContextEntry = BDFDB.htmlToElement(this.messageContextEntryMarkup);
menu.appendChild(messageContextEntry);
let searchitem = messageContextEntry.querySelector(".reverseimagesearch-item");
searchitem.addEventListener("mouseenter", () => {
let messageContextSubMenu = BDFDB.htmlToElement(this.messageContextSubMenuMarkup);
let engines = BDFDB.getAllData(this, "engines");
for (let key in engines) if (!engines[key]) BDFDB.removeEles(messageContextSubMenu.querySelector("[engine='" + key + "']"));
if (messageContextSubMenu.querySelector(".RIS-item")) BDFDB.removeEles(messageContextSubMenu.querySelector(".alldisabled-item"));
BDFDB.addChildEventListener(messageContextSubMenu, "click", ".RIS-item", e => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
let engine = e.currentTarget.getAttribute("engine");
if (engine == "_all") {
for (let key in engines) if (key != "_all" && engines[key]) window.open(this.defaults.engines[key].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
}
else window.open(this.defaults.engines[engine].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
});
BDFDB.appendSubMenu(searchitem, messageContextSubMenu);
});
}
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"SendLargeMessages"}*//
class SendLargeMessages {
getName () {return "SendLargeMessages";}
getVersion () {return "1.5.2";}
getAuthor () {return "DevilBro";}
getDescription () {return "Opens a popout when your message is too large, which allows you to automatically send the message in several smaller messages.";}
initConstructor () {
this.labels = {};
@ -63,34 +71,29 @@ class SendLargeMessages {
</span>`;
}
getName () {return "SendLargeMessages";}
getDescription () {return "Opens a popout when your message is too large, which allows you to automatically send the message in several smaller messages.";}
getVersion () {return "1.5.1";}
getAuthor () {return "DevilBro";}
//legacy
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.clipboard = require("electron").clipboard;
@ -104,7 +107,7 @@ class SendLargeMessages {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
@ -120,86 +123,72 @@ class SendLargeMessages {
processChannelTextArea (instance, wrapper) {
if (instance.props && instance.props.type && instance.props.type == "normal") {
let textarea = wrapper.querySelector("textarea");
if (textarea) {
let modaltext, checkTextarea = () => {
if (BDFDB.getParsedLength(textarea.value) > 1950) {
textarea.selectionStart = 0;
textarea.selectionEnd = textarea.value.length;
document.execCommand("insertText", false, "");
this.showSendModal(modaltext);
}
};
$(textarea)
.off("input." + this.getName())
.on("input." + this.getName(), e => {
clearTimeout(textarea.sendlargemessagestimeout);
textarea.sendlargemessagestimeout = setTimeout(() => {
modaltext = textarea.value;
checkTextarea();
},100);
})
.off("paste." + this.getName())
.on("paste." + this.getName(), e => {
modaltext = textarea.value.slice(0, textarea.selectionStart) + this.clipboard.readText() + textarea.value.slice(textarea.selectionEnd);
setImmediate(() => {checkTextarea(textarea);});
});
}
var textarea = wrapper.querySelector("textarea");
if (!textarea) return;
let modaltext, checkTextarea = () => {
if (BDFDB.getParsedLength(textarea.value) > 1950) {
textarea.selectionStart = 0;
textarea.selectionEnd = textarea.value.length;
document.execCommand("insertText", false, "");
this.showSendModal(modaltext);
}
};
BDFDB.addEventListener(this, textarea, "keyup", e => {
clearTimeout(textarea.sendlargemessagestimeout);
textarea.sendlargemessagestimeout = setTimeout(() => {
modaltext = textarea.value;
checkTextarea();
},100);
});
BDFDB.addEventListener(this, textarea, "paste", e => {
modaltext = textarea.value.slice(0, textarea.selectionStart) + this.clipboard.readText() + textarea.value.slice(textarea.selectionEnd);
setImmediate(() => {checkTextarea(textarea);});
});
}
}
showSendModal (text) {
let sendMessageModal = $(this.sendMessageModalMarkup);
let textinput = sendMessageModal.find("#modal-inputtext");
let warning = sendMessageModal.find("#warning-message");
let counter = sendMessageModal.find("#character-counter");
let sendMessageModal = BDFDB.htmlToElement(this.sendMessageModalMarkup);
let textinput = sendMessageModal.querySelector("#modal-inputtext");
let warning = sendMessageModal.querySelector("#warning-message");
let counter = sendMessageModal.querySelector("#character-counter");
let updateCounter = () => {
let parsedlength = BDFDB.getParsedLength(textinput.val());
let parsedlength = BDFDB.getParsedLength(textinput.value);
let messageAmount = Math.ceil(parsedlength/1900);
warning.text(messageAmount > 15 ? this.labels.modal_messages_warning : "");
counter.text(parsedlength + " (" + (textinput[0].selectionEnd - textinput[0].selectionStart) + ") => " + this.labels.modal_messages_translation + ": " + messageAmount);
warning.innerText = messageAmount > 15 ? this.labels.modal_messages_warning : "";
counter.innerText = parsedlength + " (" + (textinput.selectionEnd - textinput.selectionStart) + ") => " + this.labels.modal_messages_translation + ": " + messageAmount;
};
BDFDB.appendModal(sendMessageModal);
sendMessageModal
.on("click", ".btn-send", (e) => {
e.preventDefault();
let messages = this.formatText(textinput.val());
messages.forEach((message,i) => {
setTimeout(() => {
this.sendMessage(message);
if (i >= messages.length-1) BDFDB.showToast(this.labels.toast_allsent_text, {type:"success"});
},this.messageDelay * i);
});
});
textinput
.val(text)
.focus()
.off("keydown." + this.getName() + " click." + this.getName())
.on("keydown." + this.getName() + " click." + this.getName(), () => {
BDFDB.addChildEventListener(sendMessageModal, "click", ".btn-send", e => {
e.preventDefault();
let messages = this.formatText(textinput.value || "");
messages.forEach((message,i) => {
setTimeout(() => {
updateCounter();
},10);
})
.off("mousedown." + this.getName())
.on("mousedown." + this.getName(), () => {
$(document)
.off("mouseup." + this.getName())
.on("mouseup." + this.getName(), () => {
$(document)
.off("mouseup." + this.getName())
.off("mousemove." + this.getName());
})
.off("mousemove." + this.getName())
.on("mousemove." + this.getName(), () => {
setTimeout(() => {
updateCounter();
},10);
});
this.sendMessage(message);
if (i >= messages.length-1) BDFDB.showToast(this.labels.toast_allsent_text, {type:"success"});
},this.messageDelay * i);
});
});
textinput.value = text || "";
textinput.addEventListener("keyup", () => {setTimeout(() => {updateCounter();},10);});
textinput.addEventListener("click", () => {updateCounter();});
textinput.addEventListener("mousedown", () => {
var mouseup = () => {
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("mousemove", mousemove);
};
var mousemove = () => {
setTimeout(() => {updateCounter();},10);
};
document.addEventListener("mouseup", mouseup);
document.addEventListener("mousemove", mousemove);
});
updateCounter();
textinput.focus();
}
formatText (text) {

View File

@ -3,7 +3,7 @@
class ServerFolders {
getName () {return "ServerFolders";}
getVersion () {return "6.0.2";}
getVersion () {return "6.0.3";}
getAuthor () {return "DevilBro";}
@ -332,13 +332,13 @@ class ServerFolders {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "click", ".reset-button", () => {
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to delete all folders?", () => {
BDFDB.removeAllData(this, "folders");
this.resetAllElements();
});
});
BDFDB.addChildEventListener(settingspanel, "click", ".removecustom-button", () => {
BDFDB.addEventListener(this, settingspanel, "click", ".removecustom-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all custom icons?", () => {
BDFDB.removeAllData(this, "customicons");
});
@ -350,22 +350,25 @@ class ServerFolders {
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);
if (!document.querySelector(BDFDB.dotCN.guildswrapper + ".foldercontent")) {
@ -399,7 +402,7 @@ class ServerFolders {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.resetAllElements();
BDFDB.removeEles(this.foldercontent, ".serverfolder-contextmenu");
BDFDB.unloadMessage(this);
@ -450,7 +453,7 @@ class ServerFolders {
onGuildContextMenu (instance, menu) {
if (document.querySelector(".DevilBro-modal")) return;
if (instance.props && instance.props.target && instance.props.guild && !menu.querySelector(".serverfolders-item")) {
if (instance.props && instance.props.target && instance.props.guild && instance.props.type == "GUILD_ICON_BAR" && !menu.querySelector(".serverfolders-item")) {
let serverContextEntry = BDFDB.htmlToElement(this.serverContextEntryMarkup);
menu.appendChild(serverContextEntry);
let folderitem = serverContextEntry.querySelector(".serverfolders-item");

View File

@ -3,7 +3,7 @@
class ServerHider {
getName () {return "ServerHider";}
getVersion () {return "6.0.0";}
getVersion () {return "6.0.1";}
getAuthor () {return "DevilBro";}
@ -91,7 +91,7 @@ class ServerHider {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "click", ".reset-button", () => {
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all servers?", () => {
BDFDB.removeAllData(this, "servers");
BDFDB.readServerList().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, false);});
@ -104,22 +104,25 @@ class ServerHider {
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);
BDFDB.WebModules.forceAllUpdates(this);
@ -130,7 +133,7 @@ class ServerHider {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.readServerList().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, true);});
BDFDB.unloadMessage(this);

View File

@ -1,12 +1,24 @@
//META{"name":"ShowHiddenChannels"}*//
class ShowHiddenChannels {
getName () {return "ShowHiddenChannels";}
getVersion () {return "2.3.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays channels that are hidden from you by role restrictions.";}
initConstructor () {
this.updateHiddenCategory = false;
this.patchModules = {
"Channels":"componentDidMount",
"CategoryItem":"componentDidMount",
"StandardSidebarView":"componentWillUnmount"
};
this.categoryMarkup =
`<div class="container-hidden">
<div class="${BDFDB.disCN.categorycontainerdefault}">
<div class="${BDFDB.disCN.categorycontainerdefault} hidden-channel">
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstart + BDFDB.disCNS.nowrap + BDFDB.disCNS.categorywrapperdefault + BDFDB.disCN.cursorpointer}" style="flex: 1 1 auto;">
<svg class="${BDFDB.disCNS.categoryicondefault + BDFDB.disCN.categoryicontransition}" width="12" height="12" viewBox="0 0 24 24">
<path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10"></path>
@ -17,7 +29,7 @@ class ShowHiddenChannels {
</div>`;
this.channelTextMarkup =
`<div class="${BDFDB.disCN.channelcontainerdefault}">
`<div class="${BDFDB.disCN.channelcontainerdefault} hidden-channel">
<div class="${BDFDB.disCNS.channelwrapperdefaulttext + BDFDB.disCN.channelwrapper}">
<div class="${BDFDB.disCNS.channelcontentdefaulttext + BDFDB.disCN.channelcontent}">
<div class="${BDFDB.disCN.marginreset}" style="flex: 0 0 auto;">
@ -33,7 +45,7 @@ class ShowHiddenChannels {
</div>`;
this.channelVoiceMarkup =
`<div class="${BDFDB.disCN.channelcontainerdefault}">
`<div class="${BDFDB.disCN.channelcontainerdefault} hidden-channel">
<div class="${BDFDB.disCNS.channelwrapperdefaultvoice + BDFDB.disCN.channelwrapper}">
<div class="${BDFDB.disCNS.channelcontentdefaultvoice + BDFDB.disCN.channelcontent}">
<div class="${BDFDB.disCN.marginreset}" style="flex: 0 0 auto;">
@ -49,7 +61,7 @@ class ShowHiddenChannels {
</div>`;
this.channelCategoryMarkup =
`<div class="${BDFDB.disCN.channelcontainerdefault}">
`<div class="${BDFDB.disCN.channelcontainerdefault} hidden-channel">
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.categorywrappercollapsed + BDFDB.disCN.channelcontent}" style="flex: 1 1 auto;">
<svg class="${BDFDB.disCNS.categoryicontransition + BDFDB.disCNS.directionright + BDFDB.disCN.categoryiconcollapsed}" width="12" height="12" viewBox="0 0 24 24">
<path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M7 10L12 15 17 10"></path>
@ -81,14 +93,6 @@ class ShowHiddenChannels {
}
};
}
getName () {return "ShowHiddenChannels";}
getDescription () {return "Displays channels that are hidden from you by role restrictions.";}
getVersion () {return "2.3.8";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -96,23 +100,21 @@ class ShowHiddenChannels {
var amounts = BDFDB.getAllData(this, "amounts");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in amounts) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">${this.defaults.amounts[key].description}</h3><div class="${BDFDB.disCN.inputwrapper} inputNumberWrapper ${BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCNS.directioncolumn}" style="flex: 1 1 auto;"><span class="numberinput-buttons-zone"><span class="numberinput-button-up"></span><span class="numberinput-button-down"></span></span><input type="number" min="0" option="${key}" value="${amounts[key]}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} amountInput"></div></div>`;
}
settingshtml += `</div></div>`;
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("input", ".amountInput", (e) => {
var input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => {
var input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
return settingspanel;
}
@ -121,22 +123,25 @@ class ShowHiddenChannels {
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.React = BDFDB.WebModules.findByProperties("createElement", "cloneElement");
@ -147,41 +152,7 @@ class ShowHiddenChannels {
this.GuildChannels = BDFDB.WebModules.findByProperties("getChannels", "getDefaultChannel");
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions;
var observer = null;
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.addedNodes) {
change.addedNodes.forEach((node) => {
if (node && node.className && node.className.length > 0 && node.className.indexOf("container-") > -1 && node.className.indexOf("hidden") == -1) {
this.appendToChannelList(document.querySelector(".container-hidden"));
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.channels, {name:"channelListObserver",instance:observer}, {childList: true, subtree: true});
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.removedNodes) {
change.removedNodes.forEach((node) => {
if (this.updateHiddenCategory && node.tagName && node.getAttribute("layer-id") == "user-settings") {
document.querySelectorAll(".container-hidden").forEach(category => {category.remove();});
this.displayHiddenChannels();
this.updateHiddenCategory = false;
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.layers, {name:"settingsWindowObserver",instance:observer}, {childList:true});
this.displayHiddenChannels();
BDFDB.WebModules.forceAllUpdates(this, "Channels");
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
@ -189,294 +160,266 @@ class ShowHiddenChannels {
}
stop () {
if (typeof BDFDB === "object") {
$(".container-hidden").remove();
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".container-hidden");
BDFDB.unloadMessage(this);
}
}
onSwitch () {
if (typeof BDFDB === "object") {
this.displayHiddenChannels();
}
}
// 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.updateHiddenCategory = true;
processChannels (instance, wrapper) {
if (instance.props && instance.props.guild) this.appendHiddenContainer(instance.props.guild);
}
displayHiddenChannels () {
var serverObj = BDFDB.getSelectedServer();
if (serverObj) {
var serverID = serverObj.id;
if (!document.querySelector(".container-hidden[server='" + serverID + "']")) {
$(".container-hidden").remove();
var allChannels = this.ChannelStore.getChannels();
var shownChannels = this.GuildChannels.getChannels(serverID);
var hiddenChannels = {};
for (let type in this.ChannelTypes) hiddenChannels[this.ChannelTypes[type]] = [];
for (let channelID in allChannels) {
var channel = allChannels[channelID];
if (channel.guild_id == serverID) {
var isHidden = true;
if (channel.type == this.ChannelTypes.GUILD_CATEGORY) {
for (let type in this.ChannelTypes) {
if (shownChannels[this.ChannelTypes[type]]) for (let shownChannel of shownChannels[this.ChannelTypes[type]]) {
if (!channel.id || shownChannel.channel.parent_id == channel.id) {
isHidden = false;
break;
}
}
}
processCategoryItem (instance, wrapper) {
if (instance.props && instance.props.channel) this.reappendHiddenContainer(instance.props.channel.guild_id);
}
processStandardSidebarView (instance, wrapper) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this);
}
}
appendHiddenContainer (guild) {
BDFDB.removeEles(".container-hidden");
if (!guild) return;
this.currentGuild = guild.id;
var allChannels = this.ChannelStore.getChannels();
var shownChannels = this.GuildChannels.getChannels(guild.id);
var hiddenChannels = {};
for (let type in this.ChannelTypes) hiddenChannels[this.ChannelTypes[type]] = [];
for (let channel_id in allChannels) {
var channel = allChannels[channel_id];
if (channel.guild_id == guild.id) {
var isHidden = true;
if (channel.type == this.ChannelTypes.GUILD_CATEGORY) {
for (let type in this.ChannelTypes) if (shownChannels[this.ChannelTypes[type]]) for (let shownChannel of shownChannels[this.ChannelTypes[type]]) {
if (!channel.id || shownChannel.channel.parent_id == channel.id) {
isHidden = false;
break;
}
else {
for (let shownChannel of shownChannels[channel.type]) {
if (shownChannel.channel.id == channel.id) {
isHidden = false;
break;
}
}
}
if (isHidden) {
hiddenChannels[channel.type].push(channel);
}
}
}
var settings = BDFDB.getAllData(this, "settings");
var count = 0;
for (let type in this.ChannelTypes) {
if (!settings.showText && type == "GUILD_TEXT" || !settings.showVoice && type == "GUILD_VOICE" || !settings.showCategory && type == "GUILD_CATEGORY") {
hiddenChannels[this.ChannelTypes[type]] = [];
else {
for (let shownChannel of shownChannels[channel.type]) if (shownChannel.channel.id == channel.id) {
isHidden = false;
break;
}
BDFDB.sortArrayByKey(hiddenChannels[this.ChannelTypes[type]], "name");
count += hiddenChannels[this.ChannelTypes[type]].length;
}
hiddenChannels.count = count;
if (count > 0) {
var category = $(this.categoryMarkup)[0];
var wrapper = category.querySelector(BDFDB.dotCN.cursorpointer);
var svg = category.querySelector(BDFDB.dotCN.categoryicontransition);
var name = category.querySelector(BDFDB.dotCN.categorycolortransition);
$(category)
.attr("server", serverID)
.on("click", BDFDB.dotCN.categorycontainerdefault + " > " + BDFDB.dotCN.flex, (e) => {
wrapper.classList.toggle(BDFDB.disCN.categorywrapperhovered);
wrapper.classList.toggle(BDFDB.disCN.categorywrapperhoveredcollapsed);
svg.classList.toggle(BDFDB.disCN.categoryiconhovered);
svg.classList.toggle(BDFDB.disCN.categoryiconhoveredcollapsed);
svg.classList.toggle(BDFDB.disCN.directionright);
name.classList.toggle(BDFDB.disCN.categorynamehovered);
name.classList.toggle(BDFDB.disCN.categorynamehoveredcollapsed);
$(category).find(BDFDB.dotCN.channelcontainerdefault).toggle(!svg.classList.contains(BDFDB.disCN.directionright));
BDFDB.saveData(serverID, !svg.classList.contains(BDFDB.disCN.directionright), this, "categorystatus");
})
.on("mouseenter mouseleave", BDFDB.dotCN.categorycontainerdefault + " > " + BDFDB.dotCN.flex, () => {
if (!svg.classList.contains(BDFDB.disCN.directionright)) {
wrapper.classList.toggle(BDFDB.disCN.categorywrapperdefault);
wrapper.classList.toggle(BDFDB.disCN.categorywrapperhovered);
svg.classList.toggle(BDFDB.disCN.categoryicondefault);
svg.classList.toggle(BDFDB.disCN.categoryiconhovered);
name.classList.toggle(BDFDB.disCN.categorynamedefault);
name.classList.toggle(BDFDB.disCN.categorynamehovered);
}
else {
wrapper.classList.toggle(BDFDB.disCN.categorywrappercollapsed);
wrapper.classList.toggle(BDFDB.disCN.categorywrapperhoveredcollapsed)
svg.classList.toggle(BDFDB.disCN.categoryiconcollapsed)
svg.classList.toggle(BDFDB.disCN.categoryiconhoveredcollapsed);
name.classList.toggle(BDFDB.disCN.categorynamecollapsed);
name.classList.toggle(BDFDB.disCN.categorynamehoveredcollapsed)
}
});
for (let hiddenChannel of hiddenChannels[0]) {
let channel = $(this.channelTextMarkup)[0];
let channelwrapper = channel.querySelector(BDFDB.dotCN.channelwrapper);
let channelicon = channel.querySelector(BDFDB.dotCN.channelcontent);
let channelsvg = channel.querySelector(BDFDB.dotCN.channelicon);
let channelname = channel.querySelector(BDFDB.dotCN.channelname);
this.setReactInstanceOfChannel(hiddenChannel, channel);
channelname.innerText = hiddenChannel.name;
$(channel)
.on("mouseenter mouseleave", BDFDB.dotCN.channelwrapper, (e) => {
channelwrapper.classList.toggle(BDFDB.disCN.channelwrapperdefaulttext);
channelwrapper.classList.toggle(BDFDB.disCN.channelwrapperhoveredtext);
channelicon.classList.toggle(BDFDB.disCN.channelcontentdefaulttext);
channelicon.classList.toggle(BDFDB.disCN.channelcontenthoveredtext);
channelsvg.classList.toggle(BDFDB.disCN.channelcolordefaulttext);
channelsvg.classList.toggle(BDFDB.disCN.channelcolorhoveredtext);
channelname.classList.toggle(BDFDB.disCN.channelnamedefaulttext);
channelname.classList.toggle(BDFDB.disCN.channelnamehoveredtext);
this.showAccessRoles(serverObj, hiddenChannel, e, false);
})
.on("click", () => {
BDFDB.showToast(`You can not enter the hidden textchannel ${hiddenChannel.name}.`, {type:"error"});
})
.on("contextmenu", (e) => {
this.createHiddenObjContextMenu(serverObj, hiddenChannel, "TEXT", e);
})
.appendTo(category);
}
for (let hiddenChannel of hiddenChannels[2]) {
let channel = $(this.channelVoiceMarkup)[0];
let channelwrapper = channel.querySelector(BDFDB.dotCN.channelwrapper);
let channelicon = channel.querySelector(BDFDB.dotCN.channelcontent);
let channelsvg = channel.querySelector(BDFDB.dotCN.channelicon);
let channelname = channel.querySelector(BDFDB.dotCN.channelname);
this.setReactInstanceOfChannel(hiddenChannel, channel);
channelname.innerText = hiddenChannel.name;
$(channel)
.on("mouseenter mouseleave", BDFDB.dotCN.channelwrapper, (e) => {
channelwrapper.classList.toggle(BDFDB.disCN.channelwrapperdefaultvoice);
channelwrapper.classList.toggle(BDFDB.disCN.channelwrapperhoveredvoice);
channelicon.classList.toggle(BDFDB.disCN.channelcontentdefaultvoice);
channelicon.classList.toggle(BDFDB.disCN.channelcontenthoveredvoice);
channelsvg.classList.toggle(BDFDB.disCN.channelcolordefaultvoice);
channelsvg.classList.toggle(BDFDB.disCN.channelcolorhoveredvoice);
channelname.classList.toggle(BDFDB.disCN.channelnamedefaultvoice);
channelname.classList.toggle(BDFDB.disCN.channelnamehoveredvoice);
this.showAccessRoles(serverObj, hiddenChannel, e, false);
})
.on("click", () => {
BDFDB.showToast(`You can not enter the hidden voicechannel ${hiddenChannel.name}.`, {type:"error"});
})
.on("contextmenu", (e) => {
this.createHiddenObjContextMenu(serverObj, hiddenChannel, "VOICE", e);
})
.appendTo(category);
}
for (let hiddenChannel of hiddenChannels[4]) {
let channel = $(this.channelCategoryMarkup)[0];
let channelwrapper = channel.querySelector(BDFDB.dotCN.categorywrappercollapsed);
let channelsvg = channel.querySelector(BDFDB.dotCN.categoryiconcollapsed);
let channelname = channel.querySelector(BDFDB.dotCN.categorynamecollapsed);
this.setReactInstanceOfChannel(hiddenChannel, channel);
channelname.innerText = hiddenChannel.name;
$(channel)
.on("mouseenter mouseleave", BDFDB.dotCN.flex, (e) => {
channelwrapper.classList.toggle(BDFDB.disCN.categorywrappercollapsed);
channelwrapper.classList.toggle(BDFDB.disCN.categorywrapperhoveredcollapsed);
channelsvg.classList.toggle(BDFDB.disCN.categoryiconcollapsed)
channelsvg.classList.toggle(BDFDB.disCN.categoryiconhoveredcollapsed);
channelname.classList.toggle(BDFDB.disCN.categorynamecollapsed);
channelname.classList.toggle(BDFDB.disCN.categorynamehoveredcollapsed);
this.showAccessRoles(serverObj, hiddenChannel, e, false);
})
.on("click", () => {
BDFDB.showToast(`You can not open the hidden category ${hiddenChannel.name}.`, {type:"error"});
})
.on("contextmenu", (e) => {
this.createHiddenObjContextMenu(serverObj, hiddenChannel, "CATEGORY", e);
})
.appendTo(category);
}
var isOpen = BDFDB.loadData(serverID, this, "categorystatus");
isOpen = isOpen === null ? true : isOpen;
if (!isOpen) {
wrapper.classList.toggle(BDFDB.disCN.categorywrapperdefault);
wrapper.classList.toggle(BDFDB.disCN.categorywrappercollapsed);
svg.classList.toggle(BDFDB.disCN.categoryicondefault);
svg.classList.toggle(BDFDB.disCN.categoryiconcollapsed)
svg.classList.toggle(BDFDB.disCN.directionright);
name.classList.toggle(BDFDB.disCN.categorynamedefault);
name.classList.toggle(BDFDB.disCN.categorynamecollapsed);
$(category).find(BDFDB.dotCN.channelcontainerdefault).hide();
}
this.appendToChannelList(category);
}
let channelist = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
$(channelist).off("mouseenter." + this.getName()).off("mouseleave." + this.getName());
if (settings.showForNormal) {
$(channelist)
.on("mouseenter." + this.getName(), BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault, (e) => {
var channel = BDFDB.getKeyInformation({"node":e.currentTarget,"key":"channel"});
if (channel) this.showAccessRoles(serverObj, channel, e, false);
});
}
if (isHidden) hiddenChannels[channel.type].push(channel);
}
}
var settings = BDFDB.getAllData(this, "settings");
var count = 0;
for (let type in this.ChannelTypes) {
if (!settings.showText && type == "GUILD_TEXT" || !settings.showVoice && type == "GUILD_VOICE" || !settings.showCategory && type == "GUILD_CATEGORY") {
hiddenChannels[this.ChannelTypes[type]] = [];
}
BDFDB.sortArrayByKey(hiddenChannels[this.ChannelTypes[type]], "name");
count += hiddenChannels[this.ChannelTypes[type]].length;
}
hiddenChannels.count = count;
if (count > 0) {
var category = BDFDB.htmlToElement(this.categoryMarkup);
var wrapper = category.querySelector(BDFDB.dotCN.cursorpointer);
var svg = category.querySelector(BDFDB.dotCN.categoryicontransition);
var name = category.querySelector(BDFDB.dotCN.categorycolortransition);
var inner = category.querySelector(BDFDB.dotCN.categorycontainerdefault + " > " + BDFDB.dotCN.flex);
category.setAttribute("guild", guild.id);
inner.addEventListener("click", () => {
BDFDB.toggleClass(wrapper, BDFDB.disCN.categorywrapperhovered, BDFDB.disCN.categorywrapperhoveredcollapsed);
BDFDB.toggleClass(svg, BDFDB.disCN.categoryiconhovered, BDFDB.disCN.categoryiconhoveredcollapsed, BDFDB.disCN.directionright);
BDFDB.toggleClass(name, BDFDB.disCN.categorynamehovered, BDFDB.disCN.categorynamehoveredcollapsed);
var visible = BDFDB.containsClass(svg, BDFDB.disCN.directionright);
BDFDB.toggleEles(category.querySelectorAll(BDFDB.dotCN.channelcontainerdefault), !visible);
BDFDB.saveData(guild.id, !visible, this, "categorystatus");
});
var togglecontainer = () => {
if (!BDFDB.containsClass(svg, BDFDB.disCN.directionright)) {
BDFDB.toggleClass(wrapper, BDFDB.disCN.categorywrapperdefault, BDFDB.disCN.categorywrapperhovered);
BDFDB.toggleClass(svg, BDFDB.disCN.categoryicondefault, BDFDB.disCN.categoryiconhovered);
BDFDB.toggleClass(name, BDFDB.disCN.categorynamedefault,BDFDB.disCN.categorynamehovered);
}
else {
BDFDB.toggleClass(wrapper, BDFDB.disCN.categorywrappercollapsed, BDFDB.disCN.categorywrapperhoveredcollapsed)
BDFDB.toggleClass(svg, BDFDB.disCN.categoryiconcollapsed, BDFDB.disCN.categoryiconhoveredcollapsed);
BDFDB.toggleClass(name, BDFDB.disCN.categorynamecollapsed, BDFDB.disCN.categorynamehoveredcollapsed)
}
};
inner.addEventListener("mouseenter", togglecontainer);
inner.addEventListener("mouseleave", togglecontainer);
for (let hiddenChannel of hiddenChannels[0]) {
let channel = BDFDB.htmlToElement(this.channelTextMarkup);
let channelwrapper = channel.querySelector(BDFDB.dotCN.channelwrapper);
let channelicon = channel.querySelector(BDFDB.dotCN.channelcontent);
let channelsvg = channel.querySelector(BDFDB.dotCN.channelicon);
let channelname = channel.querySelector(BDFDB.dotCN.channelname);
this.setReactInstanceOfChannel(hiddenChannel, channel);
channelname.innerText = hiddenChannel.name;
BDFDB.addChildEventListener(channel, "mouseenter mouseleave", BDFDB.dotCN.channelwrapper, e => {
BDFDB.toggleClass(channelwrapper, BDFDB.disCN.channelwrapperdefaulttext, BDFDB.disCN.channelwrapperhoveredtext);
BDFDB.toggleClass(channelicon, BDFDB.disCN.channelcontentdefaulttext, BDFDB.disCN.channelcontenthoveredtext);
BDFDB.toggleClass(channelsvg, BDFDB.disCN.channelcolordefaulttext, BDFDB.disCN.channelcolorhoveredtext);
BDFDB.toggleClass(channelname, BDFDB.disCN.channelnamedefaulttext, BDFDB.disCN.channelnamehoveredtext);
this.showAccessRoles(guild, hiddenChannel, e, false);
});
channel.addEventListener("click", () => {
BDFDB.showToast(`You can not enter the hidden textchannel ${hiddenChannel.name}.`, {type:"error"});
});
channel.addEventListener("contextmenu", e => {
this.createHiddenObjContextMenu(guild, hiddenChannel, "TEXT", e);
});
category.appendChild(channel);
}
for (let hiddenChannel of hiddenChannels[2]) {
let channel = BDFDB.htmlToElement(this.channelVoiceMarkup);
let channelwrapper = channel.querySelector(BDFDB.dotCN.channelwrapper);
let channelicon = channel.querySelector(BDFDB.dotCN.channelcontent);
let channelsvg = channel.querySelector(BDFDB.dotCN.channelicon);
let channelname = channel.querySelector(BDFDB.dotCN.channelname);
this.setReactInstanceOfChannel(hiddenChannel, channel);
channelname.innerText = hiddenChannel.name;
BDFDB.addChildEventListener(channel, "mouseenter mouseleave", BDFDB.dotCN.channelwrapper, e => {
BDFDB.toggleClass(channelwrapper, BDFDB.disCN.channelwrapperdefaultvoice, BDFDB.disCN.channelwrapperhoveredvoice);
BDFDB.toggleClass(channelicon, BDFDB.disCN.channelcontentdefaultvoice, BDFDB.disCN.channelcontenthoveredvoice);
BDFDB.toggleClass(channelsvg, BDFDB.disCN.channelcolordefaultvoice, BDFDB.disCN.channelcolorhoveredvoice);
BDFDB.toggleClass(channelname, BDFDB.disCN.channelnamedefaultvoice, BDFDB.disCN.channelnamehoveredvoice);
this.showAccessRoles(guild, hiddenChannel, e, false);
});
channel.addEventListener("click", () => {
BDFDB.showToast(`You can not enter the hidden voicechannel ${hiddenChannel.name}.`, {type:"error"});
});
channel.addEventListener("contextmenu", e => {
this.createHiddenObjContextMenu(guild, hiddenChannel, "VOICE", e);
});
category.appendChild(channel);
}
for (let hiddenChannel of hiddenChannels[4]) {
let channel = BDFDB.htmlToElement(this.channelCategoryMarkup);
let channelwrapper = channel.querySelector(BDFDB.dotCN.categorywrappercollapsed);
let channelsvg = channel.querySelector(BDFDB.dotCN.categoryiconcollapsed);
let channelname = channel.querySelector(BDFDB.dotCN.categorynamecollapsed);
this.setReactInstanceOfChannel(hiddenChannel, channel);
channelname.innerText = hiddenChannel.name;
BDFDB.addChildEventListener(channel, "mouseenter mouseleave", BDFDB.dotCN.flex, e => {
BDFDB.toggleClass(channelwrapper, BDFDB.disCN.categorywrappercollapsed, BDFDB.disCN.categorywrapperhoveredcollapsed);
BDFDB.toggleClass(channelsvg, BDFDB.disCN.categoryiconcollapsed, BDFDB.disCN.categoryiconhoveredcollapsed);
BDFDB.toggleClass(channelname, BDFDB.disCN.categorynamecollapsed, BDFDB.disCN.categorynamehoveredcollapsed);
this.showAccessRoles(guild, hiddenChannel, e, false);
});
channel.addEventListener("click", () => {
BDFDB.showToast(`You can not open the hidden category ${hiddenChannel.name}.`, {type:"error"});
});
channel.addEventListener("contextmenu", e => {
this.createHiddenObjContextMenu(guild, hiddenChannel, "CATEGORY", e);
});
category.appendChild(channel);
}
if (BDFDB.loadData(guild.id, this, "categorystatus") === false) {
BDFDB.toggleClass(wrapper, BDFDB.disCN.categorywrapperdefault, BDFDB.disCN.categorywrappercollapsed);
BDFDB.toggleClass(svg, BDFDB.disCN.categoryicondefault, BDFDB.disCN.categoryiconcollapsed, BDFDB.disCN.directionright);
BDFDB.toggleClass(name, BDFDB.disCN.categorynamedefault, BDFDB.disCN.categorynamecollapsed);
BDFDB.toggleEles(category.querySelectorAll(BDFDB.dotCN.channelcontainerdefault), false);
}
this.reappendHiddenContainer(guild.id, category);
}
let channellist = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
if (channellist) {
BDFDB.removeEventListener(this, channellist, "mouseenter", BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault);
if (settings.showForNormal) BDFDB.addEventListener(this, channellist, "mouseenter", BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault, e => {
if (!BDFDB.containsClass(e.currentTarget, "hidden-channel")) {
var channel = BDFDB.getKeyInformation({"node":e.currentTarget,"key":"channel"});
if (channel) this.showAccessRoles(guild, channel, e, false);
}
});
}
}
setReactInstanceOfChannel (info, div) {
var reactInstance = this.React.createElement(div);
reactInstance.memoizedProps = {channel:info};
reappendHiddenContainer (guildid, category = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCNS.scroller + "container-hidden")) {
if (guildid != this.currentGuild) this.appendHiddenContainer(guild);
else if (category) {
var scroller = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
if (!scroller) return;
category.remove();
let count = parseInt(scroller.lastChild.previousSibling.className.split("-")[1])+1;
category.className = "container-" + count + " container-hidden";
scroller.insertBefore(category, scroller.lastChild);
}
}
setReactInstanceOfChannel (guild, div) {
var reactInstance = BDFDB.React.createElement(div);
reactInstance.memoizedProps = {channel:guild};
div.__reactInternalInstance = reactInstance;
}
createHiddenObjContextMenu (serverObj, hiddenObj, type, e) {
createHiddenObjContextMenu (guild, channel, type, e) {
e.preventDefault();
e.stopPropagation();
var contextMenu = $(`<div class="${BDFDB.disCN.contextmenu} ShowHiddenChannelsContextMenu">${BDFDB.isPluginEnabled("PermissionsViewer") ? '<div class="' + BDFDB.disCN.contextmenuitemgroup + '"><div class="' + BDFDB.disCN.contextmenuitem + '" style="display: none !important;"></div></div>' : ''}<div class="${BDFDB.disCN.contextmenuitemgroup}"><div class="${BDFDB.disCN.contextmenuitem} copyid-item"><span>${BDFDB.LanguageStrings.COPY_ID}</span><div class="${BDFDB.disCN.contextmenuhint}"></div></div></div></div>`);
var reactInstance = this.React.createElement(contextMenu[0]);
reactInstance.memoizedProps = {displayName:"ChannelDeleteGroup",guild:serverObj.data,channel:hiddenObj};
reactInstance.return = {memoizedProps:{type:("CHANNEL_LIST_" + type),guild:serverObj.data,channel:hiddenObj}};
contextMenu[0].__reactInternalInstance = reactInstance;
contextMenu
.on("click." + this.getName(), ".copyid-item", (e2) => {
contextMenu.remove();
require("electron").clipboard.write({text: hiddenObj.id});
});
var contextMenu = BDFDB.htmlToElement(`<div class="${BDFDB.disCN.contextmenu} showhiddenchannels-contextmenu">${BDFDB.isPluginEnabled("PermissionsViewer") ? '<div class="' + BDFDB.disCN.contextmenuitemgroup + '"><div class="' + BDFDB.disCN.contextmenuitem + '" style="display: none !important;"></div></div>' : ''}<div class="${BDFDB.disCN.contextmenuitemgroup}"><div class="${BDFDB.disCN.contextmenuitem} copyid-item"><span>${BDFDB.LanguageStrings.COPY_ID}</span><div class="${BDFDB.disCN.contextmenuhint}"></div></div></div></div>`);
var reactInstance = BDFDB.React.createElement(contextMenu);
reactInstance.memoizedProps = {displayName:"ChannelDeleteGroup",guild,channel};
reactInstance.return = {memoizedProps:{type:("CHANNEL_LIST_" + type),guild,channel}};
contextMenu.__reactInternalInstance = reactInstance;
BDFDB.addChildEventListener(contextMenu, "click", ".copyid-item", e2 => {
contextMenu.remove();
require("electron").clipboard.write({text: channel.id});
});
BDFDB.appendContextMenu(contextMenu[0], e);
BDFDB.appendContextMenu(contextMenu, e);
}
showAccessRoles (serverObj, channel, e, allowed) {
if ((e.type != "mouseenter" && e.type != "mouseover") || !serverObj || !channel) return;
showAccessRoles (guild, channel, e, allowed) {
if ((e.type != "mouseenter" && e.type != "mouseover") || !guild || !channel) return;
var settings = BDFDB.getAllData(this, "settings");
var myMember = this.MemberStore.getMember(serverObj.id, BDFDB.myData.id);
var myMember = this.MemberStore.getMember(guild.id, BDFDB.myData.id);
var allowedRoles = [], allowedUsers = [], overwrittenRoles = [], deniedRoles = [], deniedUsers = [];
var everyoneDenied = false;
for (let id in channel.permissionOverwrites) {
if (settings.showAllowedRoles &&
channel.permissionOverwrites[id].type == "role" &&
(serverObj.roles[id].name != "@everyone") &&
(guild.roles[id].name != "@everyone") &&
(channel.permissionOverwrites[id].allow | this.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].allow) {
if (myMember.roles.includes(id) && !allowed) {
if (settings.showOverWrittenRoles) overwrittenRoles.push(serverObj.roles[id]);
if (settings.showOverWrittenRoles) overwrittenRoles.push(guild.roles[id]);
}
else {
allowedRoles.push(serverObj.roles[id]);
allowedRoles.push(guild.roles[id]);
}
}
else if (settings.showAllowedUsers &&
channel.permissionOverwrites[id].type == "member" &&
(channel.permissionOverwrites[id].allow | this.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].allow) {
let user = this.UserStore.getUser(id);
let member = this.MemberStore.getMember(serverObj.id,id);
let member = this.MemberStore.getMember(guild.id,id);
if (user && member) allowedUsers.push(Object.assign({name:user.username},member));
}
if (settings.showDeniedRoles &&
channel.permissionOverwrites[id].type == "role" &&
(channel.permissionOverwrites[id].deny | this.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].deny) {
deniedRoles.push(serverObj.roles[id]);
if (serverObj.roles[id].name == "@everyone") everyoneDenied = true;
deniedRoles.push(guild.roles[id]);
if (guild.roles[id].name == "@everyone") everyoneDenied = true;
}
else if (settings.showDeniedUsers &&
channel.permissionOverwrites[id].type == "member" &&
(channel.permissionOverwrites[id].deny | this.Permissions.VIEW_CHANNEL) == channel.permissionOverwrites[id].deny) {
let user = this.UserStore.getUser(id);
let member = this.MemberStore.getMember(serverObj.id,id);
let member = this.MemberStore.getMember(guild.id,id);
if (user && member) deniedUsers.push(Object.assign({name:user.username},member));
}
}
@ -526,17 +469,8 @@ class ShowHiddenChannels {
if (htmlString) {
var width = window.outerWidth/2;
var tooltip = BDFDB.createTooltip(htmlString, e.currentTarget, {type:"right", selector:"showhiddenchannels-tooltip", html:true, style:`max-width: ${width < 200 ? 400 : width}px !important;`, delay:BDFDB.getData("hoverDelay", this, "amounts")});
tooltip.style.top = tooltip.style.top.replace("px","") - $(e.currentTarget).css("padding-bottom").replace("px","")/2 + $(e.currentTarget).css("padding-top").replace("px","")/2 + "px";
}
}
appendToChannelList (category) {
var channelList = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
if (channelList && category) {
category.remove();
let count = parseInt(channelList.lastChild.previousSibling.className.split("-")[1])+1;
category.className = "container-" + count + " container-hidden";
channelList.insertBefore(category,channelList.lastChild);
var style = getComputedStyle(e.currentTarget);
tooltip.style.setProperty("top", BDFDB.getRects(tooltip).top - style.paddingBottom.replace("px","")/2 + style.paddingTop.replace("px","")/2 + "px");
}
}
}

View File

@ -1,6 +1,14 @@
//META{"name":"ShowImageDetails"}*//
class ShowImageDetails {
getName () {return "ShowImageDetails";}
getVersion () {return "1.1.2";}
getAuthor () {return "DevilBro";}
getDescription () {return "Display the name, size and dimensions of uploaded images (does not include embed images) in the chat as an header or as a tooltip.";}
initConstructor () {
this.patchModules = {
"LazyImageZoomable":"componentDidMount",
@ -19,8 +27,6 @@ class ShowImageDetails {
}
`;
this.updateDetails = false;
this.defaults = {
settings: {
showOnHover: {value:false, description:"Show the details as Tooltip instead:"}
@ -30,14 +36,6 @@ class ShowImageDetails {
}
};
}
getName () {return "ShowImageDetails";}
getDescription () {return "Display the name, size and dimensions of uploaded images (does not include embed images) in the chat as an header or as a tooltip.";}
getVersion () {return "1.1.1";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -45,23 +43,21 @@ class ShowImageDetails {
let amounts = BDFDB.getAllData(this, "amounts");
let settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in amounts) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">${this.defaults.amounts[key].description}</h3><div class="${BDFDB.disCN.inputwrapper} inputNumberWrapper ${BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCNS.directioncolumn}" style="flex: 1 1 auto;"><span class="numberinput-buttons-zone"><span class="numberinput-button-up"></span><span class="numberinput-button-down"></span></span><input type="number" min="0" option="${key}" value="${amounts[key]}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} amountInput"></div></div>`;
}
settingshtml += `</div></div>`;
let 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("input", ".amountInput", (e) => {
let input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => {
let input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
return settingspanel;
}
@ -70,22 +66,25 @@ class ShowImageDetails {
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);
BDFDB.WebModules.forceAllUpdates(this);
@ -96,7 +95,7 @@ class ShowImageDetails {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);});
BDFDB.unloadMessage(this);
@ -105,49 +104,41 @@ class ShowImageDetails {
// begin of own functions
updateSettings (settingspanel) {
let settings = {};
for (let input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
this.updateDetails = true;
}
resetImage (image) {
image.classList.remove("image-details-added");
$(image).off("." + this.getName());
BDFDB.removeClass(image, "image-details-added");
image.removeEventListener("mouseenter", image.mouseenterShowImageDetails);
let wrapper = image.parentElement;
if (wrapper.classList.contains("image-details-wrapper")) {
if (BDFDB.containsClass(wrapper, "image-details-wrapper")) {
wrapper.parentElement.insertBefore(image, wrapper);
wrapper.remove();
}
}
processLazyImageZoomable (instance, image) {
let fiber = instance._reactInternalFiber;
if (fiber.return && fiber.return.return && fiber.return.return.memoizedProps && fiber.return.return.memoizedProps.attachment) {
let info = fiber.return.return.memoizedProps.attachment;
if (info && !info.filename.endsWith(".bdemote.png") && !info.filename.endsWith(".bdemote.gif")) {
image.classList.add("image-details-added");
if (BDFDB.getData("showOnHover", this, "settings")) {
$(image).on("mouseenter." + this.getName(), () => {
BDFDB.createTooltip(`<div class="image-details-tooltip-name">${info.filename}</div><div class="image-details-tooltip-size">${BDFDB.formatBytes(info.size)}</div><div class="image-details-tooltip-dimensions">${info.width}x${info.height}px</div>`, image, {type:"right", html:true, selector:"image-details-tooltip", delay:BDFDB.getData("hoverDelay", this, "amounts")});
});
}
else {
$(`<div class="image-details-wrapper"><div class="image-details"><a class="${BDFDB.disCNS.anchor + BDFDB.disCN.anchorunderlineonhover} image-details-link" title="${info.url}" href="${info.url}" target="_blank" rel="noreferrer noopener">${info.filename}</a><label class="image-details-size ${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">${BDFDB.formatBytes(info.size)}</label><label class="image-details-dimensions ${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">${info.width}x${info.height}px</label></div></div>`).insertBefore(image).append(image);
let scroller = BDFDB.getParentEle(BDFDB.dotCN.messages, image);
if (scroller) scroller.scrollTop += image.parentElement.getBoundingClientRect().height - image.getBoundingClientRect().height;
}
let attachment = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.attachment");
if (attachment && !attachment.filename.endsWith(".bdemote.png") && !attachment.filename.endsWith(".bdemote.gif")) {
BDFDB.addClass(image, "image-details-added");
image.removeEventListener("mouseenter", image.mouseenterShowImageDetails);
if (BDFDB.getData("showOnHover", this, "settings")) {
image.mouseenterShowImageDetails = () => {
BDFDB.createTooltip(`<div class="image-details-tooltip-name">${attachment.filename}</div><div class="image-details-tooltip-size">${BDFDB.formatBytes(attachment.size)}</div><div class="image-details-tooltip-dimensions">${attachment.width}x${attachment.height}px</div>`, image, {type:"right", html:true, selector:"image-details-tooltip", delay:BDFDB.getData("hoverDelay", this, "amounts")});
};
image.addEventListener("mouseenter", image.mouseenterShowImageDetails);
}
else {
let imagedetailswrapper = BDFDB.htmlToElement(`<div class="image-details-wrapper"><div class="image-details"><a class="${BDFDB.disCNS.anchor + BDFDB.disCN.anchorunderlineonhover} image-details-link" title="${attachment.url}" href="${attachment.url}" target="_blank" rel="noreferrer noopener">${attachment.filename}</a><label class="image-details-size ${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">${BDFDB.formatBytes(attachment.size)}</label><label class="image-details-dimensions ${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">${attachment.width}x${attachment.height}px</label></div></div>`);
image.parentElement.insertBefore(imagedetailswrapper, image);
imagedetailswrapper.appendChild(image);
let scroller = BDFDB.getParentEle(BDFDB.dotCN.messages, image);
if (scroller) scroller.scrollTop += BDFDB.getRects(imagedetailswrapper).height - BDFDB.getRects(image).height;
}
}
}
processStandardSidebarView (instance) {
if (this.updateDetails) {
this.updateDetails = false;
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);});
BDFDB.WebModules.forceAllUpdates(this);
}

View File

@ -1,7 +1,19 @@
//META{"name":"SpellCheck"}*//
class SpellCheck {
getName () {return "SpellCheck";}
getVersion () {return "1.2.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a spellcheck to all textareas. Select a word and rightclick it to add it to your dictionary.";}
initConstructor () {
this.patchModules = {
"ChannelTextArea":"componentDidMount"
};
this.languages = {};
this.langDictionary = [];
this.dictionary = [];
@ -30,15 +42,7 @@ class SpellCheck {
`<div class="spellcheck-overlay" style="position:absolute !important; pointer-events:none !important; background:transparent !important; color:transparent !important; text-shadow:none !important;"></div>`;
this.css =
`.spellcheck-overlay {
display: inline-block;
font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif;
white-space: pre-wrap !important;
word-wrap: break-word !important;
overflow-x: hidden !important;
overflow-y: scroll !important;
}
.spellcheck-overlay::-webkit-scrollbar,
`.spellcheck-overlay::-webkit-scrollbar,
.spellcheck-overlay::-webkit-scrollbar-button,
.spellcheck-overlay::-webkit-scrollbar-track,
.spellcheck-overlay::-webkit-scrollbar-track-piece,
@ -66,14 +70,6 @@ class SpellCheck {
}
};
}
getName () {return "SpellCheck";}
getDescription () {return "Adds a spellcheck to all textareas. Select a word and rightclick it to add it to your dictionary.";}
getVersion () {return "1.2.8";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
@ -82,7 +78,7 @@ class SpellCheck {
var amounts = BDFDB.getAllData(this, "amounts");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
for (let key in settings) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${settings[key] ? " checked" : ""}></div></div>`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
for (let key in choices) {
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">${this.defaults.choices[key].description}</h3><div class="${BDFDB.disCN.selectwrap}" style="flex: 1 1 auto"><div class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}" type="${key}" value="${choices[key]}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="padding:0;">${this.languages[choices[key]].name}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`;
@ -98,18 +94,16 @@ class SpellCheck {
settingshtml += `</div>`;
settingshtml += `</div></div>`;
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("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu(settingspanel, e);})
.on("click", ".remove-word", (e) => {this.removeFromOwnDictionary(e);})
.on("input", ".amountInput", (e) => {
var input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(settingspanel, e);});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-word", e => {this.removeFromOwnDictionarye;});
BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => {
var input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
});
return settingspanel;
}
@ -117,61 +111,32 @@ class SpellCheck {
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.nodeType == 1 && node.className.includes(BDFDB.disCN.contextmenu)) {
this.onContextMenu(node);
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"messageContextObserver",instance:observer}, {childList: true});
observer = new MutationObserver((changes, _) => {
changes.forEach(
(change, i) => {
if (change.addedNodes) {
change.addedNodes.forEach((node) => {
if (node && node.tagName && node.querySelector(BDFDB.dotCN.textareainner + ":not(" + BDFDB.dotCN.textareainnerdisabled + ")")) {
this.addSpellCheck(node.querySelector(BDFDB.dotCN.textarea));
}
});
}
}
);
});
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"textareaObserver",instance:observer}, {childList: true, subtree:true});
document.querySelectorAll(BDFDB.dotCN.textarea).forEach(textarea => {this.addSpellCheck(textarea);});
this.languages = Object.assign({},BDFDB.languages);
this.languages = BDFDB.filterObject(this.languages , (lang) => {return lang.dic == true ? lang : null});
this.setDictionary(BDFDB.getData("dictionaryLanguage", this, "choices"));
BDFDB.WebModules.forceAllUpdates(this);
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
@ -179,8 +144,9 @@ class SpellCheck {
}
stop () {
if (typeof BDFDB === "object") {
$(".spellcheck-overlay").remove();
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".spellcheck-overlay");
BDFDB.removeClasses("spellcheck-added");
this.killLanguageToast();
@ -197,66 +163,88 @@ class SpellCheck {
this.similarWordsContextSubMenuMarkup = this.similarWordsContextSubMenuMarkup.replace("REPLACE_similarwordssubmenu_none_text", this.labels.similarwordssubmenu_none_text);
}
updateSettings (settingspanel) {
var settings = {};
for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
settings[input.value] = input.checked;
}
BDFDB.saveAllData(settings, this, "settings");
}
onContextMenu (context) {
if (!context || !context.tagName || !context.parentElement || context.querySelector(".spellcheck-item")) return;
var word = window.getSelection().toString();
if (word && BDFDB.getKeyInformation({"node":context, "key":"handleCutItem"}) && this.isWordNotInDictionary(word)) {
var group = $(this.spellCheckContextEntryMarkup);
$(context).append(group)
.on("click", ".spellcheck-item", (e) => {
$(context).hide();
this.addToOwnDictionary(word);
})
.on("mouseenter", ".similarwords-item", (e) => {
this.createContextSubMenu(word, e, context);
});
BDFDB.updateContextPosition(context);
}
}
createContextSubMenu (word, e, context) {
var similarWordsContextSubMenu = $(this.similarWordsContextSubMenuMarkup);
var similarWords = this.getSimilarWords(word.toLowerCase().trim());
if (similarWords.length > 0) {
similarWordsContextSubMenu.find(".nosimilars-item").remove();
for (let foundWord of similarWords.sort()) {
similarWordsContextSubMenu.append(`<div value="${foundWord}" class="${BDFDB.disCN.contextmenuitem} similarword-item"><span>${foundWord}</span><div class="${BDFDB.disCN.contextmenuhint}"></div></div>`);
onNativeContextMenu (instance, menu) {
if (instance.props && instance.props.type == "CHANNEL_TEXT_AREA" && instance.props.value && !menu.querySelector(".spellcheck-item")) {
let selection = document.getSelection();
let word = selection.toString();
if (word && this.isWordNotInDictionary(word)) {
let cutentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleCutItem"]}));
if (cutentry) {
let spellCheckContextEntry = BDFDB.htmlToElement(this.spellCheckContextEntryMarkup);
menu.appendChild(spellCheckContextEntry);
spellCheckContextEntry.querySelector(".spellcheck-item").addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.addToOwnDictionary(word);
});
let similarwordsitem = spellCheckContextEntry.querySelector(".similarwords-item");
similarwordsitem.addEventListener("mouseenter", () => {
let similarWordsContextSubMenu = BDFDB.htmlToElement(this.similarWordsContextSubMenuMarkup);
let similarWords = this.getSimilarWords(word.toLowerCase().trim());
if (similarWords.length > 0) {
BDFDB.removeEles(similarWordsContextSubMenu.querySelector(".nosimilars-item"));
for (let foundWord of similarWords.sort()) similarWordsContextSubMenu.appendChild(BDFDB.htmlToElement(`<div value="${foundWord}" class="${BDFDB.disCN.contextmenuitem} similarword-item"><span>${foundWord}</span><div class="${BDFDB.disCN.contextmenuhint}"></div></div>`));
BDFDB.addChildEventListener(similarWordsContextSubMenu, "click", ".similarword-item", e => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.replaceWord(selection.getRangeAt(0).startContainer.querySelector("textarea"), word, e.currentTarget.getAttribute("value"));
});
}
BDFDB.appendSubMenu(similarwordsitem, similarWordsContextSubMenu);
});
}
}
}
var textarea = window.getSelection().getRangeAt(0).startContainer.querySelector("textarea");
similarWordsContextSubMenu
.on("click", ".similarword-item", (e) => {
$(context).hide();
this.replaceWord(textarea, word, e.currentTarget.getAttribute("value"));
}
processChannelTextArea (instance, wrapper) {
if (instance.props && instance.props.type) {
var textarea = wrapper.querySelector("textarea");
if (!textarea) return;
var updateSpellcheck = () => {
var style = Object.assign({},getComputedStyle(textarea));
for (let i in style) if (i.indexOf("webkit") == -1) spellcheck.style[i] = style[i];
spellcheck.style.setProperty("box-sizing", "border-box", "important");
spellcheck.style.setProperty("color", "transparent", "important");
spellcheck.style.setProperty("pointer-events", "none", "important");
spellcheck.style.setProperty("position", "absolute", "important");
spellcheck.style.setProperty("left", BDFDB.getRects(textarea).left - BDFDB.getRects(wrapper).left + "px", "important");
spellcheck.style.setProperty("width", BDFDB.getRects(textarea).width + "px", "important");
spellcheck.style.setProperty("height", BDFDB.getRects(textarea).height + "px", "important");
spellcheck.innerHTML = this.spellCheckText(textarea.value);
spellcheck.scrollTop = textarea.scrollTop;
}
var spellcheck = BDFDB.htmlToElement(this.spellCheckLayerMarkup);
BDFDB.addClass(spellcheck, textarea.className);
textarea.setAttribute("spellcheck", !BDFDB.getData("disableDiscordSpellcheck", this, "settings"));
textarea.parentElement.appendChild(spellcheck);
wrapper.addClass("spellcheck-added");
updateSpellcheck();
BDFDB.addEventListener(this, textarea, "keyup", e => {
clearTimeout(textarea.spellchecktimeout);
textarea.spellchecktimeout = setTimeout(() => {updateSpellcheck();},100);
});
BDFDB.appendSubMenu(e.currentTarget, similarWordsContextSubMenu);
BDFDB.addEventListener(this, textarea, "scroll", e => {
spellcheck.scrollTop = textarea.scrollTop;
});
}
}
replaceWord (textarea, word, replacement) {
if (!textarea || document.activeElement != textarea) return;
textarea.focus();
textarea.selectionStart = 0;
textarea.selectionEnd = textarea.value.length;
if (document.activeElement == textarea) {
var firstLetter = word.charAt(0);
var isCapitalised = firstLetter.toUpperCase() == firstLetter && firstLetter.toLowerCase() != firstLetter;
replacement = isCapitalised ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement;
document.execCommand("insertText", false, textarea.value.replace(new RegExp(word.trim(), "i"), replacement));
$(textarea).trigger("keyup");
}
var firstLetter = word.charAt(0);
var isCapitalised = firstLetter.toUpperCase() == firstLetter && firstLetter.toLowerCase() != firstLetter;
replacement = isCapitalised ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement;
document.execCommand("insertText", false, textarea.value.replace(new RegExp(word.trim(), "i"), replacement));
textarea.dispatchEvent(new Event("input"));
}
addToOwnDictionary (word) {
@ -288,19 +276,20 @@ class SpellCheck {
}
openDropdownMenu (settingspanel, 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 || selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
selectWrap.classList.add(BDFDB.disCN.selectisopen);
$("li").has(selectWrap).css("overflow", "visible");
plugincard.style.setProperty("overflow", "visible", "important");
var type = selectWrap.getAttribute("type");
var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
selectWrap.appendChild(selectMenu);
$(selectMenu).on("mousedown." + this.getName(), BDFDB.dotCN.selectoption, (e2) => {
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
var language = e2.currentTarget.getAttribute("value");
selectWrap.setAttribute("value", language);
selectControl.querySelector(BDFDB.dotCN.title).innerText = this.languages[language].name;
@ -317,13 +306,16 @@ class SpellCheck {
listcontainer.innerHTML = containerhtml;
}
});
$(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, type) {
@ -333,48 +325,7 @@ class SpellCheck {
menuhtml += `<div value="${key}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectoption + isSelected}" style="flex: 1 1 auto; display:flex;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 42%;">${this.languages[key].name}</div></div>`
}
menuhtml += `</div></div>`;
return $(menuhtml)[0];
}
addSpellCheck (textarea) {
if (!textarea) return;
var textareaWrap = textarea.parentElement;
if (textareaWrap && !textareaWrap.querySelector(".spellcheck-overlay")) {
var textareaInstance = BDFDB.getOwnerInstance({"node":textarea, "props":["handlePaste","saveCurrentText"], "up":true});
if (textareaInstance) {
var wrapper = $(BDFDB.dotCN.textareawrapall).has(textarea)[0];
var updateSpellcheck = () => {
$(spellcheck)
.css("visibility", "hidden")
.html(this.spellCheckText(textarea.value))
.css("left", textarea.getBoundingClientRect().left - wrapper.getBoundingClientRect().left)
.css("margin", $(textarea).css("margin"))
.css("padding", $(textarea).css("padding"))
.css("width", parseInt($(textarea).css("width")) + (parseInt($(textarea).css("height")) >= parseInt($(textarea).css("max-height")) ? 0 : 10))
.css("height", $(textarea).css("height"))
.scrollTop(textarea.scrollTop)
.css("visibility", "visible");
}
var spellcheck = $(this.spellCheckLayerMarkup)[0];
textarea.classList.forEach(classname => {spellcheck.classList.add(classname);});
textarea.setAttribute("spellcheck", !BDFDB.getData("disableDiscordSpellcheck", this, "settings"));
$(spellcheck).appendTo(textareaWrap)
updateSpellcheck();
$(textarea)
.off("keyup." + this.getName()).off("scroll." + this.getName())
.on("keyup." + this.getName(), (e) => {
clearTimeout(textarea.spellchecktimeout);
textarea.spellchecktimeout = setTimeout(() => {updateSpellcheck();},100);
})
.on("scroll." + this.getName(), (e) => {
$(spellcheck).scrollTop(textarea.scrollTop);
});
}
}
return BDFDB.htmlToElement(menuhtml);
}
setDictionary (lang) {
@ -410,7 +361,7 @@ class SpellCheck {
spellCheckText (string) {
var htmlString = [];
string.replace(/[\n]/g, "\n ").split(" ").forEach((word, i) => {
htmlString.push(`<label class="${this.isWordNotInDictionary(word) ? "spelling-error" : "nospelling-error"}" style="color:transparent !important; text-shadow:none !important;">${BDFDB.encodeToHTML(word)}</label>`);
htmlString.push(`<label class="${this.isWordNotInDictionary(word) ? "spelling-error" : "nospelling-error"}" style="color: transparent !important; text-shadow: none !important;">${BDFDB.encodeToHTML(word)}</label>`);
});
return htmlString.join(" ");
}

View File

@ -3,7 +3,7 @@
class StalkerNotifications {
getName () {return "StalkerNotifications";}
getVersion () {return "1.1.1";}
getVersion () {return "1.1.2";}
getAuthor () {return "DevilBro";}
@ -164,69 +164,65 @@ class StalkerNotifications {
BDFDB.initElements(settingspanel, this);
$(settingspanel)
.on("click", ".btn-savesong", e => {this.saveAudio(settingspanel, e.currentTarget.getAttribute("option"));})
.on("click", ".mute-checkbox", e => {
let option = e.currentTarget.getAttribute("option");
let notificationsound = BDFDB.getData(option, this, "notificationsounds");
notificationsound.mute = e.currentTarget.checked;
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
})
.on("mouseenter", ".settings-avatar", e => {
let user = this.UserUtils.getUser(e.currentTarget.getAttribute("user-id"));
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
BDFDB.createTooltip(data.name ? data.name : user.username, e.currentTarget, {type:"top"});
})
.on("contextmenu", ".settings-avatar", e => {
if (!("Notification" in window)) return;
let desktopoff = !BDFDB.containsClass(e.currentTarget, "desktop");
let id = e.currentTarget.getAttribute("user-id");
BDFDB.removeClass(e.currentTarget, "disabled");
BDFDB.toggleClass(e.currentTarget, "desktop", desktopoff);
BDFDB.saveData(id, {"desktop":desktopoff,"disabled":false}, this, "users");
})
.on("click", ".settings-avatar", e => {
if (BDFDB.containsClass(e.target, "remove-user")) return;
let disableoff = !BDFDB.containsClass(e.currentTarget, "disabled");
let id = e.currentTarget.getAttribute("user-id");
BDFDB.removeClass(e.currentTarget, "desktop");
BDFDB.toggleClass(e.currentTarget, "disabled", disableoff);
BDFDB.saveData(id, {"desktop":false,"disabled":disableoff}, this, "users");
})
.on("click", ".disable-all, .toast-all, .desktop-all", e => {
let button = e.currentTarget;
let disableon = button.getAttribute("do-disable");
let desktopon = button.getAttribute("do-desktop");
let users = BDFDB.loadAllData(this, "users");
settingspanel.querySelectorAll(".settings-avatar").forEach(avatar => {
let id = avatar.getAttribute("user-id");
BDFDB.toggleClass(avatar, "disabled", disableon);
BDFDB.toggleClass(avatar, "desktop", desktopon);
users[id].desktop = desktopon ? true : false;
users[id].disabled = disableon ? true : false;
});
BDFDB.saveAllData(users, this, "users");
})
.on("click", ".btn-adduser", e => {
let idinput = settingspanel.querySelector("#input-userid");
let user = this.UserUtils.getUser(idinput.value);
if (user) {
idinput.value = "";
BDFDB.saveData(user.id, {desktop:false,disabled:false}, this, "users");
BDFDB.removeEles(this.getName() + "-settings .settings-avatar");
let listhtml = `<div class="avatar-list ${BDFDB.disCN.marginbottom8}">`;
let users = BDFDB.loadAllData(this, "users");
for (let id in users) {
let user = this.UserUtils.getUser(id);
if (user) listhtml += this.createSettingsAvatarHtml(user, users[id]);
}
listhtml += `</div>`;
settingspanel.querySelector(".avatar-list").innerHTML = listhtml;
}
else BDFDB.showToast("Please enter a valid UserID.",{type:"error"});
})
.on("click", ".remove-user", e => {
BDFDB.removeData(e.currentTarget.parentElement.getAttribute("user-id"), this, "users");
BDFDB.addEventListener(this, settingspanel, "click", ".btn-savesong", e => {this.saveAudio(settingspanel, e.currentTarget.getAttribute("option"));})
BDFDB.addEventListener(this, settingspanel, "click", ".mute-checkbox", e => {
let option = e.currentTarget.getAttribute("option");
let notificationsound = BDFDB.getData(option, this, "notificationsounds");
notificationsound.mute = e.currentTarget.checked;
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
});
BDFDB.addEventListener(this, settingspanel, "mouseenter", ".settings-avatar", e => {
let user = this.UserUtils.getUser(e.currentTarget.getAttribute("user-id"));
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
BDFDB.createTooltip(data.name ? data.name : user.username, e.currentTarget, {type:"top"});
});
BDFDB.addEventListener(this, settingspanel, "contextmenu", ".settings-avatar", e => {
if (!("Notification" in window)) return;
let desktopoff = !BDFDB.containsClass(e.currentTarget, "desktop");
let id = e.currentTarget.getAttribute("user-id");
BDFDB.removeClass(e.currentTarget, "disabled");
BDFDB.toggleClass(e.currentTarget, "desktop", desktopoff);
BDFDB.saveData(id, {"desktop":desktopoff,"disabled":false}, this, "users");
});
BDFDB.addEventListener(this, settingspanel, "click", ".settings-avatar", e => {
if (BDFDB.containsClass(e.target, "remove-user")) return;
let disableoff = !BDFDB.containsClass(e.currentTarget, "disabled");
let id = e.currentTarget.getAttribute("user-id");
BDFDB.removeClass(e.currentTarget, "desktop");
BDFDB.toggleClass(e.currentTarget, "disabled", disableoff);
BDFDB.saveData(id, {"desktop":false,"disabled":disableoff}, this, "users");
});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-user", e => {
BDFDB.removeData(e.currentTarget.parentElement.getAttribute("user-id"), this, "users");
BDFDB.removeEles(this.getName() + "-settings .settings-avatar");
let listhtml = `<div class="avatar-list ${BDFDB.disCN.marginbottom8}">`;
let users = BDFDB.loadAllData(this, "users");
for (let id in users) {
let user = this.UserUtils.getUser(id);
if (user) listhtml += this.createSettingsAvatarHtml(user, users[id]);
}
listhtml += `</div>`;
settingspanel.querySelector(".avatar-list").innerHTML = listhtml;
});
BDFDB.addEventListener(this, settingspanel, "click", ".disable-all, .toast-all, .desktop-all", e => {
let disableon = e.currentTarget.getAttribute("do-disable");
let desktopon = e.currentTarget.getAttribute("do-desktop");
let users = BDFDB.loadAllData(this, "users");
settingspanel.querySelectorAll(".settings-avatar").forEach(avatar => {
let id = avatar.getAttribute("user-id");
BDFDB.toggleClass(avatar, "disabled", disableon);
BDFDB.toggleClass(avatar, "desktop", desktopon);
users[id].desktop = desktopon ? true : false;
users[id].disabled = disableon ? true : false;
});
BDFDB.saveAllData(users, this, "users");
});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-adduser", e => {
let idinput = settingspanel.querySelector("#input-userid");
let user = this.UserUtils.getUser(idinput.value);
if (user) {
idinput.value = "";
BDFDB.saveData(user.id, {desktop:false,disabled:false}, this, "users");
BDFDB.removeEles(this.getName() + "-settings .settings-avatar");
let listhtml = `<div class="avatar-list ${BDFDB.disCN.marginbottom8}">`;
let users = BDFDB.loadAllData(this, "users");
@ -236,18 +232,18 @@ class StalkerNotifications {
}
listhtml += `</div>`;
settingspanel.querySelector(".avatar-list").innerHTML = listhtml;
})
.on("click", ".btn-timelog", () => {
this.showTimeLog();
})
.on("input", ".amountInput", e => {
let input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > 0) {
BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
this.startInterval();
}
else e.currentTarget.value = 1;
});
}
else BDFDB.showToast("Please enter a valid UserID.",{type:"error"});
});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-timelog", () => {this.showTimeLog();});
BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => {
let input = parseInt(e.currentTarget.value);
if (!isNaN(input) && input > 0) {
BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
this.startInterval();
}
else e.currentTarget.value = 1;
});
return settingspanel;
}
@ -256,22 +252,25 @@ class StalkerNotifications {
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.ChannelUtils = BDFDB.WebModules.findByProperties("getDMFromUserId");
@ -292,7 +291,7 @@ class StalkerNotifications {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
clearInterval(this.checkInterval);
BDFDB.unloadMessage(this);
}
@ -364,7 +363,7 @@ class StalkerNotifications {
};
if (!user.desktop) {
let toast = BDFDB.showToast(`<div class="toast-inner"><div class="toast-avatar" style="background-image:url(${avatar});"></div><div>${string}</div></div>`, {html:true, timeout:5000, type:(online ? "success" : null), icon:false, selector:`stalkernotifications-${online ? "online" : "offline"}-toast`});
$(toast).on("click." + this.getName(), openChannel);
toast.addEventListener("click", openChannel);
let notificationsound = BDFDB.getData(online ? "toastonline" : "toastoffline", this, "notificationsounds");
if (!notificationsound.mute && notificationsound.song) {
let audio = new Audio();

View File

@ -1,40 +1,42 @@
//META{"name":"SteamProfileLink"}*//
class SteamProfileLink {
getName () {return "SteamProfileLink";}
getDescription () {return "Opens any Steam links in Steam instead of your internet browser.";}
getVersion () {return "1.0.4";}
getVersion () {return "1.0.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Opens any Steam links in Steam instead of your internet browser.";}
//legacy
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);
$(document).on("click." + this.getName(), "a[href^='https://steamcommunity.'],a[href^='https://store.steampowered.']", (e) => {
e.preventDefault();
e.stopImmediatePropagation();
BDFDB.addEventListener(this, document, "click", "a[href^='https://steamcommunity.'],a[href^='https://store.steampowered.']", e => {
e.originalEvent.preventDefault();
e.originalEvent.stopImmediatePropagation();
if (require("electron").shell.openExternal("steam://openurl/" + e.currentTarget.href));
else window.open(e.currentTarget.href, "_blank");
});
@ -46,7 +48,7 @@ class SteamProfileLink {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}

View File

@ -3,7 +3,7 @@
class ThemeRepo {
getName () {return "ThemeRepo";}
getVersion () {return "1.6.9";}
getVersion () {return "1.7.0";}
getAuthor () {return "DevilBro";}
@ -300,11 +300,11 @@ class ThemeRepo {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "click", ".btn-addtheme", () => {this.addThemeToOwnList(settingspanel);});
BDFDB.addChildEventListener(settingspanel, "click", "#input-themeurl", e => {if (e.which == 13) this.addThemeToOwnList(settingspanel);});
BDFDB.addChildEventListener(settingspanel, "click", ".remove-theme", e => {this.removeThemeFromOwnList(e);});
BDFDB.addChildEventListener(settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList();})
BDFDB.addChildEventListener(settingspanel, "click", ".refresh-button", () => {
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addtheme", () => {this.addThemeToOwnList(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", "#input-themeurl", e => {if (e.which == 13) this.addThemeToOwnList(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-theme", e => {this.removeThemeFromOwnList(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.loadThemes();
});
@ -314,22 +314,25 @@ class ThemeRepo {
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.UserUtils = BDFDB.WebModules.findByProperties("getUsers");
@ -348,7 +351,7 @@ class ThemeRepo {
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
clearInterval(this.updateInterval);
clearTimeout(this.loading.timeout);
@ -365,7 +368,7 @@ class ThemeRepo {
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(".themerepo-item")) {
if (node.tagName && BDFDB.containsClass(node, "plugin-context-menu") && !node.querySelector(".themerepo-item")) {
observer.disconnect();
let item = node.querySelectorAll(BDFDB.dotCN.contextmenuitem);
item = item[item.length-1];
@ -375,7 +378,8 @@ class ThemeRepo {
this.openThemeRepoModal();
});
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");
}
});
});
@ -409,7 +413,9 @@ class ThemeRepo {
if (!ownlist.includes(url)) {
ownlist.push(url);
BDFDB.saveData("ownlist", ownlist, this, "ownlist");
themeList.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-theme"></div></div>`));
let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-theme"></div></div>`)
BDFDB.addChildEventListener(entry, "click", ".remove-theme", e => {this.removeThemeFromOwnList(e);});
themeList.appendChild(entry);
}
}
}
@ -423,10 +429,10 @@ class ThemeRepo {
BDFDB.saveData("ownlist", ownlist, this, "ownlist");
}
removeAllFromOwnList () {
removeAllFromOwnList (settingspanel) {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all added Themes from your own list?", () => {
BDFDB.saveData("ownlist", [], this, "ownlist");
BDFDB.removeEles("." + this.getName() + "-settings " + BDFDB.dotCN.hovercard);
BDFDB.removeEles(settingspanel.querySelector(BDFDB.dotCN.hovercard));
});
}
@ -522,7 +528,7 @@ class ThemeRepo {
BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {this.sortEntries(themeRepoModal);});
});
BDFDB.addChildEventListener(themeRepoModal, "click", BDFDB.dotCN.tabbaritem + "[tab=themes]", e => {
if (!e.currentTarget.classList.contains(BDFDB.disCN.settingsitemselected)) {
if (!BDFDB.containsClass(e.currentTarget, BDFDB.disCN.settingsitemselected)) {
if (themeRepoModal.updateHidden) {
delete themeRepoModal.updateHidden;
this.sortEntries(themeRepoModal);
@ -572,7 +578,7 @@ class ThemeRepo {
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;
@ -601,7 +607,7 @@ class ThemeRepo {
});
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.deleteThemeFile(data);
if (!BDFDB.isRestartNoMoreEnabled()) this.removeTheme(data);
@ -619,8 +625,8 @@ class ThemeRepo {
if (e.currentTarget.checked) themeRepoModal.querySelectorAll(".previewCheckbox").forEach(checkbox => {
if (e.currentTarget != checkbox) {
checkbox.checked = false;
checkbox.parentElement.classList.remove(BDFDB.disCN.switchvaluechecked);
checkbox.parentElement.classList.add(BDFDB.disCN.switchvalueunchecked);
BDFDB.removeClass(checkbox.parentElement, BDFDB.disCN.switchvaluechecked);
BDFDB.addClass(checkbox.parentElement, BDFDB.disCN.switchvalueunchecked);
}
});
frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"NewTheme",checked:e.currentTarget.checked,css:data.css},"*");
@ -630,9 +636,9 @@ class ThemeRepo {
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");

View File

@ -3,7 +3,7 @@
class ThemeSettings {
getName () {return "ThemeSettings";}
getVersion () {return "1.0.9";}
getVersion () {return "1.1.0";}
getAuthor () {return "DevilBro";}
@ -19,22 +19,25 @@ class ThemeSettings {
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.fs = require("fs");
@ -49,7 +52,7 @@ class ThemeSettings {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".themes-settings-button",".themes-settings-footer");
BDFDB.unloadMessage(this);
}
@ -73,8 +76,8 @@ class ThemeSettings {
button.innerText = "Settings";
footer.appendChild(button);
button.addEventListener("click", () => {
wrapper.classList.add(BDFDB.disCN._reposettingsopen);
wrapper.classList.remove(BDFDB.disCN._reposettingsclosed);
BDFDB.addClass(wrapper, BDFDB.disCN._reposettingsopen);
BDFDB.removeClass(wrapper, BDFDB.disCN._reposettingsclosed);
let children = [];
while (wrapper.childElementCount) {
children.push(wrapper.firstChild);
@ -83,8 +86,8 @@ class ThemeSettings {
let closebutton = BDFDB.htmlToElement(`<div style="float: right; cursor: pointer;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" style="width: 18px; height: 18px;"><g class="background" fill="none" fill-rule="evenodd"><path d="M0 0h12v12H0"></path><path class="fill" fill="#dcddde" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path></g></svg></div>`);
wrapper.appendChild(closebutton);
closebutton.addEventListener("click", () => {
wrapper.classList.remove(BDFDB.disCN._reposettingsopen);
wrapper.classList.add(BDFDB.disCN._reposettingsclosed);
BDFDB.removeClass(wrapper, BDFDB.disCN._reposettingsopen);
BDFDB.addClass(wrapper, BDFDB.disCN._reposettingsclosed);
while (wrapper.childElementCount) wrapper.firstChild.remove();
while (children.length) wrapper.appendChild(children.shift());
})
@ -114,7 +117,7 @@ class ThemeSettings {
let settingspanel = BDFDB.htmlToElement(settingshtml);
var settingspanelinner = settingspanel.querySelector(".DevilBro-settings-inner");
var maxwidth = wrapper.getBoundingClientRect().width - 80;
var maxwidth = BDFDB.getRects(wrapper).width - 80;
for (let varstr of vars) {
varstr = varstr.split(":");
@ -132,7 +135,7 @@ class ThemeSettings {
BDFDB.initElements(settingspanel, this);
BDFDB.addChildEventListener(settingspanel, "click", ".update-button", () => {
BDFDB.addEventListener(this, settingspanel, "click", ".update-button", () => {
let path = this.path.join(this.dir, theme.filename);
let css = this.fs.readFileSync(path).toString();
if (css) {

View File

@ -3,7 +3,7 @@
class TopRoleEverywhere {
getName () {return "TopRoleEverywhere";}
getVersion () {return "2.7.8";}
getVersion () {return "2.7.9";}
getAuthor () {return "DevilBro";}
@ -75,22 +75,25 @@ class TopRoleEverywhere {
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.GuildPerms = BDFDB.WebModules.findByProperties("getHighestRole");
@ -105,7 +108,7 @@ class TopRoleEverywhere {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeEles(".TRE-tag");
BDFDB.unloadMessage(this);
}
@ -115,7 +118,7 @@ class TopRoleEverywhere {
// begin of own functions
processNameTag (instance, wrapper) {
if (instance.props && wrapper.classList && wrapper.classList.contains(BDFDB.disCN.membernametag) && BDFDB.getData("showInMemberList", this, "settings")) {
if (instance.props && BDFDB.containsClass(wrapper, BDFDB.disCN.membernametag) && BDFDB.getData("showInMemberList", this, "settings")) {
this.addRoleTag(instance.props.user, wrapper.querySelector(BDFDB.dotCN.memberusername), "list");
}
}
@ -147,7 +150,7 @@ class TopRoleEverywhere {
let roleColor = role && role.colorString ? BDFDB.colorCONVERT(role.colorString, "RGBCOMP") : [255,255,255];
let roleName = role ? role.name : "";
let oldwidth;
if (type == "list") oldwidth = username.getBoundingClientRect().width;
if (type == "list") oldwidth = BDFDB.getRects(username).width;
let tag = BDFDB.htmlToElement(this.tagMarkup);
username.parentElement.insertBefore(tag, username.parentElement.querySelector("svg[name=MobileDevice]"));
@ -173,11 +176,8 @@ class TopRoleEverywhere {
textColor = "white";
}
}
else if (settings.showOwnerRole && info.id == guild.ownerId) {
roleText = "Owner";
tag.classList.add("owner-tag");
}
tag.classList.add(type + "-tag");
else if (settings.showOwnerRole && info.id == guild.ownerId) roleText = "Owner";
BDFDB.addClass(tag, type + "-tag");
tag.style.setProperty("border", "1px solid " + borderColor);
tag.style.setProperty("background", bgColor);
tag.style.setProperty("order", 11, "important");
@ -187,8 +187,8 @@ class TopRoleEverywhere {
inner.style.setProperty("-webkit-background-clip", "text");
inner.textContent = roleText;
if (oldwidth && oldwidth < 100 && username.getBoundingClientRect().width < 100) {
tag.style.setProperty("max-width", (BDFDB.getParentEle(BDFDB.dotCN.memberinner, username).getBoundingClientRect().width - oldwidth - 15) + "px");
if (oldwidth && oldwidth < 100 && BDFDB.getRects(username).width < 100) {
tag.style.setProperty("max-width", (BDFDB.getRects(BDFDB.getParentEle(BDFDB.dotCN.memberinner, username)).width - oldwidth - 15) + "px");
}
}
if (type == "chat" && settings.addUserID) {
@ -204,7 +204,7 @@ class TopRoleEverywhere {
idBgColor = "rgb(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ")";
idTextColor = settings.darkIdTag ? "white" : "black";
}
idtag.classList.add("id-tag");
BDFDB.addClass(idtag, "id-tag");
idtag.style.setProperty("border", "1px solid " + idBorderColor);
idtag.style.setProperty("background", idBgColor);
idtag.style.setProperty("order", 12, "important");

View File

@ -0,0 +1,3 @@
# User Notes - [Download](https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/UserNotes/UserNotes.plugin.js)
Allows you to write your own user notes wihtout a character limit.

View File

@ -0,0 +1,149 @@
//META{"name":"UserNotes"}*//
class UserNotes {
getName () {return "UserNotes";}
getVersion () {return "1.0.1";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to write your own user notes wihtout a character limit.";}
initConstructor () {
this.css = `
.${this.getName()}-modal textarea {
rows: 0;
cols: 0;
height: 30vw;
resize: none;
}`;
this.userContextEntryMarkup =
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
<div class="${BDFDB.disCN.contextmenuitem} localusernotes-item">
<span>${BDFDB.LanguageStrings.USERS + " " + BDFDB.LanguageStrings.NOTE}</span>
<div class="${BDFDB.disCN.contextmenuhint}"></div>
</div>
</div>`;
this.userNotesModalMarkup =
`<span class="${this.getName()}-modal DevilBro-modal">
<div class="${BDFDB.disCN.backdrop}"></div>
<div class="${BDFDB.disCN.modal}">
<div class="${BDFDB.disCN.modalinner}">
<div class="${BDFDB.disCNS.modalsub + BDFDB.disCN.modalsizemedium}">
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto;">
<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">
<h4 class="${BDFDB.disCNS.h4 + BDFDB.disCNS.headertitle + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.defaultcolor + BDFDB.disCNS.h4defaultmargin + BDFDB.disCN.marginreset}">${BDFDB.LanguageStrings.USERS + " " + BDFDB.LanguageStrings.NOTE}</h4>
<div class="${BDFDB.disCNS.modalguildname + BDFDB.disCNS.small + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCN.primary}"></div>
</div>
<svg class="${BDFDB.disCNS.modalclose + BDFDB.disCN.flexchild}" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 12 12">
<g fill="none" fill-rule="evenodd">
<path d="M0 0h12v12H0"></path>
<path class="fill" fill="currentColor" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path>
</g>
</svg>
</div>
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCNS.themeghosthairline + BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCNS.directioncolumn + BDFDB.disCNS.flexchild + BDFDB.disCNS.modalsubinner + BDFDB.disCN.marginbottom20}" style="flex: 1 1 auto;">
<textarea class="${BDFDB.disCNS.scroller + BDFDB.disCNS.inputdefault + BDFDB.disCN.input}" id="modal-inputtext"></textarea>
</div>
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontalreverse + BDFDB.disCNS.horizontalreverse2 + BDFDB.disCNS.directionrowreverse + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCN.modalfooter}">
<button type="button" class="btn-save ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
<div class="${BDFDB.disCN.buttoncontents}"></div>
</button>
<button type="button" class="btn-cancel ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlooklink + BDFDB.disCNS.buttoncolorwhite + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
<div class="${BDFDB.disCN.buttoncontents}"></div>
</button>
</div>
</div>
</div>
</div>
</span>`;
}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `<div class="${this.getName()}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.getName()}</div><div class="DevilBro-settings-inner">`;
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Remove all User Notes.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} remove-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Remove</div></button></div>`;
settingshtml += `</div></div>`;
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".remove-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all usernotes?", () => {
BDFDB.removeAllData(this, "notes");
});
});
return settingspanel;
}
//legacy
load () {}
start () {
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);
}
initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.loadMessage(this);
}
else {
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
}
}
stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
// begin of own functions
onUserContextMenu (instance, menu) {
if (instance.props && instance.props.user && !menu.querySelector(".localusernotes-item")) {
let userContextEntry = BDFDB.htmlToElement(this.userContextEntryMarkup);
userContextEntry.querySelector(".localusernotes-item").addEventListener("click", () => {
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
this.openNotesModal(instance.props.user);
});
menu.appendChild(userContextEntry);
}
}
openNotesModal (info) {
let note = BDFDB.loadData(info.id, this, "notes") || "";
let userNotesModal = BDFDB.htmlToElement(this.userNotesModalMarkup);
let noteinput = userNotesModal.querySelector("#modal-inputtext")
userNotesModal.querySelector(BDFDB.dotCN.modalguildname).text(info.username);
noteinput.value = note;
noteinput.setAttribute("placeholder", note);
BDFDB.appendModal(userNotesModal);
BDFDB.addChildEventListener(userNotesModal, "click", ".btn-save", (e) => {
e.preventDefault();
BDFDB.saveData(info.id, noteinput.value, this, "notes")
});
noteinput.focus();
}
}

View File

@ -1,39 +1,42 @@
//META{"name":"WriteUpperCase"}*//
class WriteUpperCase {
initConstructor () {
this.patchModules = {
"ChannelTextArea":"componentDidMount"
};
}
getName () {return "WriteUpperCase";}
getDescription () {return "Change input to uppercase.";}
getVersion () {return "1.1.9";}
getVersion () {return "1.2.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Change input to uppercase.";}
initConstructor () {
this.patchModules = {
"ChannelTextArea":"componentDidMount",
};
}
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);
@ -44,7 +47,7 @@ class WriteUpperCase {
}
stop () {
if (typeof BDFDB === "object") {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.unloadMessage(this);
}
}
@ -52,11 +55,11 @@ class WriteUpperCase {
// begin of own functions
bindEventToTextArea (textarea) {
if (!textarea) return;
$(textarea)
.off("keyup." + this.getName())
.on("keyup." + this.getName(), () => {
processChannelTextArea (instance, wrapper) {
if (instance.props && instance.props.type) {
var textarea = wrapper.querySelector("textarea");
if (!textarea) return;
BDFDB.addEventListener(this, textarea, "keyup", () => {
clearTimeout(textarea.WriteUpperCaseTimeout);
textarea.WriteUpperCaseTimeout = setTimeout(() => {
let string = textarea.value;
@ -77,9 +80,6 @@ class WriteUpperCase {
}
},1);
});
}
processChannelTextArea (instance, wrapper) {
if (instance.props && instance.props.type) this.bindEventToTextArea(wrapper.querySelector("textarea"));
}
}
}