stuff
This commit is contained in:
parent
5945285a66
commit
f94ade3abb
|
@ -8,14 +8,14 @@ class BadgesEverywhere {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Displays Badges (Nitro, HypeSquad, etc...) in the chat/memberlist/userpopout. Thanks for Zerebos' help.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"NameTag":"componentDidMount",
|
||||
"MessageUsername":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
.BE-badge {
|
||||
display: inline-block;
|
||||
|
@ -44,11 +44,11 @@ class BadgesEverywhere {
|
|||
.BE-badge.BE-badge-EarlySupporter {width:24px !important; min-width:24px !important;}
|
||||
.BE-badge.BE-badge-Nitro {width:21px !important; min-width:21px !important;}
|
||||
.BE-badge.BE-badge-settings {width:30px !important; min-width:30px !important;}`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.requestedusers = {};
|
||||
this.loadedusers = {};
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showInPopout: {value:true, description:"Show Badge in User Popout."},
|
||||
|
@ -71,7 +71,7 @@ class BadgesEverywhere {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -84,13 +84,13 @@ class BadgesEverywhere {
|
|||
for (let flag in badges) {
|
||||
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.badges[flag].name}</h3><span class="BE-badges ${BDFDB.disCN.userprofiletopsectionplaying}" style="all: unset !important;"><div class="BE-badge BE-badge-${this.defaults.badges[flag].name.replace(/ /g, "")} BE-badge-settings ${this.BadgeClasses[this.defaults.badges[flag].selector]}"></div></span><span class="BE-badges ${BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;"><div class="BE-badge BE-badge-${this.defaults.badges[flag].name.replace(/ /g, "")} BE-badge-settings ${this.BadgeClasses[this.defaults.badges[flag].selector]}"></div></span><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="badges ${flag}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${badges[flag] ? " checked" : ""}></div></div>`;
|
||||
}
|
||||
|
||||
|
||||
settingshtml += `</div></div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -119,13 +119,13 @@ class BadgesEverywhere {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.APIModule = BDFDB.WebModules.findByProperties("getAPIBaseURL");
|
||||
this.DiscordConstants = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes", "StatusTypes");
|
||||
this.BadgeClasses = BDFDB.WebModules.findByProperties("profileBadgeStaff","profileBadgePremium");
|
||||
|
||||
|
||||
for (let flag in this.defaults.badges) if (!this.defaults.badges[flag].selector) delete this.defaults.badges[flag];
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -139,10 +139,10 @@ class BadgesEverywhere {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processNameTag (instance, wrapper) {
|
||||
if (!wrapper.classList || !instance || !instance.props) return;
|
||||
else if (BDFDB.containsClass(wrapper, BDFDB.disCN.membernametag) && BDFDB.getData("showInMemberList", this, "settings")) {
|
||||
|
@ -153,7 +153,7 @@ class BadgesEverywhere {
|
|||
this.addBadges(instance.props.user, wrapper, "popout");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processMessageUsername (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message) {
|
||||
|
@ -161,14 +161,14 @@ class BadgesEverywhere {
|
|||
if (username && BDFDB.getData("showInChat", this, "settings")) this.addBadges(message.author, wrapper, "chat");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addBadges (info, wrapper, type) {
|
||||
if (!info || info.bot || !wrapper) return;
|
||||
if (!this.requestedusers[info.id]) {
|
||||
|
@ -187,7 +187,7 @@ class BadgesEverywhere {
|
|||
this.addToWrapper(info, wrapper, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addToWrapper (info, wrapper, type) {
|
||||
BDFDB.removeEles(wrapper.querySelectorAll(".BE-badges"));
|
||||
let badges = BDFDB.getAllData(this, "badges");
|
||||
|
|
|
@ -8,13 +8,13 @@ class BetterFriendCount {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Shows the amount of total and online friends and blocked users in the friends tab.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"TabBar":"componentDidMount",
|
||||
"NameTag":["componentWillMount","componentWillUnmount"]
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCNS.friends + BDFDB.dotCNS.settingstabbar + BDFDB.dotCN.badge}:not(.betterfriendcount-badge),
|
||||
${BDFDB.dotCNS.friends + BDFDB.dotCNS.settingstabbar + BDFDB.dotCN.badgewrapper}:not(.betterfriendcount-badge) {
|
||||
|
@ -24,7 +24,7 @@ class BetterFriendCount {
|
|||
margin-left: 5px !important;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.relationshipTypes = {};
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,14 @@ class BetterFriendCount {
|
|||
|
||||
initialize () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.FriendUtils = BDFDB.WebModules.findByProperties("getFriendIDs", "getRelationships");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatus", "getOnlineFriendCount");
|
||||
let RelationshipTypes = BDFDB.WebModules.findByProperties("RelationshipTypes").RelationshipTypes;
|
||||
for (let type in RelationshipTypes) this.relationshipTypes[RelationshipTypes[type]] = type;
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -72,24 +72,24 @@ class BetterFriendCount {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processTabBar (instance, wrapper) {
|
||||
if (instance.props && instance.props.children && instance.props.children[0].key == "ADD_FRIEND") this.addCountNumbers(wrapper);
|
||||
}
|
||||
|
||||
|
||||
processNameTag (instance, wrapper) {
|
||||
if (wrapper.parentElement && BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.friendscolumn)) this.addCountNumbers();
|
||||
}
|
||||
|
||||
|
||||
addCountNumbers (wrapper = document.querySelector(BDFDB.dotCNS.friends + BDFDB.dotCN.settingstabbar)) {
|
||||
if (!wrapper) return;
|
||||
let tabitems = wrapper.querySelectorAll(BDFDB.dotCN.settingsitem);
|
||||
if (!tabitems || tabitems.length < 5) return;
|
||||
BDFDB.removeEles(".betterfriendcount-badge");
|
||||
|
||||
|
||||
let relationships = this.FriendUtils.getRelationships(), relationshipCount = {};
|
||||
for (let type in this.relationshipTypes) relationshipCount[this.relationshipTypes[type]] = 0;
|
||||
for (let id in relationships) relationshipCount[this.relationshipTypes[relationships[id]]]++;
|
||||
|
|
|
@ -8,7 +8,7 @@ class BetterNsfwTag {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds a more noticeable tag to NSFW channels.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"ChannelItem":"componentDidMount"
|
||||
|
@ -40,7 +40,7 @@ class BetterNsfwTag {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -50,14 +50,14 @@ class BetterNsfwTag {
|
|||
|
||||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".NSFW-tag");
|
||||
BDFDB.removeEles(".NSFW-tag");
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processChannelItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel && instance.props.channel.nsfw) {
|
||||
let channelname = wrapper.querySelector(BDFDB.dotCN.channelname);
|
||||
|
|
|
@ -8,12 +8,12 @@ class BetterSearchPage {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds some extra controls to the search results page.";}
|
||||
|
||||
initConstructor () {
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"SearchResults":["componentDidMount","componentDidUpdate"]
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
.BSP-pagination-button {
|
||||
background: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" width="30" height="25"><g fill="#737f8d" fill-rule="evenodd" clip-rule="evenodd"><path xmlns="http://www.w3.org/2000/svg" d="M17.338 12.485c-4.156 4.156-8.312 8.312-12.468 12.467-1.402-1.402-2.805-2.804-4.207-4.206 2.756-2.757 5.513-5.514 8.27-8.27C6.176 9.72 3.419 6.963.663 4.207L4.87 0c-.058-.059 12.555 12.562 12.468 12.485z"/><path xmlns="http://www.w3.org/2000/svg" d="M17.338 12.485c-4.156 4.156-8.312 8.312-12.468 12.467-1.402-1.402-2.805-2.804-4.207-4.206 2.756-2.757 5.513-5.514 8.27-8.27C6.176 9.72 3.419 6.963.663 4.207L4.87 0c-.058-.059 12.555 12.562 12.468 12.485z" transform="translate(12 0)"/></g></svg>') 50%/9px 12px no-repeat;
|
||||
|
@ -50,7 +50,7 @@ class BetterSearchPage {
|
|||
opacity: 1;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addFirstLast: {value:true, description:"Adds a first and last page button."},
|
||||
|
@ -59,7 +59,7 @@ class BetterSearchPage {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -68,7 +68,7 @@ class BetterSearchPage {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -100,9 +100,9 @@ class BetterSearchPage {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.SearchNavigation = BDFDB.WebModules.findByProperties("searchNextPage","searchPreviousPage");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -116,14 +116,14 @@ class BetterSearchPage {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processSearchResults (instance, wrapper) {
|
||||
if (instance.props && instance.props.searchId) this.addNewControls(wrapper.querySelector(BDFDB.dotCN.searchresultspagination), instance.props.searchId);
|
||||
}
|
||||
|
||||
|
||||
addNewControls (pagination, searchId) {
|
||||
if (!pagination || !searchId || document.querySelector(".BSP-pagination, .BSP-pagination-button, .BSP-pagination-jumpinput")) return;
|
||||
let searchResultsWrapper = BDFDB.getParentEle(BDFDB.dotCN.searchresultswrapper, pagination);
|
||||
|
@ -156,12 +156,12 @@ class BetterSearchPage {
|
|||
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);
|
||||
BDFDB.initElements(pagination, this);
|
||||
if (settings.cloneToTheTop) {
|
||||
let BSPpaginaton = pagination.cloneNode(true);
|
||||
BDFDB.addClass(BSPpaginaton, "BSP-pagination");
|
||||
searchResultsWrapper.insertBefore(BSPpaginaton, searchResultsWrapper.firstElementChild);
|
||||
BDFDB.initElements(BSPpaginaton);
|
||||
BDFDB.initElements(BSPpaginaton, this);
|
||||
}
|
||||
var doJump = (input) => {
|
||||
let value = input.value;
|
||||
|
|
|
@ -8,16 +8,16 @@ class CharCounter {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds a charcounter in the chat.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount",
|
||||
"Note":"componentDidMount",
|
||||
"Modal":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.selecting = false;
|
||||
|
||||
|
||||
this.maxLenghts = {
|
||||
normal: 2000,
|
||||
edit: 2000,
|
||||
|
@ -104,7 +104,7 @@ class CharCounter {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -120,33 +120,33 @@ class CharCounter {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
if (instance.props && instance.props.type && this.maxLenghts[instance.props.type]) this.appendCounter(wrapper.querySelector("textarea"), instance.props.type);
|
||||
}
|
||||
|
||||
|
||||
processNote (instance, wrapper) {
|
||||
this.appendCounter(wrapper.firstElementChild, BDFDB.containsClass(wrapper, BDFDB.disCN.usernotepopout) ? "popout" : (BDFDB.containsClass(wrapper, BDFDB.disCN.usernoteprofile) ? "profile" : null));
|
||||
}
|
||||
|
||||
|
||||
processModal (instance, wrapper) {
|
||||
if (instance.props && instance.props.tag == "form") {
|
||||
let reset = wrapper.querySelector(BDFDB.dotCN.reset);
|
||||
if (reset && BDFDB.getInnerText(reset.firstElementChild) == BDFDB.LanguageStrings.RESET_NICKNAME) this.appendCounter(wrapper.querySelector(BDFDB.dotCN.inputdefault), "nickname");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendCounter (input, type) {
|
||||
if (!input || !type) return;
|
||||
BDFDB.removeEles(input.parentElement.querySelectorAll("#charcounter"));
|
||||
var counter = BDFDB.htmlToElement(`<div id="charcounter" class="charcounter ${type}"></div>`);
|
||||
input.parentElement.appendChild(counter);
|
||||
|
||||
|
||||
var updateCounter = () => {counter.innerText = input.value.length + "/" + (this.maxLenghts[type] || 2000) + (input.selectionEnd - input.selectionStart == 0 ? "" : " (" + (input.selectionEnd - input.selectionStart) + ")");};
|
||||
|
||||
|
||||
BDFDB.addClass(input.parentElement.parentElement, "charcounter-added");
|
||||
if (type == "nickname") input.setAttribute("maxlength", 32);
|
||||
BDFDB.addEventListener(this, input, "keydown click", e => {
|
||||
|
@ -165,7 +165,7 @@ class CharCounter {
|
|||
});
|
||||
BDFDB.addEventListener(this, document, "mousemove", () => {setTimeout(() => {updateCounter();},10);});
|
||||
});
|
||||
|
||||
|
||||
updateCounter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ class ChatAliases {
|
|||
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 = {
|
||||
settings: {
|
||||
addAutoComplete: {value:true, description:"Add an Autocomplete-Menu for Non-Regex Aliases:"}
|
||||
|
@ -92,13 +92,13 @@ class ChatAliases {
|
|||
this.UploadModule = BDFDB.WebModules.findByProperties("instantBatchUpload");
|
||||
this.CurrentUserPerms = BDFDB.WebModules.findByProperties("getChannelPermissions", "can");
|
||||
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions;
|
||||
|
||||
|
||||
this.aliases = BDFDB.loadAllData(this, "words");
|
||||
|
||||
|
||||
BDFDB.addEventListener(document, "click", e => {
|
||||
if (!e.target.tagName === "TEXTAREA") BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
|
||||
});
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -221,18 +221,18 @@ class ChatAliases {
|
|||
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");
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
@ -286,7 +286,7 @@ class ChatAliases {
|
|||
clearTimeout(textarea.chataliastimeout);
|
||||
textarea.chataliastimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea);},100);
|
||||
}
|
||||
|
||||
|
||||
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 => {
|
||||
|
@ -294,7 +294,7 @@ class ChatAliases {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addAutoCompleteMenu (textarea) {
|
||||
if (textarea.parentElement.querySelector(".autocompleteAliasesRow")) return;
|
||||
let words = textarea.value.split(/\s/);
|
||||
|
@ -341,7 +341,7 @@ class ChatAliases {
|
|||
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
|
||||
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>`);
|
||||
|
@ -354,7 +354,7 @@ class ChatAliases {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getNextSelection (menu, selected, forward) {
|
||||
selected = selected ? selected : menu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement;
|
||||
let next, sibling = forward ? selected.nextElementSibling : selected.previousElementSibling;
|
||||
|
@ -367,7 +367,7 @@ class ChatAliases {
|
|||
}
|
||||
return next ? next : this.getNextSelection(menu, sibling, forward);
|
||||
}
|
||||
|
||||
|
||||
swapWordWithAlias (textarea) {
|
||||
let aliasword = textarea.parentElement.querySelector(".autocompleteAliasesRow " + BDFDB.dotCN.autocompleteselected + " .aliasword").innerText;
|
||||
let lastword = textarea.parentElement.querySelector(".autocompleteAliasesRow .lastword").innerText;
|
||||
|
|
|
@ -8,22 +8,22 @@ class ChatFilter {
|
|||
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 = `
|
||||
${BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messageaccessory}.blocked:not(.revealed),
|
||||
${BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messagemarkup}.blocked:not(.revealed) {
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
replaces: {
|
||||
blocked: {value:"~~BLOCKED~~", title:"Block:", description:"Default Replace Word for blocked Messages:"},
|
||||
|
@ -35,7 +35,7 @@ class ChatFilter {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var replaces = BDFDB.getAllData(this, "replaces");
|
||||
|
@ -52,7 +52,7 @@ class ChatFilter {
|
|||
for (let config of this.configs) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.tableheadersize + BDFDB.disCNS.size10 + BDFDB.disCNS.primary + BDFDB.disCN.weightbold}" style="flex: 1 1 auto; width: 34px !important; text-align: center;">${config.toUpperCase()}</div>`;
|
||||
}
|
||||
settingshtml += `</div></div><div class="DevilBro-settings-inner-list ${rtype}-list">`;
|
||||
settingshtml += `</div></div><div class="DevilBro-settings-inner-list ${rtype}-list">`;
|
||||
for (let word in words) {
|
||||
settingshtml += `<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) {
|
||||
|
@ -68,7 +68,7 @@ class ChatFilter {
|
|||
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;'" : ""}><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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -78,7 +78,7 @@ class ChatFilter {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ class ChatFilter {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -118,20 +118,20 @@ class ChatFilter {
|
|||
stop () {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
updateContainer (settingspanel, ele) {
|
||||
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>`
|
||||
|
@ -145,7 +145,7 @@ class ChatFilter {
|
|||
BDFDB.initElements(settingspanel, this);
|
||||
this.SettingsUpdated = true;
|
||||
};
|
||||
|
||||
|
||||
if (action == "add") {
|
||||
var wordinput = settingspanel.querySelector("#input-" + rtype + "-wordvalue");
|
||||
var replaceinput = settingspanel.querySelector("#input-" + rtype + "-replacevalue");
|
||||
|
@ -180,7 +180,7 @@ class ChatFilter {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
saveReplace (input) {
|
||||
var rtype = input.getAttribute("rtype");
|
||||
var wordvalue = input.value;
|
||||
|
@ -189,7 +189,7 @@ class ChatFilter {
|
|||
BDFDB.saveData(rtype, wordvalue.trim(), this, "replaces");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateConfig (ele) {
|
||||
var wordvalue = ele.getAttribute("word");
|
||||
var config = ele.getAttribute("config");
|
||||
|
@ -208,15 +208,15 @@ class ChatFilter {
|
|||
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");
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
@ -224,15 +224,15 @@ class ChatFilter {
|
|||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hideMessage (message) {
|
||||
if (message.tagName && !BDFDB.containsClass(message, "blocked", "censored", false)) {
|
||||
var orightml = message.innerHTML;
|
||||
var newhtml = "";
|
||||
|
||||
|
||||
if (orightml) {
|
||||
var blocked = null;
|
||||
|
||||
|
||||
var strings = [];
|
||||
var count = 0;
|
||||
orightml.split("").forEach((chara) => {
|
||||
|
@ -244,7 +244,7 @@ class ChatFilter {
|
|||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var replaces = BDFDB.getAllData(this, "replaces");
|
||||
var blockedWords = BDFDB.loadData("blocked", this, "words");
|
||||
|
@ -275,7 +275,7 @@ class ChatFilter {
|
|||
BDFDB.addClass(message, "blocked");
|
||||
message.ChatFilterOriginalHTML = orightml;
|
||||
message.ChatFilterNewHTML = newhtml;
|
||||
|
||||
|
||||
this.addClickListener(message, settings.showMessageOnClick.blocked);
|
||||
}
|
||||
else {
|
||||
|
@ -318,25 +318,25 @@ class ChatFilter {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (censored) {
|
||||
newhtml = strings.join("");
|
||||
message.innerHTML = newhtml;
|
||||
BDFDB.addClass(message, "censored");
|
||||
message.ChatFilterOriginalHTML = orightml;
|
||||
message.ChatFilterNewHTML = newhtml;
|
||||
|
||||
|
||||
this.addClickListener(message, settings.showMessageOnClick.censored);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createReg (word, config) {
|
||||
return new RegExp(BDFDB.encodeToHTML(config.exact ? "^" + BDFDB.regEscape(word) + "$" : BDFDB.regEscape(word)), config.case ? "" : "i");
|
||||
}
|
||||
|
||||
|
||||
testForEmoji (string, reg) {
|
||||
if (string.indexOf("<img ") == 0 && (string.indexOf('class="emote') > -1 || string.indexOf('class="emoji') > -1)) {
|
||||
var emojiname = string.split('alt="').length > 0 ? string.split('alt="')[1].split('"')[0] : null;
|
||||
|
@ -344,7 +344,7 @@ class ChatFilter {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
resetMessage (message) {
|
||||
message.innerHTML = message.ChatFilterOriginalHTML;
|
||||
BDFDB.removeClass(message, "blocked", "censored", "revealed");
|
||||
|
@ -353,7 +353,7 @@ class ChatFilter {
|
|||
delete message.ChatFilterNewHTML;
|
||||
message.removeEventListener("click", message.clickChatFilterListener);
|
||||
}
|
||||
|
||||
|
||||
addClickListener (message, addListener) {
|
||||
message.removeEventListener("click", message.clickChatFilterListener);
|
||||
if (addListener) {
|
||||
|
|
|
@ -8,15 +8,15 @@ class CompleteTimestamps {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Replace all timestamps with complete timestamps.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"MessageGroup":["componentDidMount","componentDidUpdate"],
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.languages;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showInChat: {value:true, description:"Replace Chat Timestamp with Complete Timestamp:"},
|
||||
|
@ -36,7 +36,7 @@ class CompleteTimestamps {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -57,7 +57,7 @@ class CompleteTimestamps {
|
|||
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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -68,11 +68,11 @@ class CompleteTimestamps {
|
|||
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
|
||||
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) {
|
||||
|
@ -95,9 +95,9 @@ class CompleteTimestamps {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
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;
|
||||
|
@ -122,7 +122,7 @@ class CompleteTimestamps {
|
|||
BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, time), marker, {type:"top",selector:"completetimestampedit-tooltip",css:customTooltipCSS});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates();
|
||||
}
|
||||
else {
|
||||
|
@ -135,14 +135,14 @@ class CompleteTimestamps {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".complete-timestamp-divider");
|
||||
BDFDB.removeClasses("complete-timestamp");
|
||||
|
||||
|
||||
BDFDB.removeLocalStyle(this.name + "CompactCorrection");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
saveInputs (settingspanel) {
|
||||
|
@ -169,24 +169,24 @@ class CompleteTimestamps {
|
|||
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");
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
|
||||
plugincard.style.setProperty("overflow", "visible", "important");
|
||||
|
||||
|
||||
let selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"));
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
|
||||
let language = e2.currentTarget.getAttribute("value");
|
||||
selectWrap.setAttribute("value", language);
|
||||
|
@ -194,7 +194,7 @@ class CompleteTimestamps {
|
|||
selectControl.querySelector(".languageTimestamp").innerText = this.getTimestamp(this.languages[language].id);
|
||||
BDFDB.saveData(selectWrap.getAttribute("option"), language, this, "choices");
|
||||
});
|
||||
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
|
@ -203,10 +203,10 @@ class CompleteTimestamps {
|
|||
setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice) {
|
||||
let menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (let key in this.languages) {
|
||||
|
@ -216,18 +216,18 @@ class CompleteTimestamps {
|
|||
menuhtml += `</div></div>`;
|
||||
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 || BDFDB.containsClass(stamp, "complete-timestamp")) return;
|
||||
let time = stamp.getAttribute("datetime");
|
||||
|
@ -245,7 +245,7 @@ class CompleteTimestamps {
|
|||
BDFDB.setInnerText(stamp, this.getTimestamp(this.languages[BDFDB.getData("creationDateLang", this, "choices")].id, time));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getMessageData (div, messagegroup) {
|
||||
let pos = Array.from(messagegroup.querySelectorAll("." + div.className.replace(/ /g, "."))).indexOf(div);
|
||||
let instance = BDFDB.getReactInstance(messagegroup);
|
||||
|
@ -253,7 +253,7 @@ class CompleteTimestamps {
|
|||
let info = instance.return.stateNode.props.messages;
|
||||
return info && pos > -1 ? info[pos] : null;
|
||||
}
|
||||
|
||||
|
||||
getTimestamp (languageid, time) {
|
||||
let timeobj = time ? time : new Date();
|
||||
if (typeof time == "string") timeobj = new Date(time);
|
||||
|
@ -293,21 +293,21 @@ class CompleteTimestamps {
|
|||
}
|
||||
return timestring;
|
||||
}
|
||||
|
||||
|
||||
cutOffSeconds (timestring) {
|
||||
return timestring.replace(/(.*):(.*):(.{2})(.*)/, "$1:$2$4");
|
||||
}
|
||||
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
return chararray.join("");
|
||||
}
|
||||
|
||||
|
||||
setMaxWidth () {
|
||||
if (this.currentMode != BDFDB.getDiscordMode()) {
|
||||
this.currentMode = BDFDB.getDiscordMode();
|
||||
|
|
|
@ -8,17 +8,17 @@ class CreationDate {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Displays the Creation Date of an Account in the UserPopout and UserModal.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"UserPopout":"componentDidMount",
|
||||
"UserProfile":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.languages;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCNS.userpopout + BDFDB.dotCN.nametag} {
|
||||
margin-bottom: 4px;
|
||||
|
@ -40,8 +40,8 @@ class CreationDate {
|
|||
${BDFDB.dotCN.themedark} [class*='topSection'] .creationDate {
|
||||
color: hsla(0,0%,100%,.6);
|
||||
}`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInUserPopout: {value:true, description:"Add in User Popouts:"},
|
||||
|
@ -54,7 +54,7 @@ class CreationDate {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -67,7 +67,7 @@ class CreationDate {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -105,9 +105,9 @@ class CreationDate {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.languages = Object.assign({},BDFDB.languages);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -123,23 +123,23 @@ class CreationDate {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
openDropdownMenu (e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
|
||||
plugincard.style.setProperty("overflow", "visible", "important");
|
||||
|
||||
|
||||
let type = selectWrap.getAttribute("type");
|
||||
let selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"));
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
|
||||
let language = e2.currentTarget.getAttribute("value");
|
||||
selectWrap.setAttribute("value", language);
|
||||
|
@ -147,7 +147,7 @@ class CreationDate {
|
|||
selectControl.querySelector(".languageTimestamp").innerText = this.getCreationTime(language);
|
||||
BDFDB.saveData(type, language, this, "choices");
|
||||
});
|
||||
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
|
@ -156,10 +156,10 @@ class CreationDate {
|
|||
setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice) {
|
||||
let menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (let key in this.languages) {
|
||||
|
@ -169,40 +169,40 @@ class CreationDate {
|
|||
menuhtml += `</div></div>`;
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
|
||||
processUserPopout (instance, wrapper) {
|
||||
if (instance.props && instance.props.user && BDFDB.getData("addInUserPopout", this, "settings")) {
|
||||
this.addCreationDate(instance.props.user, wrapper.querySelector(BDFDB.dotCN.userpopoutheadertext), wrapper.parentElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processUserProfile (instance, wrapper) {
|
||||
if (instance.props && instance.props.user && BDFDB.getData("addInUserProfil", this, "settings")) {
|
||||
this.addCreationDate(instance.props.user, wrapper.querySelector(BDFDB.dotCN.userprofileheaderinfo), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addCreationDate (info, container, popout) {
|
||||
if (!info || !container || container.querySelector(".creationDate")) return;
|
||||
let choice = BDFDB.getData("creationDateLang", this, "choices");
|
||||
let nametag = container.querySelector(BDFDB.dotCN.nametag);
|
||||
let joinedAtDate = container.querySelector(".joinedAtDate");
|
||||
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);
|
||||
BDFDB.initElements(container.parentElement, this);
|
||||
if (popout && popout.style.transform.indexOf("translateY(-1") == -1) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getCreationTime (languageid, timestamp = new Date()) {
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let timestring = settings.addCreationTime ? timestamp.toLocaleString(languageid) : timestamp.toLocaleDateString(languageid);
|
||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
||||
return timestring;
|
||||
}
|
||||
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
let chararray = timestring.split("");
|
||||
let numreg = /[0-9]/;
|
||||
|
@ -211,7 +211,7 @@ class CreationDate {
|
|||
}
|
||||
return chararray.join("");
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,7 +8,7 @@ class DisplayServersAsChannels {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Display servers in a similar way as channels.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.verificationBadgeMarkup =
|
||||
`<svg class="DSAC-verification-badge" name="Verified" width="24" height="24" viewBox="0 0 20 20">
|
||||
|
@ -18,7 +18,7 @@ class DisplayServersAsChannels {
|
|||
<path fill="#ffffff" d="M8.84273967,12.8167603 L13.8643,7.7952 C14.0513,7.6072 14.0513,7.3042 13.8643,7.1172 C13.6773,6.9312 13.3743,6.9312 13.1863,7.1172 L8.52303089,11.78139 L6.8883,10.1475 C6.6843,9.9445 6.3553,9.9445 6.1523,10.1475 C5.9493,10.3515 5.9493,10.6805 6.1523,10.8835 L8.08381122,12.8160053 C8.09561409,12.8309877 8.10844368,12.8454178 8.1223,12.8592 C8.3093,13.0472 8.6123,13.0472 8.8003,12.8592 L8.82157566,12.8379243 C8.82518839,12.8345112 8.82876362,12.8310364 8.8323,12.8275 C8.83584168,12.8239583 8.83932157,12.820378 8.84273967,12.8167603 Z"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
.bd-minimal .DSAC-styled ${BDFDB.dotCN.guildswrapper},
|
||||
.bd-minimal .DSAC-styled ${BDFDB.dotCN.guildsscrollerwrap},
|
||||
|
@ -102,7 +102,7 @@ class DisplayServersAsChannels {
|
|||
.DSAC-styled ${BDFDB.dotCN.guildseparator}:not([style*="display: none"]),
|
||||
.DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}:not([style*="display: none"]),
|
||||
.DSAC-styled ${BDFDB.dotCN.guild}.copy:not([style*="display: none"]),
|
||||
.DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror}:not([style*="display: none"]) {
|
||||
.DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror}:not([style*="display: none"]) {
|
||||
display: flex;
|
||||
}
|
||||
.DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildunread}.copy.
|
||||
|
@ -221,9 +221,9 @@ class DisplayServersAsChannels {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -242,10 +242,10 @@ class DisplayServersAsChannels {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true, subtree:true, attributes:true, attributeFilter: ["class", "draggable"], attributeOldValue: true});
|
||||
|
||||
|
||||
BDFDB.readServerList().forEach(info => {this.changeServer(info);});
|
||||
document.querySelectorAll(BDFDB.dotCN.guild + ".folder").forEach(folderdiv => {this.changeServer(this.getFolderObject(folderdiv));});
|
||||
|
||||
|
||||
var appcontainer = document.querySelector(BDFDB.dotCN.appcontainer);
|
||||
if (appcontainer) {
|
||||
BDFDB.addEventListener(this, appcontainer, "mouseenter", `${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, ${BDFDB.dotCN.guild}.copy`, e => {
|
||||
|
@ -269,12 +269,12 @@ class DisplayServersAsChannels {
|
|||
BDFDB.readServerList().forEach(info => {this.resetServer(info);});
|
||||
document.querySelectorAll(BDFDB.dotCN.guild + ".folder").forEach(folderdiv => {this.resetServer(this.getFolderObject(folderdiv));});
|
||||
BDFDB.removeClasses("DSAC-styled");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeServer (info) {
|
||||
|
@ -283,7 +283,7 @@ class DisplayServersAsChannels {
|
|||
if (avatar) {
|
||||
avatar.DSAColdName = avatar.textContent;
|
||||
avatar.innerHTML = `<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">${BDFDB.encodeToHTML(info.name || info.folderName || "")}</div></span>`;
|
||||
BDFDB.initElements(avatar);
|
||||
BDFDB.initElements(avatar, this);
|
||||
if (info.features && info.features.has("VERIFIED")) avatar.parentElement.insertBefore(BDFDB.htmlToElement(this.verificationBadgeMarkup), avatar);
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ class DisplayServersAsChannels {
|
|||
BDFDB.removeEles(info.div.querySelector(".DSAC-verification-badge"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getFolderObject (folderdiv) {
|
||||
var data = BDFDB.loadData(folderdiv.id, "ServerFolders", "folders");
|
||||
return data ? Object.assign({div:folderdiv}, data) : null;
|
||||
|
|
|
@ -8,10 +8,10 @@ class EditChannels {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to rename and recolor channelnames.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount",
|
||||
"AuditLog":"componentDidMount",
|
||||
|
@ -21,7 +21,7 @@ class EditChannels {
|
|||
"Clickable":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.channelContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} localchannelsettings-item ${BDFDB.disCN.contextmenuitemsubmenu}">
|
||||
|
@ -29,7 +29,7 @@ class EditChannels {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.channelContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} editchannels-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -94,13 +94,13 @@ class EditChannels {
|
|||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.channelheadertitletext}[custom-editchannelsheader] ${BDFDB.dotCN.channelheaderchannelicon} {
|
||||
opacity: 0.6;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
changeChannelIcon: {value:true, description:"Change color of Channel Icon."},
|
||||
|
@ -108,7 +108,7 @@ class EditChannels {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -118,7 +118,7 @@ class EditChannels {
|
|||
}
|
||||
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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -157,13 +157,13 @@ class EditChannels {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers","getUser");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
|
||||
this.CurrentChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getDefaultChannel");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -177,28 +177,28 @@ class EditChannels {
|
|||
BDFDB.removeAllData(this, "channels");
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
BDFDB.saveAllData(data, this, "channels");
|
||||
|
||||
|
||||
BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.channelContextEntryMarkup = this.channelContextEntryMarkup.replace("REPLACE_context_localchannelsettings_text", this.labels.context_localchannelsettings_text);
|
||||
|
||||
|
||||
this.channelContextSubMenuMarkup = this.channelContextSubMenuMarkup.replace("REPLACE_submenu_channelsettings_text", this.labels.submenu_channelsettings_text);
|
||||
this.channelContextSubMenuMarkup = this.channelContextSubMenuMarkup.replace("REPLACE_submenu_resetsettings_text", this.labels.submenu_resetsettings_text);
|
||||
|
||||
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_modal_channelname_text", this.labels.modal_channelname_text);
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_modal_colorpicker1_text", this.labels.modal_colorpicker1_text);
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_btn_save_text", this.labels.btn_save_text);
|
||||
}
|
||||
|
||||
|
||||
onChannelContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.channel && !menu.querySelector(".localchannelsettings-item")) {
|
||||
let channelContextEntry = BDFDB.htmlToElement(this.channelContextEntryMarkup);
|
||||
|
@ -224,32 +224,32 @@ class EditChannels {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showChannelSettings (info) {
|
||||
var {name,color} = BDFDB.loadData(info.id, this, "channels") || {}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(channelSettingsModal, "click", ".btn-save", e => {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ class EditChannels {
|
|||
});
|
||||
channelnameinput.focus();
|
||||
}
|
||||
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
let channel = BDFDB.getReactValue(instance, "props.channel");
|
||||
if (channel) {
|
||||
|
@ -299,7 +299,7 @@ class EditChannels {
|
|||
clearTimeout(textarea.EditChannelsAutocompleteTimeout);
|
||||
textarea.EditChannelsAutocompleteTimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea, channel);},100);
|
||||
}
|
||||
|
||||
|
||||
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow");
|
||||
});
|
||||
BDFDB.addEventListener(this, textarea, "click", e => {
|
||||
|
@ -307,7 +307,7 @@ class EditChannels {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processAuditLog (instance, wrapper) {
|
||||
let channel = BDFDB.getReactValue(instance, "props.log.options.channel");
|
||||
if (channel) {
|
||||
|
@ -315,19 +315,19 @@ class EditChannels {
|
|||
if (hooks.length > 0) this.changeChannel2(channel, hooks[0].firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processChannelCategoryItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel) {
|
||||
this.changeChannel(instance.props.channel, wrapper.querySelector(BDFDB.dotCN.categorycolortransition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processChannelItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel) {
|
||||
this.changeChannel(instance.props.channel, wrapper.querySelector(BDFDB.dotCN.channelname));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processHeaderBar (instance, wrapper) {
|
||||
let channel_id = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channelId");
|
||||
if (channel_id) {
|
||||
|
@ -347,7 +347,7 @@ 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) {
|
||||
|
@ -388,14 +388,14 @@ class EditChannels {
|
|||
if (channel) this.changeChannel2(channel, wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeChannel (info, channelname) {
|
||||
if (!info || !channelname || !channelname.parentElement) return;
|
||||
if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect();
|
||||
|
@ -420,7 +420,7 @@ class EditChannels {
|
|||
if (unread) unread.style.setProperty("background-color", color && settings.changeUnreadIndicator ? color : null, "important");
|
||||
}
|
||||
if (color) {
|
||||
channelname.EditChannelsChangeObserver = new MutationObserver((changes, _) => {
|
||||
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" && BDFDB.containsClass(change.target, BDFDB.disCN.channelheaderchannelname)) {
|
||||
|
@ -433,7 +433,7 @@ class EditChannels {
|
|||
channelname.EditChannelsChangeObserver.observe(iconparent, {attributes:true, childList:true, subtree:true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeChannel2 (info, channelname) {
|
||||
if (!info || !channelname || !channelname.parentElement) return;
|
||||
if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect();
|
||||
|
@ -442,7 +442,7 @@ class EditChannels {
|
|||
channelname.style.setProperty("color", color, "important");
|
||||
BDFDB.setInnerText(channelname, "#" + (data.name || info.name));
|
||||
if (color) {
|
||||
channelname.EditChannelsChangeObserver = new MutationObserver((changes, _) => {
|
||||
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) {
|
||||
|
@ -455,7 +455,7 @@ class EditChannels {
|
|||
channelname.EditChannelsChangeObserver.observe(channelname.parentElement, {attributes:true, childList:true, subtree:true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeMention (info, mention, categoryinfo) {
|
||||
if (!info || !mention || !mention.parentElement) return;
|
||||
if (mention.EditChannelsChangeObserver && typeof mention.EditChannelsChangeObserver.disconnect == "function") mention.EditChannelsChangeObserver.disconnect();
|
||||
|
@ -502,7 +502,7 @@ class EditChannels {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
addAutoCompleteMenu (textarea, channel) {
|
||||
if (textarea.parentElement.querySelector(".autocompleteEditChannelsRow")) return;
|
||||
let words = textarea.value.split(/\s/);
|
||||
|
@ -529,14 +529,14 @@ class EditChannels {
|
|||
else {
|
||||
amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length;
|
||||
}
|
||||
|
||||
|
||||
BDFDB.addEventListener(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => {
|
||||
var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected);
|
||||
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
|
||||
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
|
||||
BDFDB.addClass(e.currentTarget, BDFDB.disCN.autocompleteselected);
|
||||
});
|
||||
|
||||
|
||||
for (let data of channelarray) {
|
||||
if (amount-- < 1) break;
|
||||
let color = BDFDB.colorCONVERT(data.color, "RGB");
|
||||
|
@ -551,7 +551,7 @@ class EditChannels {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getNextSelection (menu, selected, forward) {
|
||||
selected = selected ? selected : menu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement;
|
||||
let next, sibling = forward ? selected.nextElementSibling : selected.previousElementSibling;
|
||||
|
@ -564,7 +564,7 @@ class EditChannels {
|
|||
}
|
||||
return next ? next : this.getNextSelection(menu, sibling, forward);
|
||||
}
|
||||
|
||||
|
||||
swapWordWithMention (textarea) {
|
||||
let selected = textarea.parentElement.querySelector(".autocompleteEditChannelsRow " + BDFDB.dotCN.autocompleteselected);
|
||||
let channelid = selected ? selected.getAttribute("channelid") : null;
|
||||
|
@ -580,7 +580,7 @@ class EditChannels {
|
|||
textarea.selectionEnd = textarea.value.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,10 +8,10 @@ class EditServers {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to change the icon, name and color of servers.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"GuildIcon":"componentDidMount",
|
||||
"GuildHeader":["componentDidMount","componentDidUpdate"],
|
||||
|
@ -25,7 +25,7 @@ class EditServers {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} editservers-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -129,13 +129,13 @@ class EditServers {
|
|||
</div>
|
||||
</span>`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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;">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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -174,9 +174,9 @@ class EditServers {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -190,20 +190,20 @@ class EditServers {
|
|||
BDFDB.removeAllData(this, "servers");
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
BDFDB.saveAllData(data, this, "servers");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.serverContextEntryMarkup = this.serverContextEntryMarkup.replace("REPLACE_context_localserversettings_text", this.labels.context_localserversettings_text);
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_serversettings_text", this.labels.submenu_serversettings_text);
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_resetsettings_text", this.labels.submenu_resetsettings_text);
|
||||
|
||||
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_servername_text", this.labels.modal_servername_text);
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_servershortname_text", this.labels.modal_servershortname_text);
|
||||
|
@ -218,7 +218,7 @@ class EditServers {
|
|||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_colorpicker4_text", this.labels.modal_colorpicker4_text);
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_btn_save_text", this.labels.btn_save_text);
|
||||
}
|
||||
|
||||
|
||||
onGuildContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.target && instance.props.guild && !menu.querySelector(".localserversettings-item")) {
|
||||
let serverContextEntry = BDFDB.htmlToElement(this.serverContextEntryMarkup);
|
||||
|
@ -244,16 +244,16 @@ class EditServers {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showServerSettings (info) {
|
||||
var {name,shortName,url,removeIcon,color1,color2,color3,color4} = BDFDB.loadData(info.id, this, "servers") || {};
|
||||
|
||||
|
||||
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);
|
||||
|
@ -268,9 +268,9 @@ class EditServers {
|
|||
BDFDB.setColorSwatches(serverSettingsModal, color2);
|
||||
BDFDB.setColorSwatches(serverSettingsModal, color3);
|
||||
BDFDB.setColorSwatches(serverSettingsModal, color4);
|
||||
|
||||
|
||||
BDFDB.appendModal(serverSettingsModal);
|
||||
|
||||
|
||||
removeiconinput.addEventListener("click", () => {
|
||||
serverurlinput.disabled = removeiconinput.checked;
|
||||
});
|
||||
|
@ -287,23 +287,23 @@ class EditServers {
|
|||
});
|
||||
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");
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ class EditServers {
|
|||
});
|
||||
servernameinput.focus();
|
||||
}
|
||||
|
||||
|
||||
checkUrl (input) {
|
||||
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
|
||||
if (!input.value) {
|
||||
|
@ -335,7 +335,7 @@ class EditServers {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createNoticeTooltip (input) {
|
||||
var disabled = input.disabled;
|
||||
var valid = BDFDB.containsClass(input, "valid");
|
||||
|
@ -344,7 +344,7 @@ class EditServers {
|
|||
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"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processGuildIcon (instance, wrapper) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
let icon = wrapper.classList && BDFDB.containsClass(wrapper, BDFDB.disCN.avataricon) ? wrapper : wrapper.querySelector(BDFDB.dotCN.avataricon);
|
||||
|
@ -354,13 +354,13 @@ class EditServers {
|
|||
else if (BDFDB.getParentEle(BDFDB.dotCN.friendscolumn, icon)) this.changeTooltip(instance.props.guild, icon.parentElement, "top");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processGuildHeader (instance, wrapper) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
this.changeGuildName(instance.props.guild, wrapper.querySelector(BDFDB.dotCN.guildheadername));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -379,7 +379,7 @@ class EditServers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeGuildName (info, guildname) {
|
||||
if (!info || !guildname || !guildname.parentElement) return;
|
||||
if (guildname.EditServersChangeObserver && typeof guildname.EditServersChangeObserver.disconnect == "function") guildname.EditServersChangeObserver.disconnect();
|
||||
|
@ -398,7 +398,7 @@ class EditServers {
|
|||
else guildname.removeAttribute("changed-by-editservers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeGuildIcon (info, icon) {
|
||||
if (!info || !icon || !icon.parentElement) return;
|
||||
if (icon.EditServersChangeObserver && typeof icon.EditServersChangeObserver.disconnect == "function") icon.EditServersChangeObserver.disconnect();
|
||||
|
@ -434,7 +434,7 @@ class EditServers {
|
|||
else icon.removeAttribute("changed-by-editservers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeTooltip (info, wrapper, type) {
|
||||
if (!info || !wrapper || !wrapper.parentElement) return;
|
||||
let data = BDFDB.loadData(info.id, this, "servers") || {};
|
||||
|
@ -448,7 +448,7 @@ class EditServers {
|
|||
wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditServers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getFontSize (icon) {
|
||||
if (icon.style.getPropertyValue("background-image")) return null;
|
||||
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizexlarge)) return "12px";
|
||||
|
@ -458,13 +458,13 @@ class EditServers {
|
|||
else if (BDFDB.containsClass(icon, BDFDB.disCN.avatariconsizemini)) return "4px";
|
||||
else return "10px";
|
||||
}
|
||||
|
||||
|
||||
getNoIconClasses (icon) {
|
||||
let noiconclasses = [BDFDB.disCN.avatarnoicon];
|
||||
if (BDFDB.containsClass(icon, BDFDB.disCN.userprofilelistavatar)) noiconclasses.push(BDFDB.disCN.userprofilelistguildavatarwithouticon);
|
||||
return noiconclasses;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,10 +8,10 @@ class EditUsers {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to change the icon, name, tag and color of users.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount",
|
||||
"NameTag":"componentDidMount",
|
||||
|
@ -26,7 +26,7 @@ class EditUsers {
|
|||
"MessageContent":["componentDidMount","componentDidUpdate"],
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.avatarselector = BDFDB.dotCNC.avatarinner + BDFDB.dotCNC.avatarimage + BDFDB.dotCNC.callavatarwrapper + BDFDB.dotCNC.voiceavatarcontainer + "[class*='avatar-']";
|
||||
|
||||
this.css = `
|
||||
|
@ -50,7 +50,7 @@ class EditUsers {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.userContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} editusers-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -64,7 +64,7 @@ class EditUsers {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.userSettingsModalMarkup =
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -159,7 +159,7 @@ class EditUsers {
|
|||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
changeInChatTextarea: {value:true, description:"Chat Textarea"},
|
||||
|
@ -183,7 +183,7 @@ class EditUsers {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -195,7 +195,7 @@ class EditUsers {
|
|||
settingshtml += `</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 Users.</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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -234,14 +234,14 @@ class EditUsers {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.RelationshipUtils = BDFDB.WebModules.findByProperties("isBlocked", "isFriend");
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers","getUser");
|
||||
this.MemberUtils = BDFDB.WebModules.findByProperties("getMembers", "getMember");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -256,22 +256,22 @@ class EditUsers {
|
|||
BDFDB.removeAllData(this, "users");
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
BDFDB.saveAllData(data, this, "users");
|
||||
|
||||
|
||||
BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.userContextEntryMarkup = this.userContextEntryMarkup.replace("REPLACE_context_localusersettings_text", this.labels.context_localusersettings_text);
|
||||
|
||||
|
||||
this.userContextSubMenuMarkup = this.userContextSubMenuMarkup.replace("REPLACE_submenu_usersettings_text", this.labels.submenu_usersettings_text);
|
||||
this.userContextSubMenuMarkup = this.userContextSubMenuMarkup.replace("REPLACE_submenu_resetsettings_text", this.labels.submenu_resetsettings_text);
|
||||
|
||||
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_modal_username_text", this.labels.modal_username_text);
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_modal_usertag_text", this.labels.modal_usertag_text);
|
||||
|
@ -288,7 +288,7 @@ class EditUsers {
|
|||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_btn_cancel_text", this.labels.btn_cancel_text);
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_btn_save_text", this.labels.btn_save_text);
|
||||
}
|
||||
|
||||
|
||||
onUserContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.user && !menu.querySelector(".localusersettings-item")) {
|
||||
let userContextEntry = BDFDB.htmlToElement(this.userContextEntryMarkup);
|
||||
|
@ -314,19 +314,19 @@ class EditUsers {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showUserSettings (info) {
|
||||
var {name,tag,url,removeIcon,ignoreTagColor,color1,color2,color3,color4} = BDFDB.loadData(info.id, this, "users") || {};
|
||||
|
||||
|
||||
var member = this.MemberUtils.getMember(this.LastGuildStore.getGuildId(), info.id) || {};
|
||||
|
||||
|
||||
let userSettingsModal = BDFDB.htmlToElement(this.userSettingsModalMarkup);
|
||||
let usernameinput = userSettingsModal.querySelector("#input-username");
|
||||
let usertaginput = userSettingsModal.querySelector("#input-usertag");
|
||||
let userurlinput = userSettingsModal.querySelector("#input-userurl");
|
||||
let removeiconinput = userSettingsModal.querySelector("#input-removeicon");
|
||||
let ignoretagcolorinput = userSettingsModal.querySelector("#input-ignoretagcolor");
|
||||
|
||||
|
||||
userSettingsModal.querySelector(BDFDB.dotCN.modalguildname).innerText = member.nick || info.username;
|
||||
usernameinput.value = name || "";
|
||||
usernameinput.setAttribute("placeholder", member.nick || info.username);
|
||||
|
@ -341,13 +341,13 @@ class EditUsers {
|
|||
BDFDB.setColorSwatches(userSettingsModal, color2);
|
||||
BDFDB.setColorSwatches(userSettingsModal, color3);
|
||||
BDFDB.setColorSwatches(userSettingsModal, color4);
|
||||
|
||||
|
||||
let ignoredswatches = userSettingsModal.querySelectorAll(".swatches[swatchnr='3'], .swatches[swatchnr='4']");
|
||||
|
||||
|
||||
BDFDB.toggleClass(ignoredswatches, "disabled", ignoretagcolorinput.checked);
|
||||
|
||||
|
||||
BDFDB.appendModal(userSettingsModal);
|
||||
|
||||
|
||||
removeiconinput.addEventListener("click", () => {
|
||||
userurlinput.disabled = removeiconinput.checked;
|
||||
});
|
||||
|
@ -367,25 +367,25 @@ class EditUsers {
|
|||
});
|
||||
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")
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ class EditUsers {
|
|||
});
|
||||
usernameinput.focus();
|
||||
}
|
||||
|
||||
|
||||
checkUrl (input) {
|
||||
BDFDB.removeEles(BDFDB.dotCNS.tooltips + ".notice-tooltip");
|
||||
if (!input.value) {
|
||||
|
@ -417,7 +417,7 @@ class EditUsers {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createNoticeTooltip (input) {
|
||||
var disabled = input.disabled;
|
||||
var valid = BDFDB.containsClass(input, "valid");
|
||||
|
@ -426,7 +426,7 @@ class EditUsers {
|
|||
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"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
let channel = BDFDB.getReactValue(instance, "props.channel");
|
||||
if (channel) {
|
||||
|
@ -469,7 +469,7 @@ class EditUsers {
|
|||
clearTimeout(textarea.EditUsersAutocompleteTimeout);
|
||||
textarea.EditUsersAutocompleteTimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea, channel);},100);
|
||||
}
|
||||
|
||||
|
||||
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow");
|
||||
});
|
||||
BDFDB.addEventListener(this, textarea, "click", e => {
|
||||
|
@ -478,14 +478,14 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processNameTag (instance, wrapper) {
|
||||
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) : ""));
|
||||
}
|
||||
|
||||
|
||||
processMessageUsername (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message) {
|
||||
|
@ -501,7 +501,7 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processAuditLog (instance, wrapper) {
|
||||
let log = BDFDB.getReactValue(instance, "props.log");
|
||||
if (log && log.user) {
|
||||
|
@ -511,14 +511,14 @@ class EditUsers {
|
|||
if (hooks.length > 1 && log.targetType == "USER") this.changeName2(log.target, hooks[1].firstChild, guild_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processFluxContainerTypingUsers (instance, wrapper) {
|
||||
let users = !instance.state.typingUsers ? [] : Object.keys(instance.state.typingUsers).filter(id => id != BDFDB.myData.id).filter(id => !this.RelationshipUtils.isBlocked(id)).map(id => this.UserUtils.getUser(id)).filter(id => id != null);
|
||||
wrapper.querySelectorAll(BDFDB.dotCNS.typing + "strong").forEach((username, i) => {
|
||||
if (users[i] && username) this.changeName2(users[i], username);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
processDirectMessage (instance, wrapper) {
|
||||
let channel = BDFDB.getReactValue(instance, "props.channel");
|
||||
if (channel && channel.type == 1) {
|
||||
|
@ -532,7 +532,7 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processCallAvatar (instance, wrapper) {
|
||||
if (instance.props && instance.props.id) {
|
||||
let user = this.UserUtils.getUser(instance.props.id);
|
||||
|
@ -548,7 +548,7 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processPrivateChannel (instance, wrapper) {
|
||||
if (instance.props && instance.props.user) {
|
||||
let username = wrapper.querySelector(BDFDB.dotCN.dmchannelname);
|
||||
|
@ -556,7 +556,7 @@ class EditUsers {
|
|||
this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processHeaderBar (instance, wrapper) {
|
||||
let channel_id = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channelId");
|
||||
if (channel_id) {
|
||||
|
@ -575,7 +575,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) {
|
||||
|
@ -631,7 +631,7 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processMessageContent (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message && message.author) {
|
||||
|
@ -644,14 +644,14 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeName (info, username, guildid = this.LastGuildStore.getGuildId()) {
|
||||
if (!info || !username || !username.parentElement) return;
|
||||
if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect();
|
||||
|
@ -681,7 +681,7 @@ class EditUsers {
|
|||
else username.removeAttribute("changed-by-editusers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeName2 (info, username, guildid = this.LastGuildStore.getGuildId()) {
|
||||
if (!info || !username || !username.parentElement) return;
|
||||
if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect();
|
||||
|
@ -701,7 +701,7 @@ class EditUsers {
|
|||
else username.removeAttribute("changed-by-editusers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeName3 (info, username, adddisc) {
|
||||
if (!info || !username || !username.parentElement) return;
|
||||
if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect();
|
||||
|
@ -726,7 +726,7 @@ class EditUsers {
|
|||
else username.removeAttribute("changed-by-editusers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeAvatar (info, avatar) {
|
||||
if (!info || !avatar || !avatar.parentElement) return;
|
||||
if (avatar.EditUsersChangeObserver && typeof avatar.EditUsersChangeObserver.disconnect == "function") avatar.EditUsersChangeObserver.disconnect();
|
||||
|
@ -757,7 +757,7 @@ class EditUsers {
|
|||
else avatar.removeAttribute("changed-by-editusers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeTooltip (info, wrapper, type) {
|
||||
if (!info || !wrapper || !wrapper.parentElement) return;
|
||||
let data = this.getUserData(info.id, wrapper);
|
||||
|
@ -769,7 +769,7 @@ class EditUsers {
|
|||
wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditUsers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addTag (info, wrapper, selector = "") {
|
||||
if (!info || !wrapper || !wrapper.parentElement || BDFDB.containsClass(wrapper, BDFDB.disCN.accountinfodetails) || BDFDB.containsClass(wrapper, "discord-tag")) return;
|
||||
BDFDB.removeEles(wrapper.querySelectorAll(".EditUsers-tag"));
|
||||
|
@ -786,7 +786,7 @@ class EditUsers {
|
|||
wrapper.appendChild(tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changePrivateChannel (info, username) {
|
||||
if (!info || !username || !username.parentElement) return;
|
||||
let dmchannel = BDFDB.getParentEle(BDFDB.dotCN.dmchannel, username);
|
||||
|
@ -801,7 +801,7 @@ class EditUsers {
|
|||
BDFDB.setInnerText(username, data.name || info.username);
|
||||
if (username.EditUsersHovered || BDFDB.containsClass(dmchannel, BDFDB.disCN.dmchannelselected)) colorHover();
|
||||
else colorDefault();
|
||||
|
||||
|
||||
if (data.name || data.color1 || data.color2) {
|
||||
dmchannel.mouseenterListenerEditUsers = () => {
|
||||
username.EditUsersHovered = true;
|
||||
|
@ -831,7 +831,7 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeMention (info, mention) {
|
||||
if (!info || !mention || !mention.parentElement) return;
|
||||
if (mention.EditUsersChangeObserver && typeof mention.EditUsersChangeObserver.disconnect == "function") mention.EditUsersChangeObserver.disconnect();
|
||||
|
@ -868,7 +868,7 @@ class EditUsers {
|
|||
mention.style.setProperty("background", color1 ? "rgba(" + color1[0] + "," + color1[1] + "," + color1[2] + ",.7)" : null, "important");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeVoiceUser (info, username) {
|
||||
if (!info || !username || !username.parentElement) return;
|
||||
if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect();
|
||||
|
@ -888,7 +888,7 @@ class EditUsers {
|
|||
else username.removeAttribute("changed-by-editusers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getAvatarDiv (wrapper) {
|
||||
var avatar = wrapper.querySelector(this.avatarselector);
|
||||
while (!avatar && wrapper.parentElement) {
|
||||
|
@ -897,7 +897,7 @@ class EditUsers {
|
|||
}
|
||||
return avatar.firstElementChild || avatar;
|
||||
}
|
||||
|
||||
|
||||
getUserData (id, wrapper) {
|
||||
let data = BDFDB.loadData(id, this, "users");
|
||||
if (!data) return {};
|
||||
|
@ -924,10 +924,10 @@ class EditUsers {
|
|||
else if (BDFDB.getParentEle(BDFDB.dotCN.auditlog, wrapper)) key = "changeInAuditLog";
|
||||
else if (BDFDB.getParentEle(BDFDB.dotCN.searchpopout, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.searchpopoutdmaddpopout, wrapper)) key = "changeInSearchPopout";
|
||||
else if (BDFDB.getParentEle(BDFDB.dotCN.accountinfo, wrapper)) key = "changeInUserAccount";
|
||||
|
||||
|
||||
return !key || BDFDB.getData(key, this, "settings") ? data : {};
|
||||
}
|
||||
|
||||
|
||||
addAutoCompleteMenu (textarea, channel) {
|
||||
if (textarea.parentElement.querySelector(".autocompleteEditUsersRow")) return;
|
||||
let words = textarea.value.split(/\s/);
|
||||
|
@ -952,14 +952,14 @@ class EditUsers {
|
|||
else {
|
||||
amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length;
|
||||
}
|
||||
|
||||
|
||||
BDFDB.addEventListener(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => {
|
||||
var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected);
|
||||
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
|
||||
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
|
||||
BDFDB.addClass(e.currentTarget, BDFDB.disCN.autocompleteselected);
|
||||
});
|
||||
|
||||
|
||||
for (let data of userarray) {
|
||||
if (amount-- < 1) break;
|
||||
let autocompleterow = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteEditUsersRow"><div userid="${data.user.id}" class="${BDFDB.disCNS.autocompleteselector + BDFDB.disCN.autocompleteselectable} autocompleteEditUsersSelector"><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.disCNS.avatarwrapper + BDFDB.disCN.avatarxsmall}"><div class="${BDFDB.disCN.avatarimage + BDFDB.disCNS.avatarxsmall + BDFDB.disCN.avatarmask}"${data.removeIcon ? '' : 'style="background-image: url(' + (data.url || BDFDB.getUserAvatar(data.user.id)) + ');"'}></div><div class="${BDFDB.disCNS['status' + BDFDB.getUserStatus(data.user.id)] + BDFDB.disCNS.status + BDFDB.disCNS.avatarxsmall + BDFDB.disCN.autocompleteavatarstatus}"></div></div><div class="${BDFDB.disCN.marginleft8}" changed-by-editusers="true" style="flex: 1 1 auto;${data.color1 ? (' color: ' + BDFDB.colorCONVERT(data.color1, 'RGB') + ' !important;') : ''}">${BDFDB.encodeToHTML(data.name || data.member.nick || data.user.username)}</div><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.autocompletedescription}" style="flex: 0 1 auto;"><div class="${BDFDB.disCN.autocompletedescriptionusername}">${BDFDB.encodeToHTML(data.user.username)}</div><div class="${BDFDB.disCN.autocompletedescriptiondiscriminator}">#${data.user.discriminator}</div></div></div></div></div>`);
|
||||
|
@ -972,7 +972,7 @@ class EditUsers {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getNextSelection (menu, selected, forward) {
|
||||
selected = selected ? selected : menu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement;
|
||||
let next, sibling = forward ? selected.nextElementSibling : selected.previousElementSibling;
|
||||
|
@ -985,7 +985,7 @@ class EditUsers {
|
|||
}
|
||||
return next ? next : this.getNextSelection(menu, sibling, forward);
|
||||
}
|
||||
|
||||
|
||||
swapWordWithMention (textarea) {
|
||||
let selected = textarea.parentElement.querySelector(".autocompleteEditUsersRow " + BDFDB.dotCN.autocompleteselected);
|
||||
let words = textarea.value.split(/\s/);
|
||||
|
@ -1003,7 +1003,7 @@ class EditUsers {
|
|||
textarea.selectionEnd = textarea.value.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,34 +8,34 @@ class EmojiStatistics {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds some helpful options to show you more information about emojis and emojiservers.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"EmojiPicker":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
.emojistatistics-tooltip,
|
||||
.emoji-tooltip {
|
||||
z-index: 2002;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles {
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .emojiserver-entry {
|
||||
height: 50px;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .emojiserver-entry .modal-emojiserver-icon {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry label,
|
||||
.${this.name}-modal .emojiserver-entry label {
|
||||
color: #b9bbbe;
|
||||
|
@ -50,12 +50,12 @@ class EmojiStatistics {
|
|||
vertical-align: top;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .emojiserver-entry label {
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry label {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
@ -64,16 +64,16 @@ class EmojiStatistics {
|
|||
text-align: center;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry .modal-titlesname-label,
|
||||
.${this.name}-modal .emojiserver-entry .modal-emojiname-label {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry .modal-sorttitle-label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry .modal-titlestotal-label,
|
||||
.${this.name}-modal .titles-entry .modal-titlesglobal-label,
|
||||
.${this.name}-modal .titles-entry .modal-titleslocal-label,
|
||||
|
@ -85,7 +85,7 @@ class EmojiStatistics {
|
|||
text-align: center;
|
||||
width: 82px;
|
||||
}
|
||||
|
||||
|
||||
.emojistatistics-button {
|
||||
background-image: url("/assets/f24711dae4f6d6b28335e866a93e9d9b.png");
|
||||
background-position: -770px -374px;
|
||||
|
@ -95,7 +95,7 @@ class EmojiStatistics {
|
|||
margin-right: 10px;
|
||||
width: 22px;
|
||||
}`;
|
||||
|
||||
|
||||
this.emojiInformationModalMarkup =
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -151,7 +151,7 @@ class EmojiStatistics {
|
|||
<label class="modal-emojilocal-label">modal-emojilocal-label</label>
|
||||
<label class="modal-emojicopies-label">modal-emojicopies-label</label>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
enableEmojiHovering: {value:true, description:"Show Information about Emojis on hover over an Emoji in the Emojipicker."},
|
||||
|
@ -175,7 +175,7 @@ class EmojiStatistics {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -184,7 +184,7 @@ class EmojiStatistics {
|
|||
var input = parseInt(e.currentTarget.value);
|
||||
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -213,9 +213,9 @@ class EmojiStatistics {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.GuildEmojis = BDFDB.WebModules.findByProperties("getGuildEmoji", "getDisambiguatedEmojiContext");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -229,15 +229,15 @@ class EmojiStatistics {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_btn_ok_text", this.labels.btn_ok_text);
|
||||
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_btn_all_text", this.labels.btn_all_text);
|
||||
|
||||
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlesicon-label", this.labels.modal_titlesicon_text);
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlesname_text", this.labels.modal_titlesname_text);
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlestotal_text", this.labels.modal_titlestotal_text);
|
||||
|
@ -245,7 +245,7 @@ class EmojiStatistics {
|
|||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titleslocal_text", this.labels.modal_titleslocal_text);
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlescopies_text", this.labels.modal_titlescopies_text);
|
||||
}
|
||||
|
||||
|
||||
processEmojiPicker (instance, wrapper) {
|
||||
if (!wrapper.querySelector(".emojistatistics-button")) {
|
||||
let emojipickerdiversityselector = document.querySelector(BDFDB.dotCN.emojipickerdiversityselector);
|
||||
|
@ -271,7 +271,7 @@ class EmojiStatistics {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadEmojiList () {
|
||||
this.emojiReplicaList = {};
|
||||
this.emojiToServerList = {};
|
||||
|
@ -282,41 +282,41 @@ class EmojiStatistics {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showEmojiInformationModal () {
|
||||
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 info of BDFDB.readServerList()) {
|
||||
let amountGlobal = 0, amountLocal = 0, amountCopies = 0;
|
||||
|
@ -338,12 +338,12 @@ class EmojiStatistics {
|
|||
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});
|
||||
}
|
||||
|
||||
|
||||
BDFDB.appendModal(emojiInformationModal);
|
||||
|
||||
|
||||
this.updateAllEntries(entriescontainer, entries);
|
||||
}
|
||||
|
||||
|
||||
updateAllEntries (entriescontainer, entries) {
|
||||
BDFDB.removeEles(entriescontainer.childNodes);
|
||||
for (let entry of entries) {
|
||||
|
@ -351,14 +351,14 @@ class EmojiStatistics {
|
|||
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
|
||||
|
|
|
@ -8,7 +8,7 @@ class ForceImagePreviews {
|
|||
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"
|
||||
|
@ -40,7 +40,7 @@ class ForceImagePreviews {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -54,11 +54,11 @@ class ForceImagePreviews {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
|
||||
|
||||
processMessage (instance, wrapper) {
|
||||
if (instance.props && instance.props.message) {
|
||||
let accessory = wrapper.querySelector(BDFDB.dotCN.messageaccessory);
|
||||
|
@ -77,7 +77,7 @@ class ForceImagePreviews {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addItemToAccessory (previmage, links, accessory) {
|
||||
let item = links.shift();
|
||||
if (!item) return;
|
||||
|
@ -122,7 +122,7 @@ class ForceImagePreviews {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
insertEmbed (embed, previmage, links, accessory) {
|
||||
let prev = accessory.querySelector(`${BDFDB.dotCNS.embed + BDFDB.dotCN.embedimage}[href="${previmage ? this.parseSrc(previmage.src) : void 0}"]`);
|
||||
let next = accessory.querySelector(`${BDFDB.dotCNS.embed + BDFDB.dotCN.embedimage}[href="${links[0] ? this.parseSrc(links[0].src) : void 0}"]`);
|
||||
|
@ -134,7 +134,7 @@ class ForceImagePreviews {
|
|||
let scroller = document.querySelector(BDFDB.dotCNS.chat + BDFDB.dotCN.messages);
|
||||
if (scroller) scroller.scrollTop += (BDFDB.getRects(embed).height + (isempty ? 15 : 0));
|
||||
}
|
||||
|
||||
|
||||
parseSrc (src) {
|
||||
return src.replace(/"/g, "");
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ class FriendNotifications {
|
|||
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"]
|
||||
};
|
||||
|
||||
|
||||
this.friendsOnlineList = {};
|
||||
|
||||
|
||||
this.timeLog = [];
|
||||
|
||||
this.timeLogModalMarkup =
|
||||
|
@ -59,7 +59,7 @@ 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.css = `
|
||||
${BDFDB.dotCN.guilds} > ${BDFDB.dotCN.friendsonline} {
|
||||
cursor: pointer;
|
||||
|
@ -110,7 +110,7 @@ class FriendNotifications {
|
|||
border-color: #36393F;
|
||||
filter: grayscale(100%) brightness(50%);
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
muteOnDND: {value:false, description:"Do not notify me when I am DnD:"},
|
||||
|
@ -125,10 +125,10 @@ class FriendNotifications {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
|
||||
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let notificationsounds = BDFDB.getAllData(this, "notificationsounds");
|
||||
let desktop = BDFDB.loadAllData(this, "desktop");
|
||||
|
@ -153,7 +153,7 @@ class FriendNotifications {
|
|||
settingshtml += `</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;">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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -202,7 +202,7 @@ class FriendNotifications {
|
|||
BDFDB.saveAllData(disabledata, this, "disabled");
|
||||
BDFDB.saveAllData(desktopdata, this, "desktop");
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -231,18 +231,18 @@ class FriendNotifications {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.FriendUtils = BDFDB.WebModules.findByProperties("getFriendIDs", "getRelationships");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getDMFromUserId");
|
||||
this.ChannelSwitchUtils = BDFDB.WebModules.findByProperties("selectPrivateChannel");
|
||||
this.PrivateChannelUtils = BDFDB.WebModules.findByProperties("openPrivateChannel");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatus", "getOnlineFriendCount");
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers");
|
||||
|
||||
|
||||
for (let id of this.FriendUtils.getFriendIDs()) {
|
||||
this.friendsOnlineList[id] = this.UserMetaStore.getStatus(id) != "offline";
|
||||
}
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -255,10 +255,10 @@ class FriendNotifications {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
saveAudio (settingspanel, option) {
|
||||
let successSavedAudio = (parsedurl, parseddata) => {
|
||||
if (parsedurl && parseddata) BDFDB.showToast(`Sound was saved successfully.`, {type:"success"});
|
||||
|
@ -267,7 +267,7 @@ class FriendNotifications {
|
|||
notificationsound.song = parseddata;
|
||||
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
|
||||
};
|
||||
|
||||
|
||||
let url = settingspanel.querySelector(`.songInput[option="${option}"]`).value;
|
||||
if (url.length == 0) {
|
||||
BDFDB.showToast(`Sound file was removed.`, {type:"warn"});
|
||||
|
@ -292,11 +292,11 @@ class FriendNotifications {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processFluxContainerFriendsOnline (instance, wrapper) {
|
||||
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()) {
|
||||
let online = this.UserMetaStore.getStatus(id) != "offline";
|
||||
|
@ -334,7 +334,7 @@ class FriendNotifications {
|
|||
this.friendsOnlineList[id] = online;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showTimeLog () {
|
||||
let timeLogModal = BDFDB.htmlToElement(this.timeLogModalMarkup);
|
||||
let container = timeLogModal.querySelector(".entries");
|
||||
|
|
|
@ -4,16 +4,16 @@ class GoogleSearchReplace {
|
|||
getName () {return "GoogleSearchReplace";}
|
||||
|
||||
getVersion () {return "1.1.8";}
|
||||
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Replaces the default Google Text Search with a selection menu of several search engines.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.textUrlReplaceString = "DEVILBRO_BD_GOOGLESEARCHREPLACE_REPLACE_TEXTURL";
|
||||
|
||||
|
||||
this.defaults = {
|
||||
engines: {
|
||||
_all: {value:true, name:BDFDB.getLibraryStrings().btn_all_text, url:null},
|
||||
|
@ -39,7 +39,7 @@ class GoogleSearchReplace {
|
|||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_googlesearchreplace_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.messageContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} googlereplacesearch-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -62,14 +62,14 @@ class GoogleSearchReplace {
|
|||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
//legacy
|
||||
load () {}
|
||||
|
||||
|
@ -106,23 +106,23 @@ class GoogleSearchReplace {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messageContextEntryMarkup = this.messageContextEntryMarkup.replace("REPLACE_context_googlesearchreplace_text", this.labels.context_googlesearchreplace_text);
|
||||
|
||||
|
||||
this.messageContextSubMenuMarkup = this.messageContextSubMenuMarkup.replace("REPLACE_submenu_disabled_text", this.labels.submenu_disabled_text);
|
||||
}
|
||||
|
||||
|
||||
onNativeContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.type == "NATIVE_TEXT" && instance.props.value && !menu.querySelector(".reverseimagesearch-item")) {
|
||||
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();
|
||||
|
@ -132,7 +132,7 @@ class GoogleSearchReplace {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendItem (instance, target, text) {
|
||||
let messageContextEntry = BDFDB.htmlToElement(this.messageContextEntryMarkup);
|
||||
target.parentElement.insertBefore(messageContextEntry, target.nextElementSibling);
|
||||
|
@ -153,7 +153,7 @@ class GoogleSearchReplace {
|
|||
});
|
||||
BDFDB.toggleEles(target, false);
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -4,26 +4,26 @@ class GoogleTranslateOption {
|
|||
getName () {return "GoogleTranslateOption";}
|
||||
|
||||
getVersion () {return "1.6.4";}
|
||||
|
||||
|
||||
getAuthor () {return "DevilBro, square";}
|
||||
|
||||
getDescription () {return "Adds a Google Translate option to your context menu, which shows a preview of the translated text and on click will open the selected text in Google Translate. Also adds a translation button to your textareas, which will automatically translate the text for you before it is being send. DeepLApi written by square. Thanks ;)";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount",
|
||||
"Message":"componentDidMount",
|
||||
"MessageOptionPopout":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.languages = {};
|
||||
|
||||
|
||||
this.doTranslate = false;
|
||||
this.translating = false;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addTranslateButton: {value:true, description:"Adds an translate button to the chatbar."},
|
||||
|
@ -63,17 +63,17 @@ class GoogleTranslateOption {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.popoutTranslateEntryMarkup =
|
||||
`<button type="button" class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} googletranslateoption-itembtn googletranslateoption-translate-itembtn">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_popout_translateoption_text</div>
|
||||
</button>`;
|
||||
|
||||
|
||||
this.popoutUntranslateEntryMarkup =
|
||||
`<button type="button" class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} googletranslateoption-itembtn googletranslateoption-untranslate-itembtn">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_popout_untranslateoption_text</div>
|
||||
</button>`;
|
||||
|
||||
|
||||
this.translateButtonMarkup =
|
||||
`<div class="${BDFDB.disCNS.textareabuttonwrapper + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} translate-button-wrapper">
|
||||
<div class="${BDFDB.disCNS.buttoncontents + BDFDB.disCNS.textareabutton + BDFDB.disCN.textareapickerbutton} translate-button">
|
||||
|
@ -82,12 +82,12 @@ class GoogleTranslateOption {
|
|||
</svg>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.reverseButtonMarkup =
|
||||
`<svg class="reverse-button ${BDFDB.disCN.flexchild}" type="REPLACETYPE" version="1.1" xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" style="flex: 0 0 auto;">
|
||||
<path d="M 0, 10.515 c 0, 2.892, 1.183, 5.521, 3.155, 7.361 L 0, 21.031 h 7.887 V 13.144 l -2.892, 2.892 C 3.549, 14.722, 2.629, 12.75, 2.629, 10.515 c 0 -3.418, 2.235 -6.309, 5.258 -7.492 v -2.629 C 3.418, 1.577, 0, 5.652, 0, 10.515 z M 21.031, 0 H 13.144 v 7.887 l 2.892 -2.892 C 17.482, 6.309, 18.402, 8.281, 18.402, 10.515 c 0, 3.418 -2.235, 6.309 -5.258, 7.492 V 20.768 c 4.469 -1.183, 7.887 -5.258, 7.887 -10.121 c 0 -2.892 -1.183 -5.521 -3.155 -7.361 L 21.031, 0 z"/>
|
||||
</svg>`;
|
||||
|
||||
|
||||
this.translatePopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCNS.popoutnoarrow + BDFDB.disCN.popoutnoshadow} popout-googletranslate DevilBro-modal" style="z-index: 2000; overflow: visible; visibility: visible; transform: translateX(-100%) translateY(-100%) translateZ(0px);">
|
||||
<div class="${BDFDB.disCN.popoutthemedpopout}">
|
||||
|
@ -130,7 +130,7 @@ class GoogleTranslateOption {
|
|||
</div>`).join("")}
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.DeepLTranslateAPI = function () {
|
||||
var INPUT, OUTPUT, clearInput, current, domReady, enabled, executeScript, getLanguage, getOutput, langI, langO, setInput, setLanguage, timer, wc, webview;
|
||||
var _extends = Object.assign || function (target) {
|
||||
|
@ -326,49 +326,49 @@ class GoogleTranslateOption {
|
|||
|
||||
return DeepLTranslateAPI;
|
||||
}.call(this);
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.textareainner} ${BDFDB.dotCN.textareapickerbuttons} {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.textareainner} .send-button {
|
||||
top: calc(50% - 15px);
|
||||
right: 9px;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.textareainner} .send-button,
|
||||
${BDFDB.dotCN.textareainner} ${BDFDB.dotCN.button} {
|
||||
max-height: unset;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.textareabuttonwrapper}.popout-open ${BDFDB.dotCN.textareabutton}.translate-button {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.textareabuttonwrapper + BDFDB.dotCNS.textareabuttonactive + BDFDB.dotCN.textareabutton}.translate-button {
|
||||
color: #F04747 !important;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCNS.textareabuttonwrapper + BDFDB.dotCN.textareabutton}.translate-button ${BDFDB.dotCN.textareaicon} {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.textareabuttonwrapper}.popout-open ${BDFDB.dotCN.textareabutton}.translate-button ${BDFDB.dotCN.textareaicon} {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
|
||||
.reverse-button {
|
||||
margin-top: -5px;
|
||||
opacity: 0.2;
|
||||
transition: all 200ms ease;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themedark} .reverse-button {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themelight} .reverse-button {
|
||||
fill: #4f545c;
|
||||
}
|
||||
|
@ -376,12 +376,12 @@ class GoogleTranslateOption {
|
|||
cursor: pointer;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.popout}.popout-googletranslate ${BDFDB.dotCN.popoutthemedpopout} {
|
||||
padding: 0 10px;
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.selectmenuouter}.inChat {
|
||||
top: 0%;
|
||||
transform: translateY(-100%);
|
||||
|
@ -389,7 +389,7 @@ class GoogleTranslateOption {
|
|||
margin-top: 1px;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var choices = BDFDB.getAllData(this, "choices");
|
||||
|
@ -407,16 +407,16 @@ class GoogleTranslateOption {
|
|||
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="flex-3B1Tl4 justifyStart-2yIZo0 ${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;">Translator:</h3><h3 class="flex-3B1Tl4 justifyStart-2yIZo0 ${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.translators[key].choice1}</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="translators ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch translators-switch"${translators[key] ? " checked" : ""}></div><h3 class="flex-3B1Tl4 justifyEnd-1ceqOU ${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.translators[key].choice2}</h3></div>`;
|
||||
}
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu("inSettings", e);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
//legacy
|
||||
load () {}
|
||||
|
||||
|
@ -442,14 +442,14 @@ class GoogleTranslateOption {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
|
||||
|
||||
this.setLanguage();
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -460,40 +460,40 @@ class GoogleTranslateOption {
|
|||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopDeepL();
|
||||
|
||||
|
||||
document.querySelectorAll(BDFDB.dotCN.message + ".translated").forEach(message => {
|
||||
this.resetMessage(message);
|
||||
});
|
||||
|
||||
|
||||
BDFDB.removeEles(".translate-button-wrapper", ".popout-googletranslate");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
startDeepL () {
|
||||
this.stopDeepL();
|
||||
this.DeepLTranslate = new this.DeepLTranslateAPI();
|
||||
this.DeepLTranslate.start();
|
||||
}
|
||||
|
||||
|
||||
stopDeepL () {
|
||||
if (this.DeepLTranslate && typeof this.DeepLTranslate.stop === "function") this.DeepLTranslate.stop();
|
||||
this.DeepLTranslate = undefined;
|
||||
}
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messageTranslateContextEntryMarkup = this.messageTranslateContextEntryMarkup.replace("REPLACE_context_messagetranslateoption_text", this.labels.context_messagetranslateoption_text);
|
||||
this.messageUntranslateContextEntryMarkup = this.messageUntranslateContextEntryMarkup.replace("REPLACE_context_messageuntranslateoption_text", this.labels.context_messageuntranslateoption_text);
|
||||
this.messageSearchContextEntryMarkup = this.messageSearchContextEntryMarkup.replace("REPLACE_context_googletranslateoption_text", this.labels.context_googletranslateoption_text);
|
||||
|
||||
|
||||
this.popoutTranslateEntryMarkup = this.popoutTranslateEntryMarkup.replace("REPLACE_popout_translateoption_text", this.labels.popout_translateoption_text);
|
||||
this.popoutUntranslateEntryMarkup = this.popoutUntranslateEntryMarkup.replace("REPLACE_popout_untranslateoption_text", this.labels.popout_untranslateoption_text);
|
||||
}
|
||||
|
||||
|
||||
onMessageContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".googletranslateoption-item")) {
|
||||
let {messagediv, pos} = this.getMessageAndPos(instance.props.target);
|
||||
|
@ -535,7 +535,7 @@ class GoogleTranslateOption {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLanguage () {
|
||||
this.languages = Object.assign({},
|
||||
{"auto": {name:"Auto", id:"auto", integrated:false, dic:false, deepl:true}},
|
||||
|
@ -548,7 +548,7 @@ class GoogleTranslateOption {
|
|||
}
|
||||
else this.stopDeepL();
|
||||
}
|
||||
|
||||
|
||||
getLanguageChoice (direction, place) {
|
||||
var type = typeof place === "undefined" ? direction : direction.toLowerCase() + place.charAt(0).toUpperCase() + place.slice(1).toLowerCase();
|
||||
var choice = BDFDB.getData(type, this, "choices");
|
||||
|
@ -556,7 +556,7 @@ class GoogleTranslateOption {
|
|||
choice = type.indexOf("output") > -1 && choice == "auto" ? "en" : choice;
|
||||
return choice;
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
|
@ -565,7 +565,7 @@ class GoogleTranslateOption {
|
|||
BDFDB.WebModules.forceAllUpdates(this, "ChannelTextArea");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
if (instance.props && instance.props.type && instance.props.type == "normal" && !instance.props.disabled && !wrapper.querySelector(".translate-button-wrapper") && BDFDB.getData("addTranslateButton", this, "settings")) {
|
||||
let textarea = wrapper.querySelector("textarea");
|
||||
|
@ -610,7 +610,7 @@ class GoogleTranslateOption {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processMessage (instance, wrapper) {
|
||||
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton)) {
|
||||
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
|
||||
|
@ -621,7 +621,7 @@ class GoogleTranslateOption {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processMessageOptionPopout (instance, wrapper) {
|
||||
if (instance.props.message && instance.props.channel && instance._reactInternalFiber.memoizedProps.target && !wrapper.querySelector(".personalpin-itembtn")) {
|
||||
let {messagediv, pos} = this.getMessageAndPos(instance._reactInternalFiber.memoizedProps.target);
|
||||
|
@ -634,13 +634,13 @@ class GoogleTranslateOption {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getMessageAndPos (target) {
|
||||
let messagediv = BDFDB.getParentEle(BDFDB.dotCN.message, target);
|
||||
let pos = messagediv ? Array.from(messagediv.parentElement.querySelectorAll(BDFDB.dotCN.message)).indexOf(messagediv) : -1;
|
||||
return {messagediv, pos};
|
||||
}
|
||||
|
||||
|
||||
translateMessage (message, target, channel) {
|
||||
if (!message || !target) return;
|
||||
let {messagediv, pos} = this.getMessageAndPos(target);
|
||||
|
@ -668,7 +668,7 @@ class GoogleTranslateOption {
|
|||
}
|
||||
else this.resetMessage(messagediv);
|
||||
}
|
||||
|
||||
|
||||
resetMessage (messagediv) {
|
||||
BDFDB.removeEles(messagediv.querySelector(BDFDB.dotCN.messageedited + ".translated"));
|
||||
BDFDB.removeClass(messagediv, "translated");
|
||||
|
@ -676,7 +676,7 @@ class GoogleTranslateOption {
|
|||
markup.innerHTML = markup.GoogleTranslateOriginalHTML;
|
||||
delete markup.GoogleTranslateOriginalHTML;
|
||||
}
|
||||
|
||||
|
||||
translateText (text, type, callback) {
|
||||
var finishTranslation = (translation, exceptions, input, output, toast) => {
|
||||
if (translation) translation = this.addExceptions(translation, exceptions);
|
||||
|
@ -725,12 +725,12 @@ class GoogleTranslateOption {
|
|||
finishTranslation(translation, exceptions, input, output, toast);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addExceptions (string, exceptions) {
|
||||
for (let i in exceptions) string = string.replace("a" + i + "_______", exceptions[i].indexOf("!") == 0 ? exceptions[i].slice(1) : exceptions[i]);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
removeExceptions (string, type) {
|
||||
var exceptions = {}, newString = [], count = 0;
|
||||
if (type == "context") {
|
||||
|
@ -761,7 +761,7 @@ class GoogleTranslateOption {
|
|||
}
|
||||
return [newString.join(" "), exceptions, newString.length-count != 0];
|
||||
}
|
||||
|
||||
|
||||
openTranslatePopout (button) {
|
||||
let container = document.querySelector(BDFDB.dotCN.popouts);
|
||||
if (!container || BDFDB.containsClass(button, "popout-open")) return;
|
||||
|
@ -771,7 +771,7 @@ class GoogleTranslateOption {
|
|||
let buttonrects = BDFDB.getRects(button);
|
||||
translatepopout.style.setProperty("left", buttonrects.left + buttonrects.width + "px");
|
||||
translatepopout.style.setProperty("top", buttonrects.top - buttonrects.height/2 + "px")
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(translatepopout, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu("inChat", e);});
|
||||
BDFDB.addChildEventListener(translatepopout, "click", ".reverse-button", e => {
|
||||
let place = e.currentTarget.getAttribute("type").replace("output","");
|
||||
|
@ -787,20 +787,20 @@ class GoogleTranslateOption {
|
|||
BDFDB.saveData("input" + place, input, this, "choices");
|
||||
BDFDB.saveData("output" + place, output, this, "choices");
|
||||
});
|
||||
|
||||
|
||||
translatepopout.querySelectorAll(BDFDB.dotCN.select).forEach(selectWrap => {
|
||||
let language = this.getLanguageChoice(selectWrap.getAttribute("type"));
|
||||
selectWrap.setAttribute("value", language);
|
||||
selectWrap.querySelector(BDFDB.dotCN.title).innerText = this.languages[language].name;
|
||||
});
|
||||
|
||||
|
||||
var translatecheckbox = translatepopout.querySelector("#translating-checkbox");
|
||||
translatecheckbox.checked = this.translating;
|
||||
translatecheckbox.addEventListener("click", () => {
|
||||
BDFDB.toggleClass(button, BDFDB.disCN.textareabuttonactive, translatecheckbox.checked);
|
||||
this.translating = translatecheckbox.checked;
|
||||
});
|
||||
|
||||
|
||||
var translators = BDFDB.getAllData(this, "translators");
|
||||
translatepopout.querySelectorAll(".translators-switch").forEach(translatorcheckbox => {
|
||||
translatorcheckbox.checked = translators[translatorcheckbox.value.split(" ")[1]];
|
||||
|
@ -811,7 +811,7 @@ class GoogleTranslateOption {
|
|||
setImmediate(() => {this.openTranslatePopout(button);});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var removePopout = e => {
|
||||
if (!translatepopout.contains(e.target)) {
|
||||
document.removeEventListener("mousedown", removePopout);
|
||||
|
@ -820,32 +820,32 @@ class GoogleTranslateOption {
|
|||
}
|
||||
};
|
||||
document.addEventListener("mousedown", removePopout);
|
||||
|
||||
|
||||
BDFDB.initElements(translatepopout, this);
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (selector, e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = selector == "inSettings" ? BDFDB.getParentEle("li", selectWrap) : document.createElement("div");
|
||||
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
|
||||
plugincard.style.setProperty("overflow", "visible", "important");
|
||||
|
||||
|
||||
var type = selectWrap.getAttribute("type");
|
||||
var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
|
||||
BDFDB.addClass(selectMenu, selector);
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
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;
|
||||
BDFDB.saveData(type, language, this, "choices");
|
||||
});
|
||||
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
|
@ -856,7 +856,7 @@ class GoogleTranslateOption {
|
|||
};
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice, type) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var key in this.languages) {
|
||||
|
@ -867,13 +867,13 @@ class GoogleTranslateOption {
|
|||
menuhtml += `</div></div>`;
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
|
||||
string2binary (string) {
|
||||
var binary = "";
|
||||
for (var character of string) binary += parseInt(character.charCodeAt(0).toString(2)).toPrecision(8).split(".").reverse().join("").toString() + " ";
|
||||
return binary;
|
||||
}
|
||||
|
||||
|
||||
binary2string (binary) {
|
||||
var string = "";
|
||||
binary = binary.replace(new RegExp(" ", "g"), "");
|
||||
|
@ -895,15 +895,15 @@ class GoogleTranslateOption {
|
|||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
getGoogleTranslateApiURL (input, output, text) {
|
||||
return "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + input + "&tl=" + output + "&dt=t&ie=UTF-8&oe=UTF-8&q=" + encodeURIComponent(text);
|
||||
}
|
||||
|
||||
|
||||
getGoogleTranslatePageURL (input, output, text) {
|
||||
return "https://translate.google.com/#" + input + "/" + output + "/" + encodeURIComponent(text);
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,25 +8,25 @@ class ImageGallery {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows the user to browse through images sent inside the same message.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"ImageModal":["componentDidMount","componentWillUnmount"]
|
||||
}
|
||||
this.eventFired = false;
|
||||
|
||||
|
||||
this.imageMarkup = `<div class="${BDFDB.disCN.imagewrapper}" style="width: 100px; height: 100px;"><img src="" style="width: 100px; height: 100px; display: inline;"></div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.prev,
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.next {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.prev {
|
||||
right: 90%;
|
||||
}
|
||||
|
||||
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.next {
|
||||
left: 90%;
|
||||
}`;
|
||||
|
@ -57,7 +57,7 @@ class ImageGallery {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -68,21 +68,21 @@ class ImageGallery {
|
|||
stop () {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processImageModal (instance, wrapper, methodnames) {
|
||||
if (this.closemodal && instance.props && instance.props.onClose) instance.props.onClose();
|
||||
else if (methodnames.includes("componentDidMount")) {
|
||||
|
@ -109,7 +109,7 @@ class ImageGallery {
|
|||
document.removeEventListener("keyup", document.keyupImageGalleryListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getMessageGroupOfImage (thisimg) {
|
||||
if (thisimg && thisimg.src) {
|
||||
for (let group of document.querySelectorAll(BDFDB.dotCN.messagegroup)) {
|
||||
|
@ -122,18 +122,18 @@ class ImageGallery {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
getSrcOfImage (img) {
|
||||
return (img.src || (img.querySelector("canvas") ? img.querySelector("canvas").src : "")).split("?width=")[0];
|
||||
}
|
||||
|
||||
|
||||
addImages (modal, imgs, img) {
|
||||
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++) {
|
||||
if (this.getSrcOfImage(img) == this.getSrcOfImage(imgs[index])) {
|
||||
|
@ -143,20 +143,20 @@ class ImageGallery {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var imagesrc = this.getSrcOfImage(img);
|
||||
modal.querySelector(BDFDB.dotCN.downloadlink).setAttribute("href", imagesrc);
|
||||
|
||||
|
||||
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);};
|
||||
|
@ -164,7 +164,7 @@ class ImageGallery {
|
|||
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);
|
||||
|
@ -174,7 +174,7 @@ class ImageGallery {
|
|||
this.resizeImage(modal, img, imagewrapperimage);
|
||||
return imagewrapper;
|
||||
}
|
||||
|
||||
|
||||
resizeImage (container, src, img) {
|
||||
BDFDB.toggleEles(img, false);
|
||||
var temp = new Image();
|
||||
|
@ -187,19 +187,19 @@ class ImageGallery {
|
|||
var newHeight = src.clientHeight * resize;
|
||||
newWidth = temp.width > newWidth ? newWidth : temp.width;
|
||||
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");
|
||||
|
||||
|
||||
img.style.setProperty("width", newWidth + "px");
|
||||
img.style.setProperty("height", newHeight + "px");
|
||||
|
||||
|
||||
BDFDB.toggleEles(img, true);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
keyPressed ({modal, imgs, prevImg, nextImg}, e) {
|
||||
if (!this.eventFired) {
|
||||
this.eventFired = true;
|
||||
|
|
|
@ -8,19 +8,19 @@ class JoinedAtDate {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Displays the Joined At Date of the current Server for a Member in the UserPopout and UserModal.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"UserPopout":"componentDidMount",
|
||||
"UserProfile":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.languages;
|
||||
|
||||
|
||||
this.loadedusers = {};
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCNS.userpopout + BDFDB.dotCN.nametag} {
|
||||
margin-bottom: 4px;
|
||||
|
@ -42,8 +42,8 @@ class JoinedAtDate {
|
|||
${BDFDB.dotCN.themedark} [class*='topSection'] .joinedAtDate {
|
||||
color: hsla(0,0%,100%,.6);
|
||||
}`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInUserPopout: {value:true, description:"Add in User Popouts:"},
|
||||
|
@ -56,7 +56,7 @@ class JoinedAtDate {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -69,7 +69,7 @@ class JoinedAtDate {
|
|||
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.getJoinedTime(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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -107,13 +107,13 @@ class JoinedAtDate {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.CurrentGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.APIModule = BDFDB.WebModules.findByProperties("getAPIBaseURL");
|
||||
this.DiscordConstants = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes", "StatusTypes");
|
||||
|
||||
|
||||
this.languages = Object.assign({},BDFDB.languages);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -129,23 +129,23 @@ class JoinedAtDate {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
openDropdownMenu (e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
|
||||
let language = e2.currentTarget.getAttribute("value");
|
||||
selectWrap.setAttribute("value", language);
|
||||
|
@ -153,7 +153,7 @@ class JoinedAtDate {
|
|||
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);
|
||||
|
@ -162,10 +162,10 @@ class JoinedAtDate {
|
|||
setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice, type) {
|
||||
let menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (let key in this.languages) {
|
||||
|
@ -175,19 +175,19 @@ class JoinedAtDate {
|
|||
menuhtml += `</div></div>`;
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
|
||||
processUserPopout (instance, wrapper) {
|
||||
if (instance.props && instance.props.user && BDFDB.getData("addInUserPopout", this, "settings")) {
|
||||
this.addJoinedAtDate(instance.props.user, wrapper.querySelector(BDFDB.dotCN.userpopoutheadertext), wrapper.parentElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processUserProfile (instance, wrapper) {
|
||||
if (instance.props && instance.props.user && BDFDB.getData("addInUserProfil", this, "settings")) {
|
||||
this.addJoinedAtDate(instance.props.user, wrapper.querySelector(BDFDB.dotCN.userprofileheaderinfo), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addJoinedAtDate (info, container, popout) {
|
||||
if (!info || !container || container.querySelector(".joinedAtDate")) return;
|
||||
let guildid = this.CurrentGuildStore.getGuildId();
|
||||
|
@ -199,7 +199,7 @@ class JoinedAtDate {
|
|||
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.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);
|
||||
BDFDB.initElements(container.parentElement, this);
|
||||
if (popout && popout.style.transform.indexOf("translateY(-1") == -1) {
|
||||
let arect = BDFDB.getRects(document.querySelector(BDFDB.dotCN.appmount));
|
||||
let prect = BDFDB.getRects(popout);
|
||||
|
@ -217,24 +217,24 @@ class JoinedAtDate {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getJoinedTime (languageid, timestamp = new Date()) {
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let timestring = settings.addJoinedAtTime ? timestamp.toLocaleString(languageid) : timestamp.toLocaleDateString(languageid);
|
||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
||||
return timestring;
|
||||
}
|
||||
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
return chararray.join("");
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,18 +8,18 @@ class MessageUtilities {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Offers a number of useful message options. Remap the keybindings in the settings.";}
|
||||
|
||||
initConstructor () {
|
||||
|
||||
initConstructor () {
|
||||
this.bindings = {};
|
||||
|
||||
|
||||
this.firedEvents = [];
|
||||
|
||||
|
||||
this.clickMap = ["CLICK" /*[0]*/, "DBLCLICK" /*[1]*/];
|
||||
|
||||
|
||||
this.keyboardMap = [
|
||||
"NONE" /*[0]*/, "" /*[1]*/, "" /*[2]*/, "CANCEL" /*[3]*/, "" /*[4]*/, "" /*[5]*/, "HELP" /*[6]*/, "" /*[7]*/, "BACK_SPACE" /*[8]*/, "TAB" /*[9]*/, "" /*[10]*/, "" /*[11]*/, "CLEAR" /*[12]*/, "ENTER" /*[13]*/, "ENTER_SPECIAL" /*[14]*/, "" /*[15]*/, "SHIFT" /*[16]*/, "CONTROL" /*[17]*/, "ALT" /*[18]*/, "PAUSE" /*[19]*/, "CAPS_LOCK" /*[20]*/, "KANA" /*[21]*/, "EISU" /*[22]*/, "JUNJA" /*[23]*/, "FINAL" /*[24]*/, "HANJA" /*[25]*/, "" /*[26]*/, "ESCAPE" /*[27]*/, "CONVERT" /*[28]*/, "NONCONVERT" /*[29]*/, "ACCEPT" /*[30]*/, "MODECHANGE" /*[31]*/, "SPACE" /*[32]*/, "PAGE_UP" /*[33]*/, "PAGE_DOWN" /*[34]*/, "END" /*[35]*/, "HOME" /*[36]*/, "LEFT" /*[37]*/, "UP" /*[38]*/, "RIGHT" /*[39]*/, "DOWN" /*[40]*/, "SELECT" /*[41]*/, "PRINT" /*[42]*/, "EXECUTE" /*[43]*/, "PRINTSCREEN" /*[44]*/, "INSERT" /*[45]*/, "DELETE" /*[46]*/, "" /*[47]*/,"0" /*[48]*/, "1" /*[49]*/, "2" /*[50]*/, "3" /*[51]*/, "4" /*[52]*/, "5" /*[53]*/, "6" /*[54]*/, "7" /*[55]*/, "8" /*[56]*/, "9" /*[57]*/, "COLON" /*[58]*/, "SEMICOLON" /*[59]*/, "LESS_THAN" /*[60]*/, "EQUALS" /*[61]*/, "GREATER_THAN" /*[62]*/, "QUESTION_MARK" /*[63]*/, "AT" /*[64]*/, "A" /*[65]*/, "B" /*[66]*/, "C" /*[67]*/, "D" /*[68]*/, "E" /*[69]*/, "F" /*[70]*/, "G" /*[71]*/, "H" /*[72]*/, "I" /*[73]*/, "J" /*[74]*/, "K" /*[75]*/, "L" /*[76]*/, "M" /*[77]*/, "N" /*[78]*/, "O" /*[79]*/, "P" /*[80]*/, "Q" /*[81]*/, "R" /*[82]*/, "S" /*[83]*/, "T" /*[84]*/, "U" /*[85]*/, "V" /*[86]*/, "W" /*[87]*/, "X" /*[88]*/, "Y" /*[89]*/, "Z" /*[90]*/, "OS_KEY" /*[91]*/, "" /*[92]*/, "CONTEXT_MENU" /*[93]*/, "" /*[94]*/, "SLEEP" /*[95]*/, "NUMPAD0" /*[96]*/, "NUMPAD1" /*[97]*/, "NUMPAD2" /*[98]*/, "NUMPAD3" /*[99]*/, "NUMPAD4" /*[100]*/, "NUMPAD5" /*[101]*/, "NUMPAD6" /*[102]*/, "NUMPAD7" /*[103]*/, "NUMPAD8" /*[104]*/, "NUMPAD9" /*[105]*/, "MULTIPLY" /*[106]*/, "ADD" /*[107]*/, "SEPARATOR" /*[108]*/, "SUBTRACT" /*[109]*/, "DECIMAL" /*[110]*/, "DIVIDE" /*[111]*/, "F1" /*[112]*/, "F2" /*[113]*/, "F3" /*[114]*/, "F4" /*[115]*/, "F5" /*[116]*/, "F6" /*[117]*/, "F7" /*[118]*/, "F8" /*[119]*/, "F9" /*[120]*/, "F10" /*[121]*/, "F11" /*[122]*/, "F12" /*[123]*/, "F13" /*[124]*/, "F14" /*[125]*/, "F15" /*[126]*/, "F16" /*[127]*/, "F17" /*[128]*/, "F18" /*[129]*/, "F19" /*[130]*/, "F20" /*[131]*/, "F21" /*[132]*/, "F22" /*[133]*/, "F23" /*[134]*/, "F24" /*[135]*/, "" /*[136]*/, "" /*[137]*/, "" /*[138]*/, "" /*[139]*/, "" /*[140]*/, "" /*[141]*/, "" /*[142]*/, "" /*[143]*/, "NUM_LOCK" /*[144]*/, "SCROLL_LOCK" /*[145]*/, "WIN_OEM_FJ_JISHO" /*[146]*/, "WIN_OEM_FJ_MASSHOU" /*[147]*/, "WIN_OEM_FJ_TOUROKU" /*[148]*/, "WIN_OEM_FJ_LOYA" /*[149]*/, "WIN_OEM_FJ_ROYA" /*[150]*/, "" /*[151]*/, "" /*[152]*/, "" /*[153]*/, "" /*[154]*/, "" /*[155]*/, "" /*[156]*/, "" /*[157]*/, "" /*[158]*/, "" /*[159]*/, "CIRCUMFLEX" /*[160]*/, "EXCLAMATION" /*[161]*/, "DOUBLE_QUOTE" /*[162]*/, "HASH" /*[163]*/, "DOLLAR" /*[164]*/, "PERCENT" /*[165]*/, "AMPERSAND" /*[166]*/, "UNDERSCORE" /*[167]*/, "OPEN_PAREN" /*[168]*/, "CLOSE_PAREN" /*[169]*/, "ASTERISK" /*[170]*/, "PLUS" /*[171]*/, "PIPE" /*[172]*/, "HYPHEN_MINUS" /*[173]*/, "OPEN_CURLY_BRACKET" /*[174]*/, "CLOSE_CURLY_BRACKET" /*[175]*/, "TILDE" /*[176]*/, "" /*[177]*/, "" /*[178]*/, "" /*[179]*/, "" /*[180]*/, "VOLUME_MUTE" /*[181]*/, "VOLUME_DOWN" /*[182]*/, "VOLUME_UP" /*[183]*/, "" /*[184]*/, "" /*[185]*/, "SEMICOLON" /*[186]*/, "EQUALS" /*[187]*/, "COMMA" /*[188]*/, "MINUS" /*[189]*/, "PERIOD" /*[190]*/, "SLASH" /*[191]*/, "BACK_QUOTE" /*[192]*/, "" /*[193]*/, "" /*[194]*/, "" /*[195]*/, "" /*[196]*/, "" /*[197]*/, "" /*[198]*/, "" /*[199]*/, "" /*[200]*/, "" /*[201]*/, "" /*[202]*/, "" /*[203]*/, "" /*[204]*/, "" /*[205]*/, "" /*[206]*/, "" /*[207]*/, "" /*[208]*/, "" /*[209]*/, "" /*[210]*/, "" /*[211]*/, "" /*[212]*/, "" /*[213]*/, "" /*[214]*/, "" /*[215]*/, "" /*[216]*/, "" /*[217]*/, "" /*[218]*/, "OPEN_BRACKET" /*[219]*/, "BACK_SLASH" /*[220]*/, "CLOSE_BRACKET" /*[221]*/, "QUOTE" /*[222]*/, "" /*[223]*/, "META" /*[224]*/, "ALTGR" /*[225]*/, "" /*[226]*/, "WIN_ICO_HELP" /*[227]*/, "WIN_ICO_00" /*[228]*/, "" /*[229]*/, "WIN_ICO_CLEAR" /*[230]*/, "" /*[231]*/,"" /*[232]*/, "WIN_OEM_RESET" /*[233]*/, "WIN_OEM_JUMP" /*[234]*/, "WIN_OEM_PA1" /*[235]*/, "WIN_OEM_PA2" /*[236]*/, "WIN_OEM_PA3" /*[237]*/, "WIN_OEM_WSCTRL" /*[238]*/,"WIN_OEM_CUSEL" /*[239]*/, "WIN_OEM_ATTN" /*[240]*/, "WIN_OEM_FINISH" /*[241]*/, "WIN_OEM_COPY" /*[242]*/, "WIN_OEM_AUTO" /*[243]*/, "WIN_OEM_ENLW" /*[244]*/, "WIN_OEM_BACKTAB" /*[245]*/, "ATTN" /*[246]*/, "CRSEL" /*[247]*/, "EXSEL" /*[248]*/, "EREOF" /*[249]*/, "PLAY" /*[250]*/, "ZOOM" /*[251]*/, "" /*[252]*/, "PA1" /*[253]*/, "WIN_OEM_CLEAR" /*[254]*/, "" /*[255]*/
|
||||
];
|
||||
|
||||
|
||||
this.clicks = ["click"];
|
||||
this.keys = ["key1","key2"];
|
||||
this.defaults = {
|
||||
|
@ -46,7 +46,7 @@ class MessageUtilities {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -69,16 +69,16 @@ class MessageUtilities {
|
|||
}
|
||||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -107,13 +107,13 @@ class MessageUtilities {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
|
||||
this.MessageActions = BDFDB.WebModules.findByProperties("startEditMessage", "endEditMessage");
|
||||
this.PinActions = BDFDB.WebModules.findByProperties("pinMessage", "unpinMessage");
|
||||
this.CurrentUserPerms = BDFDB.WebModules.findByProperties("getChannelPermissions", "can");
|
||||
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions
|
||||
|
||||
|
||||
BDFDB.addEventListener(this, document, "click", BDFDB.dotCNC.message + BDFDB.dotCN.messagesystem, e => {
|
||||
this.onClick(e.currentTarget, 0, "onSglClick");
|
||||
})
|
||||
|
@ -135,9 +135,9 @@ class MessageUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//begin of own functions
|
||||
|
||||
|
||||
resetAll (settingspanel) {
|
||||
BDFDB.openConfirmModal(this, "Are you sure you want to delete all key bindings?", () => {
|
||||
BDFDB.removeAllData(this, "bindings");
|
||||
|
@ -156,24 +156,24 @@ class MessageUtilities {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
|
||||
plugincard.style.setProperty("overflow", "visible", "important");
|
||||
|
||||
|
||||
let action = selectWrap.getAttribute("type");
|
||||
let option = selectWrap.getAttribute("option");
|
||||
let value = selectWrap.getAttribute("value");
|
||||
|
||||
|
||||
let selectMenu = this.createDropdownMenu(action, value);
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
|
||||
let binding = BDFDB.getData(action, this, "bindings");
|
||||
let selection = e2.currentTarget.getAttribute("value");
|
||||
|
@ -182,7 +182,7 @@ class MessageUtilities {
|
|||
binding[option] = parseInt(selection);
|
||||
BDFDB.saveData(action, binding, this, "bindings");
|
||||
});
|
||||
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
|
@ -193,7 +193,7 @@ class MessageUtilities {
|
|||
};
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (action, value) {
|
||||
let menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (let i in this.clickMap) {
|
||||
|
@ -203,26 +203,26 @@ class MessageUtilities {
|
|||
menuhtml += `</div></div>`;
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
|
||||
startRecording (settingspanel, e) {
|
||||
let recorderWrap = e.currentTarget;
|
||||
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");
|
||||
|
||||
|
||||
BDFDB.addClass(recorderWrap, BDFDB.disCN.hotkeyrecording);
|
||||
BDFDB.removeClass(recorderWrap, BDFDB.disCN.hotkeyhasvalue);
|
||||
recorderText.innerText = BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_RECORDING;
|
||||
|
||||
|
||||
|
||||
|
||||
var saveRecording = e => {
|
||||
recorderWrap.setAttribute("value", e.which);
|
||||
recorderInput.setAttribute("value", this.keyboardMap[e.which]);
|
||||
};
|
||||
|
||||
|
||||
var stopRecording = e => {
|
||||
document.removeEventListener("mousedown", stopRecording);
|
||||
document.removeEventListener("keydown", saveRecording);
|
||||
|
@ -235,11 +235,11 @@ class MessageUtilities {
|
|||
recorderText.innerText = BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_EDIT;
|
||||
},100);
|
||||
};
|
||||
|
||||
|
||||
document.addEventListener("mousedown", stopRecording);
|
||||
document.addEventListener("keydown", saveRecording);
|
||||
}
|
||||
|
||||
|
||||
resetRecorder (settingspanel, e) {
|
||||
let resetButton = e.currentTarget;
|
||||
let recorderWrap = e.currentTarget.parentElement.parentElement.querySelector(BDFDB.dotCN.hotkeycontainer);
|
||||
|
@ -252,7 +252,7 @@ class MessageUtilities {
|
|||
binding[option] = parseInt(recorderWrap.getAttribute("value"));
|
||||
BDFDB.saveData(action, binding, this, "bindings");
|
||||
}
|
||||
|
||||
|
||||
onClick (div, click, name) {
|
||||
if (!this.isEventFired(name)) {
|
||||
this.fireEvent(name);
|
||||
|
@ -268,7 +268,7 @@ class MessageUtilities {
|
|||
this.cancelEvent(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkIfBindingIsValid (binding, doneclick) {
|
||||
let valid = true;
|
||||
for (let click of this.clicks) {
|
||||
|
@ -279,25 +279,25 @@ class MessageUtilities {
|
|||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
doDelete ({messagediv, pos, message}) {
|
||||
let channel = this.ChannelUtils.getChannel(message.channel_id);
|
||||
if ((channel && this.CurrentUserPerms.can(this.Permissions.MANAGE_MESSAGES, channel)) || message.author.id == BDFDB.myData.id) {
|
||||
this.MessageActions.deleteMessage(message.channel_id, message.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doEdit ({messagediv, pos, message}) {
|
||||
if (message.author.id == BDFDB.myData.id && !messagediv.querySelector("textarea")) {
|
||||
this.MessageActions.startEditMessage(message.channel_id, message.id, message.content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doOpenReact ({messagediv, pos, message}) {
|
||||
let reactButton = messagediv.querySelector(BDFDB.dotCN.emojipickerbutton);
|
||||
if (reactButton) reactButton.click();
|
||||
}
|
||||
|
||||
|
||||
doPinUnPin ({messagediv, pos, message}) {
|
||||
let channel = this.ChannelUtils.getChannel(message.channel_id);
|
||||
if (channel && this.CurrentUserPerms.can(this.Permissions.MANAGE_MESSAGES, channel)) {
|
||||
|
@ -305,35 +305,35 @@ class MessageUtilities {
|
|||
else this.PinActions.pinMessage(channel, message.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doNote ({messagediv, pos, message}) {
|
||||
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
|
||||
let channel = this.ChannelUtils.getChannel(message.channel_id);
|
||||
if (channel) bdplugins[this.defaults.bindings.__Note_Message.plugin].plugin.addMessageToNotes(message, messagediv, channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doTranslate ({messagediv, pos, message}) {
|
||||
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
|
||||
let channel = this.ChannelUtils.getChannel(message.channel_id);
|
||||
if (channel) bdplugins[this.defaults.bindings.__Translate_Message.plugin].plugin.translateMessage(message, messagediv, channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doQuote ({messagediv, pos, message}) {
|
||||
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(this.defaults.bindings.__Citate_Message.plugin)) {
|
||||
let citarButton = messagediv.parentElement.querySelector(".citar-btn");
|
||||
if (citarButton) citarButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onKeyDown (div, key, name) {
|
||||
if (!this.isEventFired(name)) {
|
||||
this.fireEvent(name);
|
||||
|
@ -346,7 +346,7 @@ class MessageUtilities {
|
|||
this.cancelEvent(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getActiveShortcutString (action) {
|
||||
let str = "";
|
||||
if (BDFDB.getData(action, this, "settings")) {
|
||||
|
@ -358,7 +358,7 @@ class MessageUtilities {
|
|||
}
|
||||
return str ? str.slice(0,-1) : null;
|
||||
}
|
||||
|
||||
|
||||
getMessageData (target) {
|
||||
let messagediv = BDFDB.getParentEle(BDFDB.dotCN.message, target);
|
||||
let pos = messagediv ? Array.from(messagediv.parentElement.querySelectorAll(BDFDB.dotCN.message)).indexOf(messagediv) : -1;
|
||||
|
@ -366,15 +366,15 @@ class MessageUtilities {
|
|||
let message = instance && instance.return && instance.return.memoizedProps && instance.return.memoizedProps.message ? instance.return.memoizedProps.message : null;
|
||||
return {messagediv, pos, message};
|
||||
}
|
||||
|
||||
|
||||
fireEvent (name) {
|
||||
this.firedEvents.push(name);
|
||||
}
|
||||
|
||||
|
||||
isEventFired (name) {
|
||||
return this.firedEvents.includes(name);
|
||||
}
|
||||
|
||||
|
||||
cancelEvent (name) {
|
||||
BDFDB.removeFromArray(this.firedEvents, name);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class MoveablePopups {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -51,7 +51,7 @@ class MoveablePopups {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"popoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -82,9 +82,9 @@ class MoveablePopups {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
makeMoveable (div) {
|
||||
div.removeEventListener("click", div.clickMovablePopups);
|
||||
div.removeEventListener("mousedown", div.mousedownMovablePopups);
|
||||
|
@ -117,7 +117,7 @@ class MoveablePopups {
|
|||
oldY = e2.pageY;
|
||||
div.style.setProperty("left", left + "px", "important");
|
||||
div.style.setProperty("top", top + "px", "important");
|
||||
|
||||
|
||||
};
|
||||
document.addEventListener("mouseup", mouseup);
|
||||
document.addEventListener("mousemove", mousemove);
|
||||
|
|
|
@ -6,15 +6,15 @@ class NotificationSounds {
|
|||
getVersion () {return "3.2.5";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
||||
getDescription () {return "Allows you to replace the native sounds of Discord with your own";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"IncomingCalls":"componentDidMount",
|
||||
"PrivateChannelCall":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.types = {
|
||||
"message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute:true},
|
||||
"dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true},
|
||||
|
@ -46,7 +46,7 @@ class NotificationSounds {
|
|||
"reconnect": {implemented:false, name:"Voicechat Reconnect", src:"/assets/471cfd0005b112ff857705e894bf41a6.mp3", mute:true},
|
||||
"robot_man": {implemented:false, name:"Robot Man Voice", src:"/assets/66598bea6e59eb8acdf32cf2d9d75ba9.mp3", mute:true}
|
||||
};
|
||||
|
||||
|
||||
this.defaults = {
|
||||
"---": {
|
||||
"---": null
|
||||
|
@ -90,23 +90,23 @@ class NotificationSounds {
|
|||
"Voicechat Reconnect": "/assets/471cfd0005b112ff857705e894bf41a6.mp3"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.settingsaudio = new Audio();
|
||||
|
||||
|
||||
this.audios = {};
|
||||
|
||||
|
||||
this.choices = [];
|
||||
|
||||
|
||||
this.firedEvents = {};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
|
||||
|
||||
var fields = ["category","song"];
|
||||
|
||||
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="DevilBro-settings-inner">`;
|
||||
|
||||
|
||||
settingshtml += `<div class="add-new-song-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: 0 0 auto;">Add New Song:</h3></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;">`;
|
||||
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 50%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">Categoryname:</h5><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" placeholder="Category" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} songInput" id="input-category"></div></div>`;
|
||||
|
@ -116,7 +116,7 @@ class NotificationSounds {
|
|||
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">File:</h5><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" placeholder="Url or Filepath" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} songInput" id="input-url"></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" id="input-file" 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" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-add btn-addsong" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div></div>`;
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
|
||||
for (var type in this.types) {
|
||||
var choice = BDFDB.loadData(type, this, "choices");
|
||||
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;">`;
|
||||
|
@ -129,7 +129,7 @@ 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.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;">Show unimplemented Sounds</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" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id="input-unimplemented"></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;">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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -168,7 +168,7 @@ class NotificationSounds {
|
|||
BDFDB.toggleEles(settingspanel.querySelectorAll(".unimplemented"), e.currentTarget.checked);
|
||||
});
|
||||
BDFDB.addEventListener(this, settingspanel, "mousedown", BDFDB.dotCN.slidergrabber, e => {this.dragSlider(settingspanel,e);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -197,9 +197,9 @@ class NotificationSounds {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.ChannelSettingsUtils = BDFDB.WebModules.findByProperties("isGuildOrCategoryOrChannelMuted");
|
||||
|
||||
|
||||
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;
|
||||
|
@ -217,7 +217,7 @@ class NotificationSounds {
|
|||
}
|
||||
}
|
||||
}});
|
||||
|
||||
|
||||
BDFDB.WebModules.patch(BDFDB.WebModules.findByProperties("playSound"), "playSound", this, {instead: e => {
|
||||
setImmediate(() => {
|
||||
var type = e.methodArguments[0];
|
||||
|
@ -229,10 +229,10 @@ class NotificationSounds {
|
|||
else this.playAudio(type);
|
||||
});
|
||||
}});
|
||||
|
||||
|
||||
this.loadAudios();
|
||||
this.loadChoices();
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -247,29 +247,29 @@ class NotificationSounds {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
openDropdownMenu (settingspanel, e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
|
||||
|
||||
|
||||
var type = selectWrap.getAttribute("type");
|
||||
var option = selectWrap.getAttribute("option");
|
||||
var categorySelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type}"][option="category"]`);
|
||||
var songSelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type}"][option="song"]`);
|
||||
|
||||
|
||||
var category = categorySelect.getAttribute("value");
|
||||
var song = songSelect.getAttribute("value");
|
||||
|
||||
|
||||
var selectMenu = this.createDropdownMenu({type, option, category, song});
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
|
||||
var choice = BDFDB.loadData(type, this, "choices");
|
||||
var selection = e2.currentTarget.textContent;
|
||||
|
@ -284,7 +284,7 @@ class NotificationSounds {
|
|||
choice.src = choice.src ? choice.src : this.types[type].src;
|
||||
this.saveChoice(type, choice, true);
|
||||
});
|
||||
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
|
@ -292,10 +292,10 @@ class NotificationSounds {
|
|||
setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu ({type, option, category, song} = data) {
|
||||
var choice = BDFDB.loadData(type, this, "choices");
|
||||
var eles = option == "song" ? this.audios[category] : this.audios;
|
||||
|
@ -307,16 +307,16 @@ class NotificationSounds {
|
|||
menuhtml += `</div></div>`;
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
|
||||
dragSlider (settingspanel, e) {
|
||||
var grabber = e.target;
|
||||
var track = grabber.parentNode;
|
||||
var slider = track.parentNode;
|
||||
var input = slider.querySelector(".volumeInput");
|
||||
var bar = slider.querySelector(BDFDB.dotCN.sliderbarfill);
|
||||
|
||||
|
||||
BDFDB.appendLocalStyle("disableTextSelection", `*{user-select: none !important;}`);
|
||||
|
||||
|
||||
var volume = 0;
|
||||
var sY = 0;
|
||||
var sHalfW = BDFDB.getRects(grabber).width/2;
|
||||
|
@ -341,13 +341,13 @@ class NotificationSounds {
|
|||
document.addEventListener("mouseup", mouseup);
|
||||
document.addEventListener("mousemove", mousemove);
|
||||
}
|
||||
|
||||
|
||||
loadAudios () {
|
||||
this.audios = BDFDB.loadAllData(this, "audios");
|
||||
if (BDFDB.isObjectEmpty(this.audios)) this.audios = this.defaults;
|
||||
BDFDB.saveAllData(this.audios, this, "audios");
|
||||
}
|
||||
|
||||
|
||||
saveAudio (settingspanel) {
|
||||
var valid = true;
|
||||
var inputs = settingspanel.querySelectorAll(".songInput");
|
||||
|
@ -382,7 +382,7 @@ class NotificationSounds {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
successSavedAudio = () => {
|
||||
BDFDB.showToast(`Song ${song} was added to category ${category}.`, {type:"success"});
|
||||
if (!this.audios[category]) this.audios[category] = {};
|
||||
|
@ -397,12 +397,12 @@ class NotificationSounds {
|
|||
BDFDB.showToast("Fill out all fields to add a new song.", {type:"danger"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadChoices () {
|
||||
for (var type in this.types) {
|
||||
var choice = BDFDB.loadData(type, this, "choices");
|
||||
choice = choice ? choice : {};
|
||||
|
||||
|
||||
var songFound = false;
|
||||
for (var category in this.audios) {
|
||||
if (choice.category == category) {
|
||||
|
@ -419,13 +419,13 @@ class NotificationSounds {
|
|||
this.saveChoice(type, choice, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
saveChoice (type, choice, play) {
|
||||
BDFDB.saveData(type, choice, this, "choices");
|
||||
this.choices[type] = choice;
|
||||
if (play) this.playAudio(type, this.settingsaudio);
|
||||
}
|
||||
|
||||
|
||||
playAudio (type, audio) {
|
||||
if (!audio) {
|
||||
if (this.dontPlayAudio(type)) return;
|
||||
|
@ -436,17 +436,17 @@ class NotificationSounds {
|
|||
audio.volume = this.choices[type].volume/100;
|
||||
audio.play();
|
||||
}
|
||||
|
||||
|
||||
dontPlayAudio (type) {
|
||||
let status = BDFDB.getUserStatus();
|
||||
return this.choices[type].mute && (status == "dnd" || status == "streaming");
|
||||
}
|
||||
|
||||
|
||||
fireEvent (type) {
|
||||
this.firedEvents[type] = true;
|
||||
setTimeout(() => {this.firedEvents[type] = false;},3000);
|
||||
}
|
||||
|
||||
|
||||
patchCallingSound (instance, instancetype, type) {
|
||||
let audio = new Audio();
|
||||
let play = () => {
|
||||
|
@ -464,11 +464,11 @@ class NotificationSounds {
|
|||
BDFDB.WebModules.patch(instance._reactInternalFiber.type.prototype, "stopRinging", this, {instead: stop});
|
||||
BDFDB.WebModules.unpatch(instance._reactInternalFiber.type.prototype, this.patchModules[instancetype], this);
|
||||
}
|
||||
|
||||
|
||||
processIncomingCalls (instance, wrapper) {
|
||||
this.patchCallingSound(instance, "IncomingCalls", "call_ringing");
|
||||
}
|
||||
|
||||
|
||||
processPrivateChannelCall (instance, wrapper) {
|
||||
console.log(wrapper);
|
||||
this.patchCallingSound(instance, "PrivateChannelCall", "call_calling");
|
||||
|
|
|
@ -8,31 +8,31 @@ class OldTitleBar {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Reverts the title bar back to its former self.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"HeaderBar":["componentDidMount","componentDidUpdate"],
|
||||
"StandardSidebarView":["componentDidMount","componentWillUnmount"],
|
||||
"AuthWrapper":["componentDidMount","componentWillUnmount"]
|
||||
};
|
||||
|
||||
|
||||
this.patched = false;
|
||||
|
||||
|
||||
this.css = `
|
||||
.hidden-by-OTB ${BDFDB.dotCN.titlebar},
|
||||
.hidden-by-OTB ${BDFDB.dotCN.titlebar} + ${BDFDB.dotCNS.app + BDFDB.dotCN.splashbackground}:before {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
body:not(.settingsTitlebarOTB-added) ${BDFDB.dotCN.channelheaderheaderbardrag} {
|
||||
-webkit-app-region: drag !important;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.channelheaderheaderbardrag} *,
|
||||
${BDFDB.dotCN.contextmenu} * {
|
||||
-webkit-app-region: no-drag !important;
|
||||
}
|
||||
|
||||
|
||||
.settingsTitlebarOTB {
|
||||
position: relative;
|
||||
z-index: 1000;
|
||||
|
@ -40,9 +40,9 @@ class OldTitleBar {
|
|||
padding: 10px;
|
||||
-webkit-app-region: drag;
|
||||
}`;
|
||||
|
||||
|
||||
this.dividerMarkup = `<div class="buttonOTB dividerOTB ${BDFDB.disCN.channelheaderdivider}"></div>`;
|
||||
|
||||
|
||||
this.reloadButtonMarkup =
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB reloadButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg">
|
||||
|
@ -51,7 +51,7 @@ class OldTitleBar {
|
|||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.minButtonMarkup =
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB minButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
|
@ -60,7 +60,7 @@ class OldTitleBar {
|
|||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.maxButtonMarkup =
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB maxButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
|
@ -69,7 +69,7 @@ class OldTitleBar {
|
|||
</span>`;
|
||||
this.maxButtonInnerMin = `<path stroke-width="2" stroke="currentColor" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/>`;
|
||||
this.maxButtonInnerMax = `<path stroke-width="2" stroke="currentColor" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/>`;
|
||||
|
||||
|
||||
this.closeButtonMarkup =
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB closeButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
|
@ -78,7 +78,7 @@ class OldTitleBar {
|
|||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
displayNative: {value:!!document.querySelector(".platform-linux"), description:"Displays the native Title Bar."},
|
||||
|
@ -97,7 +97,7 @@ class OldTitleBar {
|
|||
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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -117,7 +117,7 @@ class OldTitleBar {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -146,15 +146,15 @@ class OldTitleBar {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.addEventListener(this, window, "resize", e => {this.changeMaximizeButtons();});
|
||||
|
||||
|
||||
this.window = require("electron").remote.getCurrentWindow();
|
||||
|
||||
|
||||
this.patchMainScreen(BDFDB.getData("displayNative", this, "settings"));
|
||||
|
||||
|
||||
BDFDB.addClass([document.body,document.querySelector(BDFDB.dotCN.titlebar)], "hidden-by-OTB");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -166,24 +166,24 @@ class OldTitleBar {
|
|||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".headerbarOTB", ".settingsTitlebarOTB");
|
||||
|
||||
|
||||
BDFDB.removeClasses("hidden-by-OTB", "settingsTitlebarOTB-added");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processHeaderBar (instance, wrapper) {
|
||||
this.addTitleBar();
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper, methodnames) {
|
||||
this.processAuthWrapper(instance, wrapper, methodnames);
|
||||
}
|
||||
|
||||
|
||||
processAuthWrapper (instance, wrapper, methodnames) {
|
||||
if (methodnames.includes("componentDidMount")) {
|
||||
this.addSettingsTitleBar(wrapper);
|
||||
|
@ -194,7 +194,7 @@ class OldTitleBar {
|
|||
this.addTitleBar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addTitleBar () {
|
||||
BDFDB.removeEles(".headerbarOTB");
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -206,7 +206,7 @@ class OldTitleBar {
|
|||
this.changeMaximizeButtons();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addSettingsTitleBar (settingspane) {
|
||||
BDFDB.removeEles(".settingsTitlebarOTB");
|
||||
if (BDFDB.getData("addToSettings", this, "settings")) {
|
||||
|
@ -217,7 +217,7 @@ class OldTitleBar {
|
|||
this.changeMaximizeButtons();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createButtons (bar) {
|
||||
var settings = BDFDB.containsClass(bar, "settingsTitlebarOTB");
|
||||
if (BDFDB.getData("reloadButton", this, "settings")) {
|
||||
|
@ -245,12 +245,12 @@ class OldTitleBar {
|
|||
bar.appendChild(closebutton);
|
||||
closebutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {this.window.close();});
|
||||
}
|
||||
|
||||
|
||||
changeMaximizeButtons () {
|
||||
var innerHTML = this.window.isMaximized() ? this.maxButtonInnerMax : this.maxButtonInnerMin;
|
||||
document.querySelectorAll(".maxButtonOTB g").forEach(g => {g.innerHTML = innerHTML;});
|
||||
}
|
||||
|
||||
|
||||
patchMainScreen (enable) {
|
||||
if (BdApi.getWindowPreference("frame") != enable) {
|
||||
BdApi.setWindowPreference("frame", enable);
|
||||
|
|
|
@ -8,14 +8,14 @@ class OwnerTag {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds a Tag like Bottags to the Serverowner.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"NameTag":["componentDidMount","componentDidUpdate"],
|
||||
"MessageUsername":["componentDidMount","componentDidUpdate"],
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInChatWindow: {value:true, inner:true, description:"Messages"},
|
||||
|
@ -30,7 +30,7 @@ class OwnerTag {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -48,13 +48,13 @@ class OwnerTag {
|
|||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -83,11 +83,11 @@ class OwnerTag {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.MemberUtils = BDFDB.WebModules.findByProperties("getMembers", "getMember");
|
||||
this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -101,8 +101,8 @@ class OwnerTag {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
saveInputs (settingspanel) {
|
||||
|
@ -113,7 +113,7 @@ class OwnerTag {
|
|||
BDFDB.saveAllData(inputs, this, "inputs");
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
|
||||
|
||||
processNameTag (instance, wrapper) {
|
||||
let container = null;
|
||||
if (!instance.props || !wrapper.classList) return;
|
||||
|
@ -127,7 +127,7 @@ class OwnerTag {
|
|||
this.addOwnerTag(instance.props.user, wrapper, "profile", BDFDB.disCN.bottagnametag + (instance.props.botClass ? (" " + instance.props.botClass) : ""), container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processMessageUsername (instance, wrapper, methodnames) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message && BDFDB.getData("addInChatWindow", this, "settings")) {
|
||||
|
@ -138,7 +138,7 @@ class OwnerTag {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
|
@ -146,7 +146,7 @@ class OwnerTag {
|
|||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addOwnerTag (info, wrapper, type, selector = "", container) {
|
||||
if (!info || !wrapper || !wrapper.parentElement) return;
|
||||
BDFDB.removeEles(wrapper.querySelectorAll(".owner-tag"));
|
||||
|
|
|
@ -8,16 +8,16 @@ class PersonalPins {
|
|||
getVersion () {return "1.7.4";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"HeaderBar":["componentDidMount","componentDidUpdate"],
|
||||
"Message":"componentDidMount",
|
||||
"MessageOptionPopout":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.notesButtonMarkup =
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} notes-button">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" name="Note" width="16" height="16" viewBox="0 0 26 26">
|
||||
|
@ -30,7 +30,7 @@ class PersonalPins {
|
|||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.notesPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCNS.popoutnoarrow + BDFDB.disCN.popoutnoshadow} popout-personalpins-notes DevilBro-modal" style="z-index: 1000; visibility: visible; left: 544.844px; top: 35.9896px; transform: translateX(-100%) translateY(0%) translateZ(0px);">
|
||||
<div class="${BDFDB.disCNS.messagespopoutwrap + BDFDB.disCNS.recentmentionspopout + BDFDB.disCN.popoutthemedpopout}" style="max-height: 740px; width: 500px;">
|
||||
|
@ -67,7 +67,7 @@ class PersonalPins {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.sortPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} personalpins-sort-popout" style="z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
|
||||
<div>
|
||||
|
@ -79,7 +79,7 @@ class PersonalPins {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.messagePinContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} personalpins-item personalpins-pin-item">
|
||||
|
@ -87,7 +87,7 @@ class PersonalPins {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.messageUnpinContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} personalpins-item personalpins-unpin-item">
|
||||
|
@ -95,23 +95,23 @@ class PersonalPins {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.popoutPinEntryMarkup =
|
||||
`<button role="menuitem" type="button" class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} personalpins-itembtn personalpins-pin-itembtn">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_popout_pinoption_text</div>
|
||||
</button>`;
|
||||
|
||||
|
||||
this.popoutUnpinEntryMarkup =
|
||||
`<button role="menuitem" type="button" class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} personalpins-itembtn personalpins-unpin-itembtn">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_popout_unpinoption_text</div>
|
||||
</button>`;
|
||||
|
||||
|
||||
this.messageDividerMarkup =
|
||||
`<div class="${BDFDB.disCN.messagespopoutchannelseparator}">
|
||||
<span tabindex="0" class="${BDFDB.disCN.messagespopoutchannelname}" role="button"></span>
|
||||
<span class=${BDFDB.disCN.messagespopoutguildname}></span>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.messageMarkup =
|
||||
`<div class="${BDFDB.disCN.messagespopoutmessagegroupwrapper}">
|
||||
<div class="${BDFDB.disCN.messagespopoutmessagegroupwrapperoffsetcorrection}">
|
||||
|
@ -154,13 +154,13 @@ class PersonalPins {
|
|||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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;">Delete all Notes.</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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -198,7 +198,7 @@ class PersonalPins {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.SelectChannelUtils = BDFDB.WebModules.findByProperties("selectGuild","selectChannel");
|
||||
this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
|
||||
|
@ -208,37 +208,7 @@ class PersonalPins {
|
|||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
this.HistoryUtils = BDFDB.WebModules.findByProperties("transitionTo", "replaceWith", "getHistory");
|
||||
this.MainDiscord = BDFDB.WebModules.findByProperties("ActionTypes");
|
||||
|
||||
/* REMOVE 11.01.2019 */
|
||||
let p = BDFDB.loadAllData(this, "pins");
|
||||
for (let g in p) {
|
||||
for (let c in p[g]) {
|
||||
for (let m in p[g][c]) {
|
||||
if (p[g][c][m].serverID) {
|
||||
p[g][c][m].guild_id = p[g][c][m].serverID;
|
||||
delete p[g][c][m].serverID;
|
||||
p[g][c][m].guild_name = p[g][c][m].serverName;
|
||||
delete p[g][c][m].serverName;
|
||||
p[g][c][m].channel_id = p[g][c][m].channelID;
|
||||
delete p[g][c][m].channelID;
|
||||
p[g][c][m].channel_name = p[g][c][m].channelName;
|
||||
delete p[g][c][m].channelName;
|
||||
p[g][c][m].author_id = p[g][c][m].authorID;
|
||||
delete p[g][c][m].authorID;
|
||||
p[g][c][m].author_name = p[g][c][m].authorName;
|
||||
delete p[g][c][m].authorName;
|
||||
p[g][c][m].dmuser_id = p[g][c][m].dmUserID;
|
||||
delete p[g][c][m].dmUserID;
|
||||
p[g][c][m] = BDFDB.sortObject(p[g][c][m]);
|
||||
}
|
||||
if (BDFDB.isObjectEmpty(p[g][c][m])) delete p[g][c][m];
|
||||
}
|
||||
if (BDFDB.isObjectEmpty(p[g][c])) delete p[g][c];
|
||||
}
|
||||
if (BDFDB.isObjectEmpty(p[g])) delete p[g];
|
||||
}
|
||||
BDFDB.saveAllData(p, this, "pins");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -254,30 +224,30 @@ class PersonalPins {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messagePinContextEntryMarkup = this.messagePinContextEntryMarkup.replace("REPLACE_context_pinoption_text", this.labels.context_pinoption_text);
|
||||
this.messageUnpinContextEntryMarkup = this.messageUnpinContextEntryMarkup.replace("REPLACE_context_unpinoption_text", this.labels.context_unpinoption_text);
|
||||
|
||||
|
||||
this.notesPopoutMarkup = this.notesPopoutMarkup.replace("REPLACE_popout_note_text", this.labels.popout_note_text);
|
||||
this.notesPopoutMarkup = this.notesPopoutMarkup.replace("REPLACE_popout_channel_text", this.labels.popout_channel_text);
|
||||
this.notesPopoutMarkup = this.notesPopoutMarkup.replace("REPLACE_popout_server_text", this.labels.popout_server_text);
|
||||
this.notesPopoutMarkup = this.notesPopoutMarkup.replace("REPLACE_popout_allservers_text", this.labels.popout_allservers_text);
|
||||
this.notesPopoutMarkup = this.notesPopoutMarkup.replace("REPLACE_popout_sort_text", this.labels.popout_sort_text);
|
||||
this.notesPopoutMarkup = this.notesPopoutMarkup.replace("REPLACE_popout_messagesort_text", this.labels.popout_messagesort_text);
|
||||
|
||||
|
||||
this.messageMarkup = this.messageMarkup.replace("REPLACE_popout_jump_text", this.labels.popout_jump_text);
|
||||
this.messageMarkup = this.messageMarkup.replace("REPLACE_popout_copy_text", this.labels.popout_copy_text);
|
||||
|
||||
|
||||
this.sortPopoutMarkup = this.sortPopoutMarkup.replace("REPLACE_popout_messagesort_text", this.labels.popout_messagesort_text);
|
||||
this.sortPopoutMarkup = this.sortPopoutMarkup.replace("REPLACE_popout_datesort_text", this.labels.popout_datesort_text);
|
||||
|
||||
|
||||
this.popoutPinEntryMarkup = this.popoutPinEntryMarkup.replace("REPLACE_popout_pinoption_text", this.labels.popout_pinoption_text);
|
||||
this.popoutUnpinEntryMarkup = this.popoutUnpinEntryMarkup.replace("REPLACE_popout_unpinoption_text", this.labels.context_unpinoption_text);
|
||||
}
|
||||
|
||||
|
||||
onMessageContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".personalpins-item")) {
|
||||
let pinentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,name:"MessagePinItem"}));
|
||||
|
@ -294,7 +264,7 @@ class PersonalPins {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processHeaderBar (instance, wrapper) {
|
||||
BDFDB.removeEles(".notes-button");
|
||||
let search = wrapper.querySelector(BDFDB.dotCN.channelheadersearch);
|
||||
|
@ -309,7 +279,7 @@ class PersonalPins {
|
|||
BDFDB.createTooltip(this.labels.popout_note_text, icon, {type:"bottom",selector:"note-button-tooltip"});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
processMessage (instance, wrapper) {
|
||||
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton)) {
|
||||
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
|
||||
|
@ -320,7 +290,7 @@ 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);
|
||||
|
@ -333,14 +303,14 @@ class PersonalPins {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
openNotesPopout (button) {
|
||||
let container = document.querySelector(BDFDB.dotCN.popouts);
|
||||
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);
|
||||
BDFDB.initElements(notespopout, this);
|
||||
let buttonrects = BDFDB.getRects(button);
|
||||
notespopout.style.setProperty("left", buttonrects.left + buttonrects.width/2 + "px");
|
||||
notespopout.style.setProperty("top", buttonrects.top + buttonrects.height + "px")
|
||||
|
@ -358,7 +328,7 @@ class PersonalPins {
|
|||
notespopout.querySelector(BDFDB.dotCN.recentmentionsmentionfilter).addEventListener("click", e => {
|
||||
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.addNotes(notespopout);});
|
||||
});
|
||||
|
||||
|
||||
var removePopout = e => {
|
||||
if (!notespopout.contains(e.target) && !BDFDB.getParentEle(".personalpins-sort-popout", e.target)) {
|
||||
document.removeEventListener("mousedown", removePopout);
|
||||
|
@ -367,10 +337,10 @@ class PersonalPins {
|
|||
}
|
||||
};
|
||||
document.addEventListener("mousedown", removePopout);
|
||||
|
||||
|
||||
this.addNotes(notespopout);
|
||||
}
|
||||
|
||||
|
||||
addNotes (notespopout) {
|
||||
BDFDB.removeEles(notespopout.querySelectorAll(BDFDB.dotCNC.messagegroupwrapper + BDFDB.dotCN.messagespopoutchannelseparator));
|
||||
let channel = BDFDB.getSelectedChannel();
|
||||
|
@ -410,7 +380,7 @@ class PersonalPins {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendNote (container, noteData, placeholder) {
|
||||
if (!container || !noteData) return;
|
||||
let server = this.GuildUtils.getGuild(noteData.guild_id) || {};
|
||||
|
@ -507,7 +477,7 @@ class PersonalPins {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
startYoutubeVideo (button) {
|
||||
let embedwrapper = BDFDB.getParentEle(BDFDB.dotCN.embedvideo, button);
|
||||
let ytlink = embedwrapper.parentElement.querySelector(BDFDB.dotCN.embedtitle).href;
|
||||
|
@ -520,7 +490,7 @@ class PersonalPins {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addMessageToNotes (message, target, channel) {
|
||||
if (!message || !target) return;
|
||||
let {messagediv, pos} = this.getMessageAndPos(target);
|
||||
|
@ -564,7 +534,7 @@ class PersonalPins {
|
|||
}
|
||||
else this.removeNoteData(pins[guild_id][channel.id][message.id + "_" + pos]);
|
||||
}
|
||||
|
||||
|
||||
getNoteData (message, target, channel) {
|
||||
if (!message || !target) return;
|
||||
let {messagediv, pos} = this.getMessageAndPos(target);
|
||||
|
@ -574,7 +544,7 @@ class PersonalPins {
|
|||
let guildid = channel.guild_id ? channel.guild_id : "@me";
|
||||
return pins[guildid] && pins[guildid][channel.id] && pins[guildid][channel.id][message.id + "_" + pos] ? pins[guildid][channel.id][message.id + "_" + pos] : null;
|
||||
}
|
||||
|
||||
|
||||
removeNoteData (noteData) {
|
||||
let pins = BDFDB.loadAllData(this, "pins");
|
||||
delete pins[noteData.guild_id][noteData.channel_id][noteData.id + "_" + noteData.pos];
|
||||
|
@ -585,13 +555,13 @@ class PersonalPins {
|
|||
BDFDB.saveAllData(pins, this, "pins");
|
||||
BDFDB.showToast(this.labels.toast_noteremove_text, {type:"danger"});
|
||||
}
|
||||
|
||||
|
||||
getMessageAndPos (target) {
|
||||
let messagediv = BDFDB.getParentEle(BDFDB.dotCN.message, target);
|
||||
let pos = messagediv ? Array.from(messagediv.parentElement.querySelectorAll(BDFDB.dotCN.message)).indexOf(messagediv) : -1;
|
||||
return {messagediv, pos};
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,14 +8,14 @@ class PinDMs {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to pin DMs, making them appear at the top of your DM-list.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"Guilds":"componentDidMount",
|
||||
"DirectMessage":["componentDidMount","componentDidUpdate","componentWillUnmount"],
|
||||
"LazyScroller":"render"
|
||||
};
|
||||
|
||||
|
||||
this.dmContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} pindms-item ${BDFDB.disCN.contextmenuitemsubmenu}">
|
||||
|
@ -23,7 +23,7 @@ class PinDMs {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.dmContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} pindms-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -45,7 +45,7 @@ class PinDMs {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.dmPinContextMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} pinneddm-contextmenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -55,7 +55,7 @@ class PinDMs {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.dmUnpinContextMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} pinneddm-contextmenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -65,7 +65,7 @@ class PinDMs {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.recentDMMarkup =
|
||||
`<div class="${BDFDB.disCN.guild} pinned" style="transform: translateX(0px);">
|
||||
<div class="${BDFDB.disCN.guildinner}" draggable="false" style="border-radius: 25px;">
|
||||
|
@ -75,7 +75,7 @@ class PinDMs {
|
|||
</div>
|
||||
<div class="${BDFDB.disCNS.badge + BDFDB.disCN.badgewrapper}" style="display: none !important;">0</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.guild}.pinned:after {
|
||||
background-position: 50%;
|
||||
|
@ -99,13 +99,13 @@ class PinDMs {
|
|||
background-color: #202225;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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;">Unpin all DMs.</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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -144,7 +144,7 @@ class PinDMs {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels", "getChannel");
|
||||
this.PrivateChannelUtils = BDFDB.WebModules.findByProperties("ensurePrivateChannel");
|
||||
|
@ -152,7 +152,7 @@ class PinDMs {
|
|||
this.UnreadUtils = BDFDB.WebModules.findByProperties("getUnreadCount");
|
||||
this.DiscordConstants = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes", "StatusTypes");
|
||||
this.Animations = BDFDB.WebModules.findByProperties("spring");
|
||||
|
||||
|
||||
BDFDB.addEventListener(this, document, "click", BDFDB.dotCNS.dmchannels + BDFDB.dotCN.dmchannel, e => {
|
||||
let instance = BDFDB.getReactInstance(e.currentTarget);
|
||||
if (BDFDB.getReactValue(instance, "return.return.return.memoizedProps.ispin")) {
|
||||
|
@ -171,7 +171,7 @@ class PinDMs {
|
|||
this.removePinnedDM(BDFDB.getReactValue(instance, "return.return.return.return.return.memoizedProps.channel.id"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.forceAdding = true;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
delete this.forceAdding;
|
||||
|
@ -201,33 +201,33 @@ class PinDMs {
|
|||
dms.splice(insertpoint, amount);
|
||||
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
||||
}
|
||||
|
||||
|
||||
for (let info of BDFDB.readDmList()) {
|
||||
this.unhideNativeDM(info.id);
|
||||
if (info.div) info.div.removeEventListener("contextmenu", info.div.PinDMsContextMenuListener);
|
||||
}
|
||||
BDFDB.removeEles(BDFDB.dotCNS.dms + BDFDB.dotCN.guild + ".pinned");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.dmContextEntryMarkup = this.dmContextEntryMarkup.replace("REPLACE_context_pindm_text", this.labels.context_pindm_text);
|
||||
|
||||
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_pinchannel_text", this.labels.context_pinchannel_text);
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_unpinchannel_text", this.labels.context_unpinchannel_text);
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_pinguild_text", this.labels.context_pinguild_text);
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_unpinguild_text", this.labels.context_unpinguild_text);
|
||||
|
||||
|
||||
this.dmPinContextMarkup = this.dmPinContextMarkup.replace("REPLACE_context_pinguild_text", this.labels.context_pinguild_text);
|
||||
|
||||
|
||||
this.dmUnpinContextMarkup = this.dmUnpinContextMarkup.replace("REPLACE_context_unpinguild_text", this.labels.context_unpinguild_text);
|
||||
}
|
||||
|
||||
|
||||
onUserContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.user && !menu.querySelector(".pindms-item")) {
|
||||
let closeentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleClose"]}));
|
||||
|
@ -238,7 +238,7 @@ class PinDMs {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onGroupDMContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.channelId && !menu.querySelector(".pindms-item")) {
|
||||
let changeentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleChangeIcon"]}));
|
||||
|
@ -247,7 +247,7 @@ class PinDMs {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendItem (instance, id, target) {
|
||||
let dmContextEntry = BDFDB.htmlToElement(this.dmContextEntryMarkup);
|
||||
target.parentElement.insertBefore(dmContextEntry, target);
|
||||
|
@ -304,12 +304,12 @@ class PinDMs {
|
|||
BDFDB.appendSubMenu(pindmsitem, dmContextSubMenu);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
processGuilds (instance, wrapper) {
|
||||
let dms = wrapper.querySelector(BDFDB.dotCN.dms);
|
||||
if (dms) for (let id of this.sortAndUpdate("pinnedRecents")) this.addPinnedRecent(id);
|
||||
}
|
||||
|
||||
|
||||
processDirectMessage (instance, wrapper, methodnames) {
|
||||
if (instance.props && instance.props.channel) {
|
||||
if (methodnames.includes("componentDidMount")) {
|
||||
|
@ -336,7 +336,7 @@ class PinDMs {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processLazyScroller (instance, wrapper) {
|
||||
let privateChannelIds = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.privateChannelIds");
|
||||
if (privateChannelIds) {
|
||||
|
@ -355,7 +355,7 @@ class PinDMs {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getInsertPoint (dms) {
|
||||
let insertpoint = null;
|
||||
for (let i in dms) {
|
||||
|
@ -375,7 +375,7 @@ class PinDMs {
|
|||
}
|
||||
return insertpoint;
|
||||
}
|
||||
|
||||
|
||||
addPinnedDM (id, dms, insertpoint) {
|
||||
for (let ele of dms) if (ele && !ele.pinned && id == ele.key) {
|
||||
ele.pinned = true;
|
||||
|
@ -385,7 +385,7 @@ class PinDMs {
|
|||
dms.splice(insertpoint, 0, dmpin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removePinnedDM (id) {
|
||||
if (!id) return;
|
||||
BDFDB.removeData(id, this, "pinnedDMs");
|
||||
|
@ -409,7 +409,7 @@ class PinDMs {
|
|||
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sortAndUpdate (type) {
|
||||
let pinnedDMs = BDFDB.loadAllData(this, type);
|
||||
delete pinnedDMs[""];
|
||||
|
@ -426,7 +426,7 @@ class PinDMs {
|
|||
BDFDB.saveAllData(pinnedDMs, this, type);
|
||||
return existingDMs;
|
||||
}
|
||||
|
||||
|
||||
forceUpdateScroller (scroller) {
|
||||
if (this.updatingScroller) return;
|
||||
this.updatingScroller = true;
|
||||
|
@ -434,7 +434,7 @@ class PinDMs {
|
|||
if (stateNode) stateNode.updater.enqueueForceUpdate(stateNode);
|
||||
setTimeout(() => {delete this.updatingScroller;},1000);
|
||||
}
|
||||
|
||||
|
||||
addPinnedRecent (id) {
|
||||
let dms = document.querySelector(BDFDB.dotCN.dms);
|
||||
if (dms && !dms.querySelector(`${BDFDB.dotCN.guild}.pinned[channelid="${id}"]`)) {
|
||||
|
@ -478,7 +478,7 @@ class PinDMs {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateUnreadCount (id) {
|
||||
let dmdiv = document.querySelector(`${BDFDB.dotCNS.dms + BDFDB.dotCN.guild}.pinned[channelid="${id}"]`);
|
||||
if (Node.prototype.isPrototypeOf(dmdiv)) {
|
||||
|
@ -489,7 +489,7 @@ class PinDMs {
|
|||
badge.innerText = count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hideNativeDM (id) {
|
||||
let dmdiv = BDFDB.getDmDiv(id);
|
||||
if (Node.prototype.isPrototypeOf(dmdiv)) {
|
||||
|
@ -497,7 +497,7 @@ class PinDMs {
|
|||
BDFDB.addClass(dmdiv, "hidden-by-pin");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unhideNativeDM (id) {
|
||||
let dmdiv = BDFDB.getDmDiv(id);
|
||||
if (Node.prototype.isPrototypeOf(dmdiv) && BDFDB.containsClass(dmdiv, "hidden-by-pin")) {
|
||||
|
@ -505,7 +505,7 @@ class PinDMs {
|
|||
BDFDB.removeClass(dmdiv, "hidden-by-pin");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addHoverBehaviour (div) {
|
||||
/* based on stuff from Zerebos */
|
||||
let divinner = div.querySelector(BDFDB.dotCN.guildinner);
|
||||
|
@ -543,7 +543,7 @@ class PinDMs {
|
|||
div.addEventListener("mouseenter", () => {animate(1);})
|
||||
div.addEventListener("mouseleave", () => {if (!BDFDB.containsClass(div, BDFDB.disCN.guildselected)) animate(0);});
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,12 +8,12 @@ class PluginRepo {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to look at all plugins from the plugin repo and download them on the fly. Repo button is in the plugins settings.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"V2C_List":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.sortings = {
|
||||
sort: {
|
||||
name: "Name",
|
||||
|
@ -28,21 +28,21 @@ class PluginRepo {
|
|||
desc: "Descending"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.loading = {is:false, timeout:null, amount:0};
|
||||
|
||||
|
||||
this.grabbedPlugins = [];
|
||||
this.foundPlugins = [];
|
||||
this.loadedPlugins = {};
|
||||
|
||||
|
||||
this.updateInterval;
|
||||
|
||||
|
||||
this.settingsContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitem} pluginrepo-item">
|
||||
<span>Plugin Repo</span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.pluginRepoLoadingIconMarkup =
|
||||
`<svg class="pluginrepo-loadingicon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="40" height="30" viewBox="0 0 483 382">
|
||||
<path d="M0.000 183.023 L 0.000 366.046 46.377 366.046 L 92.754 366.046 92.754 312.629 L 92.754 259.213 127.223 259.213 C 174.433 259.213,187.432 257.146,210.766 245.926 C 311.105 197.681,301.344 41.358,195.859 7.193 C 173.603 -0.015,173.838 0.000,80.846 0.000 L 0.000 0.000 0.000 183.023 M157.615 88.195 C 193.007 97.413,198.827 152.678,166.407 171.674 C 158.993 176.019,155.494 176.398,122.807 176.398 L 92.754 176.398 92.754 131.677 L 92.754 86.957 122.807 86.957 C 146.807 86.957,153.819 87.206,157.615 88.195" stroke="none" fill="#7289da" fill-rule="evenodd"></path>
|
||||
|
@ -83,7 +83,7 @@ class PluginRepo {
|
|||
<button class="${BDFDB.disCN._reposettingsbutton} btn-download" style="margin-left: 0 !important;">Download</button>
|
||||
</div>
|
||||
</li>`;
|
||||
|
||||
|
||||
this.pluginRepoModalMarkup =
|
||||
`<span class="${this.name}-modal Repo-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -171,7 +171,7 @@ class PluginRepo {
|
|||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.sortPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} pluginrepo-sort-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
|
||||
<div>
|
||||
|
@ -182,7 +182,7 @@ class PluginRepo {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.orderPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} pluginrepo-order-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
|
||||
<div>
|
||||
|
@ -193,7 +193,7 @@ class PluginRepo {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.app} > .repo-loadingwrapper {
|
||||
position: absolute;
|
||||
|
@ -232,7 +232,7 @@ class PluginRepo {
|
|||
pointer-events: none !important;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="DevilBro-settings-inner">`;
|
||||
|
@ -246,7 +246,7 @@ class PluginRepo {
|
|||
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;">Force all Plugins to be fetched again.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} refresh-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Refresh</div></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.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 Plugins from your own list.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} remove-all" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -259,7 +259,7 @@ class PluginRepo {
|
|||
this.loading = {is:false, timeout:null, amount:0};
|
||||
this.loadPlugins();
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -288,11 +288,11 @@ class PluginRepo {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.loadPlugins();
|
||||
|
||||
|
||||
this.updateInterval = setInterval(() => {this.checkForNewPlugins();},1000*60*30);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -305,16 +305,16 @@ class PluginRepo {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
clearInterval(this.updateInterval);
|
||||
clearTimeout(this.loading.timeout);
|
||||
|
||||
|
||||
BDFDB.removeEles("webview[webview-pluginrepo]",".pluginrepo-notice",".bd-pluginrepobutton",".pluginrepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
onUserSettingsCogContextMenu (instance, menu) {
|
||||
let observer = new MutationObserver(changes => {
|
||||
changes.forEach(change => {
|
||||
|
@ -337,7 +337,7 @@ class PluginRepo {
|
|||
});
|
||||
observer.observe(menu, {childList: true, subtree:true});
|
||||
}
|
||||
|
||||
|
||||
processV2CList (instance, wrapper) {
|
||||
if (!document.querySelector(".bd-pluginrepobutton") && window.PluginUpdates && window.PluginUpdates.plugins && instance._reactInternalFiber.key && instance._reactInternalFiber.key.split("-")[0] == "plugin") {
|
||||
var folderbutton = document.querySelector(BDFDB.dotCN._repofolderbutton);
|
||||
|
@ -348,12 +348,12 @@ class PluginRepo {
|
|||
});
|
||||
repoButton.addEventListener("mouseenter", () => {
|
||||
BDFDB.createTooltip("Open Plugin Repo", repoButton, {type:"top",selector:"pluginrepo-button-tooltip"});
|
||||
});
|
||||
});
|
||||
folderbutton.parentElement.insertBefore(repoButton, folderbutton.nextSibling);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
addPluginToOwnList (settingspanel) {
|
||||
var pluginUrlInput = settingspanel.querySelector("#input-pluginurl");
|
||||
var pluginList = settingspanel.querySelector(".plugin-list");
|
||||
|
@ -370,7 +370,7 @@ class PluginRepo {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removePluginFromOwnList (e) {
|
||||
var entry = e.currentTarget.parentElement;
|
||||
var url = entry.querySelector(".entryurl").textContent;
|
||||
|
@ -379,20 +379,20 @@ class PluginRepo {
|
|||
BDFDB.removeFromArray(ownlist, url);
|
||||
BDFDB.saveData("ownlist", ownlist, this, "ownlist");
|
||||
}
|
||||
|
||||
|
||||
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(settingspanel.querySelector(BDFDB.dotCN.hovercard));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
openPluginRepoModal (showOnlyOutdated = false) {
|
||||
if (this.loading.is) {
|
||||
BDFDB.showToast(`Plugins are still being fetched. Try again in some seconds.`, {type:"danger"});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var pluginRepoModal = BDFDB.htmlToElement(this.pluginRepoModalMarkup);
|
||||
var hiddenSettings = BDFDB.loadAllData(this, "hidden");
|
||||
pluginRepoModal.querySelector("#input-hideupdated").checked = hiddenSettings.updated || showOnlyOutdated;
|
||||
|
@ -400,7 +400,7 @@ class PluginRepo {
|
|||
pluginRepoModal.querySelector("#input-hidedownloadable").checked = hiddenSettings.downloadable || showOnlyOutdated;
|
||||
if (!BDFDB.isRestartNoMoreEnabled()) pluginRepoModal.querySelector("#RNMoption").remove();
|
||||
else pluginRepoModal.querySelector("#input-rnmstart").checked = BDFDB.loadData("RNMstart", this, "settings");
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(pluginRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => {
|
||||
clearTimeout(pluginRepoModal.searchTimeout);
|
||||
pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000);
|
||||
|
@ -428,7 +428,7 @@ class PluginRepo {
|
|||
this.sortEntries(pluginRepoModal);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let favorites = BDFDB.loadAllData(this, "favorites");
|
||||
let container = pluginRepoModal.querySelector(".plugins");
|
||||
pluginRepoModal.entries = {};
|
||||
|
@ -452,12 +452,12 @@ class PluginRepo {
|
|||
this.addEntry(pluginRepoModal, container, data);
|
||||
}
|
||||
this.sortEntries(pluginRepoModal);
|
||||
|
||||
|
||||
BDFDB.appendModal(pluginRepoModal);
|
||||
|
||||
|
||||
pluginRepoModal.querySelector(BDFDB.dotCN.searchbarinput).focus();
|
||||
}
|
||||
|
||||
|
||||
addEntry (pluginRepoModal, container, data) {
|
||||
if (!pluginRepoModal || !container || !data) return;
|
||||
let entry = BDFDB.htmlToElement(this.pluginEntryMarkup);
|
||||
|
@ -513,9 +513,9 @@ class PluginRepo {
|
|||
this.downloadPlugin(data);
|
||||
if (pluginRepoModal.querySelector("#input-rnmstart").checked) setTimeout(() => {this.startPlugin(data);},3000);
|
||||
});
|
||||
|
||||
|
||||
container.appendChild(entry);
|
||||
|
||||
|
||||
function setEntryState (state) {
|
||||
data.state = state;
|
||||
BDFDB.toggleClass(entry, "downloadable", state > 1);
|
||||
|
@ -527,28 +527,28 @@ class PluginRepo {
|
|||
pluginRepoModal.entries[data.url] = data;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
sortEntries (pluginRepoModal) {
|
||||
if (!pluginRepoModal || typeof pluginRepoModal.entries != "object") return;
|
||||
|
||||
|
||||
let container = pluginRepoModal.querySelector(".plugins");
|
||||
if (!container) return;
|
||||
|
||||
|
||||
let searchstring = pluginRepoModal.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase();
|
||||
|
||||
|
||||
let entries = pluginRepoModal.entries;
|
||||
if (pluginRepoModal.querySelector("#input-hideupdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state < 1 ? null : entry;});
|
||||
if (pluginRepoModal.querySelector("#input-hideoutdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state == 1 ? null : entry;});
|
||||
if (pluginRepoModal.querySelector("#input-hidedownloadable").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state > 1 ? null : entry;});
|
||||
entries = BDFDB.filterObject(entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;});
|
||||
|
||||
|
||||
entries = BDFDB.sortObject(entries, pluginRepoModal.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option"));
|
||||
if (pluginRepoModal.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option") == "desc") entries = BDFDB.reverseObject(entries);
|
||||
|
||||
|
||||
let entrypositions = Object.keys(entries);
|
||||
|
||||
|
||||
pluginRepoModal.querySelector(".pluginAmount").innerText = "PluginRepo Repository " + entrypositions.length + "/" + Object.keys(this.loadedPlugins).length + " Plugins";
|
||||
|
||||
|
||||
for (let li of container.children) {
|
||||
let pos = entrypositions.indexOf(li.getAttribute("data-url"));
|
||||
if (pos > -1) {
|
||||
|
@ -561,7 +561,7 @@ class PluginRepo {
|
|||
BDFDB.toggleEles(li, pos > -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadPlugins () {
|
||||
BDFDB.removeEles("webview[webview-pluginrepo]",".pluginrepo-loadingicon");
|
||||
var getPluginInfo, createWebview, runInWebview;
|
||||
|
@ -589,7 +589,7 @@ class PluginRepo {
|
|||
var loadingicon = BDFDB.htmlToElement(this.pluginRepoLoadingIconMarkup);
|
||||
loadingicon.addEventListener("mouseenter", () => {BDFDB.createTooltip("Loading PluginRepo",loadingicon,{type:"left",delay:500});})
|
||||
loadingiconwrapper.appendChild(loadingicon);
|
||||
|
||||
|
||||
createWebview().then(() => {
|
||||
getPluginInfo(() => {
|
||||
if (!this.started) {
|
||||
|
@ -632,7 +632,7 @@ class PluginRepo {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
getPluginInfo = (callback) => {
|
||||
if (i >= this.foundPlugins.length || !this.started || !this.loading.is) {
|
||||
callback();
|
||||
|
@ -713,7 +713,7 @@ class PluginRepo {
|
|||
getPluginInfo(callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createWebview = () => {
|
||||
return new Promise(function(callback) {
|
||||
webview = document.createElement("webview");
|
||||
|
@ -731,7 +731,7 @@ class PluginRepo {
|
|||
document.body.appendChild(webview);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
runInWebview = () => {
|
||||
if (webviewrunning) return;
|
||||
let webviewdata = webviewqueue.shift();
|
||||
|
@ -764,7 +764,7 @@ class PluginRepo {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkForNewPlugins () {
|
||||
let request = require("request");
|
||||
request("https://mwittrien.github.io/BetterDiscordAddons/Plugins/PluginRepo/res/PluginList.txt", (error, response, result) => {
|
||||
|
@ -774,7 +774,7 @@ class PluginRepo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
downloadPlugin (data) {
|
||||
let request = require("request");
|
||||
request(data.url, (error, response, body) => {
|
||||
|
@ -787,7 +787,7 @@ class PluginRepo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createPluginFile (filename, content) {
|
||||
let fileSystem = require("fs");
|
||||
let path = require("path");
|
||||
|
@ -801,7 +801,7 @@ class PluginRepo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
startPlugin (data) {
|
||||
var name = data.name;
|
||||
if (BDFDB.isPluginEnabled(name) == false) {
|
||||
|
@ -811,7 +811,7 @@ class PluginRepo {
|
|||
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Started Plugin " + name + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deletePluginFile (data) {
|
||||
let fileSystem = require("fs");
|
||||
let path = require("path");
|
||||
|
@ -823,7 +823,7 @@ class PluginRepo {
|
|||
else BDFDB.showToast(`Successfully deleted Plugin "${filename}".`, {type:"success"});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
stopPlugin (data) {
|
||||
var name = data.name;
|
||||
if (BDFDB.isPluginEnabled(name) == true) {
|
||||
|
|
|
@ -6,15 +6,15 @@ class ReadAllNotificationsButton {
|
|||
getVersion () {return "1.3.9";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
||||
getDescription () {return "Adds a button to clear all notifications.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"Guilds":"componentDidMount",
|
||||
"RecentMentions":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.RANbuttonMarkup =
|
||||
`<div class="${BDFDB.disCN.guild} RANbutton-frame" id="bd-pub-li" style="height: 20px; margin-bottom: 10px;">
|
||||
<div class="${BDFDB.disCN.guildinner}" style="height: 20px; border-radius: 4px;">
|
||||
|
@ -23,19 +23,19 @@ class ReadAllNotificationsButton {
|
|||
</a>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.RAMbuttonMarkup =
|
||||
`<button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow} RAMbutton" style="flex: 0 0 auto; margin-left: 25px; height: 25px;">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">Clear Mentions</div>
|
||||
</button>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
includeMuted: {value:false, description:"Include muted Servers (means more API-Requests):"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -44,7 +44,7 @@ class ReadAllNotificationsButton {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -77,7 +77,7 @@ class ReadAllNotificationsButton {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -92,10 +92,10 @@ class ReadAllNotificationsButton {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processGuilds (instance, wrapper) {
|
||||
BDFDB.removeEles(".RANbutton-frame");
|
||||
let guildseparator = wrapper.querySelector(BDFDB.dotCN.guildseparator);
|
||||
|
@ -108,7 +108,7 @@ class ReadAllNotificationsButton {
|
|||
BDFDB.addClass(wrapper, "RAN-added");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processRecentMentions (instance, wrapper) {
|
||||
BDFDB.removeEles(".RAMbutton");
|
||||
if (instance.props && instance.props.popoutName == "RECENT_MENTIONS_POPOUT") {
|
||||
|
@ -121,7 +121,7 @@ class ReadAllNotificationsButton {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
clearMentions (instance, wrapper) {
|
||||
let closebuttons = wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
|
||||
for (let btn of wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton)) btn.click();
|
||||
|
|
|
@ -8,7 +8,7 @@ class RemoveNicknames {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Replace all nicknames with the actual accountnames.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"NameTag":"componentDidMount",
|
||||
|
@ -17,7 +17,7 @@ class RemoveNicknames {
|
|||
"Clickable":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
replaceOwn: {value:false, description:"Replace your own name:"},
|
||||
|
@ -26,7 +26,7 @@ class RemoveNicknames {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -35,7 +35,7 @@ class RemoveNicknames {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
;
|
||||
|
@ -67,14 +67,14 @@ class RemoveNicknames {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.reseting = false;
|
||||
|
||||
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
this.MemberStore = BDFDB.WebModules.findByProperties("getNicknames", "getNick");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -86,16 +86,16 @@ class RemoveNicknames {
|
|||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.reseting = true;
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
getNewName (info) {
|
||||
if (!info) return null;
|
||||
let EditUsersData = BDFDB.isPluginEnabled("EditUsers") ? BDFDB.loadData(info.id, "EditUsers", "users") : null;
|
||||
|
@ -106,12 +106,12 @@ class RemoveNicknames {
|
|||
if (this.reseting) return member.nick || info.username;
|
||||
return settings.addNickname ? (settings.swapPositions ? (member.nick + " (" + info.username + ")") : (info.username + " (" + member.nick + ")")) : info.username;
|
||||
}
|
||||
|
||||
|
||||
processNameTag (instance, wrapper) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
processMessageUsername (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message) {
|
||||
|
@ -119,14 +119,14 @@ class RemoveNicknames {
|
|||
if (username) BDFDB.setInnerText(username, this.getNewName(message.author));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processFluxContainerTypingUsers (instance, wrapper) {
|
||||
let users = !instance.state.typingUsers ? [] : Object.keys(instance.state.typingUsers).filter(id => id != BDFDB.myData.id).filter(id => !this.RelationshipUtils.isBlocked(id)).map(id => this.UserUtils.getUser(id)).filter(id => id != null);
|
||||
wrapper.querySelectorAll("strong").forEach((username, i) => {
|
||||
if (users[i] && username) BDFDB.setInnerText(username, this.getNewName(users[i]));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
processClickable (instance, wrapper) {
|
||||
if (!wrapper || !instance.props || !instance.props.className) return;
|
||||
if (instance.props.tag == "a" && instance.props.className.indexOf(BDFDB.disCN.anchorunderlineonhover) > -1) {
|
||||
|
@ -154,7 +154,7 @@ class RemoveNicknames {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
|
|
|
@ -8,14 +8,14 @@ class RepoControls {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Lets you sort and filter your list of downloaded Themes and Plugins.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"V2C_List":"componentDidMount",
|
||||
"V2C_PluginCard": ["componentDidMount","componentDidUpdate"],
|
||||
"V2C_ThemeCard": ["componentDidMount","componentDidUpdate"]
|
||||
};
|
||||
|
||||
|
||||
this.sortings = {
|
||||
sort: {
|
||||
name: "Name",
|
||||
|
@ -31,7 +31,7 @@ class RepoControls {
|
|||
desc: "Descending"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.repoControlsMarkup =
|
||||
`<div class="repo-controls ${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;">
|
||||
<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;">
|
||||
|
@ -64,7 +64,7 @@ class RepoControls {
|
|||
</div>
|
||||
</div>
|
||||
</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);">
|
||||
<div>
|
||||
|
@ -75,7 +75,7 @@ class RepoControls {
|
|||
</div>
|
||||
</div>
|
||||
</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);">
|
||||
<div>
|
||||
|
@ -86,13 +86,13 @@ class RepoControls {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.deleteButtonMarkup =
|
||||
`<svg class="trashIcon" fill="currentColor" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" transform="translate(2,1.5)">
|
||||
<path d="M 18.012, 0.648 H 12.98 C 12.944, 0.284, 12.637, 0, 12.264, 0 H 8.136 c -0.373, 0 -0.68, 0.284 -0.716, 0.648 H 2.389 c -0.398, 0 -0.72, 0.322 -0.72, 0.72 v 1.368 c 0, 0.398, 0.322, 0.72, 0.72, 0.72 h 15.623 c 0.398, 0, 0.72 -0.322, 0.72 -0.72 V 1.368 C 18.731, 0.97, 18.409, 0.648, 18.012, 0.648 z"/>
|
||||
<path d="M 3.178, 4.839 v 14.841 c 0, 0.397, 0.322, 0.72, 0.72, 0.72 h 12.604 c 0.398, 0, 0.72 -0.322, 0.72 -0.72 V 4.839 H 3.178 z M 8.449, 15.978 c 0, 0.438 -0.355, 0.794 -0.794, 0.794 c -0.438, 0 -0.794 -0.355 -0.794 -0.794 V 8.109 c 0 -0.438, 0.355 -0.794, 0.794 -0.794 c 0.438, 0, 0.794, 0.355, 0.794, 0.794 V 15.978 z M 13.538, 15.978 c 0, 0.438 -0.355, 0.794 -0.794, 0.794 s -0.794 -0.355 -0.794 -0.794 V 8.109 c 0 -0.438, 0.355 -0.794, 0.794 -0.794 c 0.438, 0, 0.794, 0.355, 0.794, 0.794 V 15.978 z"/>
|
||||
</svg>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
#bd-settingspane-container .trashIcon {
|
||||
margin-right: 5px;
|
||||
|
@ -103,7 +103,7 @@ class RepoControls {
|
|||
${BDFDB.dotCN.themedark} #bd-settingspane-container .trashIcon {
|
||||
color: #dcddde;
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addDeleteButton: {value:true, description:"Add a Delete Button to your Plugin and Theme List."},
|
||||
|
@ -115,7 +115,7 @@ class RepoControls {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -124,7 +124,7 @@ class RepoControls {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -157,11 +157,11 @@ class RepoControls {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.fs = require("fs");
|
||||
this.path = require("path");
|
||||
this.dirs = {theme: BDFDB.getThemesFolder(), plugin: BDFDB.getPluginsFolder()};
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -174,7 +174,7 @@ class RepoControls {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".repo-controls","#bd-settingspane-container .trashIcon");
|
||||
BDFDB.removeClasses("repocontrols-added");
|
||||
|
||||
|
||||
for (let list of document.querySelectorAll(BDFDB.dotCNS._repolist)) {
|
||||
list.style.removeProperty("display");
|
||||
list.style.removeProperty("flex-direction");
|
||||
|
@ -185,32 +185,32 @@ class RepoControls {
|
|||
if (checkbox) checkbox.removeEventListener("change", checkbox.changeRepoControlsListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processV2CList (instance, container) {
|
||||
if (instance._reactInternalFiber.key) this.addControls(instance._reactInternalFiber.key.split("-")[0], container);
|
||||
}
|
||||
|
||||
|
||||
processV2CPluginCard (instance, wrapper, methodnames) {
|
||||
if (wrapper.querySelector(BDFDB.dotCN._reponame)) {
|
||||
if (instance.props && BDFDB.getData("addDeleteButton", this, "settings")) this.addDeleteButton("plugin", wrapper);
|
||||
if (methodnames.includes("componentDidUpdate")) this.changeTextToHTML(wrapper, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processV2CThemeCard (instance, wrapper, methodnames) {
|
||||
if (wrapper.querySelector(BDFDB.dotCN._reponame)) {
|
||||
if (instance.props && BDFDB.getData("addDeleteButton", this, "settings")) this.addDeleteButton("theme", wrapper);
|
||||
if (methodnames.includes("componentDidUpdate")) this.changeTextToHTML(wrapper, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addDeleteButton (type, wrapper) {
|
||||
if (!type || !wrapper || wrapper.querySelector(".trashIcon")) return;
|
||||
let name = wrapper.getAttribute("data-name");
|
||||
|
@ -236,27 +236,27 @@ class RepoControls {
|
|||
let controls = wrapper.querySelector(BDFDB.dotCN._repocontrols);
|
||||
if (controls) controls.insertBefore(button, controls.firstElementChild);
|
||||
}
|
||||
|
||||
|
||||
addControls (type, container) {
|
||||
if (!type || !container) return;
|
||||
BDFDB.removeEles(".repo-controls");
|
||||
|
||||
|
||||
container.style.setProperty("display", "flex", "important");
|
||||
container.style.setProperty("flex-direction", "column", "important");
|
||||
|
||||
|
||||
let sortings = BDFDB.getAllData(this, "sortings");
|
||||
|
||||
|
||||
let repocontrols = BDFDB.htmlToElement(this.repoControlsMarkup);
|
||||
BDFDB.initElements(repocontrols);
|
||||
BDFDB.initElements(repocontrols, this);
|
||||
container.parentElement.insertBefore(repocontrols, container);
|
||||
|
||||
|
||||
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);
|
||||
|
@ -282,9 +282,9 @@ class RepoControls {
|
|||
this.sortEntries(container, repocontrols);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
BDFDB.addClass(container, "repocontrols-added");
|
||||
|
||||
|
||||
container.entries = {};
|
||||
for (let li of container.children) {
|
||||
if (li.querySelector(BDFDB.dotCN._reponame)) {
|
||||
|
@ -312,11 +312,11 @@ class RepoControls {
|
|||
}
|
||||
this.sortEntries(container, repocontrols);
|
||||
}
|
||||
|
||||
|
||||
sortEntries (container, repocontrols) {
|
||||
if (typeof container.entries != "object") return;
|
||||
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;});
|
||||
entries = BDFDB.sortObject(entries, sortings.sort);
|
||||
|
@ -339,7 +339,7 @@ class RepoControls {
|
|||
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)) {
|
||||
|
@ -351,7 +351,7 @@ class RepoControls {
|
|||
else if (searchstring && searchstring.length > 2 || ele.querySelector(BDFDB.dotCN.highlight)) ele.innerHTML = BDFDB.highlightText(ele.innerText, searchstring);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toggleAll (type, container, enable) {
|
||||
BDFDB.openConfirmModal(this, `Are you sure you want to ${enable ? "enable" : "disable"} all ${type[0].toUpperCase() + type.slice(1)}s?`, () => {
|
||||
for (let header of container.querySelectorAll(BDFDB.dotCN._repoheader)) {
|
||||
|
|
|
@ -4,14 +4,14 @@ 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";
|
||||
|
||||
|
||||
this.defaults = {
|
||||
engines: {
|
||||
_all: {value:true, name:BDFDB.getLibraryStrings().btn_all_text, url:null},
|
||||
|
@ -35,8 +35,8 @@ class ReverseImageSearch {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.messageContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} reverseimagesearch-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -59,14 +59,14 @@ class ReverseImageSearch {
|
|||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
//legacy
|
||||
load () {}
|
||||
|
||||
|
@ -103,20 +103,20 @@ class ReverseImageSearch {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messageContextSubMenuMarkup = this.messageContextSubMenuMarkup.replace("REPLACE_submenu_disabled_text", this.labels.submenu_disabled_text);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onMessageContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".reverseimagesearch-item")) {
|
||||
if (instance.props.attachment) {
|
||||
|
@ -134,7 +134,7 @@ class ReverseImageSearch {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendItem (instance, menu, url) {
|
||||
if (instance && menu && url) {
|
||||
if (url.indexOf("discordapp.com/assets/") == -1) {
|
||||
|
@ -163,7 +163,7 @@ class ReverseImageSearch {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,16 +8,16 @@ class SendLargeMessages {
|
|||
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 = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.messageDelay = 1000; //changing at own risk, might result in bans or mutes
|
||||
|
||||
|
||||
this.css = `
|
||||
.${this.name}-modal textarea {
|
||||
rows: 0;
|
||||
|
@ -28,7 +28,7 @@ class SendLargeMessages {
|
|||
.${this.name}-modal #warning-message {
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal #character-counter {
|
||||
float: right;
|
||||
color: white;
|
||||
|
@ -100,9 +100,9 @@ class SendLargeMessages {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.clipboard = require("electron").clipboard;
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -112,12 +112,12 @@ class SendLargeMessages {
|
|||
|
||||
|
||||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
|
@ -125,7 +125,7 @@ class SendLargeMessages {
|
|||
this.sendMessageModalMarkup = this.sendMessageModalMarkup.replace("REPLACE_btn_cancel_text", this.labels.btn_cancel_text);
|
||||
this.sendMessageModalMarkup = this.sendMessageModalMarkup.replace("REPLACE_btn_send_text", this.labels.btn_send_text);
|
||||
}
|
||||
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
if (instance.props && instance.props.type && instance.props.type == "normal") {
|
||||
var textarea = wrapper.querySelector("textarea");
|
||||
|
@ -151,22 +151,22 @@ class SendLargeMessages {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showSendModal (text) {
|
||||
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.value);
|
||||
let messageAmount = Math.ceil(parsedlength/1900);
|
||||
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);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(sendMessageModal, "click", ".btn-send", e => {
|
||||
e.preventDefault();
|
||||
let messages = this.formatText(textinput.value || "");
|
||||
|
@ -177,7 +177,7 @@ class SendLargeMessages {
|
|||
},this.messageDelay * i);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
textinput.value = text || "";
|
||||
textinput.addEventListener("keyup", () => {setTimeout(() => {updateCounter();},10);});
|
||||
textinput.addEventListener("click", () => {updateCounter();});
|
||||
|
@ -195,7 +195,7 @@ class SendLargeMessages {
|
|||
updateCounter();
|
||||
textinput.focus();
|
||||
}
|
||||
|
||||
|
||||
formatText (text) {
|
||||
text = text.replace(new RegExp("\t", 'g'), " ");
|
||||
let longwords = text.match(/[\S]{1800,}/gm);
|
||||
|
@ -215,7 +215,7 @@ class SendLargeMessages {
|
|||
if (messages[count2] && BDFDB.getParsedLength(messages[count2] + "" + word) > 1900) count2++;
|
||||
messages[count2] = messages[count2] ? messages[count2] + " " + word : word;
|
||||
});
|
||||
|
||||
|
||||
let insertCodeBlock = null, insertCodeLine = null;
|
||||
for (let j = 0; j < messages.length; j++) {
|
||||
if (insertCodeBlock) {
|
||||
|
@ -226,10 +226,10 @@ class SendLargeMessages {
|
|||
messages[j] = insertCodeLine + messages[j];
|
||||
insertCodeLine = null;
|
||||
}
|
||||
|
||||
|
||||
let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
|
||||
let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
|
||||
|
||||
|
||||
if (codeBlocks && codeBlocks.length % 2 == 1) {
|
||||
messages[j] = messages[j] + "```";
|
||||
insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n";
|
||||
|
@ -239,10 +239,10 @@ class SendLargeMessages {
|
|||
messages[j] = messages[j] + insertCodeLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
sendMessage (text) {
|
||||
let textarea = document.querySelector(BDFDB.dotCNS.textareawrapchat + "textarea");
|
||||
if (textarea) {
|
||||
|
@ -253,7 +253,7 @@ class SendLargeMessages {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,15 +8,15 @@ class ServerFolders {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds the feature to create folders to organize your servers. Right click a server > 'Serverfolders' > 'Create Server' to create a server. To add servers to a folder hold 'Ctrl' and drag the server onto the folder, this will add the server to the folderlist and hide it in the serverlist. To open a folder click the folder. A folder can only be opened when it has at least one server in it. To remove a server from a folder, open the folder and either right click the server > 'Serverfolders' > 'Remove Server from Folder' or hold 'Del' and click the server in the folderlist.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"Guilds":"componentDidMount",
|
||||
"Guild":["componentDidMount","componentWillUnmount"]
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
.${this.name}-modal .ui-icon-picker-icon {
|
||||
position: relative;
|
||||
|
@ -99,7 +99,7 @@ class ServerFolders {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} serverfolders-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -113,7 +113,7 @@ class ServerFolders {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.folderContextMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} serverfolder-contextmenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -145,14 +145,14 @@ class ServerFolders {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.folderContentMarkup =
|
||||
`<div class="${BDFDB.disCN.guildswrapper} foldercontent foldercontentclosed">
|
||||
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.firefoxfixscrollflex + BDFDB.disCNS.guildsscrollerwrap + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.themeghosthairline}">
|
||||
<div class="${BDFDB.disCNS.guilds + BDFDB.disCN.scroller}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.folderIconMarkup =
|
||||
`<div class="${BDFDB.disCN.guild} folder">
|
||||
<div draggable="true">
|
||||
|
@ -291,8 +291,8 @@ class ServerFolders {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
</span>`;
|
||||
|
||||
this.folderIcons = [
|
||||
{"openicon":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAAB2ElEQVR4Xu2Z4W6DMAwG4f0fmqloq0YJw0dIhLPb7y+qfT0Hr8yTf2ECczhpcBIWkEBYwgIEQFSzhAUIgKhmCQsQAFHNEhYgAKKaJSxAAETvMGsBn1eK3lFDZQmx4zWF1kL6rLCmlli3lamrBd4N6qeNq/VUYogdv1JcK1CPByasmFRrisJqbdWj7RLWAGaBFi5FqSSPHsNLBOAhDIwe6HVnwb4vx1H/KDxN02iw0ENOWGAjEJaw0B0WFiYc/P547yzwPYwI66j9nUiadW7Km5GwzmG91wthCStGAKRWqbqatSw5ng/zXL7bu8FKDKr/nSWs4NAnB9XXLGEFrXrFksPqt5QmB7XZGJo/DZPD2vBpCis5qN0eKqzXZr5fQosLezNYo1nV9N8dYYG3O8lhFSeuyRgmB3U4ccLaL9eHTG6HNapVTS745LD+lEeztmPYD9bIVt0+hsLaanr4I3pyUCFxbruzksMKcQiFfsk1qlkhDqHQGaz/YFVoTj8W3Bwv/sBP3uTdKTVr/Umd1fLoNOofhc/G8dFYysWh/lF4sJHEveMDhS8o01hW9Vt1OOHYVZUsLIBPWMICBEBUs4QFCICoZgkLEABRzRIWIACimiUsQABENQvA+gLIy3lMlnMoMQAAAABJRU5ErkJggg==",
|
||||
"closedicon":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAABkElEQVR4Xu3a6xKCIABEYXz/h7bpOl1M94CWMqffywRfK1I2FF+xwBAnDRaxQAnEEgsIgKjNEgsIgKjNEgsIgKjNEgsIgKjNEgsIgOgazRrB+01F15hD4xSy4S0TbUV6n2HLXLLVNqZqJ7g21H0ZtfNpZMiG10xuK6jdg4mVleqSolhbt2rX7RKrg2aBJVRFaUl2fRlWCcBBGIwO+NWeBdddHUfrR+FSSm9Y6CYnFjgRNGON43HKNgyTy40N4uBtV3iRORLU4wD3CRYbxEGxwPUqlli/uxu6Z82f79zgwflXLLEyAY8O4CYnlljfL6uJrzxxYeKgh1JQQbHE8gQ/dxBwz8qOSdeHDv5Ek2uJlVvZLGAlllhEAGTds8QCAiBqs8QCAiBqs8QCAiBqs8QCAiD6t2ad53ikB61//ReNWOCJNGj/nqPxc4g4+LTa4/x7bfkjQutH4c7A8NrxgE7AqtZdNWi53X0mxAKfq1hiAQEQtVliAQEQtVliAQEQtVliAQEQtVliAQEQtVliAQEQPQHGLZBMBnSlGQAAAABJRU5ErkJggg=="},
|
||||
|
@ -309,7 +309,7 @@ class ServerFolders {
|
|||
{"openicon":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAABrklEQVR4Xu3ayZLCMAxFUfz/H50upnQanFjXdi8SXba8TAdJGBfl5issUMJJgzexQBGIJRYQAFErSywgAKJWllhAAEStLLGAAIhaWWIBARC1ssQCAiDaU1kLOH8t2nPNwUvOOZze+CjU+67pdec87eBZ6E3PwrrfNr324KOOH05veCbW6cCGsJZltt34p986QymFPvN6SnrgqnNGqHVgdoJ1YZ0Z6tH7YrUa8Pd9seJWj2QPWMo2fGHhb+PsWAhMLLA4Fkus9rTfrB7CBXMUPN/yvG0USeya7L2RFepwV6SGlR1qF0ys/cb8shFLrMgcb2asrCbR5vf2Z9Y2tA1B/Qxi3Q/Pvnyorj9dlNYrSyzQnGL9F1bmuYV/SItVKUO3aL5RrKzReRXZrM+23jrcNW1tqYq1KUmx/vanlTVjXkVmVqYlRKvLQv++yzK3xJrVgrYhGO5RrAxzq9mCYh3st9faNySaYOc05BAKifWssyjWledW2CAcvHB1hQ3CQbBeuWxULPDRiiUWEABRK0ssIACiVpZYQABErSyxgACIWlliAQEQtbLEAgIgamUBrB+JEUtMl61hQwAAAABJRU5ErkJggg==",
|
||||
"closedicon":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAABhUlEQVR4Xu3YwQqDMBBF0eT/P9oiVAji4l1rIh1u1w8zHifTaG/+YoEeJw02sUATiCUWEABRO0ssIACidpZYQABE7SyxgACI2lliAQEQtbPEAgIgeqezNnD9q+idNa+us7wOWvivBR43Tdc9Y71SBy36qSL3m6drH2BP1oDqoAW/VuhX6un112Ft24zarydi7/S5xpM1vnAcPD/ZIlDzO6sQVB2siVtv3KPx7oqD4zZc0VmLoOZ3Vjw6/yMYN0wcnPjX/TZpbBAHW2vrzglr+WKDOCgWe+Wws0DHiyVW/kLvzAKjSCyxwHARSywkAMLxKIqDHkrBfhVLrGmfaDzBg0Eolli+7oAeEEssIgCy8VkzDnrO8pzlOQtsQbHEggIgHs/tOOiAd8A7s8AWFEssKADi8dyOgw54B7wzC2zBaVj7hat9LSVjKP/wNTytKmAICrUgbO2ScaxbUiG8KbFCKLchgBJLLCgA4s4ssYAAiNpZYgEBELWzxAICIGpniQUEQNTOAlgf/fBATBZ555AAAAAASUVORK5CYII="}
|
||||
];
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
closeOtherFolders: {value:false, description:"Close other Folders when opening a Folder."},
|
||||
|
@ -321,7 +321,7 @@ class ServerFolders {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -332,7 +332,7 @@ class ServerFolders {
|
|||
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 Folders.</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 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 custom Icons.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} removecustom-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);
|
||||
|
@ -376,13 +376,13 @@ class ServerFolders {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
if (BDFDB.isPluginEnabled("HideUtils") && !BDFDB.loadData("hideutils", this, "warnings")) BDFDB.openConfirmModal(this, this.name + " is not compartible with the plugin HideUtils by Arashiryuu. You might expierence bugs like Servers that should be hidden due to being part of a Folder still being visible in the Guildlist. To avoid this disable the Plugin HideUtils. Press the " + BDFDB.getLibraryStrings().btn_ok_text + "-Button to not show this Message again.", "Warning", () => {BDFDB.saveData("hideutils", true, this, "warnings")});
|
||||
|
||||
|
||||
this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
|
||||
this.DiscordConstants = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes", "StatusTypes");
|
||||
this.Animations = BDFDB.WebModules.findByProperties("spring");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this, "Guilds");
|
||||
}
|
||||
else {
|
||||
|
@ -407,22 +407,22 @@ class ServerFolders {
|
|||
this.openCloseFolder(folderdiv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.serverContextEntryMarkup = this.serverContextEntryMarkup.replace("REPLACE_servercontext_serverfolders_text", this.labels.servercontext_serverfolders_text);
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_serversubmenu_createfolder_text", this.labels.serversubmenu_createfolder_text);
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_serversubmenu_removefromfolder_text", this.labels.serversubmenu_removefromfolder_text);
|
||||
|
||||
|
||||
this.folderContextMarkup = this.folderContextMarkup.replace("REPLACE_foldercontext_unreadfolder_text", this.labels.foldercontext_unreadfolder_text);
|
||||
this.folderContextMarkup = this.folderContextMarkup.replace("REPLACE_foldercontext_autounreadfolder_text", this.labels.foldercontext_autounreadfolder_text);
|
||||
this.folderContextMarkup = this.folderContextMarkup.replace("REPLACE_foldercontext_foldersettings_text", this.labels.foldercontext_foldersettings_text);
|
||||
this.folderContextMarkup = this.folderContextMarkup.replace("REPLACE_foldercontext_createfolder_text", this.labels.serversubmenu_createfolder_text);
|
||||
this.folderContextMarkup = this.folderContextMarkup.replace("REPLACE_foldercontext_removefolder_text", this.labels.foldercontext_removefolder_text);
|
||||
|
||||
|
||||
this.folderSettingsModalMarkup = this.folderSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.folderSettingsModalMarkup = this.folderSettingsModalMarkup.replace("REPLACE_modal_foldername_text", this.labels.modal_foldername_text);
|
||||
this.folderSettingsModalMarkup = this.folderSettingsModalMarkup.replace("REPLACE_modal_tabheader1_text", this.labels.modal_tabheader1_text);
|
||||
|
@ -439,7 +439,7 @@ class ServerFolders {
|
|||
this.folderSettingsModalMarkup = this.folderSettingsModalMarkup.replace("REPLACE_modal_customclosed_text", this.labels.modal_customclosed_text);
|
||||
this.folderSettingsModalMarkup = this.folderSettingsModalMarkup.replace("REPLACE_modal_custompreview_text", this.labels.modal_custompreview_text);
|
||||
}
|
||||
|
||||
|
||||
onGuildContextMenu (instance, menu) {
|
||||
if (document.querySelector(".DevilBro-modal")) return;
|
||||
if (instance.props && instance.props.target && instance.props.guild && instance.props.type == "GUILD_ICON_BAR" && !menu.querySelector(".serverfolders-item")) {
|
||||
|
@ -466,7 +466,7 @@ class ServerFolders {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processGuilds (instance, wrapper) {
|
||||
setTimeout(() => {
|
||||
if (!wrapper.parentElement.querySelector(BDFDB.dotCN.guildswrapper + ".foldercontent")) {
|
||||
|
@ -483,7 +483,7 @@ class ServerFolders {
|
|||
BDFDB.WebModules.forceAllUpdates(this, "Guild");
|
||||
},5000);
|
||||
}
|
||||
|
||||
|
||||
processGuild (instance, wrapper, methodnames) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
if (methodnames.includes("componentDidMount")) {
|
||||
|
@ -525,16 +525,16 @@ class ServerFolders {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showFolderSettings (folderdiv) {
|
||||
if (!folderdiv) return;
|
||||
let {folderID,folderName,position,iconID,icons,copyTooltipColor,color1,color2,color3,color4,servers} = BDFDB.loadData(folderdiv.id, this, "folders") || {};
|
||||
if (!folderID) return;
|
||||
|
||||
|
||||
let folderSettingsModal = BDFDB.htmlToElement(this.folderSettingsModalMarkup);
|
||||
let foldernameinput = folderSettingsModal.querySelector("#input-foldername");
|
||||
let copytooltipcolorinput = folderSettingsModal.querySelector("#input-copytooltipcolor");
|
||||
|
||||
|
||||
folderSettingsModal.querySelector(BDFDB.dotCN.modalguildname).innerText = folderName || "";
|
||||
foldernameinput.value = folderName || "";
|
||||
foldernameinput.setAttribute("placeholder", folderName || "");
|
||||
|
@ -544,9 +544,9 @@ class ServerFolders {
|
|||
BDFDB.setColorSwatches(folderSettingsModal, color2);
|
||||
BDFDB.setColorSwatches(folderSettingsModal, color3);
|
||||
BDFDB.setColorSwatches(folderSettingsModal, color4);
|
||||
|
||||
|
||||
BDFDB.appendModal(folderSettingsModal);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(folderSettingsModal, "change", "input[type='file'][option]", e => {
|
||||
let file = e.currentTarget.files[0];
|
||||
if (file) this.fetchCustomIcon(folderSettingsModal, e.currentTarget.getAttribute("option"));
|
||||
|
@ -559,23 +559,23 @@ class ServerFolders {
|
|||
});
|
||||
BDFDB.addChildEventListener(folderSettingsModal, "click", ".btn-save", e => {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
folderName = foldernameinput.value.trim();
|
||||
folderName = folderName ? folderName : null;
|
||||
|
||||
|
||||
var oldIconID = iconID;
|
||||
var selectedIcon = folderSettingsModal.querySelector(".ui-icon-picker-icon.selected");
|
||||
iconID = selectedIcon.getAttribute("value");
|
||||
|
||||
|
||||
copyTooltipColor = copytooltipcolorinput.checked;
|
||||
|
||||
|
||||
var oldColor1 = color1;
|
||||
var oldColor2 = color2;
|
||||
color1 = BDFDB.getSwatchColor(folderSettingsModal, 1);
|
||||
color2 = BDFDB.getSwatchColor(folderSettingsModal, 2);
|
||||
color3 = BDFDB.getSwatchColor(folderSettingsModal, 3);
|
||||
color4 = BDFDB.getSwatchColor(folderSettingsModal, 4);
|
||||
|
||||
|
||||
if (iconID != oldIconID || !BDFDB.equals(color1, oldColor1) || !BDFDB.equals(color2, oldColor2)) {
|
||||
let folderIcons = this.loadAllIcons();
|
||||
let isOpen = BDFDB.containsClass(folderdiv, "open");
|
||||
|
@ -600,7 +600,7 @@ class ServerFolders {
|
|||
});
|
||||
foldernameinput.focus();
|
||||
}
|
||||
|
||||
|
||||
changeImgColor (color1, color2, icon, callback) {
|
||||
color1 = BDFDB.colorCONVERT(color1, "RGBCOMP");
|
||||
color2 = BDFDB.colorCONVERT(color2, "RGBCOMP");
|
||||
|
@ -636,18 +636,18 @@ class ServerFolders {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
setIcons (modal, selection) {
|
||||
let wrapper = modal.querySelector(".icons");
|
||||
if (!wrapper) return;
|
||||
BDFDB.removeEles(wrapper.childNodes);
|
||||
|
||||
|
||||
let folderIcons = this.loadAllIcons();
|
||||
|
||||
|
||||
wrapper.appendChild(BDFDB.htmlToElement(`<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.disCN.margintop4}" 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.alignstretch + BDFDB.disCN.wrap} ui-icon-picker-row" style="flex: 1 1 auto; display: flex; flex-wrap: wrap; overflow: visible !important;">${Object.getOwnPropertyNames(folderIcons).map(id => `<div class="ui-icon-picker-icon${folderIcons[id].customID ? ' custom' : ''}" value="${id}"><div class="ui-picker-inner" style="background-image: url(${folderIcons[id].closedicon});"></div>${folderIcons[id].customID ? '<div value="' + id + '" class="' + BDFDB.disCN.hovercardbutton + '"></div>' : ''}</div>`).join("")}</div></div>`));
|
||||
|
||||
|
||||
setIcon(wrapper.querySelector(`.ui-icon-picker-icon[value="${folderIcons[selection] ? selection : 0}"]`), false, true);
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(wrapper, "click", ".ui-icon-picker-icon", e => {
|
||||
if (BDFDB.containsClass(e.target, BDFDB.disCN.hovercardbutton)) return;
|
||||
setIcon(wrapper.querySelector(".ui-icon-picker-icon.selected"), false, false);
|
||||
|
@ -665,7 +665,7 @@ class ServerFolders {
|
|||
BDFDB.addChildEventListener(wrapper, "mouseleave", ".ui-icon-picker-icon", e => {
|
||||
setIcon(e.currentTarget, false);
|
||||
});
|
||||
|
||||
|
||||
function setIcon (icon, hover, enable) {
|
||||
if (!icon) return;
|
||||
if (enable != undefined) BDFDB.toggleClass(icon, "selected", enable);
|
||||
|
@ -681,14 +681,14 @@ class ServerFolders {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadAllIcons () {
|
||||
let icons = {};
|
||||
this.folderIcons.forEach((array,i) => {icons[i] = {"openicon":array.openicon,"closedicon":array.closedicon,"customID":null};});
|
||||
Object.assign(icons, BDFDB.loadAllData(this, "customicons"));
|
||||
return icons;
|
||||
}
|
||||
|
||||
|
||||
fetchCustomIcon (modal, type) {
|
||||
let successFetchIcon;
|
||||
let url = modal.querySelector("input[type='text'][option='" + type + "']").value;
|
||||
|
@ -719,23 +719,23 @@ class ServerFolders {
|
|||
BDFDB.showToast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
successFetchIcon = () => {
|
||||
let iconpreview = modal.querySelector(".ui-icon-picker-icon.preview." + type);
|
||||
let iconpreviewinner = iconpreview.querySelector(".ui-picker-inner");
|
||||
BDFDB.removeClass(iconpreview, "nopic");
|
||||
iconpreview.url = url;
|
||||
iconpreviewinner.style.setProperty("background-image", `url(${url})`);
|
||||
|
||||
|
||||
let iconpreviewopen = modal.querySelector(".ui-icon-picker-icon.preview.open");
|
||||
let iconpreviewclosed = modal.querySelector(".ui-icon-picker-icon.preview.closed");
|
||||
if (!BDFDB.containsClass(iconpreviewopen, "nopic") && !BDFDB.containsClass(iconpreviewclosed, "nopic")) {
|
||||
let iconpreviewswitching = modal.querySelector(".ui-icon-picker-icon.preview.switching");
|
||||
|
||||
|
||||
let iconpreviewopenimage = iconpreviewopen.querySelector(".ui-picker-inner").style.getPropertyValue("background-image");
|
||||
let iconpreviewclosedimage = iconpreviewclosed.querySelector(".ui-picker-inner").style.getPropertyValue("background-image");
|
||||
let iconpreviewswitchinginner = iconpreviewswitching.querySelector(".ui-picker-inner");
|
||||
|
||||
|
||||
BDFDB.removeClass(iconpreviewswitching, "nopic");
|
||||
iconpreviewswitchinginner.style.setProperty("background-image", iconpreviewopenimage);
|
||||
let switching = true;
|
||||
|
@ -746,7 +746,7 @@ class ServerFolders {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
saveCustomIcon (modal) {
|
||||
let iconpreviewopen = modal.querySelector(".ui-icon-picker-icon.preview.open");
|
||||
let iconpreviewclosed = modal.querySelector(".ui-icon-picker-icon.preview.closed");
|
||||
|
@ -755,11 +755,11 @@ class ServerFolders {
|
|||
let customID = this.generateID("customicon");
|
||||
BDFDB.saveData(customID, {"openicon":iconpreviewopen.url,"closedicon":iconpreviewclosed.url,customID}, this, "customicons");
|
||||
modal.querySelectorAll("input[type='text'][option]").forEach((input) => {input.value = "";});
|
||||
|
||||
|
||||
let iconpreviewopeninner = iconpreviewopen.querySelector(".ui-picker-inner");
|
||||
let iconpreviewclosedinner = iconpreviewclosed.querySelector(".ui-picker-inner");
|
||||
let iconpreviewswitchinginner = iconpreviewswitching.querySelector(".ui-picker-inner");
|
||||
|
||||
|
||||
BDFDB.addClass(iconpreviewopen, "nopic");
|
||||
iconpreviewopeninner.style.removeProperty("background-image");
|
||||
BDFDB.addClass(iconpreviewclosed, "nopic");
|
||||
|
@ -774,13 +774,13 @@ class ServerFolders {
|
|||
BDFDB.showToast(`Add an image for the open and the closed icon.`, {type:"danger"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resetAllElements () {
|
||||
this.toggleFolderContent(false);
|
||||
BDFDB.removeEles(BDFDB.dotCN.guild + ".folder", ".serverfolders-dragpreview");
|
||||
BDFDB.readServerList().forEach(info => {this.unhideServer(info.div);});
|
||||
}
|
||||
|
||||
|
||||
createNewFolder (ankerdiv) {
|
||||
if (!Node.prototype.isPrototypeOf(ankerdiv)) return;
|
||||
let guilddiv = BDFDB.getParentEle(BDFDB.dotCN.guild, ankerdiv);
|
||||
|
@ -796,18 +796,18 @@ class ServerFolders {
|
|||
let color3 = null;
|
||||
let color4 = null;
|
||||
let servers = [];
|
||||
|
||||
|
||||
this.showFolderSettings(this.createFolderDiv({folderID,folderName,position,iconID,icons,autounread,color1,color2,color3,color4,servers}));
|
||||
|
||||
|
||||
this.updateFolderPositions();
|
||||
}
|
||||
|
||||
|
||||
createFolderDiv (data) {
|
||||
let folderdiv = BDFDB.htmlToElement(this.folderIconMarkup);
|
||||
let serversandfolders = document.querySelectorAll(`div${BDFDB.dotCN.guildseparator}:not(.folderseparator) ~ div${BDFDB.dotCN.guild}`);
|
||||
let insertnode = serversandfolders[data.position > serversandfolders.length - 1 ? serversandfolders.length - 1 : data.position];
|
||||
insertnode.parentElement.insertBefore(folderdiv, insertnode);
|
||||
|
||||
|
||||
folderdiv.id = data.folderID;
|
||||
BDFDB.addClass(folderdiv, "closed");
|
||||
folderdiv.querySelector(BDFDB.dotCN.avataricon).style.setProperty("background-image", `url(${data.icons.closedicon})`);
|
||||
|
@ -849,7 +849,7 @@ class ServerFolders {
|
|||
folderContext.remove();
|
||||
this.removeFolder(folderdiv);
|
||||
});
|
||||
|
||||
|
||||
let unreadServers = BDFDB.readUnreadServerList(this.readIncludedServerList(folderdiv));
|
||||
if (unreadServers.length > 0) {
|
||||
let unreaditem = folderContext.querySelector(".unreadfolder-item");
|
||||
|
@ -906,22 +906,22 @@ class ServerFolders {
|
|||
document.addEventListener("mousemove", mousemove);
|
||||
document.addEventListener("mouseup", mouseup);
|
||||
});
|
||||
|
||||
|
||||
this.addHoverBehaviour(folderdiv);
|
||||
|
||||
|
||||
BDFDB.saveData(data.folderID, data, this, "folders");
|
||||
|
||||
|
||||
this.updateFolderNotifications(folderdiv);
|
||||
|
||||
|
||||
return folderdiv;
|
||||
}
|
||||
|
||||
|
||||
generateID (prefix) {
|
||||
let data = BDFDB.loadAllData(this, prefix + "s");
|
||||
let id = prefix + "_" + Math.round(Math.random()*10000000000000000);
|
||||
return data[id] ? this.generateID(prefix) : id;
|
||||
}
|
||||
|
||||
|
||||
addServerToFolder (info, folderdiv) {
|
||||
if (!info || !folderdiv) return;
|
||||
let guilddiv = BDFDB.getServerDiv(info);
|
||||
|
@ -934,7 +934,7 @@ class ServerFolders {
|
|||
this.updateFolderNotifications(folderdiv);
|
||||
BDFDB.showToast(this.labels.toast_addserver_text.replace("${servername}", info.name).replace("${foldername}", data.folderName ? " " + data.folderName : ""), {type:"success"});
|
||||
}
|
||||
|
||||
|
||||
removeServerFromFolder (info, folderdiv) {
|
||||
if (!info || !folderdiv) return;
|
||||
let data = BDFDB.loadData(folderdiv.id, this, "folders");
|
||||
|
@ -946,7 +946,7 @@ class ServerFolders {
|
|||
this.updateFolderNotifications(folderdiv);
|
||||
BDFDB.showToast(this.labels.toast_removeserver_text.replace("${servername}", info.name).replace("${foldername}", data.folderName ? " " + data.folderName : ""), {type:"danger"});
|
||||
}
|
||||
|
||||
|
||||
removeFolder (folderdiv) {
|
||||
if (!folderdiv) return;
|
||||
this.readIncludedServerList(folderdiv).forEach(guilddiv => {this.unhideServer(guilddiv);});
|
||||
|
@ -955,7 +955,7 @@ class ServerFolders {
|
|||
folderdiv.remove();
|
||||
this.updateFolderPositions();
|
||||
}
|
||||
|
||||
|
||||
getFolderOfServer (idOrInfoOrEle) {
|
||||
if (!idOrInfoOrEle) return;
|
||||
let id = Node.prototype.isPrototypeOf(idOrInfoOrEle) ? BDFDB.getServerID(idOrInfoOrEle) : (typeof idOrInfoOrEle == "object" ? idOrInfoOrEle.id : idOrInfoOrEle);
|
||||
|
@ -964,7 +964,7 @@ class ServerFolders {
|
|||
for (let folderid in folders) for (let serverid of folders[folderid].servers) if (serverid == id) return document.querySelector("#" + folderid);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
hideServer (guilddiv, folderdiv) {
|
||||
if (!Node.prototype.isPrototypeOf(guilddiv) || !folderdiv) return;
|
||||
guilddiv.setAttribute("folder", folderdiv.id);
|
||||
|
@ -985,7 +985,7 @@ class ServerFolders {
|
|||
});
|
||||
guilddiv.ServerFoldersChangeObserver.observe(guilddiv, {attributes:true, childList:true, characterData: true, subtree:true});
|
||||
}
|
||||
|
||||
|
||||
unhideServer (guilddiv) {
|
||||
if (!Node.prototype.isPrototypeOf(guilddiv)) return;
|
||||
guilddiv.removeAttribute("folder");
|
||||
|
@ -993,14 +993,14 @@ class ServerFolders {
|
|||
if (guilddiv.ServerFoldersChangeObserver && typeof guilddiv.ServerFoldersChangeObserver.disconnect == "function") guilddiv.ServerFoldersChangeObserver.disconnect();
|
||||
delete guilddiv.ServerFoldersChangeObserver;
|
||||
}
|
||||
|
||||
|
||||
toggleFolderContent (forceOpenClose) {
|
||||
if (!this.foldercontent) return;
|
||||
forceOpenClose = forceOpenClose === undefined ? BDFDB.containsClass(this.foldercontent, "foldercontentclosed") : forceOpenClose;
|
||||
BDFDB.toggleClass(this.foldercontent, "foldercontentopen", forceOpenClose);
|
||||
BDFDB.toggleClass(this.foldercontent, "foldercontentclosed", !forceOpenClose);
|
||||
}
|
||||
|
||||
|
||||
openCloseFolder (folderdiv) {
|
||||
if (!folderdiv) return;
|
||||
let data = BDFDB.loadData(folderdiv.id, this, "folders");
|
||||
|
@ -1011,22 +1011,22 @@ class ServerFolders {
|
|||
if (includedServers.length == 0) return;
|
||||
BDFDB.addClass(folderdiv, "open");
|
||||
BDFDB.removeClass(folderdiv, "closed");
|
||||
|
||||
|
||||
this.toggleFolderContent(true);
|
||||
|
||||
|
||||
let containsguilds = this.foldercontent.querySelectorAll(BDFDB.dotCN.guild).length;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
if (settings.addSeparators && containsguilds) this.foldercontentguilds.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.guildseparator} folderseparator" folder="${folderdiv.id}"></div>`));
|
||||
includedServers.forEach(guilddiv => {this.updateCopyInFolderContent(guilddiv, folderdiv);});
|
||||
}, settings.closeOtherFolders && containsguilds ? 300 : 0);
|
||||
}
|
||||
else this.closeFolderContent(folderdiv);
|
||||
|
||||
|
||||
folderdiv.querySelector(BDFDB.dotCN.avataricon).style.setProperty("background-image", `url(${isClosed ? data.icons.openicon : data.icons.closedicon})`);
|
||||
}
|
||||
|
||||
|
||||
closeFolderContent (folderdiv) {
|
||||
if (!folderdiv) return;
|
||||
BDFDB.removeClass(folderdiv, "open");
|
||||
|
@ -1042,11 +1042,11 @@ class ServerFolders {
|
|||
}, 300);
|
||||
}
|
||||
else BDFDB.removeEles(includedCopies);
|
||||
|
||||
|
||||
let firstchild = this.foldercontentguilds.firstElementChild;
|
||||
if (BDFDB.containsClass(firstchild, "folderseparator")) BDFDB.removeEles(firstchild);
|
||||
}
|
||||
|
||||
|
||||
updateCopyInFolderContent (guilddiv, folderdiv) {
|
||||
if (!guilddiv || !folderdiv) return;
|
||||
if (BDFDB.containsClass(folderdiv, "open")) {
|
||||
|
@ -1064,7 +1064,7 @@ class ServerFolders {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createCopyOfServer (guilddiv, folderdiv) {
|
||||
if (!guilddiv || !folderdiv) return;
|
||||
let info = this.GuildUtils.getGuild(BDFDB.getServerID(guilddiv));
|
||||
|
@ -1102,7 +1102,7 @@ class ServerFolders {
|
|||
let hovcopy = null;
|
||||
let placeholder = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.guild + BDFDB.disCN.guildplaceholder} copyplaceholder"></div>`);
|
||||
let dragpreview = this.createDragPreview(guilddiv, e);
|
||||
|
||||
|
||||
let dragging = e3 => {
|
||||
BDFDB.removeEles(placeholder);
|
||||
BDFDB.toggleEles(guildcopy, false);
|
||||
|
@ -1139,19 +1139,19 @@ class ServerFolders {
|
|||
document.addEventListener("mousemove", mousemove);
|
||||
document.addEventListener("mouseup", mouseup);
|
||||
});
|
||||
|
||||
|
||||
let copyinner = guildcopy.querySelector(BDFDB.dotCN.guildinner);
|
||||
let isselected = BDFDB.containsClass(guildcopy, BDFDB.disCN.guildselected);
|
||||
let hasicon = !BDFDB.containsClass(guildcopy.querySelector(BDFDB.dotCN.guildicon), BDFDB.disCN.avatarnoicon);
|
||||
guildcopy.querySelector("a").setAttribute("draggable", false);
|
||||
copyinner.style.setProperty("border-radius", isselected ? "15px" : "25px");
|
||||
copyinner.style.setProperty("background-color", hasicon ? null : BDFDB.colorCONVERT(this.DiscordConstants.Colors[isselected ? "BRAND_PURPLE" : "CHANNELS_GREY"], "RGB"));
|
||||
|
||||
|
||||
this.addHoverBehaviour(guildcopy);
|
||||
|
||||
|
||||
return guildcopy;
|
||||
}
|
||||
|
||||
|
||||
createDragPreview (div, e) {
|
||||
if (!Node.prototype.isPrototypeOf(div)) return;
|
||||
let dragpreview = div.cloneNode(true);
|
||||
|
@ -1163,14 +1163,14 @@ class ServerFolders {
|
|||
document.querySelector(BDFDB.dotCN.appmount).appendChild(dragpreview);
|
||||
return dragpreview;
|
||||
}
|
||||
|
||||
|
||||
updateDragPreview (dragpreview, e) {
|
||||
if (!Node.prototype.isPrototypeOf(dragpreview)) return;
|
||||
BDFDB.toggleEles(dragpreview, true);
|
||||
dragpreview.style.setProperty("left", e.clientX - 25 + "px", "important");
|
||||
dragpreview.style.setProperty("top", e.clientY - 25 + "px", "important");
|
||||
}
|
||||
|
||||
|
||||
updateFolderPositions () {
|
||||
let serverAndFolders = document.querySelectorAll(`div${BDFDB.dotCN.guildseparator}:not(.folderseparator) ~ div${BDFDB.dotCN.guild}`);
|
||||
for (let i = 0; i < serverAndFolders.length; i++) {
|
||||
|
@ -1183,8 +1183,8 @@ class ServerFolders {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateServerPositions (folderdiv) {
|
||||
let data = BDFDB.loadData(folderdiv.id, this, "folders");
|
||||
if (data) {
|
||||
|
@ -1193,8 +1193,8 @@ class ServerFolders {
|
|||
data.servers = BDFDB.removeCopiesFromArray(servers.concat(data.servers));
|
||||
BDFDB.saveData(folderdiv.id, data, this, "folders");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateFolderNotifications (folderdiv) {
|
||||
let data = BDFDB.loadData(folderdiv.id, this, "folders");
|
||||
var a = performance.now();
|
||||
|
@ -1206,14 +1206,14 @@ class ServerFolders {
|
|||
let badgeAmount = 0;
|
||||
let audioEnabled = false;
|
||||
let videoEnabled = false;
|
||||
|
||||
|
||||
includedServers.forEach(div => {
|
||||
let badge = div.querySelector(BDFDB.dotCN.badge);
|
||||
if (badge) badgeAmount += parseInt(badge.innerText);
|
||||
if (BDFDB.containsClass(div, BDFDB.disCN.guildaudio)) audioEnabled = true;
|
||||
if (BDFDB.containsClass(div, BDFDB.disCN.guildvideo)) videoEnabled = true;
|
||||
});
|
||||
|
||||
|
||||
BDFDB.toggleClass(folderdiv, BDFDB.disCN.guildunread, unreadServers.length > 0);
|
||||
BDFDB.toggleClass(folderdiv, BDFDB.disCN.guildaudio, audioEnabled);
|
||||
BDFDB.toggleClass(folderdiv, BDFDB.disCN.guildvideo, videoEnabled);
|
||||
|
@ -1223,11 +1223,11 @@ class ServerFolders {
|
|||
let amount = folderdiv.querySelector(".folder" + BDFDB.dotCN.badge + ".count");
|
||||
amount.innerText = includedServers.length;
|
||||
BDFDB.toggleEles(amount, includedServers.length > 0 && BDFDB.getData("showCountBadge", this, "settings"));
|
||||
|
||||
|
||||
if (BDFDB.containsClass(folderdiv, "open") && !document.querySelector(".foldercontent [folder='" + folderdiv.id + "']")) this.openCloseFolder(folderdiv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readIncludedServerList (folderdiv) {
|
||||
let data = BDFDB.loadData(folderdiv.id, this, "folders");
|
||||
let includedServers = [];
|
||||
|
@ -1237,7 +1237,7 @@ class ServerFolders {
|
|||
}
|
||||
return includedServers;
|
||||
}
|
||||
|
||||
|
||||
addHoverBehaviour (div) {
|
||||
/* based on stuff from Zerebos */
|
||||
let divinner = div.querySelector(BDFDB.dotCN.guildinner);
|
||||
|
@ -1275,7 +1275,7 @@ class ServerFolders {
|
|||
div.addEventListener("mouseenter", () => {animate(1);})
|
||||
div.addEventListener("mouseleave", () => {if (!BDFDB.containsClass(div, BDFDB.disCN.guildselected)) animate(0);});
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,14 +8,14 @@ class ServerHider {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Hide Servers in your Serverlist";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"Guild":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.serverHiderModalMarkup =
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -69,7 +69,7 @@ class ServerHider {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} serverhider-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -84,13 +84,13 @@ class ServerHider {
|
|||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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;">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>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -129,9 +129,9 @@ class ServerHider {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
if (BDFDB.isPluginEnabled("HideUtils") && !BDFDB.loadData("hideutils", this, "warnings")) BDFDB.openConfirmModal(this, this.name + " is not compartible with the plugin HideUtils by Arashiryuu. You might expierence bugs like Servers that should be hidden by " + this.name + " still being visible in the Guildlist. To avoid this disable the Plugin HideUtils. Press the " + BDFDB.getLibraryStrings().btn_ok_text + "-Button to not show this Message again.", "Warning", () => {BDFDB.saveData("hideutils", true, this, "warnings")});
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -142,27 +142,27 @@ class ServerHider {
|
|||
stop () {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.serverContextEntryMarkup = this.serverContextEntryMarkup.replace("REPLACE_context_serverhider_text", this.labels.context_serverhider_text);
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_hideserver_text", this.labels.submenu_hideserver_text);
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_openhidemenu_text", this.labels.submenu_openhidemenu_text);
|
||||
|
||||
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_btn_ok_text", this.labels.btn_ok_text);
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_btn_all_text", this.labels.btn_all_text);
|
||||
|
||||
|
||||
this.serverEntryMarkup = this.serverEntryMarkup.replace("REPLACE_btn_visible_text", this.labels.btn_visible_text);
|
||||
}
|
||||
|
||||
|
||||
onGuildContextMenu (instance, menu) {
|
||||
if (document.querySelector(".DevilBro-modal")) return;
|
||||
if (instance.props && instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(".serverhider-item")) {
|
||||
|
@ -188,19 +188,19 @@ class ServerHider {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processGuild (instance, wrapper) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || [];
|
||||
this.toggleServer(instance.props.guild, wrapper, !hiddenservers.includes(instance.props.guild.id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showServerModal () {
|
||||
let serverHiderModal = BDFDB.htmlToElement(this.serverHiderModalMarkup);
|
||||
let container = serverHiderModal.querySelector(".entries");
|
||||
if (!container) return;
|
||||
|
||||
|
||||
BDFDB.addChildEventListener(serverHiderModal, "click", ".btn-all", () => {
|
||||
let firstcheckbox = serverHiderModal.querySelector(".serverhiderCheckbox");
|
||||
firstcheckbox.click();
|
||||
|
@ -208,7 +208,7 @@ class ServerHider {
|
|||
if (checkbox != firstcheckbox && checkbox.checked != firstcheckbox.checked) checkbox.click();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
for (let info of BDFDB.readServerList()) {
|
||||
if (!info.div.getAttribute("folder")) {
|
||||
if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.modaldivider}"></div>`));
|
||||
|
@ -226,7 +226,7 @@ class ServerHider {
|
|||
}
|
||||
BDFDB.appendModal(serverHiderModal);
|
||||
}
|
||||
|
||||
|
||||
createCopyOfServer (info) {
|
||||
let serverCopy = info.div.cloneNode(true);
|
||||
BDFDB.toggleEles(serverCopy, true);
|
||||
|
@ -249,7 +249,7 @@ class ServerHider {
|
|||
if (!visible) hiddenservers.push(info.id);
|
||||
BDFDB.saveData("hiddenservers", hiddenservers, this, "hiddenservers");
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,7 +8,7 @@ class ShowHiddenChannels {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Displays channels that are hidden from you by role restrictions.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"Channels":["componentDidMount","componentDidUpdate"],
|
||||
|
@ -16,7 +16,7 @@ class ShowHiddenChannels {
|
|||
"ChannelCategoryItem":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.categoryMarkup =
|
||||
`<div class="container-hidden">
|
||||
<div class="${BDFDB.disCN.categorycontainerdefault} hidden-channel">
|
||||
|
@ -28,7 +28,7 @@ class ShowHiddenChannels {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.channelTextMarkup =
|
||||
`<div class="${BDFDB.disCN.channelcontainerdefault} hidden-channel">
|
||||
<div class="${BDFDB.disCNS.channelwrapperdefaulttext + BDFDB.disCN.channelwrapper}">
|
||||
|
@ -44,7 +44,7 @@ class ShowHiddenChannels {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.channelVoiceMarkup =
|
||||
`<div class="${BDFDB.disCN.channelcontainerdefault} hidden-channel">
|
||||
<div class="${BDFDB.disCNS.channelwrapperdefaultvoice + BDFDB.disCN.channelwrapper}">
|
||||
|
@ -60,7 +60,7 @@ class ShowHiddenChannels {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.channelCategoryMarkup =
|
||||
`<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;">
|
||||
|
@ -70,12 +70,12 @@ class ShowHiddenChannels {
|
|||
<div class="${BDFDB.disCNS.categorycolortransition + BDFDB.disCNS.categoryoverflowellipsis + BDFDB.disCN.categorynamecollapsed}" style="flex: 1 1 auto;"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
.container-hidden .containerDefault-1ZnADq .iconTransition-2pOJ7l {
|
||||
position: static;
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showText: {value:true, description:"Show hidden Textchannels:"},
|
||||
|
@ -94,7 +94,7 @@ class ShowHiddenChannels {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -107,7 +107,7 @@ class ShowHiddenChannels {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -116,7 +116,7 @@ class ShowHiddenChannels {
|
|||
var input = parseInt(e.currentTarget.value);
|
||||
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class ShowHiddenChannels {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.React = BDFDB.WebModules.findByProperties("createElement", "cloneElement");
|
||||
this.ChannelTypes = BDFDB.WebModules.findByProperties("ChannelTypes").ChannelTypes;
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
|
@ -154,7 +154,7 @@ class ShowHiddenChannels {
|
|||
this.ChannelStore = BDFDB.WebModules.findByProperties("getChannels", "getDMFromUserId");
|
||||
this.GuildChannels = BDFDB.WebModules.findByProperties("getChannels", "getDefaultChannel");
|
||||
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions;
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this, "Channels");
|
||||
}
|
||||
else {
|
||||
|
@ -169,31 +169,31 @@ class ShowHiddenChannels {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processChannels (instance, wrapper, methodnames) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
if (methodnames.includes("componentDidMount")) this.appendHiddenContainer(instance.props.guild);
|
||||
if (methodnames.includes("componentDidUpdate")) this.reappendHiddenContainer(instance.props.guild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processChannelItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel) this.reappendHiddenContainer(this.GuildStore.getGuild(instance.props.channel.guild_id));
|
||||
}
|
||||
|
||||
|
||||
processChannelCategoryItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel) this.reappendHiddenContainer(this.GuildStore.getGuild(instance.props.channel.guild_id));
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.WebModules.forceAllUpdates(this, "Channels");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
appendHiddenContainer (guild) {
|
||||
BDFDB.removeEles(".container-hidden");
|
||||
if (!guild) return;
|
||||
|
@ -201,9 +201,9 @@ class ShowHiddenChannels {
|
|||
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) {
|
||||
|
@ -225,8 +225,8 @@ class ShowHiddenChannels {
|
|||
if (isHidden) hiddenChannels[channel.type].push(channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var count = 0;
|
||||
for (let type in this.ChannelTypes) {
|
||||
|
@ -237,7 +237,7 @@ class ShowHiddenChannels {
|
|||
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);
|
||||
|
@ -249,7 +249,7 @@ class ShowHiddenChannels {
|
|||
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");
|
||||
|
@ -268,7 +268,7 @@ class ShowHiddenChannels {
|
|||
};
|
||||
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);
|
||||
|
@ -292,7 +292,7 @@ class ShowHiddenChannels {
|
|||
});
|
||||
category.appendChild(channel);
|
||||
}
|
||||
|
||||
|
||||
for (let hiddenChannel of hiddenChannels[2]) {
|
||||
let channel = BDFDB.htmlToElement(this.channelVoiceMarkup);
|
||||
let channelwrapper = channel.querySelector(BDFDB.dotCN.channelwrapper);
|
||||
|
@ -316,7 +316,7 @@ class ShowHiddenChannels {
|
|||
});
|
||||
category.appendChild(channel);
|
||||
}
|
||||
|
||||
|
||||
for (let hiddenChannel of hiddenChannels[4]) {
|
||||
let channel = BDFDB.htmlToElement(this.channelCategoryMarkup);
|
||||
let channelwrapper = channel.querySelector(BDFDB.dotCN.categorywrappercollapsed);
|
||||
|
@ -342,10 +342,10 @@ class ShowHiddenChannels {
|
|||
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, category);
|
||||
}
|
||||
let channellist = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
|
||||
|
@ -359,7 +359,7 @@ class ShowHiddenChannels {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
reappendHiddenContainer (guild, category = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCNS.scroller + ".container-hidden")) {
|
||||
if (!guild) return;
|
||||
if (guild.id != this.currentGuild) this.appendHiddenContainer(guild);
|
||||
|
@ -372,13 +372,13 @@ class ShowHiddenChannels {
|
|||
scroller.insertBefore(category, scroller.lastChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setReactInstanceOfChannel (guild, div) {
|
||||
var reactInstance = BDFDB.React.createElement(div);
|
||||
reactInstance.memoizedProps = {channel:guild};
|
||||
div.__reactInternalInstance = reactInstance;
|
||||
}
|
||||
|
||||
|
||||
createHiddenObjContextMenu (guild, channel, type, e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
@ -391,10 +391,10 @@ class ShowHiddenChannels {
|
|||
contextMenu.remove();
|
||||
require("electron").clipboard.write({text: channel.id});
|
||||
});
|
||||
|
||||
|
||||
BDFDB.appendContextMenu(contextMenu, e);
|
||||
}
|
||||
|
||||
|
||||
showAccessRoles (guild, channel, e, allowed) {
|
||||
if ((e.type != "mouseenter" && e.type != "mouseover") || !guild || !channel) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
|
|
@ -8,13 +8,13 @@ class ShowImageDetails {
|
|||
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",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
.image-details .image-details-size {
|
||||
margin: 0 10px;
|
||||
|
@ -26,7 +26,7 @@ class ShowImageDetails {
|
|||
margin: 10px 0;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showOnHover: {value:false, description:"Show the details as Tooltip instead:"}
|
||||
|
@ -36,7 +36,7 @@ class ShowImageDetails {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -49,7 +49,7 @@ class ShowImageDetails {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -58,7 +58,7 @@ class ShowImageDetails {
|
|||
let input = parseInt(e.currentTarget.value);
|
||||
if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts");
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class ShowImageDetails {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -98,14 +98,14 @@ class ShowImageDetails {
|
|||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
resetImage (image) {
|
||||
BDFDB.removeClass(image, "image-details-added");
|
||||
image.removeEventListener("mouseenter", image.mouseenterShowImageDetails);
|
||||
|
@ -115,7 +115,7 @@ class ShowImageDetails {
|
|||
wrapper.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processLazyImageZoomable (instance, image) {
|
||||
let attachment = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.attachment");
|
||||
if (attachment && !attachment.filename.endsWith(".bdemote.png") && !attachment.filename.endsWith(".bdemote.gif")) {
|
||||
|
@ -136,7 +136,7 @@ class ShowImageDetails {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
|
|
|
@ -8,12 +8,12 @@ class SpellCheck {
|
|||
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 = [];
|
||||
|
@ -29,7 +29,7 @@ class SpellCheck {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.similarWordsContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} spellcheck-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} nosimilars-item">
|
||||
|
@ -37,10 +37,10 @@ class SpellCheck {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.spellCheckLayerMarkup =
|
||||
`<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::-webkit-scrollbar,
|
||||
.spellcheck-overlay::-webkit-scrollbar-button,
|
||||
|
@ -56,8 +56,8 @@ class SpellCheck {
|
|||
background-repeat: repeat-x;
|
||||
background-position: bottom;
|
||||
}`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
disableDiscordSpellcheck: {value:true, description:"Disable Discord's internal Spellcheck:"}
|
||||
|
@ -70,7 +70,7 @@ class SpellCheck {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -93,11 +93,11 @@ class SpellCheck {
|
|||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
|
||||
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 => {
|
||||
|
@ -132,11 +132,11 @@ class SpellCheck {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
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 {
|
||||
|
@ -148,23 +148,23 @@ class SpellCheck {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".spellcheck-overlay");
|
||||
BDFDB.removeClasses("spellcheck-added");
|
||||
|
||||
|
||||
this.killLanguageToast();
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.spellCheckContextEntryMarkup = this.spellCheckContextEntryMarkup.replace("REPLACE_context_spellcheck_text", this.labels.context_spellcheck_text);
|
||||
this.spellCheckContextEntryMarkup = this.spellCheckContextEntryMarkup.replace("REPLACE_context_similarwords_text", this.labels.context_similarwords_text);
|
||||
|
||||
|
||||
this.similarWordsContextSubMenuMarkup = this.similarWordsContextSubMenuMarkup.replace("REPLACE_similarwordssubmenu_none_text", this.labels.similarwordssubmenu_none_text);
|
||||
}
|
||||
|
||||
|
||||
onNativeContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.type == "CHANNEL_TEXT_AREA" && instance.props.value && !menu.querySelector(".spellcheck-item")) {
|
||||
let selection = document.getSelection();
|
||||
|
@ -196,12 +196,12 @@ class SpellCheck {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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];
|
||||
|
@ -214,19 +214,19 @@ class SpellCheck {
|
|||
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);
|
||||
|
@ -237,7 +237,7 @@ class SpellCheck {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
replaceWord (textarea, word, replacement) {
|
||||
if (!textarea) return;
|
||||
textarea.focus();
|
||||
|
@ -251,7 +251,7 @@ class SpellCheck {
|
|||
textarea.dispatchEvent(new Event("keyup"));
|
||||
textarea.dispatchEvent(new Event("change"));
|
||||
}
|
||||
|
||||
|
||||
addToOwnDictionary (word) {
|
||||
word = word.split(" ")[0].split("\n")[0].split("\r")[0].split("\t")[0];
|
||||
if (word) {
|
||||
|
@ -268,7 +268,7 @@ class SpellCheck {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeFromOwnDictionary (e) {
|
||||
var entry = e.currentTarget.parentElement;
|
||||
var word = entry.querySelector(".entryword").textContent;
|
||||
|
@ -279,28 +279,28 @@ class SpellCheck {
|
|||
BDFDB.saveData(lang, ownDictionary, this, "owndics");
|
||||
this.dictionary = this.langDictionary.concat(ownDictionary);
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (settingspanel, e) {
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
|
||||
if (!plugincard || selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
selectWrap.classList.add(BDFDB.disCN.selectisopen);
|
||||
plugincard.style.setProperty("overflow", "visible", "important");
|
||||
|
||||
|
||||
var type = selectWrap.getAttribute("type");
|
||||
var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
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;
|
||||
this.setDictionary(language);
|
||||
BDFDB.saveData(type, language, this, "choices");
|
||||
|
||||
|
||||
var listcontainer = settingspanel.querySelector(".word-list");
|
||||
if (listcontainer) {
|
||||
var ownDictionary = BDFDB.loadData(language, this, "owndics") || [];
|
||||
|
@ -311,7 +311,7 @@ class SpellCheck {
|
|||
listcontainer.innerHTML = containerhtml;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
|
@ -322,7 +322,7 @@ class SpellCheck {
|
|||
};
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice, type) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var key in this.languages) {
|
||||
|
@ -332,7 +332,7 @@ class SpellCheck {
|
|||
menuhtml += `</div></div>`;
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
|
||||
setDictionary (lang) {
|
||||
this.dictionary = BDFDB.loadData(lang, this, "owndics") || [];
|
||||
this.killLanguageToast();
|
||||
|
@ -355,14 +355,14 @@ class SpellCheck {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
killLanguageToast () {
|
||||
if (this.languageToast && typeof this.languageToast.close == "function") {
|
||||
clearInterval(this.languageToast.interval);
|
||||
this.languageToast.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spellCheckText (string) {
|
||||
var htmlString = [];
|
||||
string.replace(/[\n]/g, "\n ").split(" ").forEach((word, i) => {
|
||||
|
@ -370,14 +370,14 @@ class SpellCheck {
|
|||
});
|
||||
return htmlString.join(" ");
|
||||
}
|
||||
|
||||
|
||||
isWordNotInDictionary (word) {
|
||||
var wordLow = word.toLowerCase();
|
||||
var wordWithoutSymbols = wordLow.replace(/[0-9\µ\@\$\£\€\¥\¢\²\³\>\<\|\,\;\.\:\_\#\+\*\~\?\¿\\\´\`\}\=\]\)\[\(\{\/\&\%\§\"\!\¡\^\°\n\t\r]/g, "");
|
||||
return (wordLow.indexOf("http://") != 0 && wordLow.indexOf("https://") != 0 && wordWithoutSymbols && Array.isArray(this.dictionary) && this.dictionary.length > 0 && !this.dictionary.includes(wordLow) && !this.dictionary.includes(wordWithoutSymbols));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
getSimilarWords (word) {
|
||||
var maxAmount = BDFDB.getData("maxSimilarAmount", this, "amounts"), similarWords = [];
|
||||
if (maxAmount > 0) {
|
||||
|
@ -402,7 +402,7 @@ class SpellCheck {
|
|||
}
|
||||
return similarWords;
|
||||
}
|
||||
|
||||
|
||||
wordSimilarity (a, b) {
|
||||
var temp;
|
||||
if (a.length === 0 || b.length === 0 || a.length - b.length > 3 || b.length - a.length > 3) { return 0; }
|
||||
|
@ -423,7 +423,7 @@ class SpellCheck {
|
|||
}
|
||||
return (b.length - result) / b.length;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -8,12 +8,12 @@ class StalkerNotifications {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Lets you observe the status of people that aren't your friends.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.stalkerOnlineList = {};
|
||||
|
||||
|
||||
this.checkInterval = null;
|
||||
|
||||
|
||||
this.timeLog = [];
|
||||
|
||||
this.timeLogModalMarkup =
|
||||
|
@ -57,9 +57,9 @@ class StalkerNotifications {
|
|||
<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 = `
|
||||
.${this.name}-modal .log-time {
|
||||
width: 110px;
|
||||
|
@ -115,7 +115,7 @@ class StalkerNotifications {
|
|||
.${this.name}-settings .settings-avatar:not(:hover) ${BDFDB.dotCN.hovercardbutton} {
|
||||
opacity: 1;
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
muteOnDND: {value:false, description:"Do not notify me when I am DnD:"},
|
||||
|
@ -133,10 +133,10 @@ class StalkerNotifications {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
|
||||
|
||||
let amounts = BDFDB.getAllData(this, "amounts");
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let users = BDFDB.loadAllData(this, "users");
|
||||
|
@ -163,7 +163,7 @@ class StalkerNotifications {
|
|||
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 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;">Timelog of LogIns/-Outs:</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-timelog" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Timelog</div></button></div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -248,7 +248,7 @@ class StalkerNotifications {
|
|||
}
|
||||
else e.currentTarget.value = 1;
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -277,17 +277,17 @@ class StalkerNotifications {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getDMFromUserId");
|
||||
this.ChannelSwitchUtils = BDFDB.WebModules.findByProperties("selectPrivateChannel");
|
||||
this.PrivateChannelUtils = BDFDB.WebModules.findByProperties("openPrivateChannel");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatus", "getOnlineFriendCount");
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers");
|
||||
|
||||
|
||||
for (let id in BDFDB.loadAllData(this, "users")) {
|
||||
this.stalkerOnlineList[id] = this.UserMetaStore.getStatus(id) != "offline";
|
||||
}
|
||||
|
||||
|
||||
this.startInterval();
|
||||
}
|
||||
else {
|
||||
|
@ -301,10 +301,10 @@ class StalkerNotifications {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
saveAudio (settingspanel, option) {
|
||||
let successSavedAudio = (parsedurl, parseddata) => {
|
||||
if (parsedurl && parseddata) BDFDB.showToast(`Sound was saved successfully.`, {type:"success"});
|
||||
|
@ -313,7 +313,7 @@ class StalkerNotifications {
|
|||
notificationsound.song = parseddata;
|
||||
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
|
||||
};
|
||||
|
||||
|
||||
let url = settingspanel.querySelector(`.songInput[option="${option}"]`).value;
|
||||
if (url.length == 0) {
|
||||
BDFDB.showToast(`Sound file was removed.`, {type:"warn"});
|
||||
|
@ -338,12 +338,12 @@ class StalkerNotifications {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createSettingsAvatarHtml (user, settings) {
|
||||
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
|
||||
return `<div class="settings-avatar${settings.desktop ? " desktop" : ""}${settings.disabled ? " disabled" : ""}" user-id="${user.id}" style="background-image: url(${data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(user.id))});"><div class="${BDFDB.disCN.hovercardbutton} remove-user"></div></div>`;
|
||||
}
|
||||
|
||||
|
||||
startInterval () {
|
||||
clearInterval(this.checkInterval);
|
||||
this.checkInterval = setInterval(() => {
|
||||
|
@ -386,8 +386,8 @@ class StalkerNotifications {
|
|||
}
|
||||
},BDFDB.getData("checkInterval", this, "amounts") * 1000);
|
||||
}
|
||||
|
||||
showTimeLog () {
|
||||
|
||||
showTimeLog () {
|
||||
let timeLogModal = BDFDB.htmlToElement(this.timeLogModalMarkup);
|
||||
let container = timeLogModal.querySelector(".entries");
|
||||
if (!container) return;
|
||||
|
|
|
@ -34,7 +34,7 @@ class SteamProfileLink {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.addEventListener(this, document, "click", "a[href^='https://steamcommunity.'],a[href^='https://store.steampowered.']", e => {
|
||||
e.originalEvent.preventDefault();
|
||||
e.originalEvent.stopImmediatePropagation();
|
||||
|
@ -49,7 +49,7 @@ class SteamProfileLink {
|
|||
|
||||
|
||||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ class ThemeRepo {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to preview all themes from the theme repo and download them on the fly. Repo button is in the theme settings.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"V2C_List":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.sortings = {
|
||||
sort: {
|
||||
name: "Name",
|
||||
|
@ -28,32 +28,32 @@ class ThemeRepo {
|
|||
desc: "Descending"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.loading = {is:false, timeout:null, amount:0};
|
||||
|
||||
|
||||
this.grabbedThemes = [];
|
||||
this.foundThemes = [];
|
||||
this.loadedThemes = {};
|
||||
|
||||
|
||||
this.updateInterval;
|
||||
|
||||
|
||||
this.themeFixerCSS = `${BDFDB.dotCNC.appmount + BDFDB.dotCNC.appcontainer + BDFDB.dotCNC.channelheaderheaderbar + BDFDB.dotCNC.channelheadertitle + BDFDB.dotCNC.guildchannels + BDFDB.dotCNC.channels + BDFDB.dotCNC.callcurrentcontainer + BDFDB.dotCNC.callcurrentvideo + BDFDB.dotCNC.callcurrentdetails + BDFDB.dotCNC.accountinfo + BDFDB.dotCNC.nochannel + BDFDB.dotCNC.friends + BDFDB.dotCNC.friendstable + BDFDB.dotCNC.friendstableheader + BDFDB.dotCNC.guilds + BDFDB.dotCNC.guildswrapper + BDFDB.dotCNC.channelheadertitle + BDFDB.dotCNC.typing + BDFDB.dotCNS.emojipicker + BDFDB.dotCNS.emojipickerscroller + BDFDB.dotCN.emojipickeremojiitem + BDFDB.dotCNC.emojipickerselected + BDFDB.dotCNC.members + BDFDB.dotCNC.chat + BDFDB.dotCNS.chat+ "form," + BDFDB.dotCNC.chatcontent + BDFDB.dotCNC.messageswrapper + BDFDB.dotCNC.searchresultswrap + BDFDB.dotCNC.searchresultschannelname + BDFDB.dotCNC.searchresultssearchheader + BDFDB.dotCNC.giftinventory + BDFDB.dotCNC.activityfeed + BDFDB.dotCNC.lfg + BDFDB.dotCNC.applicationstore + BDFDB.dotCNC.gamelibrary + BDFDB.dotCNC.gamelibrarytableheader + BDFDB.dotCNC.standardsidebarview + BDFDB.dotCNC.sidebarregion + BDFDB.dotCNC.contentregion + BDFDB.dotCN.scroller} {background: transparent !important;} ${BDFDB.dotCNC.layer + BDFDB.dotCNC.layers + BDFDB.dotCN.titlebar} {background: rgba(0,0,0,0.18) !important;} ${BDFDB.dotCN.card}:not([style*="background-color"]) {background: rgba(0,0,0,0.4) !important;}`;
|
||||
|
||||
|
||||
this.themeRepoButtonMarkup =
|
||||
`<button class="bd-pfbtn bd-themerepobutton">Theme Repo</button>`;
|
||||
|
||||
|
||||
this.settingsContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitem} themerepo-item">
|
||||
<span>Theme Repo</span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.themeRepoLoadingIconMarkup =
|
||||
`<svg class="themerepo-loadingicon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="42" height="31" viewBox="0 0 483 332">
|
||||
<path d="M0.000 39.479 L 0.000 78.957 43.575 78.957 L 87.151 78.957 87.151 204.097 L 87.151 329.236 129.609 329.236 L 172.067 329.236 172.067 204.097 L 172.067 78.957 215.642 78.957 L 259.218 78.957 259.218 39.479 L 259.218 0.000 129.609 0.000 L 0.000 0.000 0.000 39.479" stroke="none" fill="#7289da" fill-rule="evenodd"></path>
|
||||
<path d="M274.115 38.624 L 274.115 77.248 280.261 77.734 C 309.962 80.083,325.986 106.575,313.378 132.486 C 305.279 149.131,295.114 152.700,255.800 152.700 L 230.168 152.700 230.168 123.277 L 230.168 93.855 208.566 93.855 L 186.965 93.855 186.965 211.546 L 186.965 329.236 208.566 329.236 L 230.168 329.236 230.168 277.068 L 230.168 224.899 237.268 225.113 L 244.368 225.326 282.215 277.095 L 320.062 328.864 360.031 329.057 L 400.000 329.249 400.000 313.283 L 400.000 297.317 367.924 256.908 L 335.848 216.499 340.182 214.869 C 376.035 201.391,395.726 170.616,399.382 122.342 C 405.008 48.071,360.214 0.000,285.379 0.000 L 274.115 0.000 274.115 38.624" stroke="none" fill="#7f8186" fill-rule="evenodd"></path>
|
||||
</svg>`;
|
||||
|
||||
|
||||
this.frameMarkup =
|
||||
`<iframe class="discordPreview" src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/DiscordPreview.html"></iframe>`;
|
||||
|
||||
|
@ -95,7 +95,7 @@ class ThemeRepo {
|
|||
<button class="${BDFDB.disCN._reposettingsbutton} btn-download" style="margin-left: 0 !important;">Download</button>
|
||||
</div>
|
||||
</li>`;
|
||||
|
||||
|
||||
this.themeRepoModalMarkup =
|
||||
`<span class="${this.name}-modal Repo-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -213,7 +213,7 @@ class ThemeRepo {
|
|||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.sortPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} themerepo-sort-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
|
||||
<div>
|
||||
|
@ -224,7 +224,7 @@ class ThemeRepo {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.orderPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCN.popoutnoshadow} themerepo-order-popout" style="position: fixed; z-index: 1100; visibility: visible; transform: translateX(-100%) translateY(0%) translateZ(0px);">
|
||||
<div>
|
||||
|
@ -235,7 +235,7 @@ class ThemeRepo {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.app} > .repo-loadingwrapper {
|
||||
position: absolute;
|
||||
|
@ -291,7 +291,7 @@ class ThemeRepo {
|
|||
pointer-events: none !important;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="DevilBro-settings-inner">`;
|
||||
|
@ -305,7 +305,7 @@ class ThemeRepo {
|
|||
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;">Force all Themes to be fetched again.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} refresh-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Refresh</div></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.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 Themes from your own list.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} remove-all" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
@ -345,11 +345,11 @@ class ThemeRepo {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.loadThemes();
|
||||
|
||||
|
||||
this.updateInterval = setInterval(() => {this.checkForNewThemes();},1000*60*30);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -362,16 +362,16 @@ class ThemeRepo {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
clearInterval(this.updateInterval);
|
||||
clearTimeout(this.loading.timeout);
|
||||
|
||||
|
||||
BDFDB.removeEles(".discordPreview",".themerepo-notice",".bd-themerepobutton",".themerepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
onUserSettingsCogContextMenu (instance, menu) {
|
||||
let observer = new MutationObserver(changes => {
|
||||
changes.forEach(change => {
|
||||
|
@ -394,7 +394,7 @@ class ThemeRepo {
|
|||
});
|
||||
observer.observe(menu, {childList: true, subtree:true});
|
||||
}
|
||||
|
||||
|
||||
processV2CList (instance, wrapper) {
|
||||
if (!document.querySelector(".bd-themerepobutton") && window.PluginUpdates && window.PluginUpdates.plugins && instance._reactInternalFiber.key && instance._reactInternalFiber.key.split("-")[0] == "theme") {
|
||||
var folderbutton = document.querySelector(BDFDB.dotCN._repofolderbutton);
|
||||
|
@ -405,12 +405,12 @@ class ThemeRepo {
|
|||
});
|
||||
repoButton.addEventListener("mouseenter", () => {
|
||||
BDFDB.createTooltip("Open Theme Repo", repoButton, {type:"top",selector:"themerepo-button-tooltip"});
|
||||
});
|
||||
});
|
||||
folderbutton.parentElement.insertBefore(repoButton, folderbutton.nextSibling);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
addThemeToOwnList (settingspanel) {
|
||||
var themeUrlInput = settingspanel.querySelector("#input-themeurl");
|
||||
var themeList = settingspanel.querySelector(".theme-list");
|
||||
|
@ -427,7 +427,7 @@ class ThemeRepo {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeThemeFromOwnList (e) {
|
||||
var entry = e.currentTarget.parentElement;
|
||||
var url = entry.querySelector(".entryurl").textContent;
|
||||
|
@ -436,25 +436,25 @@ class ThemeRepo {
|
|||
BDFDB.removeFromArray(ownlist, url);
|
||||
BDFDB.saveData("ownlist", ownlist, this, "ownlist");
|
||||
}
|
||||
|
||||
|
||||
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(settingspanel.querySelector(BDFDB.dotCN.hovercard));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
openThemeRepoModal (showOnlyOutdated = false) {
|
||||
if (this.loading.is) {
|
||||
BDFDB.showToast(`Themes are still being fetched. Try again in some seconds.`, {type:"danger"});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var keyPressed = e => {
|
||||
if (e.which == 17 && themeRepoModal.querySelector(BDFDB.dotCN.searchbarinput) != document.activeElement) BDFDB.toggleEles(themeRepoModal);
|
||||
if (e.which == 27) frame.remove();
|
||||
};
|
||||
|
||||
|
||||
var messageReceived = e => {
|
||||
if (typeof e.data === "object" && e.data.origin == "DiscordPreview") {
|
||||
switch (e.data.reason) {
|
||||
|
@ -475,10 +475,10 @@ class ThemeRepo {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.addEventListener("keyup", keyPressed);
|
||||
window.addEventListener("message", messageReceived);
|
||||
|
||||
|
||||
var frame = BDFDB.htmlToElement(this.frameMarkup);
|
||||
var themeRepoModal = BDFDB.htmlToElement(this.themeRepoModalMarkup);
|
||||
var hiddenSettings = BDFDB.loadAllData(this, "hidden");
|
||||
|
@ -495,7 +495,7 @@ class ThemeRepo {
|
|||
themeRepoModal.querySelector("#input-hidedownloadable").checked = hiddenSettings.downloadable || showOnlyOutdated;
|
||||
if (!BDFDB.isRestartNoMoreEnabled()) themeRepoModal.querySelector("#RNMoption").remove();
|
||||
else themeRepoModal.querySelector("#input-rnmstart").checked = BDFDB.loadData("RNMstart", this, "settings");
|
||||
|
||||
|
||||
darklightinput.addEventListener("change", e => {
|
||||
frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"DarkLight",checked:darklightinput.checked,light:BDFDB.disCN.themelight,dark:BDFDB.disCN.themedark},"*");
|
||||
});
|
||||
|
@ -546,7 +546,7 @@ class ThemeRepo {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let favorites = BDFDB.loadAllData(this, "favorites");
|
||||
let container = themeRepoModal.querySelector(".themes");
|
||||
themeRepoModal.entries = {};
|
||||
|
@ -571,14 +571,14 @@ class ThemeRepo {
|
|||
this.addEntry(frame, themeRepoModal, container, data);
|
||||
}
|
||||
this.sortEntries(themeRepoModal);
|
||||
|
||||
|
||||
BDFDB.appendModal(themeRepoModal);
|
||||
|
||||
|
||||
document.body.insertBefore(frame, document.body.firstElementChild);
|
||||
|
||||
|
||||
themeRepoModal.querySelector(BDFDB.dotCN.searchbarinput).focus();
|
||||
}
|
||||
|
||||
|
||||
addEntry (frame, themeRepoModal, container, data) {
|
||||
if (!frame || !themeRepoModal || !container || !data) return;
|
||||
let entry = BDFDB.htmlToElement(this.themeEntryMarkup);
|
||||
|
@ -644,9 +644,9 @@ class ThemeRepo {
|
|||
});
|
||||
frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"NewTheme",checked:e.currentTarget.checked,css:data.css},"*");
|
||||
});
|
||||
|
||||
|
||||
container.appendChild(entry);
|
||||
|
||||
|
||||
function setEntryState (state) {
|
||||
data.state = state;
|
||||
BDFDB.toggleClass(entry, "downloadable", state > 1);
|
||||
|
@ -658,28 +658,28 @@ class ThemeRepo {
|
|||
themeRepoModal.entries[data.url] = data;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
sortEntries (themeRepoModal) {
|
||||
if (!themeRepoModal || typeof themeRepoModal.entries != "object") return;
|
||||
|
||||
|
||||
let container = themeRepoModal.querySelector(".themes");
|
||||
if (!container) return;
|
||||
|
||||
|
||||
let searchstring = themeRepoModal.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase();
|
||||
|
||||
|
||||
let entries = themeRepoModal.entries;
|
||||
if (themeRepoModal.querySelector("#input-hideupdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state < 1 ? null : entry;});
|
||||
if (themeRepoModal.querySelector("#input-hideoutdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state == 1 ? null : entry;});
|
||||
if (themeRepoModal.querySelector("#input-hidedownloadable").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state > 1 ? null : entry;});
|
||||
entries = BDFDB.filterObject(entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;});
|
||||
|
||||
|
||||
entries = BDFDB.sortObject(entries, themeRepoModal.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option"));
|
||||
if (themeRepoModal.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option") == "desc") entries = BDFDB.reverseObject(entries);
|
||||
|
||||
|
||||
let entrypositions = Object.keys(entries);
|
||||
|
||||
|
||||
themeRepoModal.querySelector(".themeAmount").innerText = "ThemeRepo Repository " + entrypositions.length + "/" + Object.keys(this.loadedThemes).length + " Themes";
|
||||
|
||||
|
||||
for (let li of container.children) {
|
||||
let pos = entrypositions.indexOf(li.getAttribute("data-url"));
|
||||
if (pos > -1) {
|
||||
|
@ -692,7 +692,7 @@ class ThemeRepo {
|
|||
BDFDB.toggleEles(li, pos > -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadThemes () {
|
||||
BDFDB.removeEles(".themerepo-loadingicon");
|
||||
var getThemeInfo, outdated = 0, i = 0;
|
||||
|
@ -718,7 +718,7 @@ class ThemeRepo {
|
|||
var loadingicon = BDFDB.htmlToElement(this.themeRepoLoadingIconMarkup);
|
||||
loadingicon.addEventListener("mouseenter", () => {BDFDB.createTooltip("Loading ThemeRepo",loadingicon,{type:"left",delay:500});})
|
||||
loadingiconwrapper.appendChild(loadingicon);
|
||||
|
||||
|
||||
getThemeInfo(() => {
|
||||
if (!this.started) {
|
||||
clearTimeout(this.loading.timeout);
|
||||
|
@ -792,7 +792,7 @@ class ThemeRepo {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkForNewThemes () {
|
||||
let request = require("request");
|
||||
request("https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/res/ThemeList.txt", (error, response, result) => {
|
||||
|
@ -802,7 +802,7 @@ class ThemeRepo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
downloadTheme (data) {
|
||||
let request = require("request");
|
||||
request(data.url, (error, response, body) => {
|
||||
|
@ -815,7 +815,7 @@ class ThemeRepo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createThemeFile (filename, content) {
|
||||
let fileSystem = require("fs");
|
||||
let path = require("path");
|
||||
|
@ -829,7 +829,7 @@ class ThemeRepo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
applyTheme (data) {
|
||||
var name = data.name;
|
||||
if (BDFDB.isThemeEnabled(name) == false) {
|
||||
|
@ -840,7 +840,7 @@ class ThemeRepo {
|
|||
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Applied Theme " + name + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deleteThemeFile (data) {
|
||||
let fileSystem = require("fs");
|
||||
let path = require("path");
|
||||
|
@ -852,7 +852,7 @@ class ThemeRepo {
|
|||
else BDFDB.showToast(`Successfully deleted Theme "${filename}".`, {type:"success"});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
removeTheme (data) {
|
||||
var name = data.name;
|
||||
if (BDFDB.isThemeEnabled(name) == true) {
|
||||
|
|
|
@ -8,7 +8,7 @@ class ThemeSettings {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to change Theme Variables within BetterDiscord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"V2C_ThemeCard":"componentDidMount"
|
||||
|
@ -40,11 +40,11 @@ class ThemeSettings {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.fs = require("fs");
|
||||
this.path = require("path");
|
||||
this.dir = BDFDB.getThemesFolder();
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -58,10 +58,10 @@ class ThemeSettings {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processV2CThemeCard (instance, wrapper) {
|
||||
if (instance.props && instance.props.theme && !wrapper.querySelector(BDFDB.dotCN._reposettingsbutton + ".themes-settings-button")) {
|
||||
let vars = this.getThemeVars(instance.props.theme.css);
|
||||
|
@ -97,7 +97,7 @@ class ThemeSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getThemeVars (css) {
|
||||
let vars = css.split(":root");
|
||||
if (vars.length > 1) {
|
||||
|
@ -110,16 +110,16 @@ class ThemeSettings {
|
|||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
createThemeSettings (wrapper, theme, vars) {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settingshtml = `<div class="theme-settings" id="theme-settings-${theme.name}"><div class="${theme.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${BDFDB.encodeToHTML(theme.name)}</div><div class="DevilBro-settings-inner"><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;">Update all variables</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorgreen + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} update-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Update</div></button></div></div></div>`;
|
||||
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
var settingspanelinner = settingspanel.querySelector(".DevilBro-settings-inner");
|
||||
|
||||
|
||||
var maxwidth = BDFDB.getRects(wrapper).width - 80;
|
||||
|
||||
|
||||
for (let varstr of vars) {
|
||||
varstr = varstr.split(":");
|
||||
let varname = varstr.shift().trim();
|
||||
|
@ -133,7 +133,7 @@ class ThemeSettings {
|
|||
varinput.setAttribute("placeholder", varvalue || "");
|
||||
settingspanelinner.appendChild(varcontainer);
|
||||
}
|
||||
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.addEventListener(this, settingspanel, "click", ".update-button", () => {
|
||||
|
@ -158,7 +158,7 @@ class ThemeSettings {
|
|||
}
|
||||
else BDFDB.showToast(`Could not find themefile: ${theme.filename}`, {type:"error"});
|
||||
});
|
||||
|
||||
|
||||
wrapper.appendChild(settingspanel);
|
||||
}
|
||||
}
|
|
@ -8,14 +8,14 @@ class TopRoleEverywhere {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Adds the highest role of a user as a tag.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"NameTag":"componentDidMount",
|
||||
"MessageUsername":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
|
||||
this.css = `
|
||||
.TRE-tag {
|
||||
border-radius: 3px;
|
||||
|
@ -38,9 +38,9 @@ class TopRoleEverywhere {
|
|||
margin-left: 2px;
|
||||
margin-right: 6px;
|
||||
}`;
|
||||
|
||||
|
||||
this.tagMarkup = `<span class="TRE-tag"><span class="role-inner"></span></span>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showInChat: {value:true, description:"Show Tag in Chat Window."},
|
||||
|
@ -54,7 +54,7 @@ class TopRoleEverywhere {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -63,11 +63,11 @@ class TopRoleEverywhere {
|
|||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
@ -94,13 +94,13 @@ class TopRoleEverywhere {
|
|||
|
||||
initialize () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.GuildPerms = BDFDB.WebModules.findByProperties("getHighestRole");
|
||||
this.GuildStore = BDFDB.WebModules.findByProperties("getGuild");
|
||||
this.UserGuildState = BDFDB.WebModules.findByProperties("getGuildId", "getLastSelectedGuildId");
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -114,16 +114,16 @@ class TopRoleEverywhere {
|
|||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processNameTag (instance, wrapper) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processMessageUsername (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message) {
|
||||
|
@ -131,7 +131,7 @@ class TopRoleEverywhere {
|
|||
if (username && BDFDB.getData("showInChat", this, "settings")) this.addRoleTag(message.author, username, "chat");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
|
@ -139,7 +139,7 @@ class TopRoleEverywhere {
|
|||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addRoleTag (info, username, type) {
|
||||
if (!info || !username) return;
|
||||
BDFDB.removeEles(username.parentElement.querySelectorAll(".TRE-tag"));
|
||||
|
@ -187,7 +187,7 @@ class TopRoleEverywhere {
|
|||
inner.style.setProperty("background-image", bgInner);
|
||||
inner.style.setProperty("-webkit-background-clip", "text");
|
||||
inner.textContent = roleText;
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ class UserNotes {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Allows you to write your own user notes wihtout a character limit.";}
|
||||
|
||||
initConstructor () {
|
||||
|
||||
initConstructor () {
|
||||
this.css = `
|
||||
.${this.name}-modal textarea {
|
||||
rows: 0;
|
||||
|
@ -25,7 +25,7 @@ class UserNotes {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.userNotesModalMarkup =
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -64,14 +64,14 @@ class UserNotes {
|
|||
</div>
|
||||
</span>`;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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);
|
||||
|
@ -117,14 +117,14 @@ class UserNotes {
|
|||
|
||||
|
||||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
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);
|
||||
|
@ -135,10 +135,10 @@ class UserNotes {
|
|||
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);
|
||||
|
|
|
@ -8,7 +8,7 @@ class WriteUpperCase {
|
|||
getAuthor () {return "DevilBro";}
|
||||
|
||||
getDescription () {return "Change input to uppercase.";}
|
||||
|
||||
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount",
|
||||
|
@ -39,7 +39,7 @@ class WriteUpperCase {
|
|||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
else {
|
||||
|
@ -48,14 +48,14 @@ class WriteUpperCase {
|
|||
}
|
||||
|
||||
stop () {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
if (instance.props && instance.props.type) {
|
||||
var textarea = wrapper.querySelector("textarea");
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
|
@ -28,11 +26,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.BE-badge-HypeSquad {width:17px}
|
||||
.BE-badge-BugHunter {width:17px}
|
||||
.BE-badge-Nitro {width:21px}`;
|
||||
|
||||
|
||||
this.loading = false;
|
||||
|
||||
|
||||
this.updateBadges = false;
|
||||
|
||||
|
||||
this.badges = {
|
||||
1: {name:"Staff", implemented:true, white:"url(https://discordapp.com/assets/7cfd90c8062139e4804a1fa59f564731.svg)", color:"url(https://discordapp.com/assets/4358ad1fb423b346324516453750f569.svg)"},
|
||||
2: {name:"Partner", implemented:true, white:"url(https://discordapp.com/assets/a0e288a458c48dfcf548dadc277e42e6.svg)", color:"url(https://discordapp.com/assets/33fedf082addb91d88abc272b4b18daa.svg)"},
|
||||
|
@ -42,10 +40,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
32: {name:"PROMODISMISSED", implemented:false, white:"", color:""},
|
||||
256: {name:"Nitro", implemented:true, white:"url(https://discordapp.com/assets/379d2b3171722ef8be494231234da5d1.svg)", color:"url(https://discordapp.com/assets/386884eecd36164487505ddfbac35a9d.svg)"}
|
||||
};
|
||||
|
||||
|
||||
this.requestedusers = {};
|
||||
this.loadedusers = {};
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showInChat: {value:true, description:"Show Badge in Chat Window."},
|
||||
|
@ -57,29 +55,31 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.UserModalUtils = BDFDB.WebModules.findByProperties("fetchMutualFriends","open");
|
||||
this.APIModule = BDFDB.WebModules.findByProperties("getAPIBaseURL");
|
||||
this.DiscordConstants = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes", "StatusTypes");
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -96,7 +96,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.memberswrap, {name:"userListObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -131,7 +131,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -146,11 +146,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"userPopoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
for (let flag in this.badges) {
|
||||
if (!this.badges[flag].implemented) delete this.badges[flag];
|
||||
}
|
||||
|
||||
|
||||
this.loadBadges();
|
||||
|
||||
return true;
|
||||
|
@ -162,9 +162,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(".BE-badge").forEach(node=>{node.remove();});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -172,15 +172,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.memberswrap, {name:"userListObserver"}, {childList:true, subtree:true});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver"}, {childList:true, subtree:true});
|
||||
this.loadBadges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -219,10 +219,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addBadges (wrapper, type, compact, settings = BDFDB.getAllData(this, "settings")) {
|
||||
if (!wrapper) return;
|
||||
|
||||
|
||||
let user = compact ? BDFDB.getKeyInformation({"node":$(BDFDB.dotCN.messagegroup).has(wrapper)[0],"key":"message"}).author : BDFDB.getKeyInformation({"node":wrapper,"key":"user"});
|
||||
if (user && !user.bot) {
|
||||
if (!this.requestedusers[user.id]) {
|
||||
|
@ -242,7 +242,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addToWrapper (wrapper, id, type, settings) {
|
||||
if (wrapper.querySelector(".BE-badge")) return;
|
||||
let memberwrap = wrapper.querySelector(BDFDB.dotCNC.memberusername + BDFDB.dotCNC.messageusernamewrapper + BDFDB.dotCN.nametag);
|
||||
|
@ -259,7 +259,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
@ -267,15 +267,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateBadges) {
|
||||
this.loadBadges();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
|
@ -10,32 +8,34 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
display: none !important;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.relationshipTypes = {};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
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) => {
|
||||
|
@ -57,7 +57,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.idCN.friends, {name:"friendListObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -66,7 +66,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.friendsonline, {name:"friendCountObserver",instance:observer}, {childList:true, subtree:true, characterData:true});
|
||||
|
||||
|
||||
this.FriendUtils = BDFDB.WebModules.findByProperties("getFriendIDs", "getRelationships");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatuses", "getOnlineFriendCount");
|
||||
var RelationshipTypes = BDFDB.WebModules.findByProperties("RelationshipTypes").RelationshipTypes;
|
||||
|
@ -84,9 +84,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(".betterfriendcount-badge").forEach(counter => {counter.remove();});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -94,24 +94,24 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
this.addCountNumbers();
|
||||
|
||||
|
||||
BDFDB.addObserver(this, BDFDB.idCN.friends, {name:"friendListObserver"}, {childList:true, subtree:true});
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
addCountNumbers () {
|
||||
var friendstabbar = document.querySelector(BDFDB.idCNS.friends + BDFDB.dotCN.friendstabbar);
|
||||
if (!friendstabbar) return;
|
||||
friendstabbar.querySelectorAll(".betterfriendcount-badge").forEach(counter => {counter.remove();});
|
||||
|
||||
|
||||
var relationships = this.FriendUtils.getRelationships(), relationshipCount = {};
|
||||
for (let type in this.relationshipTypes) {relationshipCount[this.relationshipTypes[type]] = 0;}
|
||||
for (let id in relationships) {relationshipCount[this.relationshipTypes[relationships[id]]]++;}
|
||||
|
||||
|
||||
var tabitems = friendstabbar.querySelectorAll(BDFDB.dotCN.friendstabbaritem);
|
||||
$(`<div class="badge betterfriendcount-badge friendcount">${relationshipCount.FRIEND}</div>`).appendTo(tabitems[1]);
|
||||
$(`<div class="badge betterfriendcount-badge onlinefriendcount">${this.UserMetaStore.getOnlineFriendCount()}</div>`).appendTo(tabitems[2]);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
|
@ -22,30 +20,32 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
background-color: rgba(240, 71, 71, 0.0980392);
|
||||
border: 1px solid rgba(240, 71, 71, 0.498039);
|
||||
}`;
|
||||
|
||||
|
||||
this.tagMarkup = `<span class="nsfw-tag">NSFW</span>`;
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -65,7 +65,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.channels, {name:"channelListObserver",instance:observer}, {childList: true, subtree: true});
|
||||
|
||||
|
||||
this.checkAllContainers();
|
||||
|
||||
return true;
|
||||
|
@ -77,9 +77,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
$(".nsfw-tag").remove();
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -87,28 +87,28 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.checkAllContainers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
checkAllContainers () {
|
||||
document.querySelectorAll(BDFDB.dotCNS.channels + "[class*=container-]").forEach(container => {
|
||||
this.checkContainerForNsfwChannel(container);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
checkContainerForNsfwChannel (container) {
|
||||
container.querySelectorAll(BDFDB.dotCN.channelcontainerdefault).forEach(channel => {
|
||||
this.checkChannel(channel);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
checkChannel (channel) {
|
||||
let channelData = BDFDB.getKeyInformation({"node":channel,"key":"channel"});
|
||||
if (channelData && channelData.nsfw == true) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
|
@ -38,7 +36,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
opacity: 1;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addFirstLast: {value:true, description:"Adds a first and last page button."},
|
||||
|
@ -47,30 +45,32 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.SearchNavigation = BDFDB.WebModules.findByProperties("searchNextPage","searchPreviousPage");
|
||||
this.SearchUtils = BDFDB.WebModules.findByProperties("getCurrentSearchId");
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -103,7 +103,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCNS.searchresultswrap, {name:"searchResultsObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
let pagination = document.querySelector(BDFDB.dotCNS.searchresultswrap + BDFDB.dotCNS.searchresultspagination);
|
||||
if (pagination) this.addNewControls(pagination);
|
||||
|
||||
|
@ -116,9 +116,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(".BSP-pagination, .BSP-pagination-button, .BSP-pagination-jumpinput").forEach(ele => {ele.remove();});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
let pagination = document.querySelector(BDFDB.dotCNS.searchresultswrap + BDFDB.dotCNS.searchresultspagination);
|
||||
if (pagination) this.addNewControls(pagination);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -144,7 +144,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
|
||||
addNewControls (pagination) {
|
||||
if (!pagination || document.querySelector(".BSP-pagination, .BSP-pagination-button, .BSP-pagination-jumpinput")) return;
|
||||
let searchResults = document.querySelector(BDFDB.dotCN.searchresults);
|
||||
|
@ -192,12 +192,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
</div>`)[0];
|
||||
pagination.appendChild(jumpInput);
|
||||
}
|
||||
BDFDB.initElements(pagination);
|
||||
BDFDB.initElements(pagination, this);
|
||||
if (settings.cloneToTheTop) {
|
||||
let BSPpaginaton = pagination.cloneNode(true);
|
||||
BSPpaginaton.classList.add("BSP-pagination");
|
||||
searchResults.parentElement.insertBefore(BSPpaginaton, searchResults);
|
||||
BDFDB.initElements(BSPpaginaton);
|
||||
BDFDB.initElements(BSPpaginaton, this);
|
||||
}
|
||||
$(searchResults.parentElement)
|
||||
.off("click." + this.name).off("keyup." + this.name)
|
||||
|
@ -245,7 +245,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
@ -253,14 +253,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
document.querySelectorAll(".BSP-pagination, .BSP-pagination-button, .BSP-pagination-jumpinput").forEach(ele => {ele.remove();});
|
||||
let pagination = document.querySelector(BDFDB.dotCNS.searchresultswrap + BDFDB.dotCNS.searchresultspagination);
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.selecting = false;
|
||||
|
||||
|
||||
this.counterMarkup = `<div id="charcounter"></div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
#charcounter {
|
||||
display: block;
|
||||
|
@ -30,27 +28,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
bottom: -1.0em;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -67,7 +67,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"textareaObserver",instance:observer}, {childList: true, subtree: true});
|
||||
|
||||
|
||||
document.querySelectorAll("textarea").forEach(textarea => {this.appendCounter(textarea);});
|
||||
|
||||
return true;
|
||||
|
@ -80,10 +80,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
$("#charcounter").remove();
|
||||
$(".charcounter-added").removeClass("charcounter-added");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
appendCounter (textarea) {
|
||||
if (!textarea) return;
|
||||
var textareaWrap = textarea.parentElement;
|
||||
|
@ -102,12 +102,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
if (textareaInstance && textareaInstance.props && textareaInstance.props.type) {
|
||||
var counter = $(this.counterMarkup);
|
||||
counter.addClass(textareaInstance.props.type).appendTo(textareaWrap);
|
||||
|
||||
|
||||
var updateCounter = () => {
|
||||
var selection = textarea.selectionEnd - textarea.selectionStart == 0 ? "" : " (" + (textarea.selectionEnd - textarea.selectionStart) + ")";
|
||||
counter.text(BDFDB.getParsedLength(textarea.value) + "/2000" + selection);
|
||||
}
|
||||
|
||||
|
||||
textareaWrap.parentElement.classList.add("charcounter-added");
|
||||
$(textarea)
|
||||
.off("keydown." + this.name + " click." + this.name)
|
||||
|
@ -135,7 +135,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
},10);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
updateCounter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.configstypes = ["case","exact","autoc","regex","file"];
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addAutoComplete: {value:true, description:"Add an Autocomplete-Menu for Non-Regex Aliases:"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
this.UploadModule = BDFDB.WebModules.findByProperties("instantBatchUpload");
|
||||
|
@ -61,9 +61,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
aliases[alias].autoc = aliases[alias].autoc == undefined ? !aliases[alias].regex : aliases[alias].autoc;
|
||||
}
|
||||
BDFDB.saveAllData(aliases, this, "words");
|
||||
|
||||
|
||||
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
|
||||
|
||||
|
||||
$(document).off("click." + this.name).on("click." + this.name, (e) => {
|
||||
if (!e.target.tagName === "TEXTAREA") $(".autocompleteAliases, .autocompleteAliasesRow").remove();
|
||||
});
|
||||
|
@ -77,9 +77,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
$(".autocompleteAliases, .autocompleteAliasesRow").remove();
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
settings[input.value] = input.checked;
|
||||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
|
||||
|
||||
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
containerhtml += `</div><div word="${word}" action="remove" class="${BDFDB.disCN.hovercardbutton} remove-word"></div></div>`;
|
||||
}
|
||||
$(settingspanel).find(".alias-list").html(containerhtml);
|
||||
BDFDB.initElements(settingspanel);
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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)) {
|
||||
$(".autocompleteAliases, .autocompleteAliasesRow").remove();
|
||||
|
@ -291,7 +291,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addAutoCompleteMenu (textarea) {
|
||||
if (textarea.parentElement.querySelector(".autocompleteAliasesRow")) return;
|
||||
let words = textarea.value.split(" ");
|
||||
|
@ -330,14 +330,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
else {
|
||||
amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length;
|
||||
}
|
||||
|
||||
|
||||
$(autocompletemenu)
|
||||
.append(`<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>`)
|
||||
.off("mouseenter." + this.name).on("mouseenter." + this.name, BDFDB.dotCN.autocompleteselectable, (e) => {
|
||||
autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected).forEach(selected => {selected.classList.remove(BDFDB.disCN.autocompleteselected);});
|
||||
e.currentTarget.classList.add(BDFDB.disCN.autocompleteselected);
|
||||
});
|
||||
|
||||
|
||||
for (let alias in matchedaliases) {
|
||||
if (amount-- < 1) break;
|
||||
$(`<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(alias)}</div><div class="${BDFDB.disCNS.autocompletedescription + BDFDB.disCN.flexchild}">${BDFDB.encodeToHTML(matchedaliases[alias].replace)}</div></div></div></div>`)
|
||||
|
@ -352,7 +352,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getNextSelection (menu, selected, forward) {
|
||||
selected = selected ? selected : menu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement;
|
||||
let next, sibling = forward ? selected.nextElementSibling : selected.previousElementSibling;
|
||||
|
@ -365,7 +365,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return next ? next : this.getNextSelection(menu, sibling, forward);
|
||||
}
|
||||
|
||||
|
||||
swapWordWithAlias (textarea) {
|
||||
let aliasword = textarea.parentElement.querySelector(".autocompleteAliasesRow " + BDFDB.dotCN.autocompleteselected + " .aliasword").innerText;
|
||||
let lastword = textarea.parentElement.querySelector(".autocompleteAliasesRow .lastword").innerText;
|
||||
|
@ -432,7 +432,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
rest = string.slice(a.indexOf(b)+b.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var words = BDFDB.loadAllData(this, "words");
|
||||
|
@ -472,7 +472,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("click", ".toggle-info", (e) => {this.toggleInfo(settingspanel, e.currentTarget);});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
|
||||
}
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.configstypes = ["case","exact"];
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCNS.messagegroup + BDFDB.dotCNS.messagecomment + BDFDB.dotCN.messageaccessory}.blocked:not(.revealed),
|
||||
${BDFDB.dotCNS.messagegroup + BDFDB.dotCNS.messagecomment + BDFDB.dotCN.messagemarkup}.blocked:not(.revealed) {
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCNS.messagegroup + BDFDB.dotCNS.messagecomment + BDFDB.dotCN.messageaccessory}.censored:not(.revealed),
|
||||
${BDFDB.dotCNS.messagegroup + BDFDB.dotCNS.messagecomment + BDFDB.dotCN.messagemarkup}:not(.revealed) {
|
||||
|
||||
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
replaces: {
|
||||
blocked: {value:"~~BLOCKED~~", title:"Block:", description:"Default Replace Word for blocked Messages:"},
|
||||
|
@ -30,27 +28,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -68,7 +68,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, null, {name:"messageChangeObserver",instance:observer,multi:true}, {childList:true, characterData:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -86,7 +86,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true});
|
||||
|
||||
|
||||
this.hideAllMessages();
|
||||
|
||||
return true;
|
||||
|
@ -98,11 +98,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -110,22 +110,22 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
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") || {};
|
||||
|
||||
|
||||
if (action == "add") {
|
||||
var wordinput = settingspanel.querySelector("#input-" + rtype + "-wordvalue");
|
||||
var replaceinput = settingspanel.querySelector("#input-" + rtype + "-replacevalue");
|
||||
|
@ -161,7 +161,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`
|
||||
|
@ -172,10 +172,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
containerhtml += `</div>`;
|
||||
$(settingspanel).find("." + rtype + "-list").html(containerhtml);
|
||||
BDFDB.initElements(settingspanel);
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
saveReplace (input) {
|
||||
var rtype = input.getAttribute("rtype");
|
||||
var wordvalue = input.value;
|
||||
|
@ -195,7 +195,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
|
||||
updateConfig (ele) {
|
||||
var wordvalue = ele.getAttribute("word");
|
||||
var config = ele.getAttribute("config");
|
||||
|
@ -206,7 +206,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.saveData(rtype, words, this, "words");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toggleInfo (settingspanel, ele) {
|
||||
ele.classList.toggle(BDFDB.disCN.categorywrappercollapsed);
|
||||
ele.classList.toggle(BDFDB.disCN.categorywrapperdefault);
|
||||
|
@ -214,12 +214,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
svg.classList.toggle(BDFDB.disCN.closed);
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
hideAllMessages () {
|
||||
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {
|
||||
this.resetMessage(message);
|
||||
|
@ -231,15 +231,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
hideMessage (message) {
|
||||
if (!$(message).hasClass("blocked") && !$(message).hasClass("censored")) {
|
||||
var orightml = $(message).html();
|
||||
var newhtml = "";
|
||||
|
||||
|
||||
if (orightml) {
|
||||
var blocked = null;
|
||||
|
||||
|
||||
var strings = [];
|
||||
var count = 0;
|
||||
orightml.split("").forEach((chara) => {
|
||||
|
@ -251,7 +251,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var replaces = BDFDB.getAllData(this, "replaces");
|
||||
var blockedWords = BDFDB.loadData("blocked", this, "words");
|
||||
|
@ -283,7 +283,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.addClass("blocked")
|
||||
.data("newhtmlChatFilter",newhtml)
|
||||
.data("orightmlChatFilter",orightml);
|
||||
|
||||
|
||||
this.addClickListener(message, settings.showMessageOnClick.blocked);
|
||||
}
|
||||
else {
|
||||
|
@ -317,27 +317,27 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
newhtml = strings.join("");
|
||||
|
||||
|
||||
if (newhtml != orightml) {
|
||||
$(message)
|
||||
.html(newhtml)
|
||||
.addClass("censored")
|
||||
.data("newhtmlChatFilter",newhtml)
|
||||
.data("orightmlChatFilter",orightml);
|
||||
|
||||
|
||||
this.addClickListener(message, settings.showMessageOnClick.censored);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createReg (word, config) {
|
||||
return new RegExp(BDFDB.encodeToHTML(config.exact ? "^" + BDFDB.regEscape(word) + "$" : BDFDB.regEscape(word)), config.case ? "" : "i");
|
||||
}
|
||||
|
||||
|
||||
getEmojiName (string) {
|
||||
if (string.indexOf("<img ") == 0 && (string.indexOf('class="emote') > -1 || string.indexOf('class="emoji') > -1)) {
|
||||
var emojiname = string.split('alt="').length > 0 ? string.split('alt="')[1] : null;
|
||||
|
@ -345,7 +345,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return emojiname = emojiname ? emojiname.replace(new RegExp(":", 'g'), "") : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resetMessage (message) {
|
||||
$(message)
|
||||
.html($(message).data("orightmlChatFilter"))
|
||||
|
@ -354,7 +354,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.removeClass("censored")
|
||||
.removeClass("revealed");
|
||||
}
|
||||
|
||||
|
||||
addClickListener (message, add) {
|
||||
$(message)
|
||||
.off("click." + this.name);
|
||||
|
@ -362,7 +362,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
var orightml = $(message).data("orightmlChatFilter");
|
||||
var newhtml = $(message).data("newhtmlChatFilter");
|
||||
$(message)
|
||||
.on("click." + this.name, () => {
|
||||
.on("click." + this.name, () => {
|
||||
if ($(message).hasClass("revealed")) {
|
||||
$(message)
|
||||
.html(newhtml)
|
||||
|
@ -374,7 +374,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.addClass("revealed");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
getSettingsPanel () {
|
||||
|
@ -388,7 +388,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`;
|
||||
}
|
||||
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: 495px;">List of ${rtype} Words:</h3><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.tableheadersize + BDFDB.disCNS.size10 + BDFDB.disCNS.primary + BDFDB.disCN.weightbold}" style="flex: 1 1 auto; max-width: 32px;">CASE</div><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.tableheadersize + BDFDB.disCNS.size10 + BDFDB.disCNS.primary + BDFDB.disCN.weightbold}" style="flex: 0 0 auto;">EXACT</div></div><div class="DevilBro-settings-inner-list ${rtype}-list">`;
|
||||
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: 495px;">List of ${rtype} Words:</h3><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.tableheadersize + BDFDB.disCNS.size10 + BDFDB.disCNS.primary + BDFDB.disCN.weightbold}" style="flex: 1 1 auto; max-width: 32px;">CASE</div><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.tableheadersize + BDFDB.disCNS.size10 + BDFDB.disCNS.primary + BDFDB.disCN.weightbold}" style="flex: 0 0 auto;">EXACT</div></div><div class="DevilBro-settings-inner-list ${rtype}-list">`;
|
||||
for (let word in words) {
|
||||
settingshtml += `<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) {
|
||||
|
@ -404,7 +404,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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.cursorpointer} ${infoHidden ? BDFDB.disCN.categorywrappercollapsed : BDFDB.disCN.categorywrapperdefault} toggle-info" style="flex: 1 1 auto;"><svg class="${BDFDB.disCNS.categoryicontransition + (infoHidden ? BDFDB.disCNS.closed + 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;'" : ""}><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>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
|
@ -414,7 +414,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.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);});
|
||||
|
||||
|
||||
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();
|
||||
|
@ -422,7 +422,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
this.hideAllMessages();
|
||||
}
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.languages;
|
||||
|
||||
|
||||
this.updateTimestamps = false;
|
||||
|
||||
|
||||
this.compactWidth = null;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showInChat: {value:true, description:"Replace Chat Timestamp with Complete Timestamp:"},
|
||||
|
@ -30,27 +28,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -70,14 +70,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"messageObserver",instance:observer}, {childList: true, subtree: true});
|
||||
|
||||
|
||||
this.languages = Object.assign({},
|
||||
{"own": {name:"Own", id:"own", integrated:false, dic:false}},
|
||||
BDFDB.languages
|
||||
);
|
||||
|
||||
|
||||
this.setMaxWidth();
|
||||
|
||||
|
||||
$(document)
|
||||
.on("mouseenter." + this.name, BDFDB.dotCNS.message + BDFDB.dotCNC.messagetext + BDFDB.dotCNS.message + BDFDB.dotCN.messageaccessory, (e) => {
|
||||
if (BDFDB.getData("showOnHover", this, "settings")) {
|
||||
|
@ -105,7 +105,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, info.editedTimestamp._i), marker, {type:"top",selector:"completetimestampedit-tooltip",css:customTooltipCSS});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.querySelectorAll(BDFDB.dotCN.messagetext).forEach(message => {this.changeTimestamp(message);});
|
||||
|
||||
return true;
|
||||
|
@ -118,9 +118,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(".complete-timestamp").forEach(timestamp => {timestamp.classList.remove("complete-timestamp");});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -157,7 +157,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
this.updateTimestamps = true;
|
||||
}
|
||||
|
||||
|
||||
toggleInfo (settingspanel, ele) {
|
||||
ele.classList.toggle(BDFDB.disCN.categorywrappercollapsed);
|
||||
ele.classList.toggle(BDFDB.disCN.categorywrapperdefault);
|
||||
|
@ -165,24 +165,24 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
svg.classList.toggle(BDFDB.disCN.closed);
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (e) {
|
||||
var selectControl = e.currentTarget;
|
||||
var selectWrap = selectControl.parentElement;
|
||||
|
||||
|
||||
if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
selectWrap.classList.add(BDFDB.disCN.selectisopen);
|
||||
$("li").has(selectWrap).css("overflow", "visible");
|
||||
|
||||
|
||||
var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"));
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
$(selectMenu).on("mousedown." + this.name, BDFDB.dotCN.selectoption, (e2) => {
|
||||
var language = e2.currentTarget.getAttribute("value");
|
||||
selectWrap.setAttribute("value", language);
|
||||
|
@ -198,7 +198,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var key in this.languages) {
|
||||
|
@ -208,7 +208,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
menuhtml += `</div></div>`;
|
||||
return $(menuhtml)[0];
|
||||
}
|
||||
|
||||
|
||||
changeTimestamp (message) {
|
||||
if (!message || !message.tagName || !BDFDB.getData("showInChat", this, "settings")) return;
|
||||
var messagegroup = this.getMessageGroup(message);
|
||||
|
@ -231,7 +231,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getMessageGroup (message) {
|
||||
var messagegroup = null;
|
||||
while (messagegroup == null || message.parentElement) {
|
||||
|
@ -240,14 +240,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return messagegroup;
|
||||
}
|
||||
|
||||
|
||||
getMessageData (message, messagegroup) {
|
||||
var pos = $(messagegroup).find(BDFDB.dotCN.message).index($(messagegroup).find(BDFDB.dotCN.message).has(message)[0]);
|
||||
var info = BDFDB.getKeyInformation({"node":message,"key":"messages","up":true,"time":1000});
|
||||
if (info && pos > -1) info = info[pos];
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
getTimestamp (languageid, time = new Date()) {
|
||||
var settings = BDFDB.getAllData(this, "settings"), timestring = "";
|
||||
if (languageid != "own") {
|
||||
|
@ -283,21 +283,21 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return timestring;
|
||||
}
|
||||
|
||||
|
||||
cutOffSeconds (timestring) {
|
||||
return timestring.replace(/(.*):(.*):(.{2})(.*)/, "$1:$2$4");
|
||||
}
|
||||
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
var chararray = timestring.split("");
|
||||
var numreg = /[0-9]/;
|
||||
for (var 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];
|
||||
}
|
||||
|
||||
|
||||
return chararray.join("");
|
||||
}
|
||||
|
||||
|
||||
setMaxWidth () {
|
||||
var wrapper = $(`<div class="${BDFDB.disCNS.messagegroup + BDFDB.disCN.messagecompact}"><div class="${BDFDB.disCN.messagetimestamp}"></div></div>`);
|
||||
var timestamp = wrapper.find(BDFDB.dotCN.messagetimestamp);
|
||||
|
@ -306,7 +306,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.compactWidth = timestamp.css("width", "auto").text(this.getTimestamp(this.languages[choice].id, new Date(253402124399995))).outerWidth();
|
||||
wrapper.remove();
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var choices = BDFDB.getAllData(this, "choices");
|
||||
|
@ -326,7 +326,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
|
||||
|
@ -337,7 +337,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("click", ".toggle-info", (e) => {this.toggleInfo(settingspanel, e.currentTarget);});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateTimestamps) {
|
||||
this.setMaxWidth();
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.languages;
|
||||
|
||||
|
||||
this.creationDateMarkup = `<div class="creationDate ${BDFDB.disCN.textrow}"></div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheadernormal} .creationDate {
|
||||
color: #b9bbbe;
|
||||
|
@ -26,8 +24,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
${BDFDB.dotCN.themedark} [class*='topSection'] .creationDate {
|
||||
color: hsla(0,0%,100%,.6);
|
||||
}`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addInUserPopout: {value:true, description:"Add in User Popouts:"},
|
||||
|
@ -40,27 +38,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -77,7 +77,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"userPopoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -92,7 +92,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.app + " ~ [class^='theme-']:not([class*='popouts'])", {name:"userProfilModalObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
this.languages = Object.assign({},BDFDB.languages);
|
||||
|
||||
return true;
|
||||
|
@ -105,7 +105,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -124,20 +124,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (e) {
|
||||
var selectControl = e.currentTarget;
|
||||
var selectWrap = selectControl.parentElement;
|
||||
|
||||
|
||||
if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
selectWrap.classList.add(BDFDB.disCN.selectisopen);
|
||||
$("li").has(selectWrap).css("overflow", "visible");
|
||||
|
||||
|
||||
var type = selectWrap.getAttribute("type");
|
||||
var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
$(selectMenu).on("mousedown." + this.name, BDFDB.dotCN.selectoption, (e2) => {
|
||||
var language = e2.currentTarget.getAttribute("value");
|
||||
selectWrap.setAttribute("value", language);
|
||||
|
@ -153,7 +153,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice, type) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var key in this.languages) {
|
||||
|
@ -163,7 +163,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
menuhtml += `</div></div>`;
|
||||
return $(menuhtml)[0];
|
||||
}
|
||||
|
||||
|
||||
addCreationDate (container) {
|
||||
if (!container) return;
|
||||
var info = BDFDB.getKeyInformation({"node":container,"key":"user"});
|
||||
|
@ -175,24 +175,24 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
container.insertBefore(creationDate[0], nametag ? nametag.nextSibling : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getCreationTime (languageid, timestamp = new Date()) {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var timestring = settings.addCreationTime ? timestamp.toLocaleString(languageid) : timestamp.toLocaleDateString(languageid);
|
||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
||||
return timestring;
|
||||
}
|
||||
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
var chararray = timestring.split("");
|
||||
var numreg = /[0-9]/;
|
||||
for (var 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];
|
||||
}
|
||||
|
||||
|
||||
return chararray.join("");
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var choices = BDFDB.getAllData(this, "choices");
|
||||
|
@ -204,7 +204,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
|
@ -218,7 +218,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu(e);});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
|
@ -13,7 +11,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<path fill="#ffffff" d="M8.84273967,12.8167603 L13.8643,7.7952 C14.0513,7.6072 14.0513,7.3042 13.8643,7.1172 C13.6773,6.9312 13.3743,6.9312 13.1863,7.1172 L8.52303089,11.78139 L6.8883,10.1475 C6.6843,9.9445 6.3553,9.9445 6.1523,10.1475 C5.9493,10.3515 5.9493,10.6805 6.1523,10.8835 L8.08381122,12.8160053 C8.09561409,12.8309877 8.10844368,12.8454178 8.1223,12.8592 C8.3093,13.0472 8.6123,13.0472 8.8003,12.8592 L8.82157566,12.8379243 C8.82518839,12.8345112 8.82876362,12.8310364 8.8323,12.8275 C8.83584168,12.8239583 8.83932157,12.820378 8.84273967,12.8167603 Z"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
.bd-minimal ${BDFDB.dotCN.guildswrapper}.DSAC-styled,
|
||||
.bd-minimal ${BDFDB.dotCN.guildswrapper}.DSAC-styled ${BDFDB.dotCN.scrollerwrapold},
|
||||
|
@ -149,29 +147,31 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
top: -5px;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
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) => {
|
||||
|
@ -190,11 +190,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true, subtree:true, attributes:true, attributeFilte: ["class", "draggable"], attributeOldValue: true});
|
||||
|
||||
|
||||
BDFDB.readServerList().forEach(serverObj => {
|
||||
this.changeServer(serverObj);
|
||||
});
|
||||
|
||||
|
||||
document.body.classList.add("DSAC-styled");
|
||||
$(BDFDB.dotCN.guildswrapper).addClass("DSAC-styled");
|
||||
|
||||
|
@ -207,12 +207,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.readServerList().forEach(serverObj => {
|
||||
this.resetServer(serverObj);
|
||||
});
|
||||
$(".DSAC-styled").removeClass("DSAC-styled");
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeServer (serverObj) {
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.channelContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} localchannelsettings-item ${BDFDB.disCN.contextmenuitemsubmenu}">
|
||||
|
@ -14,7 +12,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.channelContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} editchannels-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -77,34 +75,36 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
changeInChannelHeader: {value:true, description:"Change in Channel Header."}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -132,7 +132,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.channels, {name:"channelListObserver",instance:observer}, {childList: true, attributes:true, subtree: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -147,9 +147,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"channelContextObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
this.loadAllChannels();
|
||||
|
||||
|
||||
this.changeChannelHeader();
|
||||
|
||||
return true;
|
||||
|
@ -161,9 +161,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.resetAllChannels();
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -171,16 +171,16 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
$(`${BDFDB.dotCN.channelheadertitletext}[custom-editchannelsheader]`).find(BDFDB.dotCN.channelheaderchannelname + BDFDB.dotCN.channelheaderprivate).css("color", "").css("background-color", "").parent().removeAttr("custom-editchannelsheader");
|
||||
this.loadAllChannels();
|
||||
setImmediate(() => {this.changeChannelHeader();}); //setImmediate so EditChannels sets the color after EditUsers set it back to white
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -194,23 +194,23 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
resetAll () {
|
||||
if (confirm("Are you sure you want to reset all channels?")) {
|
||||
BDFDB.removeAllData(this, "channels");
|
||||
|
||||
|
||||
this.resetAllChannels();
|
||||
}
|
||||
}
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.channelContextEntryMarkup = this.channelContextEntryMarkup.replace("REPLACE_context_localchannelsettings_text", this.labels.context_localchannelsettings_text);
|
||||
|
||||
|
||||
this.channelContextSubMenuMarkup = this.channelContextSubMenuMarkup.replace("REPLACE_submenu_channelsettings_text", this.labels.submenu_channelsettings_text);
|
||||
this.channelContextSubMenuMarkup = this.channelContextSubMenuMarkup.replace("REPLACE_submenu_resetsettings_text", this.labels.submenu_resetsettings_text);
|
||||
|
||||
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_modal_channelname_text", this.labels.modal_channelname_text);
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_modal_colorpicker1_text", this.labels.modal_colorpicker1_text);
|
||||
this.channelSettingsModalMarkup = this.channelSettingsModalMarkup.replace("REPLACE_btn_save_text", this.labels.btn_save_text);
|
||||
}
|
||||
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!context || !context.tagName || !context.parentElement || context.querySelector(".localchannelsettings-item")) return;
|
||||
var info = BDFDB.getKeyInformation({"node":context, "key":"channel"});
|
||||
|
@ -219,20 +219,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("mouseenter", ".localchannelsettings-item", (e) => {
|
||||
this.createContextSubMenu(info, e, context);
|
||||
});
|
||||
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createContextSubMenu (info, e, context) {
|
||||
var channelContextSubMenu = $(this.channelContextSubMenuMarkup);
|
||||
|
||||
|
||||
channelContextSubMenu
|
||||
.on("click", ".channelsettings-item", () => {
|
||||
$(context).hide();
|
||||
this.showChannelSettings(info);
|
||||
});
|
||||
|
||||
|
||||
if (BDFDB.loadData(info.id, this, "channels")) {
|
||||
channelContextSubMenu
|
||||
.find(".resetsettings-item")
|
||||
|
@ -242,18 +242,18 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.removeChannelData(info);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, channelContextSubMenu);
|
||||
}
|
||||
|
||||
|
||||
showChannelSettings (info) {
|
||||
var channelObj = BDFDB.getDivOfChannel(info.id);
|
||||
|
||||
|
||||
var data = BDFDB.loadData(info.id, this, "channels");
|
||||
|
||||
|
||||
var name = data ? data.name : null;
|
||||
var color = data ? data.color : null;
|
||||
|
||||
|
||||
var channelSettingsModal = $(this.channelSettingsModalMarkup);
|
||||
channelSettingsModal.find(BDFDB.dotCN.modalguildname).text(info.name);
|
||||
channelSettingsModal.find("#input-channelname").val(name);
|
||||
|
@ -263,20 +263,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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("swatch1");
|
||||
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) {
|
||||
this.removeChannelData(info.id);
|
||||
}
|
||||
|
@ -286,56 +286,56 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.changeChannelHeader();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
channelSettingsModal.find("#input-channelname").focus();
|
||||
}
|
||||
|
||||
|
||||
removeChannelData (info) {
|
||||
this.resetChannel(BDFDB.getDivOfChannel(info.id));
|
||||
|
||||
|
||||
BDFDB.removeData(info.id, this, "channels");
|
||||
|
||||
|
||||
this.changeChannelHeader();
|
||||
}
|
||||
|
||||
|
||||
resetChannel (channelObj) {
|
||||
if (!channelObj || !channelObj.div) return;
|
||||
|
||||
|
||||
var channel = channelObj.div.querySelector(BDFDB.dotCNC.channelname + BDFDB.dotCN.categorycolortransition);
|
||||
|
||||
|
||||
$(channelObj.div)
|
||||
.removeAttr("custom-editchannels");
|
||||
$(channel)
|
||||
.css("color", "");
|
||||
|
||||
|
||||
BDFDB.setInnerText(channel, channelObj.name);
|
||||
}
|
||||
|
||||
|
||||
loadChannel (channelObj) {
|
||||
if (!channelObj || !channelObj.div) return;
|
||||
|
||||
|
||||
var channel = channelObj.div.querySelector(BDFDB.dotCNC.channelname + BDFDB.dotCN.categorycolortransition);
|
||||
|
||||
|
||||
var data = BDFDB.loadData(channelObj.id, this, "channels");
|
||||
if (data) {
|
||||
var name = data.name ? data.name : channelObj.name;
|
||||
var color = data.color ? this.chooseColor(channel, data.color) : "";
|
||||
|
||||
|
||||
$(channelObj.div)
|
||||
.attr("custom-editchannels", true);
|
||||
$(channel)
|
||||
.css("color", color);
|
||||
|
||||
|
||||
BDFDB.setInnerText(channel, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadAllChannels () {
|
||||
for (let channelObj of BDFDB.readChannelList()) {
|
||||
this.loadChannel(channelObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeChannelHeader () {
|
||||
if (BDFDB.getData("changeInChannelHeader", this, "settings")) {
|
||||
var channelHeader = document.querySelector(BDFDB.dotCNS.channelheadertitle + BDFDB.dotCN.channelheadertitletext);
|
||||
|
@ -349,7 +349,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
var color = data && data.color ? BDFDB.color2RGB(data.color) : "";
|
||||
BDFDB.setInnerText(channel, name);
|
||||
$(channel).css("color", color);
|
||||
|
||||
|
||||
if (data && (data.name || data.color)) {
|
||||
$(channelHeader).attr("custom-editchannelsheader", true);
|
||||
}
|
||||
|
@ -359,13 +359,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resetAllChannels () {
|
||||
document.querySelectorAll("[custom-editchannels]").forEach(channelDiv => {
|
||||
var info = BDFDB.getKeyInformation({"node":channelDiv, "key":"channel"});
|
||||
if (info) this.resetChannel({div:channelDiv,info});
|
||||
});
|
||||
|
||||
|
||||
var channelHeader = document.querySelector("[custom-editchannelsheader]");
|
||||
if (channelHeader) {
|
||||
var info = BDFDB.getKeyInformation({"node":channelHeader, "key":"channel"});
|
||||
|
@ -393,7 +393,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
@ -402,7 +402,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
|
@ -410,7 +410,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("click", ".reset-button", () => {this.resetAll();});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.serverDragged = false;
|
||||
|
||||
this.serverContextEntryMarkup =
|
||||
|
@ -16,7 +14,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} editservers-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -124,25 +122,27 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -159,7 +159,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"serverContextObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -178,7 +178,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true, subtree:true, attributes:true, attributeFilte: ["class", "draggable"], attributeOldValue: true});
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
this.loadAllServers();
|
||||
},3000);
|
||||
|
@ -192,9 +192,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll("[custom-editservers]").forEach(serverDiv => {this.resetServer(BDFDB.getIdOfServer(serverDiv));});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -203,23 +203,23 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
resetAll () {
|
||||
if (confirm("Are you sure you want to reset all servers?")) {
|
||||
BDFDB.removeAllData(this, "servers");
|
||||
|
||||
|
||||
document.querySelectorAll("[custom-editservers]").forEach(serverDiv => {this.resetServer(BDFDB.getIdOfServer(serverDiv));});
|
||||
}
|
||||
}
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.serverContextEntryMarkup = this.serverContextEntryMarkup.replace("REPLACE_context_localserversettings_text", this.labels.context_localserversettings_text);
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_serversettings_text", this.labels.submenu_serversettings_text);
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_resetsettings_text", this.labels.submenu_resetsettings_text);
|
||||
|
||||
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_servername_text", this.labels.modal_servername_text);
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_servershortname_text", this.labels.modal_servershortname_text);
|
||||
|
@ -234,7 +234,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_modal_colorpicker4_text", this.labels.modal_colorpicker4_text);
|
||||
this.serverSettingsModalMarkup = this.serverSettingsModalMarkup.replace("REPLACE_btn_save_text", this.labels.btn_save_text);
|
||||
}
|
||||
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!context || !context.tagName || !context.parentElement || context.querySelector(".localserversettings-item")) return;
|
||||
var info = BDFDB.getKeyInformation({"node":context, "key":"guild"});
|
||||
|
@ -243,22 +243,22 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("mouseenter", ".localserversettings-item", (e) => {
|
||||
this.createContextSubMenu(info, e, context);
|
||||
});
|
||||
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createContextSubMenu (info, e, context) {
|
||||
var id = info.id;
|
||||
|
||||
|
||||
var serverContextSubMenu = $(this.serverContextSubMenuMarkup);
|
||||
|
||||
|
||||
serverContextSubMenu
|
||||
.on("click", ".serversettings-item", () => {
|
||||
$(context).hide();
|
||||
this.showServerSettings(info);
|
||||
});
|
||||
|
||||
|
||||
if (BDFDB.loadData(id, this, "servers")) {
|
||||
serverContextSubMenu
|
||||
.find(".resetsettings-item")
|
||||
|
@ -268,13 +268,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.removeServerData(info.id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, serverContextSubMenu);
|
||||
}
|
||||
|
||||
|
||||
showServerSettings (info) {
|
||||
var data = BDFDB.loadData(info.id, this, "servers");
|
||||
|
||||
|
||||
var name = data ? data.name : null;
|
||||
var shortName = data ? data.shortName : null;
|
||||
var url = data ? data.url : null;
|
||||
|
@ -283,7 +283,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
var color2 = data ? data.color2 : null;
|
||||
var color3 = data ? data.color3 : null;
|
||||
var color4 = data ? data.color4 : null;
|
||||
|
||||
|
||||
var serverSettingsModal = $(this.serverSettingsModalMarkup);
|
||||
serverSettingsModal.find(BDFDB.dotCN.modalguildname).text(info.name);
|
||||
serverSettingsModal.find("#input-servername").val(name);
|
||||
|
@ -317,14 +317,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
})
|
||||
.on("click", ".btn-save", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
name = null;
|
||||
if (serverSettingsModal.find("#input-servername").val()) {
|
||||
if (serverSettingsModal.find("#input-servername").val().trim().length > 0) {
|
||||
name = serverSettingsModal.find("#input-servername").val().trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
shortName = null;
|
||||
if (serverSettingsModal.find("#input-servershortname").val()) {
|
||||
if (serverSettingsModal.find("#input-servershortname").val().trim().length > 0) {
|
||||
|
@ -332,7 +332,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
shortName = shortName == info.acronym ? null : shortName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (serverSettingsModal.find("#input-serverurl:not('.invalid')").length > 0) {
|
||||
url = null;
|
||||
if (!serverSettingsModal.find("#input-removeicon").prop("checked") && serverSettingsModal.find("#input-serverurl").val()) {
|
||||
|
@ -341,14 +341,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeIcon = serverSettingsModal.find("#input-removeicon").prop("checked");
|
||||
|
||||
|
||||
color1 = BDFDB.getSwatchColor("swatch1");
|
||||
color2 = BDFDB.getSwatchColor("swatch2");
|
||||
color3 = BDFDB.getSwatchColor("swatch3");
|
||||
color4 = BDFDB.getSwatchColor("swatch4");
|
||||
|
||||
|
||||
if (name == null && shortName == null && url == null && !removeIcon && color1 == null && color2 == null && color3 == null && color4 == null) {
|
||||
this.removeServerData(info.id);
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
serverSettingsModal.find("#input-servername").focus();
|
||||
}
|
||||
|
||||
|
||||
checkUrl (modal, e) {
|
||||
if (!e.target.value) {
|
||||
$(e.target)
|
||||
|
@ -384,10 +384,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createNoticeTooltip (e) {
|
||||
$(BDFDB.dotCN.tooltips).find(".notice-tooltip").remove();
|
||||
|
||||
|
||||
var input = e.target;
|
||||
var disabled = $(input).prop("disabled");
|
||||
var valid = $(input).hasClass("valid");
|
||||
|
@ -405,13 +405,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.createTooltip(text, input, {type:"right",selector:"notice-tooltip",css:customTooltipCSS});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeServerData (id) {
|
||||
this.resetServer(id);
|
||||
|
||||
|
||||
BDFDB.removeData(id, this, "servers");
|
||||
}
|
||||
|
||||
|
||||
resetServer (id) {
|
||||
let serverObj = BDFDB.getDivOfServer(id);
|
||||
if (typeof serverObj !== "object" || !serverObj) return;
|
||||
|
@ -424,7 +424,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.css("background-color", "")
|
||||
.css("color", "");
|
||||
}
|
||||
|
||||
|
||||
loadServer (serverObj) {
|
||||
if (typeof serverObj !== "object" || !serverObj) return;
|
||||
var data = BDFDB.loadData(serverObj.id, this, "servers");
|
||||
|
@ -446,14 +446,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.css("color", color2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadAllServers () {
|
||||
var serverObjs = BDFDB.readServerList();
|
||||
for (var i = 0; i < serverObjs.length; i++) {
|
||||
this.loadServer(serverObjs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createServerToolTip (serverObj) {
|
||||
var data = BDFDB.loadData(serverObj.id, this, "servers");
|
||||
if (data) {
|
||||
|
@ -471,23 +471,23 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
body .guild-custom-tooltip:after {
|
||||
border-right-color: ${bgColor} !important;
|
||||
}`;
|
||||
|
||||
|
||||
BDFDB.createTooltip(text, serverObj.div, {type:"right",selector:"guild-custom-tooltip",css:customTooltipCSS});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-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: 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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", ".reset-button", () => {this.resetAll();});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.updateUsers = false;
|
||||
|
||||
this.css = `
|
||||
|
@ -33,7 +31,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
position: relative;
|
||||
top: 2px;
|
||||
}`;
|
||||
|
||||
|
||||
this.tagMarkup = `<span class="user-tag"></span>`;
|
||||
|
||||
this.userContextEntryMarkup =
|
||||
|
@ -43,7 +41,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.userContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} editusers-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -57,7 +55,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.userSettingsModalMarkup =
|
||||
`<span class=""${this.name}-modal DevilBro-modal"">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -154,7 +152,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
changeInChatWindow: {value:true, description:"Chat"},
|
||||
|
@ -174,31 +172,33 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.MemberPerms = BDFDB.WebModules.findByProperties("getNicknames", "getNick");
|
||||
this.TypingUtils = BDFDB.WebModules.findByProperties("getTypingUsers");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -215,7 +215,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"userContextObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -228,7 +228,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.dms, {name:"dmObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -246,7 +246,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.channels, {name:"channelListObserver",instance:observer}, {childList: true, subtree: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -261,7 +261,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.idCN.friends, {name:"friendListObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -276,7 +276,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.memberswrap, {name:"userListObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -372,7 +372,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.callcurrentcontainer, {name:"callObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -387,7 +387,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"userPopoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -402,7 +402,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.app + " ~ [class^='theme-']:not([class*='popouts'])", {name:"userProfilModalObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -415,7 +415,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.layers, {name:"settingsWindowObserver",instance:observer}, {childList:true});
|
||||
|
||||
|
||||
this.loadAllUsers();
|
||||
|
||||
return true;
|
||||
|
@ -427,9 +427,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.resetAllUsers();
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -437,9 +437,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
$(`${BDFDB.dotCN.channelheadertitletext}[custom-editusers]`).find(`${BDFDB.dotCN.channelheaderchannelname}:not(${BDFDB.dotCN.channelheaderprivate})`).css("color", "").css("background-color", "").parent().removeAttr("custom-editusers");
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.memberswrap, {name:"userListObserver"}, {childList:true, subtree:true});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"messagesObserver"}, {childList:true, subtree:true});
|
||||
|
@ -451,7 +451,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -471,10 +471,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
changeLanguageStrings () {
|
||||
this.userContextEntryMarkup = this.userContextEntryMarkup.replace("REPLACE_context_localusersettings_text", this.labels.context_localusersettings_text);
|
||||
|
||||
|
||||
this.userContextSubMenuMarkup = this.userContextSubMenuMarkup.replace("REPLACE_submenu_usersettings_text", this.labels.submenu_usersettings_text);
|
||||
this.userContextSubMenuMarkup = this.userContextSubMenuMarkup.replace("REPLACE_submenu_resetsettings_text", this.labels.submenu_resetsettings_text);
|
||||
|
||||
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_modal_username_text", this.labels.modal_username_text);
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_modal_usertag_text", this.labels.modal_usertag_text);
|
||||
|
@ -491,7 +491,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_btn_cancel_text", this.labels.btn_cancel_text);
|
||||
this.userSettingsModalMarkup = this.userSettingsModalMarkup.replace("REPLACE_btn_save_text", this.labels.btn_save_text);
|
||||
}
|
||||
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!context || !context.tagName || !context.parentElement || context.querySelector(".localusersettings-item")) return;
|
||||
var info = BDFDB.getKeyInformation({"node":context, "key":"user"});
|
||||
|
@ -500,20 +500,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("mouseenter", ".localusersettings-item", (e) => {
|
||||
this.createContextSubMenu(info, e, context);
|
||||
});
|
||||
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createContextSubMenu (info, e, context) {
|
||||
var userContextSubMenu = $(this.userContextSubMenuMarkup);
|
||||
|
||||
|
||||
userContextSubMenu
|
||||
.on("click", ".usersettings-item", () => {
|
||||
$(context).hide();
|
||||
this.showUserSettings(info);
|
||||
});
|
||||
|
||||
|
||||
if (BDFDB.loadData(info.id, this, "users")) {
|
||||
userContextSubMenu
|
||||
.find(".resetsettings-item")
|
||||
|
@ -524,13 +524,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.loadAllUsers();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, userContextSubMenu);
|
||||
}
|
||||
|
||||
|
||||
showUserSettings (info, e) {
|
||||
var data = BDFDB.loadData(info.id, this, "users");
|
||||
|
||||
|
||||
var name = data ? data.name : null;
|
||||
var tag = data ? data.tag : null;
|
||||
var url = data ? data.url : null;
|
||||
|
@ -540,9 +540,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
var color2 = data ? data.color2 : null;
|
||||
var color3 = data ? data.color3 : null;
|
||||
var color4 = data ? data.color4 : null;
|
||||
|
||||
|
||||
var member = this.MemberPerms.getMember(this.LastGuildStore.getGuildId(), info.id) ;
|
||||
|
||||
|
||||
var userSettingsModal = $(this.userSettingsModalMarkup);
|
||||
userSettingsModal.find(BDFDB.dotCN.modalguildname).text(member && member.nick ? member.nick : info.username);
|
||||
userSettingsModal.find("#input-username").val(name);
|
||||
|
@ -580,24 +580,24 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
})
|
||||
.on("click", ".btn-save", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
removeIcon = userSettingsModal.find("#input-removeicon").prop("checked");
|
||||
ignoreTagColor = userSettingsModal.find("#input-ignoretagcolor").prop("checked");
|
||||
|
||||
|
||||
name = null;
|
||||
if (userSettingsModal.find("#input-username").val()) {
|
||||
if (userSettingsModal.find("#input-username").val().trim().length > 0) {
|
||||
name = userSettingsModal.find("#input-username").val().trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tag = null;
|
||||
if (userSettingsModal.find("#input-usertag").val()) {
|
||||
if (userSettingsModal.find("#input-usertag").val().trim().length > 0) {
|
||||
tag = userSettingsModal.find("#input-usertag").val().trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (userSettingsModal.find("#input-userurl:not('.invalid')").length > 0) {
|
||||
url = null;
|
||||
if (!removeIcon && userSettingsModal.find("#input-userurl").val()) {
|
||||
|
@ -606,12 +606,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
color1 = BDFDB.getSwatchColor("swatch1");
|
||||
color2 = BDFDB.getSwatchColor("swatch2");
|
||||
color3 = BDFDB.getSwatchColor("swatch3");
|
||||
color4 = BDFDB.getSwatchColor("swatch4");
|
||||
|
||||
|
||||
if (name == null && tag == null && url == null && !removeIcon && !ignoreTagColor && color1 == null && color2 == null && color3 == null && color4 == null) {
|
||||
BDFDB.removeData(info.id, this, "users")
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
userSettingsModal.find("#input-username").focus();
|
||||
}
|
||||
|
||||
|
||||
checkUrl (modal, e) {
|
||||
if (!e.target.value) {
|
||||
$(e.target)
|
||||
|
@ -647,10 +647,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createNoticeTooltip (e) {
|
||||
$(BDFDB.dotCN.tooltips).find(".notice-tooltip").remove();
|
||||
|
||||
|
||||
var input = e.target;
|
||||
var disabled = $(input).prop("disabled");
|
||||
var valid = $(input).hasClass("valid");
|
||||
|
@ -671,9 +671,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
loadAllUsers () {
|
||||
this.resetAllUsers();
|
||||
|
||||
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
||||
|
||||
if (settings.changeInMemberList) {
|
||||
for (let user of document.querySelectorAll(BDFDB.dotCN.member)) {
|
||||
this.loadUser(user, "list", false);
|
||||
|
@ -737,20 +737,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadUser (div, type, compact) {
|
||||
if (!div || $(div).attr("custom-editusers") || !div.tagName || (!div.querySelector(BDFDB.dotCN.dmchannelactivitytext) && div.querySelector(BDFDB.dotCN.dmchannelactivity))) return;
|
||||
|
||||
|
||||
let {avatar, username, wrapper} = this.getAvatarNameWrapper(div);
|
||||
if (!avatar && !username && !wrapper) return;
|
||||
|
||||
|
||||
$(div).data("compact", compact);
|
||||
|
||||
|
||||
var info = this.getUserInfo(compact ? $(BDFDB.dotCN.messagegroup).has(div)[0] : div);
|
||||
if (!info) return;
|
||||
|
||||
|
||||
var data = BDFDB.loadData(info.id, this, "users");
|
||||
|
||||
|
||||
if (data) {
|
||||
var member = this.MemberPerms.getMember(this.LastGuildStore.getGuildId(), info.id);
|
||||
if (username) {
|
||||
|
@ -761,7 +761,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
username.style.color = color1;
|
||||
username.style.background = color2;
|
||||
}
|
||||
|
||||
|
||||
if (avatar && (data.removeIcon || data.url)) {
|
||||
avatar.style.background = data.removeIcon ? "" : "url(" + data.url + ")";
|
||||
avatar.style.backgroundSize = "cover";
|
||||
|
@ -774,7 +774,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var tag = data.tag ? data.tag : null;
|
||||
if (tag && wrapper && !wrapper.querySelector(".user-tag") && (type == "list" || type == "chat" || type == "popout" || type == "profil" || type == "dmheader")) {
|
||||
var color3 = data.ignoreTagColor ?
|
||||
|
@ -791,7 +791,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
thisTag.style.color = color4;
|
||||
wrapper.appendChild(thisTag);
|
||||
}
|
||||
|
||||
|
||||
if (type == "recentdms") {
|
||||
$(div).find(BDFDB.dotCN.guildinner)
|
||||
.off("mouseenter." + this.name)
|
||||
|
@ -799,43 +799,43 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.createDmToolTip({"div":div,"nick":data.name,"name":info.username});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(div).attr("custom-editusers", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resetAllUsers () {
|
||||
document.querySelectorAll(".user-tag").forEach(node=>{node.remove();});
|
||||
document.querySelectorAll("[custom-editusers]").forEach((div) => {
|
||||
var {avatar, username, wrapper} = this.getAvatarNameWrapper(div);
|
||||
if (!avatar && !username && !wrapper) return;
|
||||
|
||||
|
||||
var info = this.getUserInfo($(div).data(BDFDB.disCN.messagecompact) ? $(BDFDB.dotCN.messagegroup).has(div)[0] : div);
|
||||
if (!info) return;
|
||||
|
||||
|
||||
if (username) {
|
||||
var serverObj = BDFDB.getSelectedServer();
|
||||
var member = serverObj ? this.MemberPerms.getMember(serverObj.id, info.id) : null;
|
||||
var name = div.classList.contains(BDFDB.disCN.accountinfo) || !member || !member.nick ? info.username : member.nick;
|
||||
var color1 = member && member.colorString ? BDFDB.color2RGB(member.colorString) : "";
|
||||
var color2 = "";
|
||||
|
||||
|
||||
BDFDB.setInnerText(username, name);
|
||||
username.style.color = color1;
|
||||
username.style.background = color2;
|
||||
}
|
||||
|
||||
|
||||
if (avatar) {
|
||||
avatar.style.background = "url(" + BDFDB.getUserAvatar(info.id) + ")";
|
||||
avatar.style.backgroundSize = "cover";
|
||||
$(avatar).off("mouseenter." + this.name);
|
||||
}
|
||||
|
||||
|
||||
$(div).removeAttr("custom-editusers")
|
||||
.find(BDFDB.dotCN.guildinner).off("mouseenter." + this.name);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createDmToolTip (userObj) {
|
||||
var text = userObj.nick ? userObj.nick : userObj.name;
|
||||
var customTooltipCSS = `
|
||||
|
@ -844,7 +844,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}`;
|
||||
BDFDB.createTooltip(text, userObj.div, {type:"right",selector:"dm-custom-tooltip",css:customTooltipCSS});
|
||||
}
|
||||
|
||||
|
||||
createCallToolTip (userObj) {
|
||||
var text = userObj.nick ? userObj.nick : userObj.name;
|
||||
var customTooltipCSS = `
|
||||
|
@ -853,17 +853,17 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}`;
|
||||
BDFDB.createTooltip(text, userObj.div, {type:"left",selector:"call-custom-tooltip",css:customTooltipCSS});
|
||||
}
|
||||
|
||||
|
||||
getAvatarNameWrapper (div) {
|
||||
var avatar = div.querySelector(BDFDB.dotCNC.avatarsmallold + BDFDB.dotCN.avatarlargeold + ":not(" + BDFDB.dotCN.avatarwrapper + "), " + BDFDB.dotCNC.avatarprofileold + BDFDB.dotCNC.voiceavatardefault + BDFDB.dotCNC.avatarimage + BDFDB.dotCN.callavatar);
|
||||
|
||||
|
||||
var username = div.querySelector(BDFDB.dotCNC.userpopoutheadernickname + BDFDB.dotCNC.userpopoutheadernonickname + BDFDB.dotCNC.userprofileusername + BDFDB.dotCNC.memberusername + BDFDB.dotCNC.voicenamedefault + BDFDB.dotCNC.messageusername + BDFDB.dotCNC.dmchannelname + BDFDB.dotCN.channelheaderchannelname + BDFDB.dotCNC.channelheaderprivate + BDFDB.dotCNS.friendscolumnnamewrap + BDFDB.dotCNC.friendscolumnusername + BDFDB.dotCNS.accountinfodetails + BDFDB.dotCN.accountinfousername);
|
||||
|
||||
|
||||
var wrapper = div.querySelector(BDFDB.dotCNC.userpopoutheadernickname + BDFDB.dotCNC.userpopoutheadernonickname + BDFDB.dotCNC.userprofileusername + BDFDB.dotCNC.memberusername + BDFDB.dotCNC.voicenamedefault + BDFDB.dotCNC.messageusernamewrapper + BDFDB.dotCNC.dmchannelname + BDFDB.dotCN.channelheaderchannelname + BDFDB.dotCNC.channelheaderprivate + BDFDB.dotCNS.friendscolumnnamewrap + BDFDB.dotCNC.nametag + BDFDB.dotCNS.accountinfodetails + BDFDB.dotCN.accountinfousername);
|
||||
|
||||
|
||||
return {avatar, username, wrapper};
|
||||
}
|
||||
|
||||
|
||||
getUserInfo (div) {
|
||||
let info, avatar = div.querySelector("[style*='/avatars/']");
|
||||
if (avatar) info = this.UserStore.getUser(avatar.style.backgroundImage.split("/avatars/")[1].split("/")[0]);
|
||||
|
@ -887,7 +887,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return info && info.id ? this.UserStore.getUser(info.id) : null;
|
||||
}
|
||||
|
||||
|
||||
changeTyping (div) {
|
||||
let i = 0, ids = Object.assign({},this.TypingUtils.getTypingUsers(this.LastChannelStore.getChannelId())), sortedids = [], alldata = BDFDB.loadAllData(this, "users");
|
||||
delete ids[BDFDB.myData.id];
|
||||
|
@ -906,7 +906,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
@ -917,7 +917,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
settingshtml += `</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 Users.</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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
|
@ -925,14 +925,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("click", ".reset-button", () => {this.resetAll();});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateUsers) {
|
||||
this.loadAllUsers();
|
||||
this.updateUsers = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.css = `
|
||||
.${this.name}-modal .titles {
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .emojiserver-entry {
|
||||
height: 50px;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .emojiserver-entry .modal-emojiserver-icon {
|
||||
background-color: #484B51;
|
||||
background-size: cover;
|
||||
|
@ -32,7 +30,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
text-align: center;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry label,
|
||||
.${this.name}-modal .emojiserver-entry label {
|
||||
color: #b9bbbe;
|
||||
|
@ -47,12 +45,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
vertical-align: top;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .emojiserver-entry label {
|
||||
height: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry label {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
@ -61,16 +59,16 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
text-align: center;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry .modal-titlesname-label,
|
||||
.${this.name}-modal .emojiserver-entry .modal-emojiname-label {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry .modal-sorttitle-label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal .titles-entry .modal-titlestotal-label,
|
||||
.${this.name}-modal .titles-entry .modal-titlesglobal-label,
|
||||
.${this.name}-modal .titles-entry .modal-titleslocal-label,
|
||||
|
@ -82,7 +80,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
text-align: center;
|
||||
width: 82px;
|
||||
}
|
||||
|
||||
|
||||
.emojistatistics-button {
|
||||
background-image: url("/assets/f24711dae4f6d6b28335e866a93e9d9b.png");
|
||||
background-position: -770px -374px;
|
||||
|
@ -92,7 +90,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
margin-right: 10px;
|
||||
width: 22px;
|
||||
}`;
|
||||
|
||||
|
||||
this.emojiInformationModalMarkup =
|
||||
`<span class=""${this.name}-modal DevilBro-modal"">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
|
@ -144,11 +142,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<label class="modal-emojilocal-label">modal-emojilocal-label</label>
|
||||
<label class="modal-emojicopies-label">modal-emojicopies-label</label>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.dividerMarkup = `<div class="${BDFDB.disCNS.modaldivider + BDFDB.disCN.modaldividerdefault}"></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."},
|
||||
|
@ -158,25 +156,27 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -206,7 +206,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"emojiPickerObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
this.GuildEmojis = BDFDB.WebModules.findByProperties("getGuildEmoji", "getDisambiguatedEmojiContext");
|
||||
|
||||
return true;
|
||||
|
@ -218,7 +218,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -226,8 +226,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -237,12 +237,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_btn_ok_text", this.labels.btn_ok_text);
|
||||
this.emojiInformationModalMarkup = this.emojiInformationModalMarkup.replace("REPLACE_btn_all_text", this.labels.btn_all_text);
|
||||
|
||||
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlesicon-label", this.labels.modal_titlesicon_text);
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlesname_text", this.labels.modal_titlesname_text);
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlestotal_text", this.labels.modal_titlestotal_text);
|
||||
|
@ -250,7 +250,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titleslocal_text", this.labels.modal_titleslocal_text);
|
||||
this.emojiserverTitlesMarkup = this.emojiserverTitlesMarkup.replace("REPLACE_modal_titlescopies_text", this.labels.modal_titlescopies_text);
|
||||
}
|
||||
|
||||
|
||||
loadEmojiList () {
|
||||
this.emojiReplicaList = {};
|
||||
this.emojiToServerList = {};
|
||||
|
@ -268,7 +268,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hoverEmoji (picker) {
|
||||
$(picker)
|
||||
.off("mouseenter." + this.name)
|
||||
|
@ -280,7 +280,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addEmojiInformationButton (node) {
|
||||
$(node).find(BDFDB.dotCN.emojipickerheader)
|
||||
.append(this.emojiButtonMarkup)
|
||||
|
@ -290,11 +290,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.showEmojiInformationModal();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
showEmojiInformationModal () {
|
||||
var emojiInformationModal = $(this.emojiInformationModalMarkup);
|
||||
BDFDB.appendModal(emojiInformationModal);
|
||||
|
||||
|
||||
var entries = [], index = 0;
|
||||
for (let serverObj of BDFDB.readServerList()) {
|
||||
let amountGlobal = 0, amountLocal = 0, amountCopies = 0;
|
||||
|
@ -321,33 +321,33 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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 titleentry = $(this.emojiserverTitlesMarkup)
|
||||
.appendTo("." + this.name + "-modal .titles")
|
||||
.on("click", ".modal-title-label ", (e2) => {
|
||||
var oldTitle = e2.target.innerText;
|
||||
|
||||
|
||||
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 + "▲";
|
||||
}
|
||||
|
||||
|
||||
this.updateAllEntries(emojiInformationModal, entries);
|
||||
});
|
||||
|
||||
|
||||
this.updateAllEntries(emojiInformationModal, entries);
|
||||
}
|
||||
|
||||
|
||||
updateAllEntries (modal, entries) {
|
||||
var container = modal.find(".entries");
|
||||
container.children().remove();
|
||||
|
@ -356,7 +356,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
container.append(entries[i].entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
@ -364,15 +364,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
|
@ -199,23 +197,25 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
this.LanguageUtils = BDFDB.WebModules.findByProperties("getLanguages");
|
||||
this.translateInterval = setInterval(() => {
|
||||
|
@ -237,12 +237,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
clearInterval(this.translateInterval);
|
||||
for (var key in this.oldStrings) {
|
||||
this.LanguageUtils.Messages[key] = this.oldStrings[key];
|
||||
}
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.waitTime = 3000;
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -45,7 +45,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, null, {name:"messageChangeObserver",instance:observer,multi:true}, {childList:true, characterData:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -63,7 +63,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true});
|
||||
|
||||
|
||||
this.addAllPreviews();
|
||||
|
||||
return true;
|
||||
|
@ -75,9 +75,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(".FIP-embed").forEach(embed => {embed.remove();});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -85,17 +85,17 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.addAllPreviews();
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver"}, {childList:true, subtree:true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
addAllPreviews () {
|
||||
document.querySelectorAll(".FIP-embed").forEach(embed => {embed.remove();});
|
||||
document.querySelectorAll(BDFDB.dotCN.messagegroup).forEach(messageContainer => {
|
||||
|
@ -105,13 +105,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addPreviews (message) {
|
||||
let scroller = document.querySelector(BDFDB.dotCNS.chat + BDFDB.dotCN.messages);
|
||||
if (!message || !scroller) return;
|
||||
var messageData = BDFDB.getKeyInformation({node:message,key:"message",up:true});
|
||||
if (!messageData) return;
|
||||
|
||||
|
||||
let accessory = this.getAccessoryOfMessage(message);
|
||||
if (accessory) {
|
||||
let links = [];
|
||||
|
@ -127,7 +127,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
if (links.length > 0) this.addItemToAccessory(null, links, accessory, scroller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addItemToAccessory (previmage, links, accessory, scroller) {
|
||||
let item = links.shift();
|
||||
if (!item) return;
|
||||
|
@ -167,7 +167,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
insertEmbed (embed, previmage, links, accessory, scroller) {
|
||||
let prev = accessory.querySelector(`${BDFDB.dotCNS.embed + BDFDB.dotCN.embedimage}[href="${previmage ? this.parseSrc(previmage.src) : void 0}"]`);
|
||||
let next = accessory.querySelector(`${BDFDB.dotCNS.embed + BDFDB.dotCN.embedimage}[href="${links[0] ? this.parseSrc(links[0].src) : void 0}"]`);
|
||||
|
@ -176,7 +176,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
accessory.insertBefore(embed, prev ? prev.nextSibling : next);
|
||||
scroller.scrollTop += embed.getBoundingClientRect().height;
|
||||
}
|
||||
|
||||
|
||||
getAccessoryOfMessage (message) {
|
||||
var accessory = null;
|
||||
while (message && !message.querySelector(BDFDB.dotCN.messagegroup) && !accessory) {
|
||||
|
@ -185,7 +185,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return accessory;
|
||||
}
|
||||
|
||||
|
||||
parseSrc (src) {
|
||||
return src.replace(/"/g, "");
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.friendsOnlineList = {};
|
||||
|
||||
|
||||
this.timeLog = [];
|
||||
|
||||
this.timeLogModalMarkup =
|
||||
|
@ -46,9 +44,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<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.disCNS.modaldivider + BDFDB.disCN.modaldividerdefault}"></div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.guilds} > ${BDFDB.dotCN.friendsonline} {
|
||||
cursor: pointer;
|
||||
|
@ -104,7 +102,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
background-color: #36393F;
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
muteOnDND: {value:false, description:"Do not notify me when I am DnD:"},
|
||||
|
@ -115,33 +113,35 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.FriendUtils = BDFDB.WebModules.findByProperties("getFriendIDs", "getRelationships");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getDMFromUserId");
|
||||
this.ChannelSwitchUtils = BDFDB.WebModules.findByProperties("selectPrivateChannel");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatuses", "getOnlineFriendCount");
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers");
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -180,7 +180,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, `${BDFDB.dotCN.guilds} > ${BDFDB.dotCN.friendsonline}`, {name:"friendCountObserver",instance:observer}, {childList:true, subtree:true, characterData:true});
|
||||
|
||||
|
||||
for (let id of this.FriendUtils.getFriendIDs()) {
|
||||
this.friendsOnlineList[id] = this.UserMetaStore.getStatus(id) != "offline";
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -209,8 +209,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -220,7 +220,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
|
||||
saveAudio (settingspanel) {
|
||||
var successSavedAudio = (parsedurl, parseddata) => {
|
||||
if (parsedurl && parseddata) BDFDB.showToast(`Sound was saved successfully.`, {type:"success"});
|
||||
|
@ -229,7 +229,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
notificationsound.song = parseddata;
|
||||
BDFDB.saveAllData(notificationsound, this, "notificationsound");
|
||||
};
|
||||
|
||||
|
||||
var url = settingspanel.querySelector(".songInput").value;
|
||||
if (url.length == 0) {
|
||||
BDFDB.showToast(`Sound was set to the default sound.`, {type:"warn"});
|
||||
|
@ -258,8 +258,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
showTimeLog () {
|
||||
|
||||
showTimeLog () {
|
||||
var timeLogModal = $(this.timeLogModalMarkup);
|
||||
let logs = this.timeLog.slice(0).reverse();
|
||||
for (let log of logs) {
|
||||
|
@ -274,7 +274,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
timeLogModal.find(BDFDB.dotCN.modaldivider + ":last-of-type").remove();
|
||||
BDFDB.appendModal(timeLogModal);
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var notificationsound = BDFDB.loadAllData(this, "notificationsound");
|
||||
|
@ -298,7 +298,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
settingshtml += `</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;">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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
|
@ -347,7 +347,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.saveAllData(disabledata, this, "disabled");
|
||||
BDFDB.saveAllData(desktopdata, this, "desktop");
|
||||
});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.textUrlReplaceString = "DEVILBRO_BD_GOOGLESEARCHREPLACE_REPLACE_TEXTURL";
|
||||
|
||||
|
||||
this.defaults = {
|
||||
engines: {
|
||||
_all: {value:true, name:BDFDB.getLibraryStrings().btn_all_text, url:null},
|
||||
|
@ -33,7 +31,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_googlesearchreplace_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.messageContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} googleReplaceSearchSubMenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -45,27 +43,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -92,7 +92,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -110,13 +110,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "engines");
|
||||
}
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messageContextEntryMarkup = this.messageContextEntryMarkup.replace("REPLACE_context_googlesearchreplace_text", this.labels.context_googlesearchreplace_text);
|
||||
|
||||
|
||||
this.messageContextSubMenuMarkup = this.messageContextSubMenuMarkup.replace("REPLACE_submenu_disabled_text", this.labels.submenu_disabled_text);
|
||||
}
|
||||
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!context || !context.tagName || !context.parentElement || context.querySelector(".googlereplacesearch-item")) return;
|
||||
for (let group of context.querySelectorAll(BDFDB.dotCN.contextmenuitemgroup)) {
|
||||
|
@ -128,17 +128,17 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("mouseenter", ".googlereplacesearch-item", (e) => {
|
||||
this.createContextSubMenu(text, e, context);
|
||||
});
|
||||
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
createContextSubMenu (text, e, context) {
|
||||
var messageContextSubMenu = $(this.messageContextSubMenuMarkup);
|
||||
|
||||
|
||||
messageContextSubMenu
|
||||
.on("click", ".GRS-item", (e2) => {
|
||||
$(context).hide();
|
||||
|
@ -153,7 +153,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
window.open(this.defaults.engines[engine].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var engines = BDFDB.getAllData(this, "engines");
|
||||
for (let key in engines) {
|
||||
if (!engines[key]) messageContextSubMenu.find("[engine='" + key + "']").remove();
|
||||
|
@ -161,10 +161,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
if (messageContextSubMenu.find(".GRS-item").length > 0) {
|
||||
messageContextSubMenu.find(".alldisabled-item").remove();
|
||||
}
|
||||
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, messageContextSubMenu);
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var engines = BDFDB.getAllData(this, "engines");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
@ -174,15 +174,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.languages = {};
|
||||
|
||||
|
||||
this.doTranslate = false;
|
||||
this.translating = false;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
sendOriginalMessage: {value:false, description:"Send the original message together with the translation."}
|
||||
|
@ -42,29 +40,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.optionButtonMarkup =
|
||||
`<div class="${BDFDB.disCN.optionpopoutbutton} btn-googletranslateoption"></div>`;
|
||||
|
||||
|
||||
this.optionsPopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottom + BDFDB.disCN.popoutnoarrow} popout-googletranslateoption-options" style="z-index: 1000; visibility: visible;">
|
||||
<div class="${BDFDB.disCN.optionpopout}"></div
|
||||
</div>`;
|
||||
|
||||
|
||||
this.popoutEntryMarkup =
|
||||
`<div class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCN.weightmedium} btn-item-googletranslateoption">REPLACE_popout_translateoption_text</div>`;
|
||||
|
||||
|
||||
this.translateButtonMarkup =
|
||||
`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" class="translate-button" width="22" height="30" fill="currentColor">
|
||||
<path d="M 19.794, 3.299 H 9.765 L 8.797, 0 h -6.598 C 0.99, 0, 0, 0.99, 0, 2.199 V 16.495 c 0, 1.21, 0.99, 2.199, 2.199, 2.199 H 9.897 l 1.1, 3.299 H 19.794 c 1.21, 0, 2.199 -0.99, 2.199 -2.199 V 5.498 C 21.993, 4.289, 21.003, 3.299, 19.794, 3.299 z M 5.68, 13.839 c -2.48, 0 -4.492 -2.018 -4.492 -4.492 s 2.018 -4.492, 4.492 -4.492 c 1.144, 0, 2.183, 0.407, 3.008, 1.171 l 0.071, 0.071 l -1.342, 1.298 l -0.066 -0.06 c -0.313 -0.297 -0.858 -0.643 -1.671 -0.643 c -1.441, 0 -2.612, 1.193 -2.612, 2.661 c 0, 1.468, 1.171, 2.661, 2.612, 2.661 c 1.507, 0, 2.161 -0.962, 2.337 -1.606 h -2.43 v -1.704 h 4.344 l 0.016, 0.077 c 0.044, 0.231, 0.06, 0.434, 0.06, 0.665 C 10.001, 12.036, 8.225, 13.839, 5.68, 13.839 z M 11.739, 9.979 h 4.393 c 0, 0 -0.374, 1.446 -1.715, 3.008 c -0.588 -0.676 -0.995 -1.336 -1.254 -1.864 h -1.089 L 11.739, 9.979 z M 13.625, 13.839 l -0.588, 0.583 l -0.72 -2.452 C 12.685, 12.63, 13.13, 13.262, 13.625, 13.839 z M 20.893, 19.794 c 0, 0.605 -0.495, 1.1 -1.1, 1.1 H 12.096 l 2.199 -2.199 l -0.896 -3.041 l 1.012 -1.012 l 2.953, 2.953 l 0.803 -0.803 l -2.975 -2.953 c 0.99 -1.138, 1.759 -2.474, 2.106 -3.854 h 1.397 V 8.841 H 14.697 v -1.144 h -1.144 v 1.144 H 11.398 l -1.309 -4.443 H 19.794 c 0.605, 0, 1.1, 0.495, 1.1, 1.1 V 19.794 z"/>
|
||||
</svg>`;
|
||||
|
||||
|
||||
this.reverseButtonMarkup =
|
||||
`<svg class="reverse-button ${BDFDB.disCN.flexchild}" type="REPLACETYPE" version="1.1" xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" style="flex: 0 0 auto;">
|
||||
<path d="M 0, 10.515 c 0, 2.892, 1.183, 5.521, 3.155, 7.361 L 0, 21.031 h 7.887 V 13.144 l -2.892, 2.892 C 3.549, 14.722, 2.629, 12.75, 2.629, 10.515 c 0 -3.418, 2.235 -6.309, 5.258 -7.492 v -2.629 C 3.418, 1.577, 0, 5.652, 0, 10.515 z M 21.031, 0 H 13.144 v 7.887 l 2.892 -2.892 C 17.482, 6.309, 18.402, 8.281, 18.402, 10.515 c 0, 3.418 -2.235, 6.309 -5.258, 7.492 V 20.768 c 4.469 -1.183, 7.887 -5.258, 7.887 -10.121 c 0 -2.892 -1.183 -5.521 -3.155 -7.361 L 21.031, 0 z"/>
|
||||
</svg>`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.translatePopoutMarkup =
|
||||
`<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCNS.popoutnoarrow + BDFDB.disCN.popoutnoshadow} popout-googletranslate DevilBro-modal" style="z-index: 2000; overflow: visible; visibility: visible; transform: translateX(-100%) translateY(-100%) translateZ(0px);">
|
||||
<div class="${BDFDB.disCN.popoutthemedpopout}">
|
||||
|
@ -107,8 +105,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
</div>`).join("")}
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.DeepLTranslateAPI = function () {
|
||||
var INPUT, OUTPUT, clearInput, current, domReady, enabled, executeScript, getLanguage, getOutput, langI, langO, setInput, setLanguage, timer, wc, webview;
|
||||
var _extends = Object.assign || function (target) {
|
||||
|
@ -304,12 +302,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
return DeepLTranslateAPI;
|
||||
}.call(this);
|
||||
|
||||
|
||||
this.css = `
|
||||
.chat form textarea {
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
.translate-button {
|
||||
position: absolute;
|
||||
right: 46px;
|
||||
|
@ -317,15 +315,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
opacity: 0.2;
|
||||
transition: all 200ms ease;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themedark} .translate-button {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themelight} .translate-button {
|
||||
fill: #4f545c;
|
||||
}
|
||||
|
||||
|
||||
.translate-button.active {
|
||||
fill: #F04747;
|
||||
opacity: 1;
|
||||
|
@ -336,17 +334,17 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
opacity: 1;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
|
||||
.reverse-button {
|
||||
margin-top: -5px;
|
||||
opacity: 0.2;
|
||||
transition: all 200ms ease;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themedark} .reverse-button {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themelight} .reverse-button {
|
||||
fill: #4f545c;
|
||||
}
|
||||
|
@ -354,19 +352,19 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
cursor: pointer;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.popout}.popout-googletranslate ${BDFDB.dotCN.popoutthemedpopout} {
|
||||
padding: 0 10px;
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.themedark} ${BDFDB.dotCN.popout}.popout-googletranslate ${BDFDB.dotCN.popoutthemedpopout} {
|
||||
-webkit-box-shadow: 0 2px 10px 0 rgba(0,0,0,20%);
|
||||
background-color: #2f3136;
|
||||
border: 1px solid rgba(28,36,43,.6);
|
||||
box-shadow: 0 2px 10px 0 rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
|
||||
${BDFDB.dotCN.selectmenuouter} .inChat {
|
||||
top: 0%;
|
||||
transform: translateY(-100%);
|
||||
|
@ -375,27 +373,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -412,7 +412,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"messageContextObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -430,7 +430,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -446,7 +446,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"optionPopoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
$(document).off("click." + this.name, BDFDB.dotCN.optionpopoutbutton).off("contextmenu." + this.name, BDFDB.dotCN.message)
|
||||
.on("click." + this.name, BDFDB.dotCN.optionpopoutbutton, (e) => {
|
||||
this.getMessageData($(BDFDB.dotCN.message).has(e.currentTarget)[0]);
|
||||
|
@ -454,11 +454,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("contextmenu." + this.name, BDFDB.dotCN.message, (e) => {
|
||||
this.getMessageData(e.currentTarget);
|
||||
});
|
||||
|
||||
|
||||
document.querySelectorAll(BDFDB.dotCNS.messagegroup + BDFDB.dotCN.message).forEach(message => {this.addOptionButton(message);});
|
||||
|
||||
|
||||
document.querySelectorAll(BDFDB.dotCNS.chat + "form textarea").forEach(textarea => {this.addTranslationButton(textarea);});
|
||||
|
||||
|
||||
this.setLanguage();
|
||||
|
||||
return true;
|
||||
|
@ -470,17 +470,17 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.stopDeepL();
|
||||
$(document).off("click." + this.name, BDFDB.dotCN.optionpopoutbutton).off("contextmenu." + this.name, BDFDB.dotCN.message);
|
||||
|
||||
|
||||
document.querySelectorAll(BDFDB.dotCN.message + ".translated").forEach(message => {
|
||||
this.resetMessage(message);
|
||||
});
|
||||
|
||||
|
||||
document.querySelectorAll(".translate-button").forEach(button => {button.remove();});
|
||||
document.querySelectorAll(BDFDB.dotCNS.chat + "form textarea").forEach(textarea => {textarea.parentElement.style.paddingRight = "0px";});
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -488,22 +488,22 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
document.querySelectorAll(BDFDB.dotCNS.chat + "form textarea").forEach(textarea => {this.addTranslationButton(textarea);});
|
||||
document.querySelectorAll(BDFDB.dotCNS.messages + BDFDB.dotCN.message).forEach(message => {this.addOptionButton(message);});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messageContextEntryMarkup = this.messageContextEntryMarkup.replace("REPLACE_context_messagetranslateoption_text", this.labels.context_messagetranslateoption_text);
|
||||
|
||||
|
||||
this.messageContextEntryMarkup2 = this.messageContextEntryMarkup2.replace("REPLACE_context_googletranslateoption_text", this.labels.context_googletranslateoption_text);
|
||||
|
||||
|
||||
this.popoutEntryMarkup = this.popoutEntryMarkup.replace("REPLACE_popout_translateoption_text", this.labels.popout_translateoption_text);
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
this.setLanguage();
|
||||
}
|
||||
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!context || !context.tagName || !context.parentElement) return;
|
||||
for (let group of context.querySelectorAll(BDFDB.dotCN.contextmenuitemgroup)) {
|
||||
|
@ -532,7 +532,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
$(context).hide();
|
||||
this.translateMessage();
|
||||
});
|
||||
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
if (!context.querySelector(".googletranslateoption-item") && BDFDB.getKeyInformation({"node":group, "key":"handleSearchWithGoogle"})) {
|
||||
|
@ -556,24 +556,24 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
window.open(this.getGoogleTranslatePageURL(input.id, output.id, text), "_blank");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
startDeepL () {
|
||||
this.stopDeepL();
|
||||
this.DeepLTranslate = new this.DeepLTranslateAPI();
|
||||
this.DeepLTranslate.start();
|
||||
}
|
||||
|
||||
|
||||
stopDeepL () {
|
||||
if (this.DeepLTranslate && typeof this.DeepLTranslate.stop === "function") this.DeepLTranslate.stop();
|
||||
this.DeepLTranslate = undefined;
|
||||
}
|
||||
|
||||
|
||||
setLanguage () {
|
||||
this.languages = Object.assign({},
|
||||
{"auto": {name:"Auto", id:"auto", integrated:false, dic:false, deepl:true}},
|
||||
|
@ -588,7 +588,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.stopDeepL();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getLanguageChoice (direction, place) {
|
||||
var type = typeof place === "undefined" ? direction : direction.toLowerCase() + place.charAt(0).toUpperCase() + place.slice(1).toLowerCase();
|
||||
var choice = BDFDB.getData(type, this, "choices");
|
||||
|
@ -596,7 +596,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
choice = type.indexOf("output") > -1 && choice == "auto" ? "en" : choice;
|
||||
return choice;
|
||||
}
|
||||
|
||||
|
||||
addOptionButton (message) {
|
||||
if (!message.querySelector(BDFDB.dotCN.optionpopoutbutton) && !message.querySelector(BDFDB.dotCN.messagesystem) && !message.querySelector(BDFDB.dotCN.messageuploadcancel)) {
|
||||
$(this.optionButtonMarkup).insertBefore(message.querySelector(BDFDB.dotCN.messagetext).firstChild);
|
||||
|
@ -605,7 +605,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
openOptionPopout (e) {
|
||||
var wrapper = e.currentTarget;
|
||||
if (wrapper.classList.contains(BDFDB.disCN.optionpopoutopen)) return;
|
||||
|
@ -614,11 +614,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
$(BDFDB.dotCN.popouts).append(popout);
|
||||
$(popout).find(BDFDB.dotCN.optionpopout).append(this.popoutEntryMarkup);
|
||||
this.addClickListener(popout);
|
||||
|
||||
|
||||
popout
|
||||
.css("left", e.pageX - ($(popout).outerWidth() / 2) + "px")
|
||||
.css("top", e.pageY + "px");
|
||||
|
||||
|
||||
$(document).on("mousedown.optionpopout" + this.name, (e2) => {
|
||||
if (popout.has(e2.target).length == 0) {
|
||||
$(document).off("mousedown.optionpopout" + this.name);
|
||||
|
@ -627,7 +627,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addClickListener (popout) {
|
||||
$(popout)
|
||||
.off("click." + this.name, ".btn-item-googletranslateoption")
|
||||
|
@ -640,7 +640,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
},300);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getMessageData (div) {
|
||||
if (div && !div.querySelector(BDFDB.dotCN.messagesystem)) {
|
||||
var messagegroup = $(BDFDB.dotCN.messagegroup).has(div);
|
||||
|
@ -654,7 +654,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.message = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addTranslationButton (textarea) {
|
||||
if (!textarea) return;
|
||||
var textareaWrap = textarea.parentElement;
|
||||
|
@ -705,7 +705,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
translateMessage () {
|
||||
if (this.message && this.message.content) {
|
||||
var message = this.message.div;
|
||||
|
@ -732,16 +732,16 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
this.message = null;
|
||||
}
|
||||
|
||||
|
||||
resetMessage (message) {
|
||||
$(message)
|
||||
.removeClass("translated")
|
||||
.find(BDFDB.dotCN.messageedited + ".translated").remove();
|
||||
|
||||
|
||||
var markup = message.querySelector(BDFDB.dotCN.messagecontent) || message.querySelector(BDFDB.dotCN.messagemarkup);
|
||||
markup.innerHTML = $(markup).data("orightmlGoogleTranslate");
|
||||
}
|
||||
|
||||
|
||||
translateText (text, type, callback) {
|
||||
var finishTranslation = (translation, mentions, input, output, toast) => {
|
||||
if (translation) translation = this.addMentions(translation, mentions);
|
||||
|
@ -782,7 +782,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
if (newtext.lastIndexOf(".") != newtext.length-1 && translation.lastIndexOf(".") == translation.length-1) translation = translation.slice(0,-1);
|
||||
finishTranslation(translation, mentions, input, output, toast);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,14 +791,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
finishTranslation(translation, mentions, input, output, toast);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addMentions (string, mentions) {
|
||||
for (let i in mentions) {
|
||||
string = string.replace("a" + i + "_______", mentions[i].indexOf("!") == 0 ? mentions[i].slice(1) : mentions[i]);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
removeMentions (string) {
|
||||
var mentions = {}, newString = [], count = 0;
|
||||
string.split(" ").forEach((word) => {
|
||||
|
@ -813,7 +813,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
return [newString.join(" "), mentions, newString.length-count != 0];
|
||||
}
|
||||
|
||||
|
||||
openTranslatePopout (button) {
|
||||
if (button.classList.contains(BDFDB.disCN.optionpopoutopen)) return;
|
||||
button.classList.add(BDFDB.disCN.optionpopoutopen);
|
||||
|
@ -833,20 +833,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.saveData("input" + place, input, this, "choices");
|
||||
BDFDB.saveData("output" + place, output, this, "choices");
|
||||
});
|
||||
|
||||
|
||||
popout.find(BDFDB.dotCN.select).each((_,selectWrap) => {
|
||||
let language = this.getLanguageChoice(selectWrap.getAttribute("type"));
|
||||
selectWrap.setAttribute("value", language);
|
||||
selectWrap.querySelector(BDFDB.dotCN.title).innerText = this.languages[language].name;
|
||||
});
|
||||
|
||||
|
||||
var checkbox = popout[0].querySelector("#translating-checkbox");
|
||||
checkbox.checked = this.translating;
|
||||
$(checkbox).on("click." + this.name, () => {
|
||||
button.classList.toggle("active", checkbox.checked);
|
||||
this.translating = checkbox.checked;
|
||||
});
|
||||
|
||||
|
||||
var translators = BDFDB.getAllData(this, "translators");
|
||||
popout[0].querySelectorAll(BDFDB.dotCN.switchinner + "[option=translators]").forEach((checkbox) => {
|
||||
checkbox.checked = translators[checkbox.value];
|
||||
|
@ -857,7 +857,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.openTranslatePopout(button);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on("mousedown.translatepopout" + this.name, (e) => {
|
||||
if (popout.has(e.target).length == 0) {
|
||||
$(document).off("mousedown.translatepopout" + this.name);
|
||||
|
@ -865,23 +865,23 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
setTimeout(() => {button.classList.remove(BDFDB.disCN.optionpopoutopen);},300);
|
||||
}
|
||||
});
|
||||
|
||||
BDFDB.initElements(popout[0]);
|
||||
|
||||
BDFDB.initElements(popout[0], this);
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (selector, e) {
|
||||
var selectControl = e.currentTarget;
|
||||
var selectWrap = selectControl.parentElement;
|
||||
|
||||
|
||||
if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
selectWrap.classList.add(BDFDB.disCN.selectisopen);
|
||||
$("li").has(selectWrap).css("overflow", "visible");
|
||||
|
||||
|
||||
var type = selectWrap.getAttribute("type");
|
||||
var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
$(selectMenu).addClass(selector).on("mousedown." + this.name, BDFDB.dotCN.selectoption, (e2) => {
|
||||
var language = e2.currentTarget.getAttribute("value");
|
||||
selectWrap.setAttribute("value", language);
|
||||
|
@ -896,7 +896,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (choice, type) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var key in this.languages) {
|
||||
|
@ -907,13 +907,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
menuhtml += `</div></div>`;
|
||||
return $(menuhtml)[0];
|
||||
}
|
||||
|
||||
|
||||
string2binary (string) {
|
||||
var binary = "";
|
||||
for (var character of string) binary += parseInt(character.charCodeAt(0).toString(2)).toPrecision(8).split(".").reverse().join("").toString() + " ";
|
||||
return binary;
|
||||
}
|
||||
|
||||
|
||||
binary2string (binary) {
|
||||
var string = "";
|
||||
binary = binary.replace(new RegExp(" ", "g"), "");
|
||||
|
@ -935,15 +935,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
getGoogleTranslateApiURL (input, output, text) {
|
||||
return "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + input + "&tl=" + output + "&dt=t&ie=UTF-8&oe=UTF-8&q=" + encodeURIComponent(text);
|
||||
}
|
||||
|
||||
|
||||
getGoogleTranslatePageURL (input, output, text) {
|
||||
return "https://translate.google.com/#" + input + "/" + output + "/" + encodeURIComponent(text);
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var choices = BDFDB.getAllData(this, "choices");
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
|
@ -960,13 +960,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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="flex-3B1Tl4 justifyStart-2yIZo0 ${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;">Translator:</h3><h3 class="flex-3B1Tl4 justifyStart-2yIZo0 ${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.translators[key].choice1}</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}" option="translators" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"${translators[key] ? " checked" : ""}></div><h3 class="flex-3B1Tl4 justifyEnd-1ceqOU ${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.translators[key].choice2}</h3></div>`;
|
||||
}
|
||||
settingshtml += `</div>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.selectcontrol, (e) => {this.openDropdownMenu("inSettings", e);})
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.eventFired = false;
|
||||
|
||||
|
||||
this.imageMarkup = `<div class="${BDFDB.disCN.imagewrapper}" style="width: 100px; height: 100px;"><img src="" style="width: 100px; height: 100px; display: inline;"></div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.prev,
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.next {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.prev {
|
||||
right: 90%;
|
||||
}
|
||||
|
||||
|
||||
.image-gallery ${BDFDB.dotCN.imagewrapper}.next {
|
||||
left: 90%;
|
||||
}`;
|
||||
}
|
||||
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -77,7 +77,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
loadImages (modal) {
|
||||
var start = performance.now();
|
||||
var waitForImg = setInterval(() => {
|
||||
|
@ -106,7 +106,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
||||
getMessageGroupOfImage (thisimg) {
|
||||
if (thisimg && thisimg.src) {
|
||||
for (let group of document.querySelectorAll(BDFDB.dotCN.messagegroup)) {
|
||||
|
@ -119,15 +119,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
getSrcOfImage (img) {
|
||||
var src = img.src ? img.src : (img.querySelector("canvas") ? img.querySelector("canvas").src : "");
|
||||
return src.split("?width=")[0];
|
||||
}
|
||||
|
||||
|
||||
addImages (modal, imgs, img) {
|
||||
modal.querySelectorAll(`${BDFDB.dotCN.imagewrapper}.prev, ${BDFDB.dotCN.imagewrapper}.next`).forEach(ele => {ele.remove();});
|
||||
|
||||
|
||||
var prevImg, nextImg, index;
|
||||
for (index = 0; index < imgs.length; index++) {
|
||||
if (this.getSrcOfImage(img) == this.getSrcOfImage(imgs[index])) {
|
||||
|
@ -137,14 +137,14 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$(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)
|
||||
|
@ -166,7 +166,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.find("img").attr("src", this.getSrcOfImage(nextImg));
|
||||
this.resizeImage(modal, nextImg, modal.querySelector(BDFDB.dotCN.imagewrapper + ".next img"));
|
||||
}
|
||||
|
||||
|
||||
$(document).off("keydown." + this.name).off("keyup." + this.name)
|
||||
.on("keydown." + this.name, (e) => {
|
||||
this.keyPressed({modal, imgs, prevImg, nextImg}, e);
|
||||
|
@ -175,7 +175,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.eventFired = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
resizeImage (container, src, img) {
|
||||
$(img).hide();
|
||||
var temp = new Image();
|
||||
|
@ -188,22 +188,22 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
var newHeight = src.clientHeight * resize;
|
||||
newWidth = temp.width > newWidth ? newWidth : temp.width;
|
||||
newHeight = temp.height > newHeight ? newHeight : temp.height;
|
||||
|
||||
|
||||
var wrapper = img.parentElement;
|
||||
|
||||
|
||||
|
||||
|
||||
$(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();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
keyPressed (data, e) {
|
||||
if (!this.eventFired) {
|
||||
this.eventFired = true;
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
initConstructor () {
|
||||
this.bindings = {};
|
||||
|
||||
|
||||
this.firedEvents = [];
|
||||
|
||||
|
||||
this.clickMap = ["SINGLE" /*[0]*/, "DOUBLE" /*[1]*/];
|
||||
|
||||
|
||||
this.keyboardMap = [
|
||||
"NONE" /*[0]*/, "" /*[1]*/, "" /*[2]*/, "CANCEL" /*[3]*/, "" /*[4]*/, "" /*[5]*/, "HELP" /*[6]*/, "" /*[7]*/, "BACK_SPACE" /*[8]*/, "TAB" /*[9]*/, "" /*[10]*/, "" /*[11]*/, "CLEAR" /*[12]*/, "ENTER" /*[13]*/, "ENTER_SPECIAL" /*[14]*/, "" /*[15]*/, "SHIFT" /*[16]*/, "CONTROL" /*[17]*/, "ALT" /*[18]*/, "PAUSE" /*[19]*/, "CAPS_LOCK" /*[20]*/, "KANA" /*[21]*/, "EISU" /*[22]*/, "JUNJA" /*[23]*/, "FINAL" /*[24]*/, "HANJA" /*[25]*/, "" /*[26]*/, "ESCAPE" /*[27]*/, "CONVERT" /*[28]*/, "NONCONVERT" /*[29]*/, "ACCEPT" /*[30]*/, "MODECHANGE" /*[31]*/, "SPACE" /*[32]*/, "PAGE_UP" /*[33]*/, "PAGE_DOWN" /*[34]*/, "END" /*[35]*/, "HOME" /*[36]*/, "LEFT" /*[37]*/, "UP" /*[38]*/, "RIGHT" /*[39]*/, "DOWN" /*[40]*/, "SELECT" /*[41]*/, "PRINT" /*[42]*/, "EXECUTE" /*[43]*/, "PRINTSCREEN" /*[44]*/, "INSERT" /*[45]*/, "DELETE" /*[46]*/, "" /*[47]*/,"0" /*[48]*/, "1" /*[49]*/, "2" /*[50]*/, "3" /*[51]*/, "4" /*[52]*/, "5" /*[53]*/, "6" /*[54]*/, "7" /*[55]*/, "8" /*[56]*/, "9" /*[57]*/, "COLON" /*[58]*/, "SEMICOLON" /*[59]*/, "LESS_THAN" /*[60]*/, "EQUALS" /*[61]*/, "GREATER_THAN" /*[62]*/, "QUESTION_MARK" /*[63]*/, "AT" /*[64]*/, "A" /*[65]*/, "B" /*[66]*/, "C" /*[67]*/, "D" /*[68]*/, "E" /*[69]*/, "F" /*[70]*/, "G" /*[71]*/, "H" /*[72]*/, "I" /*[73]*/, "J" /*[74]*/, "K" /*[75]*/, "L" /*[76]*/, "M" /*[77]*/, "N" /*[78]*/, "O" /*[79]*/, "P" /*[80]*/, "Q" /*[81]*/, "R" /*[82]*/, "S" /*[83]*/, "T" /*[84]*/, "U" /*[85]*/, "V" /*[86]*/, "W" /*[87]*/, "X" /*[88]*/, "Y" /*[89]*/, "Z" /*[90]*/, "OS_KEY" /*[91]*/, "" /*[92]*/, "CONTEXT_MENU" /*[93]*/, "" /*[94]*/, "SLEEP" /*[95]*/, "NUMPAD0" /*[96]*/, "NUMPAD1" /*[97]*/, "NUMPAD2" /*[98]*/, "NUMPAD3" /*[99]*/, "NUMPAD4" /*[100]*/, "NUMPAD5" /*[101]*/, "NUMPAD6" /*[102]*/, "NUMPAD7" /*[103]*/, "NUMPAD8" /*[104]*/, "NUMPAD9" /*[105]*/, "MULTIPLY" /*[106]*/, "ADD" /*[107]*/, "SEPARATOR" /*[108]*/, "SUBTRACT" /*[109]*/, "DECIMAL" /*[110]*/, "DIVIDE" /*[111]*/, "F1" /*[112]*/, "F2" /*[113]*/, "F3" /*[114]*/, "F4" /*[115]*/, "F5" /*[116]*/, "F6" /*[117]*/, "F7" /*[118]*/, "F8" /*[119]*/, "F9" /*[120]*/, "F10" /*[121]*/, "F11" /*[122]*/, "F12" /*[123]*/, "F13" /*[124]*/, "F14" /*[125]*/, "F15" /*[126]*/, "F16" /*[127]*/, "F17" /*[128]*/, "F18" /*[129]*/, "F19" /*[130]*/, "F20" /*[131]*/, "F21" /*[132]*/, "F22" /*[133]*/, "F23" /*[134]*/, "F24" /*[135]*/, "" /*[136]*/, "" /*[137]*/, "" /*[138]*/, "" /*[139]*/, "" /*[140]*/, "" /*[141]*/, "" /*[142]*/, "" /*[143]*/, "NUM_LOCK" /*[144]*/, "SCROLL_LOCK" /*[145]*/, "WIN_OEM_FJ_JISHO" /*[146]*/, "WIN_OEM_FJ_MASSHOU" /*[147]*/, "WIN_OEM_FJ_TOUROKU" /*[148]*/, "WIN_OEM_FJ_LOYA" /*[149]*/, "WIN_OEM_FJ_ROYA" /*[150]*/, "" /*[151]*/, "" /*[152]*/, "" /*[153]*/, "" /*[154]*/, "" /*[155]*/, "" /*[156]*/, "" /*[157]*/, "" /*[158]*/, "" /*[159]*/, "CIRCUMFLEX" /*[160]*/, "EXCLAMATION" /*[161]*/, "DOUBLE_QUOTE" /*[162]*/, "HASH" /*[163]*/, "DOLLAR" /*[164]*/, "PERCENT" /*[165]*/, "AMPERSAND" /*[166]*/, "UNDERSCORE" /*[167]*/, "OPEN_PAREN" /*[168]*/, "CLOSE_PAREN" /*[169]*/, "ASTERISK" /*[170]*/, "PLUS" /*[171]*/, "PIPE" /*[172]*/, "HYPHEN_MINUS" /*[173]*/, "OPEN_CURLY_BRACKET" /*[174]*/, "CLOSE_CURLY_BRACKET" /*[175]*/, "TILDE" /*[176]*/, "" /*[177]*/, "" /*[178]*/, "" /*[179]*/, "" /*[180]*/, "VOLUME_MUTE" /*[181]*/, "VOLUME_DOWN" /*[182]*/, "VOLUME_UP" /*[183]*/, "" /*[184]*/, "" /*[185]*/, "SEMICOLON" /*[186]*/, "EQUALS" /*[187]*/, "COMMA" /*[188]*/, "MINUS" /*[189]*/, "PERIOD" /*[190]*/, "SLASH" /*[191]*/, "BACK_QUOTE" /*[192]*/, "" /*[193]*/, "" /*[194]*/, "" /*[195]*/, "" /*[196]*/, "" /*[197]*/, "" /*[198]*/, "" /*[199]*/, "" /*[200]*/, "" /*[201]*/, "" /*[202]*/, "" /*[203]*/, "" /*[204]*/, "" /*[205]*/, "" /*[206]*/, "" /*[207]*/, "" /*[208]*/, "" /*[209]*/, "" /*[210]*/, "" /*[211]*/, "" /*[212]*/, "" /*[213]*/, "" /*[214]*/, "" /*[215]*/, "" /*[216]*/, "" /*[217]*/, "" /*[218]*/, "OPEN_BRACKET" /*[219]*/, "BACK_SLASH" /*[220]*/, "CLOSE_BRACKET" /*[221]*/, "QUOTE" /*[222]*/, "" /*[223]*/, "META" /*[224]*/, "ALTGR" /*[225]*/, "" /*[226]*/, "WIN_ICO_HELP" /*[227]*/, "WIN_ICO_00" /*[228]*/, "" /*[229]*/, "WIN_ICO_CLEAR" /*[230]*/, "" /*[231]*/,"" /*[232]*/, "WIN_OEM_RESET" /*[233]*/, "WIN_OEM_JUMP" /*[234]*/, "WIN_OEM_PA1" /*[235]*/, "WIN_OEM_PA2" /*[236]*/, "WIN_OEM_PA3" /*[237]*/, "WIN_OEM_WSCTRL" /*[238]*/,"WIN_OEM_CUSEL" /*[239]*/, "WIN_OEM_ATTN" /*[240]*/, "WIN_OEM_FINISH" /*[241]*/, "WIN_OEM_COPY" /*[242]*/, "WIN_OEM_AUTO" /*[243]*/, "WIN_OEM_ENLW" /*[244]*/, "WIN_OEM_BACKTAB" /*[245]*/, "ATTN" /*[246]*/, "CRSEL" /*[247]*/, "EXSEL" /*[248]*/, "EREOF" /*[249]*/, "PLAY" /*[250]*/, "ZOOM" /*[251]*/, "" /*[252]*/, "PA1" /*[253]*/, "WIN_OEM_CLEAR" /*[254]*/, "" /*[255]*/
|
||||
];
|
||||
|
||||
|
||||
this.clicks = ["click"];
|
||||
this.keys = ["key1","key2"];
|
||||
this.defaults = {
|
||||
|
@ -43,31 +41,33 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.ChannelStore = BDFDB.WebModules.findByProperties("getChannel", "getChannels");
|
||||
this.MessageActions = BDFDB.WebModules.findByProperties("startEditMessage", "endEditMessage");
|
||||
this.PinActions = BDFDB.WebModules.findByProperties("pinMessage", "unpinMessage");
|
||||
this.CurrentUserPerms = BDFDB.WebModules.findByProperties("getChannelPermissions", "can");
|
||||
this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions
|
||||
|
||||
|
||||
$(document)
|
||||
.on("click." + this.name, BDFDB.dotCN.message, (e) => {
|
||||
this.onClick(e.currentTarget, 0, "onSglClick");
|
||||
|
@ -88,11 +88,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
$(document).off("click." + this.name, BDFDB.dotCN.message);
|
||||
$(document).off("dblclick." + this.name, BDFDB.dotCN.message);
|
||||
$(document).off("keydown." + this.name, BDFDB.dotCN.textareawrapchat);
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
|
@ -111,7 +111,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
|
||||
resetAll (settingspanel) {
|
||||
if (confirm("Are you sure you want to delete all key bindings?")) {
|
||||
BDFDB.removeAllData(this, "bindings");
|
||||
|
@ -130,22 +130,22 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (settingspanel, e) {
|
||||
var selectControl = e.currentTarget;
|
||||
var selectWrap = e.currentTarget.parentElement;
|
||||
|
||||
|
||||
if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
|
||||
selectWrap.classList.add(BDFDB.disCN.selectisopen);
|
||||
|
||||
|
||||
var action = selectWrap.getAttribute("type");
|
||||
var option = selectWrap.getAttribute("option");
|
||||
var value = selectWrap.getAttribute("value");
|
||||
|
||||
|
||||
var selectMenu = this.createDropdownMenu(action, value);
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
|
||||
$(selectMenu).on("mousedown." + this.name, BDFDB.dotCN.selectoption, (e2) => {
|
||||
var binding = BDFDB.getData(action, this, "bindings");
|
||||
var selection = e2.currentTarget.getAttribute("value");
|
||||
|
@ -161,7 +161,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu (action, value) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var i in this.clickMap) {
|
||||
|
@ -171,26 +171,26 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
menuhtml += `</div></div>`;
|
||||
return $(menuhtml)[0];
|
||||
}
|
||||
|
||||
|
||||
startRecording (settingspanel, e) {
|
||||
var recorderWrap = e.currentTarget;
|
||||
|
||||
|
||||
if (recorderWrap.classList.contains(BDFDB.disCN.hotkeyrecording)) return;
|
||||
|
||||
|
||||
var recorderInput = recorderWrap.querySelector("input");
|
||||
var recorderText = recorderWrap.querySelector(BDFDB.dotCN.hotkeytext);
|
||||
var action = recorderWrap.getAttribute("type");
|
||||
var option = recorderWrap.getAttribute("option");
|
||||
|
||||
|
||||
recorderWrap.classList.add(BDFDB.disCN.hotkeyrecording);
|
||||
recorderWrap.classList.remove(BDFDB.disCN.hotkeyhasvalue);
|
||||
recorderText.innerText = BDFDB.LanguageStrings.SHORTCUT_RECORDER_BUTTON_RECORDING;
|
||||
|
||||
|
||||
$(document).on("keydown.recorder" + this.name, (e) => {
|
||||
recorderWrap.setAttribute("value", e.which);
|
||||
recorderInput.setAttribute("value", this.keyboardMap[e.which]);
|
||||
});
|
||||
|
||||
|
||||
$(document).on("mousedown.recorder" + this.name, () => {
|
||||
$(document).off("mousedown.recorder" + this.name);
|
||||
$(document).off("keydown.recorder" + this.name);
|
||||
|
@ -204,7 +204,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
},100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
resetRecorder (settingspanel, e) {
|
||||
var resetButton = e.currentTarget;
|
||||
var recorderWrap = e.currentTarget.parentElement.parentElement.querySelector(BDFDB.dotCN.hotkeycontainer);
|
||||
|
@ -217,7 +217,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
binding[option] = parseInt(recorderWrap.getAttribute("value"));
|
||||
BDFDB.saveData(action, binding, this, "bindings");
|
||||
}
|
||||
|
||||
|
||||
onClick (div, click, name) {
|
||||
if (!this.isEventFired(name)) {
|
||||
this.fireEvent(name);
|
||||
|
@ -233,7 +233,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.cancelEvent(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkIfBindingIsValid (binding, doneclick) {
|
||||
var valid = true;
|
||||
for (let click of this.clicks) {
|
||||
|
@ -244,25 +244,25 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
doDelete (message) {
|
||||
var channel = this.ChannelStore.getChannel(message.channel_id);
|
||||
if ((channel && this.CurrentUserPerms.can(this.Permissions.MANAGE_MESSAGES, channel)) || message.author.id == BDFDB.myData.id) {
|
||||
this.MessageActions.deleteMessage(message.channel_id, message.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doEdit (message) {
|
||||
if (message.author.id == BDFDB.myData.id) {
|
||||
this.MessageActions.startEditMessage(message.channel_id, message.id, message.content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doOpenReact (message) {
|
||||
var reactButton = message.div.querySelector(BDFDB.dotCN.emojipickerbutton);
|
||||
if (reactButton) reactButton.click();
|
||||
}
|
||||
|
||||
|
||||
doPinUnPin (message) {
|
||||
var channel = this.ChannelStore.getChannel(message.channel_id);
|
||||
if (channel && this.CurrentUserPerms.can(this.Permissions.MANAGE_MESSAGES, channel)) {
|
||||
|
@ -270,7 +270,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
else this.PinActions.pinMessage(channel, message.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doNote (message) {
|
||||
if (BDFDB.isPluginEnabled("PersonalPins") == true) {
|
||||
var PersonalPins = window.bdplugins["PersonalPins"].plugin;
|
||||
|
@ -278,7 +278,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
PersonalPins.addMessageToNotes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doTranslate (message) {
|
||||
if (BDFDB.isPluginEnabled("GoogleTranslateOption") == true) {
|
||||
var GoogleTranslateOption = window.bdplugins["GoogleTranslateOption"].plugin;
|
||||
|
@ -286,21 +286,21 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
GoogleTranslateOption.translateMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doQuote (message) {
|
||||
if (BDFDB.isPluginEnabled("Quoter") == true) {
|
||||
var quoteButton = message.div.querySelector(".btn-quote");
|
||||
if (quoteButton) quoteButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
doCitate (message) {
|
||||
if (BDFDB.isPluginEnabled("Citador") == true) {
|
||||
var citarButton = message.div.parentElement.querySelector(".citar-btn");
|
||||
if (citarButton) citarButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onKeyDown (div, key, name) {
|
||||
if (!this.isEventFired(name)) {
|
||||
this.fireEvent(name);
|
||||
|
@ -311,7 +311,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.cancelEvent(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getMessageData (div) {
|
||||
if (div) {
|
||||
var messagegroup = $(BDFDB.dotCN.messagegroup).has(div);
|
||||
|
@ -323,19 +323,19 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
fireEvent (name) {
|
||||
this.firedEvents.push(name);
|
||||
}
|
||||
|
||||
|
||||
isEventFired (name) {
|
||||
return this.firedEvents.includes(name);
|
||||
}
|
||||
|
||||
|
||||
cancelEvent (name) {
|
||||
BDFDB.removeFromArray(this.firedEvents, name);
|
||||
}
|
||||
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var bindings = BDFDB.getAllData(this, "bindings");
|
||||
|
@ -355,21 +355,21 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
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>`;
|
||||
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
|
||||
$(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);
|
||||
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
|
@ -40,7 +40,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"popoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
|
@ -69,7 +69,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
makeMoveable (div) {
|
||||
$(div)
|
||||
.off("mousedown." + this.name).off("click." + this.name)
|
||||
|
@ -93,12 +93,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
.on("mousedown." + this.name, (e) => {
|
||||
if (e.ctrlKey) {
|
||||
this.dragging = true;
|
||||
|
||||
|
||||
var disableTextSelectionCSS = `
|
||||
* {
|
||||
user-select: none !important;
|
||||
}`;
|
||||
|
||||
|
||||
BDFDB.appendLocalStyle("disableTextSelection", disableTextSelectionCSS);
|
||||
var left = div.getBoundingClientRect().left;
|
||||
var top = div.getBoundingClientRect().top;
|
||||
|
|
|
@ -1,42 +1,45 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.types = {
|
||||
"message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3"},
|
||||
"dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3"},
|
||||
"mentioned": {implemented:true, name:"Mention Ping", src:"/assets/a5f42064e8120e381528b14fd3188b72.mp3"},
|
||||
"deafen": {implemented:true, name:"Voicechat Deafen", src:"/assets/e4d539271704b87764dc465b1a061abd.mp3"},
|
||||
"mute": {implemented:true, name:"Voicechat Mute", src:"/assets/429d09ee3b86e81a75b5e06d3fb482be.mp3"},
|
||||
"disconnect": {implemented:true, name:"Voicechat Disconnect", src:"/assets/7e125dc075ec6e5ae796e4c3ab83abb3.mp3"},
|
||||
"undeafen": {implemented:true, name:"Voicechat Undeafen", src:"/assets/5a000a0d4dff083d12a1d4fc2c7cbf66.mp3"},
|
||||
"unmute": {implemented:true, name:"Voicechat Unmute", src:"/assets/43805b9dd757ac4f6b9b58c1a8ee5f0d.mp3"},
|
||||
"user_join": {implemented:true, name:"Voicechat User Joined", src:"/assets/5dd43c946894005258d85770f0d10cff.mp3"},
|
||||
"user_leave": {implemented:true, name:"Voicechat User Left", src:"/assets/4fcfeb2cba26459c4750e60f626cebdc.mp3"},
|
||||
"user_moved": {implemented:true, name:"Voicechat User Moved", src:"/assets/e81d11590762728c1b811eadfa5be766.mp3"},
|
||||
"ptt_start": {implemented:true, name:"Push2Talk Start", src:"/assets/8b63833c8d252fedba6b9c4f2517c705.mp3"},
|
||||
"ptt_stop": {implemented:true, name:"Push2Talk Stop", src:"/assets/74ab980d6890a0fa6aa0336182f9f620.mp3"},
|
||||
"call_calling": {implemented:true, name:"Outgoing Call", src:"/assets/c6e92752668dde4eee5923d70441579f.mp3"},
|
||||
"call_ringing": {implemented:true, name:"Incoming Call", src:"/assets/84a1b4e11d634dbfa1e5dd97a96de3ad.mp3"},
|
||||
"call_ringing_beat": {implemented:false, name:"Incoming Call Beat", src:"/assets/b9411af07f154a6fef543e7e442e4da9.mp3"},
|
||||
"ddr-down": {implemented:true, name:"HotKeys Window Down", src:"/assets/71f048f8aa7d4b24bf4268a87cbbb192.mp3"},
|
||||
"ddr-left": {implemented:true, name:"HotKeys Window Left", src:"/assets/1de04408e62b5d52ae3ebbb91e9e1978.mp3"},
|
||||
"ddr-right": {implemented:true, name:"HotKeys Window Right", src:"/assets/2c0433f93db8449e4a82b76dc520cb29.mp3"},
|
||||
"ddr-up": {implemented:true, name:"HotKeys Window Up", src:"/assets/68472713f7a62c7c37e0a6a5d5a1faeb.mp3"},
|
||||
"human_man": {implemented:false, name:"Human Man Voice", src:"/assets/a37dcd6272ae41cf49295d58c9806fe3.mp3"},
|
||||
"mention1": {implemented:false, name:"Mention Ping 1", src:"/assets/fa4d62c3cbc80733bf1f01b9c6f181de.mp3"},
|
||||
"mention2": {implemented:false, name:"Mention Ping 2", src:"/assets/a5f42064e8120e381528b14fd3188b72.mp3"},
|
||||
"mention3": {implemented:false, name:"Mention Ping 3", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3"},
|
||||
"message2": {implemented:false, name:"New Chatmessage 2", src:"/assets/15fe810f6cfab609c7fcda61652b9b34.mp3"},
|
||||
"message3": {implemented:false, name:"New Chatmessage 3", src:"/assets/53ce6a92d3c233e8b4ac529d34d374e4.mp3"},
|
||||
"overlayunlock": {implemented:false, name:"Overlay Unlocked", src:"/assets/ad322ffe0a88436296158a80d5d11baa.mp3"},
|
||||
"reconnect": {implemented:false, name:"Voicechat Reconnect", src:"/assets/471cfd0005b112ff857705e894bf41a6.mp3"},
|
||||
"robot_man": {implemented:false, name:"Robot Man Voice", src:"/assets/66598bea6e59eb8acdf32cf2d9d75ba9.mp3"}
|
||||
this.patchModules = {
|
||||
"IncomingCalls":"componentDidMount",
|
||||
"PrivateChannelCall":"componentDidMount"
|
||||
};
|
||||
|
||||
|
||||
this.types = {
|
||||
"message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute:true},
|
||||
"dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true},
|
||||
"mentioned": {implemented:true, name:"Mention Ping", src:"/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute:true},
|
||||
"deafen": {implemented:true, name:"Voicechat Deafen", src:"/assets/e4d539271704b87764dc465b1a061abd.mp3", mute:false},
|
||||
"mute": {implemented:true, name:"Voicechat Mute", src:"/assets/429d09ee3b86e81a75b5e06d3fb482be.mp3", mute:false},
|
||||
"disconnect": {implemented:true, name:"Voicechat Disconnect", src:"/assets/7e125dc075ec6e5ae796e4c3ab83abb3.mp3", mute:false},
|
||||
"undeafen": {implemented:true, name:"Voicechat Undeafen", src:"/assets/5a000a0d4dff083d12a1d4fc2c7cbf66.mp3", mute:false},
|
||||
"unmute": {implemented:true, name:"Voicechat Unmute", src:"/assets/43805b9dd757ac4f6b9b58c1a8ee5f0d.mp3", mute:false},
|
||||
"user_join": {implemented:true, name:"Voicechat User Joined", src:"/assets/5dd43c946894005258d85770f0d10cff.mp3", mute:false},
|
||||
"user_leave": {implemented:true, name:"Voicechat User Left", src:"/assets/4fcfeb2cba26459c4750e60f626cebdc.mp3", mute:false},
|
||||
"user_moved": {implemented:true, name:"Voicechat User Moved", src:"/assets/e81d11590762728c1b811eadfa5be766.mp3", mute:false},
|
||||
"ptt_start": {implemented:true, name:"Push2Talk Start", src:"/assets/8b63833c8d252fedba6b9c4f2517c705.mp3", mute:false},
|
||||
"ptt_stop": {implemented:true, name:"Push2Talk Stop", src:"/assets/74ab980d6890a0fa6aa0336182f9f620.mp3", mute:false},
|
||||
"call_calling": {implemented:true, name:"Outgoing Call", src:"/assets/c6e92752668dde4eee5923d70441579f.mp3", mute:false},
|
||||
"call_ringing": {implemented:true, name:"Incoming Call", src:"/assets/84a1b4e11d634dbfa1e5dd97a96de3ad.mp3", mute:true},
|
||||
"call_ringing_beat": {implemented:false, name:"Incoming Call Beat", src:"/assets/b9411af07f154a6fef543e7e442e4da9.mp3", mute:true},
|
||||
"ddr-down": {implemented:true, name:"HotKeys Window Down", src:"/assets/71f048f8aa7d4b24bf4268a87cbbb192.mp3", mute:true},
|
||||
"ddr-left": {implemented:true, name:"HotKeys Window Left", src:"/assets/1de04408e62b5d52ae3ebbb91e9e1978.mp3", mute:true},
|
||||
"ddr-right": {implemented:true, name:"HotKeys Window Right", src:"/assets/2c0433f93db8449e4a82b76dc520cb29.mp3", mute:true},
|
||||
"ddr-up": {implemented:true, name:"HotKeys Window Up", src:"/assets/68472713f7a62c7c37e0a6a5d5a1faeb.mp3", mute:true},
|
||||
"human_man": {implemented:false, name:"Human Man Voice", src:"/assets/a37dcd6272ae41cf49295d58c9806fe3.mp3", mute:true},
|
||||
"mention1": {implemented:false, name:"Mention Ping 1", src:"/assets/fa4d62c3cbc80733bf1f01b9c6f181de.mp3", mute:true},
|
||||
"mention2": {implemented:false, name:"Mention Ping 2", src:"/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute:true},
|
||||
"mention3": {implemented:false, name:"Mention Ping 3", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true},
|
||||
"message2": {implemented:false, name:"New Chatmessage 2", src:"/assets/15fe810f6cfab609c7fcda61652b9b34.mp3", mute:true},
|
||||
"message3": {implemented:false, name:"New Chatmessage 3", src:"/assets/53ce6a92d3c233e8b4ac529d34d374e4.mp3", mute:true},
|
||||
"overlayunlock": {implemented:false, name:"Overlay Unlocked", src:"/assets/ad322ffe0a88436296158a80d5d11baa.mp3", mute:true},
|
||||
"reconnect": {implemented:false, name:"Voicechat Reconnect", src:"/assets/471cfd0005b112ff857705e894bf41a6.mp3", mute:true},
|
||||
"robot_man": {implemented:false, name:"Robot Man Voice", src:"/assets/66598bea6e59eb8acdf32cf2d9d75ba9.mp3", mute:true}
|
||||
};
|
||||
|
||||
this.defaults = {
|
||||
"---": {
|
||||
"---": null
|
||||
|
@ -80,202 +83,76 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
"Voicechat Reconnect": "/assets/471cfd0005b112ff857705e894bf41a6.mp3"
|
||||
}
|
||||
};
|
||||
|
||||
this.audios = {};
|
||||
|
||||
this.choices = [];
|
||||
|
||||
this.oldmentions = {};
|
||||
|
||||
this.firedEvents = {};
|
||||
|
||||
this.hasPatchedOutgoing = false;
|
||||
this.settingsaudio = new Audio();
|
||||
|
||||
this.audios = {};
|
||||
|
||||
this.choices = [];
|
||||
|
||||
this.firedEvents = {};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
this.SoundUtils = BDFDB.WebModules.findByProperties("playSound");
|
||||
|
||||
this.patchCancel = BDFDB.WebModules.monkeyPatch(this.SoundUtils, "playSound", {instead: (e) => {
|
||||
|
||||
this.ChannelSettingsUtils = BDFDB.WebModules.findByProperties("isGuildOrCategoryOrChannelMuted");
|
||||
|
||||
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) {
|
||||
if (!guildid) {
|
||||
this.fireEvent("dm");
|
||||
this.playAudio("dm");
|
||||
}
|
||||
else if (message.mentions) {
|
||||
for (let mention of message.mentions) if (mention.id == BDFDB.myData.id) {
|
||||
this.fireEvent("mentioned");
|
||||
this.playAudio("mentioned");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
|
||||
BDFDB.WebModules.patch(BDFDB.WebModules.findByProperties("playSound"), "playSound", this, {instead: e => {
|
||||
setImmediate(() => {
|
||||
var type = e.methodArguments[0];
|
||||
if (type == "message1") {
|
||||
if (this.firedEvents["dm"]) {
|
||||
type = "dm";
|
||||
this.firedEvents["dm"] = false;
|
||||
}
|
||||
else if (this.firedEvents["mentioned"]) {
|
||||
type = "mentioned";
|
||||
this.firedEvents["mentioned"] = false;
|
||||
}
|
||||
if (this.firedEvents["dm"]) this.firedEvents["dm"] = false;
|
||||
else if (this.firedEvents["mentioned"]) this.firedEvents["mentioned"] = false;
|
||||
else this.playAudio(type);
|
||||
}
|
||||
this.playAudio(type);
|
||||
else this.playAudio(type);
|
||||
});
|
||||
}});
|
||||
|
||||
var incomingCallAudio = new Audio();
|
||||
this.incomingCallOwnerInstance = BDFDB.getOwnerInstance({"node":document.querySelector(BDFDB.dotCN.callcontainer), "props":["startRinging","stopRinging"], "up":true});
|
||||
this.oldStartRining = this.incomingCallOwnerInstance.startRinging;
|
||||
this.oldStopRining = this.incomingCallOwnerInstance.stopRinging;
|
||||
this.incomingCallOwnerInstance.startRinging = () => {
|
||||
incomingCallAudio.pause();
|
||||
incomingCallAudio.loop = true;
|
||||
incomingCallAudio.src = this.choices["call_ringing"].src;
|
||||
incomingCallAudio.volume = this.choices["call_ringing"].volume/100;
|
||||
incomingCallAudio.play();
|
||||
};
|
||||
this.incomingCallOwnerInstance.stopRinging = () => {incomingCallAudio.pause();};
|
||||
|
||||
|
||||
this.loadAudios();
|
||||
this.loadChoices();
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
this.fireEvent("dm");
|
||||
});
|
||||
BDFDB.addObserver(this, null, {name:"dmBadgeObserver",instance:observer,multi:true}, {characterData: true, subtree: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
this.fireEvent("mentioned");
|
||||
});
|
||||
BDFDB.addObserver(this, null, {name:"mentionBadgeObserver",instance:observer,multi:true}, {characterData: true, subtree: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
BDFDB.addObserver(this, node, {name:"dmBadgeObserver",multi:true}, {characterData: true, subtree: true});
|
||||
this.fireEvent("dm");
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.dms, {name:"dmObserver",instance:observer}, {childList: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.className === BDFDB.disCN.badge) {
|
||||
var data = BDFDB.getKeyInformation({"node":node.parentElement,"key":"guild"});
|
||||
if (data) {
|
||||
BDFDB.addObserver(this, node, {name:"mentionBadgeObserver",multi:true}, {characterData: true, subtree: true});
|
||||
if (this.oldmentions && this.oldmentions[data.id] == 0) this.fireEvent("mentioned");
|
||||
}
|
||||
}
|
||||
if (node && node.classList && node.classList.contains(BDFDB.disCN.guild) && !node.classList.contains(BDFDB.disCN.guildsadd) && !document.querySelector(BDFDB.dotCN.dms).contains(node)) {
|
||||
BDFDB.addObserver(this, node, {name:"mentionBadgeObserver",multi:true}, {characterData: true, subtree: true});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (change.removedNodes) {
|
||||
change.removedNodes.forEach((node) => {
|
||||
if (node && node.className === BDFDB.disCN.badge) {
|
||||
this.oldmentions = BDFDB.getKeyInformation({"node":document.querySelector(BDFDB.dotCN.layers),"key":"mentionCounts"});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"mentionObserver",instance:observer}, {childList: true, subtree:true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node.classList && node.classList.contains(BDFDB.dotCN.channeliconspacing) && $(node).find(BDFDB.dotCN.channelbadge).length > 0) {
|
||||
BDFDB.addObserver(this, node, {name:"mentionBadgeObserver",multi:true}, {characterData: true, subtree: true});
|
||||
this.fireEvent("mentioned");
|
||||
this.oldmentions = BDFDB.getKeyInformation({"node":$(BDFDB.dotCN.channelswrap).parent()[0],"key":"mentionCounts"});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (change.removedNodes) {
|
||||
change.removedNodes.forEach((node) => {
|
||||
if (node.classList && node.classList.contains(BDFDB.dotCN.channeliconspacing) && $(node).find(BDFDB.dotCN.channelbadge).length > 0) {
|
||||
this.oldmentions = BDFDB.getKeyInformation({"node":$(BDFDB.dotCN.channelswrap).parent()[0],"key":"mentionCounts"});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.channels, {name:"channelListObserver",instance:observer}, {childList: true, subtree: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.tagName && node.classList.contains(BDFDB.disCN.callcurrentcontainer)) {
|
||||
if (!this.hasPatchedOutgoing) {
|
||||
var outgoingCallAudio = new Audio();
|
||||
let play = () => {
|
||||
outgoingCallAudio.loop = true;
|
||||
outgoingCallAudio.src = this.choices["call_calling"].src;
|
||||
outgoingCallAudio.volume = this.choices["call_calling"].volume/100;
|
||||
outgoingCallAudio.play();
|
||||
};
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
let stop = () => {outgoingCallAudio.pause();}
|
||||
|
||||
var outgoingCallOwnerInstance = BDFDB.getOwnerInstance({"node":node, "props":["startRinging"], "up":true});
|
||||
outgoingCallOwnerInstance.stopRinging();
|
||||
outgoingCallOwnerInstance.startRinging = play;
|
||||
outgoingCallOwnerInstance.stopRinging = stop;
|
||||
|
||||
let CallingWrap = outgoingCallOwnerInstance._reactInternalFiber.type;
|
||||
this.cancelOutgoingStart = BDFDB.WebModules.monkeyPatch(CallingWrap.prototype, "startRinging", {instead: play});
|
||||
this.cancelOutgoingStop = BDFDB.WebModules.monkeyPatch(CallingWrap.prototype, "stopRinging", {instead: stop});
|
||||
|
||||
this.hasPatchedOutgoing = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCNS.chat, {name:"chatObserver",instance:observer}, {childList:true});
|
||||
|
||||
BDFDB.readServerList().forEach((serverObj) => {
|
||||
var badge = serverObj.div.querySelector(BDFDB.dotCN.badge);
|
||||
if (badge) {
|
||||
BDFDB.addObserver(this, badge, {name:"mentionBadgeObserver",multi:true}, {characterData: true, subtree: true});
|
||||
}
|
||||
});
|
||||
|
||||
BDFDB.readDmList().forEach((dmObj) => {
|
||||
var badge = dmObj.div.querySelector(BDFDB.dotCN.badge);
|
||||
if (badge) {
|
||||
BDFDB.addObserver(this, badge, {name:"dmBadgeObserver",multi:true}, {characterData: true, subtree: true});
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -286,14 +163,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (typeof this.patchCancel === "function") this.patchCancel();
|
||||
if (typeof this.cancelOutgoingStart === "function") this.cancelOutgoingStart();
|
||||
if (typeof this.cancelOutgoingStop === "function") this.cancelOutgoingStop();
|
||||
|
||||
this.incomingCallOwnerInstance.startRinging = this.oldStartRining;
|
||||
this.incomingCallOwnerInstance.stopRinging = this.oldStopRining;
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -302,57 +172,30 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (!this.hasPatchedOutgoing) BDFDB.addObserver(this, BDFDB.dotCNS.chat, {name:"chatObserver"}, {childList:true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
resetAll (settingspanel) {
|
||||
if (confirm("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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (settingspanel, e) {
|
||||
var selectControl = e.currentTarget;
|
||||
var selectWrap = selectControl.parentElement;
|
||||
|
||||
if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
selectWrap.classList.add(BDFDB.disCN.selectisopen);
|
||||
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
|
||||
|
||||
var type = selectWrap.getAttribute("type");
|
||||
var option = selectWrap.getAttribute("option");
|
||||
var categorySelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type}"][option="category"]`);
|
||||
var songSelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type}"][option="song"]`);
|
||||
|
||||
|
||||
var category = categorySelect.getAttribute("value");
|
||||
var song = songSelect.getAttribute("value");
|
||||
|
||||
|
||||
var selectMenu = this.createDropdownMenu({type, option, category, song});
|
||||
selectWrap.appendChild(selectMenu);
|
||||
|
||||
$(selectMenu).on("mousedown." + this.name, 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);
|
||||
|
@ -364,17 +207,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
choice.src = this.audios[choice.category][choice.song];
|
||||
choice.src = choice.src ? choice.src : this.types[type].src;
|
||||
choice.volume = settingspanel.querySelector(`.${type}-volume`).value;
|
||||
this.saveChoice(type, choice, true);
|
||||
});
|
||||
$(document).on("mousedown.select" + this.name, (e2) => {
|
||||
if (e2.target.parentElement == selectMenu) return;
|
||||
$(document).off("mousedown.select" + this.name);
|
||||
selectMenu.remove()
|
||||
setTimeout(() => {selectWrap.classList.remove(BDFDB.disCN.selectisopen);},100);
|
||||
});
|
||||
|
||||
var removeMenu = e2 => {
|
||||
if (e2.target.parentElement != selectMenu) {
|
||||
document.removeEventListener("mousedown", removeMenu);
|
||||
selectMenu.remove();
|
||||
setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("mousedown", removeMenu);
|
||||
}
|
||||
|
||||
|
||||
createDropdownMenu ({type, option, category, song} = data) {
|
||||
var choice = BDFDB.loadData(type, this, "choices");
|
||||
var eles = option == "song" ? this.audios[category] : this.audios;
|
||||
|
@ -384,53 +230,49 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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) {
|
||||
var grabber = e.target;
|
||||
var track = grabber.parentNode;
|
||||
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.name).off("mousemove.slider" + this.name)
|
||||
.on("mouseup.slider" + this.name, () => {
|
||||
$(document).off("mouseup.slider" + this.name).off("mousemove.slider" + this.name);
|
||||
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.name, (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 () {
|
||||
this.audios = BDFDB.loadAllData(this, "audios");
|
||||
if (BDFDB.isObjectEmpty(this.audios)) this.audios = this.defaults;
|
||||
BDFDB.saveAllData(this.audios, this, "audios");
|
||||
}
|
||||
|
||||
|
||||
saveAudio (settingspanel) {
|
||||
var valid = true;
|
||||
var inputs = settingspanel.querySelectorAll(".songInput");
|
||||
|
@ -465,7 +307,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
successSavedAudio = () => {
|
||||
BDFDB.showToast(`Song ${song} was added to category ${category}.`, {type:"success"});
|
||||
if (!this.audios[category]) this.audios[category] = {};
|
||||
|
@ -480,12 +322,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.showToast("Fill out all fields to add a new song.", {type:"danger"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadChoices () {
|
||||
for (var type in this.types) {
|
||||
var choice = BDFDB.loadData(type, this, "choices");
|
||||
choice = choice ? choice : {};
|
||||
|
||||
|
||||
var songFound = false;
|
||||
for (var category in this.audios) {
|
||||
if (choice.category == category) {
|
||||
|
@ -497,34 +339,73 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!songFound) choice = {"category":"---","song":"---","volume":100,"src":this.types[type].src};
|
||||
if (!songFound) choice = {category:"---",song:"---",volume:100,src:this.types[type].src,mute:this.types[type].mute};
|
||||
if (typeof choice.mute == "undefined") choice.mute = this.types[type].mute;
|
||||
this.saveChoice(type, choice, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
saveChoice (type, choice, play) {
|
||||
BDFDB.saveData(type, choice, this, "choices");
|
||||
this.choices[type] = choice;
|
||||
if (play) this.playAudio(type);
|
||||
if (play) this.playAudio(type, this.settingsaudio);
|
||||
}
|
||||
|
||||
playAudio (type) {
|
||||
this.audio.pause();
|
||||
this.audio.src = this.choices[type].src;
|
||||
this.audio.volume = this.choices[type].volume/100;
|
||||
this.audio.play();
|
||||
|
||||
playAudio (type, audio) {
|
||||
if (!audio) {
|
||||
if (this.dontPlayAudio(type)) return;
|
||||
audio = new Audio()
|
||||
}
|
||||
else audio.pause();
|
||||
audio.src = this.choices[type].src;
|
||||
audio.volume = this.choices[type].volume/100;
|
||||
audio.play();
|
||||
}
|
||||
|
||||
|
||||
dontPlayAudio (type) {
|
||||
let status = BDFDB.getUserStatus();
|
||||
return this.choices[type].mute && (status == "dnd" || status == "streaming");
|
||||
}
|
||||
|
||||
fireEvent (type) {
|
||||
this.firedEvents[type] = true;
|
||||
setTimeout(() => {this.firedEvents[type] = false;},3000);
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
|
||||
patchCallingSound (instance, instancetype, type) {
|
||||
let audio = new Audio();
|
||||
let play = () => {
|
||||
if (!audio.paused || this.dontPlayAudio(type)) return;
|
||||
audio.loop = true;
|
||||
audio.src = this.choices[type].src;
|
||||
audio.volume = this.choices[type].volume/100;
|
||||
audio.play();
|
||||
};
|
||||
let stop = () => {audio.pause();}
|
||||
instance.stopRinging();
|
||||
BDFDB.WebModules.patch(instance, "startRinging", this, {instead: play});
|
||||
BDFDB.WebModules.patch(instance, "stopRinging", this, {instead: stop});
|
||||
BDFDB.WebModules.patch(instance._reactInternalFiber.type.prototype, "startRinging", this, {instead: play});
|
||||
BDFDB.WebModules.patch(instance._reactInternalFiber.type.prototype, "stopRinging", this, {instead: stop});
|
||||
BDFDB.WebModules.unpatch(instance._reactInternalFiber.type.prototype, this.patchModules[instancetype], this);
|
||||
}
|
||||
|
||||
processIncomingCalls (instance, wrapper) {
|
||||
this.patchCallingSound(instance, "IncomingCalls", "call_ringing");
|
||||
}
|
||||
|
||||
processPrivateChannelCall (instance, wrapper) {
|
||||
console.log(wrapper);
|
||||
this.patchCallingSound(instance, "PrivateChannelCall", "call_calling");
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
|
||||
var fields = ["category","song"];
|
||||
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
|
||||
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="DevilBro-settings-inner">`;
|
||||
|
||||
settingshtml += `<div class="add-new-song-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: 0 0 auto;">Add New Song:</h3></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;">`;
|
||||
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 50%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">Categoryname:</h5><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" placeholder="Category" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} songInput" id="input-category"></div></div>`;
|
||||
|
@ -534,11 +415,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">File:</h5><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" placeholder="Url or Filepath" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16} songInput" id="input-url"></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" id="input-file" 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" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-add btn-addsong" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div></div>`;
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
|
||||
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: 0 0 auto;">${this.types[type].name}:</h3></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>`;
|
||||
}
|
||||
|
@ -547,21 +427,47 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
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;">Show unimplemented Sounds</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" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id="input-unimplemented"></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;">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>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
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 = "---";
|
||||
});
|
||||
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);});
|
||||
|
||||
$(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", () => {this.resetAll(settingspanel);})
|
||||
.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();
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,137 +1,124 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"HeaderBar":["componentDidMount","componentDidUpdate"],
|
||||
"StandardSidebarView":["componentDidMount","componentWillUnmount"],
|
||||
"AuthWrapper":["componentDidMount","componentWillUnmount"]
|
||||
};
|
||||
|
||||
this.patched = false;
|
||||
|
||||
this.css = `
|
||||
body.titlebar-hidden-by-OTB .bd-settings-button, body.titlebar-hidden-by-OTB .bd-settings {
|
||||
body.hidden-by-OTB .bd-settings-button,
|
||||
body.hidden-by-OTB .bd-settings {
|
||||
top: 0 !important;
|
||||
}
|
||||
${BDFDB.dotCN.titlebar}.hidden-by-OTB {
|
||||
display: none;
|
||||
|
||||
.hidden-by-OTB ${BDFDB.dotCN.titlebar},
|
||||
.hidden-by-OTB ${BDFDB.dotCN.titlebar} + ${BDFDB.dotCNS.app + BDFDB.dotCN.splashbackground}:before {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
${BDFDB.dotCN.channelheadertopic},
|
||||
|
||||
body:not(.settingsTitlebarOTB-added) ${BDFDB.dotCN.channelheaderheaderbardrag} {
|
||||
-webkit-app-region: drag !important;
|
||||
}
|
||||
|
||||
${BDFDB.dotCN.channelheaderheaderbardrag} *,
|
||||
${BDFDB.dotCN.contextmenu} * {
|
||||
-webkit-app-region: no-drag;
|
||||
-webkit-app-region: no-drag !important;
|
||||
}
|
||||
|
||||
.settings-titlebar-OTB {
|
||||
|
||||
.settingsTitlebarOTB {
|
||||
position: relative;
|
||||
z-index: 1000;
|
||||
text-align: right;
|
||||
padding: 10px;
|
||||
-webkit-app-region: drag;
|
||||
}`;
|
||||
|
||||
this.dividerMarkup = `<div class="dividerOTB ${BDFDB.disCN.channelheaderdivider}"></div>`;
|
||||
|
||||
|
||||
this.dividerMarkup = `<div class="buttonOTB dividerOTB ${BDFDB.disCN.channelheaderdivider}"></div>`;
|
||||
|
||||
this.reloadButtonMarkup =
|
||||
`<svg class="reloadButtonOTB ${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCNS.channelheadericon + BDFDB.disCN.channelheadericonmargin}" xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path fill="currentColor" transform="translate(4,4)" d="M17.061,7.467V0l-2.507,2.507C13.013,0.96,10.885,0,8.528,0C3.813,0,0.005,3.819,0.005,8.533s3.808,8.533,8.523,8.533c3.973,0,7.301-2.72,8.245-6.4h-2.219c-0.88,2.485-3.237,4.267-6.027,4.267c-3.536,0-6.4-2.864-6.4-6.4s2.864-6.4,6.4-6.4c1.765,0,3.349,0.736,4.507,1.893l-3.44,3.44H17.061z"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB reloadButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path fill="currentColor" transform="translate(4,4)" d="M17.061,7.467V0l-2.507,2.507C13.013,0.96,10.885,0,8.528,0C3.813,0,0.005,3.819,0.005,8.533s3.808,8.533,8.523,8.533c3.973,0,7.301-2.72,8.245-6.4h-2.219c-0.88,2.485-3.237,4.267-6.027,4.267c-3.536,0-6.4-2.864-6.4-6.4s2.864-6.4,6.4-6.4c1.765,0,3.349,0.736,4.507,1.893l-3.44,3.44H17.061z"/>
|
||||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
this.minButtonMarkup =
|
||||
`<svg class="minButtonOTB ${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCNS.channelheadericon + BDFDB.disCN.channelheadericonmargin}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path stroke-width="2" stroke="currentColor" d="M6 18 l13 0"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
this.maxButtonIsMaxMarkup =
|
||||
`<svg class="maxButtonOTB ${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCNS.channelheadericon + BDFDB.disCN.channelheadericonmargin}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path stroke-width="2" stroke="currentColor" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
this.maxButtonIsMinMarkup =
|
||||
`<svg class="maxButtonOTB ${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCNS.channelheadericon + BDFDB.disCN.channelheadericonmargin}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path stroke-width="2" stroke="currentColor" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB minButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path stroke-width="2" stroke="currentColor" d="M6 18 l13 0"/>
|
||||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
this.maxButtonMarkup =
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB maxButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd"></g>
|
||||
</svg>
|
||||
</span>`;
|
||||
this.maxButtonInnerMin = `<path stroke-width="2" stroke="currentColor" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/>`;
|
||||
this.maxButtonInnerMax = `<path stroke-width="2" stroke="currentColor" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/>`;
|
||||
|
||||
this.closeButtonMarkup =
|
||||
`<svg class="closeButtonOTB ${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCNS.channelheadericon + BDFDB.disCN.channelheadericonmargin}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path stroke-width="2" stroke="currentColor" d="M6 6 l13 13 m0 -13 l-13 13"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
|
||||
`<span class="${BDFDB.disCN.channelheadericonmargin} buttonOTB closeButtonOTB">
|
||||
<svg class="${BDFDB.disCNS.channelheadericoninactive + BDFDB.disCN.channelheadericon}" xmlns="http://www.w3.org/2000/svg" width="26" height="26">
|
||||
<g fill="none" class="${BDFDB.disCN.channelheadericonforeground}" fill-rule="evenodd">
|
||||
<path stroke-width="2" stroke="currentColor" d="M6 6 l13 13 m0 -13 l-13 13"/>
|
||||
</g>
|
||||
</svg>
|
||||
</span>`;
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
addToSettings: {value:true, description:"Add a Title Bar to Settings Windows."},
|
||||
reloadButton: {value:false, description:"Add a Reload Button to the Title Bar."}
|
||||
displayNative: {value:!!document.querySelector(".platform-linux"), description:"Displays the native Title Bar."},
|
||||
addOldBar: {value:true, description:"Displays the Title Bar in the old fashion."},
|
||||
addToSettings: {value:true, description:"Adds a Title Bar to Settings Windows."},
|
||||
reloadButton: {value:false, description:"Adds a Reload Button to the Title Bar."}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
setImmediate(() => {
|
||||
if (node && node.tagName && node.getAttribute("layer-id") || node.querySelector(".ui-standard-sidebar-view")) {
|
||||
$(BDFDB.dotCN.channelheaderdivider).parent().has(BDFDB.dotCN.channelheadericoninactive).parent().css("-webkit-app-region", "initial");
|
||||
if (BDFDB.getData("addToSettings", this, "settings")) this.addSettingsTitleBar(node);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (change.removedNodes) {
|
||||
change.removedNodes.forEach((node) => {
|
||||
if (node && node.tagName && (node.getAttribute("layer-id") || node.querySelector(".ui-standard-sidebar-view"))) {
|
||||
this.removeTitleBar();
|
||||
this.addTitleBar();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.layers, {name:"settingsWindowObserver",instance:observer}, {childList:true});
|
||||
|
||||
$(window).on("resize." + this.name, (e) => {
|
||||
this.changeMaximizeButton();
|
||||
});
|
||||
|
||||
this.addTitleBar();
|
||||
|
||||
document.body.classList.add("titlebar-hidden-by-OTB");
|
||||
$(BDFDB.dotCN.titlebar).addClass("hidden-by-OTB");
|
||||
|
||||
var settingswindow = document.querySelector(BDFDB.dotCN.layers + "[layer-id]");
|
||||
if (settingswindow && BDFDB.getData("addToSettings", this, "settings")) {
|
||||
this.addSettingsTitleBar(settingswindow);
|
||||
}
|
||||
BDFDB.addEventListener(this, window, "resize", e => {this.changeMaximizeButtons();});
|
||||
|
||||
this.window = require("electron").remote.getCurrentWindow();
|
||||
|
||||
this.patchMainScreen(BDFDB.getData("displayNative", this, "settings"));
|
||||
|
||||
BDFDB.addClass([document.body,document.querySelector(BDFDB.dotCN.titlebar)], "hidden-by-OTB");
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -143,11 +130,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
this.removeTitleBar();
|
||||
|
||||
$(".titlebar-hidden-by-OTB, .hidden-by-OTB").removeClass("hidden-by-OTB");
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".headerbarOTB", ".settingsTitlebarOTB");
|
||||
|
||||
BDFDB.removeClasses("hidden-by-OTB", "settingsTitlebarOTB-added");
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -155,161 +142,130 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
setImmediate(() => {this.addTitleBar();});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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");
|
||||
processHeaderBar (instance, wrapper) {
|
||||
this.addTitleBar();
|
||||
}
|
||||
|
||||
|
||||
processStandardSidebarView (instance, wrapper, methodnames) {
|
||||
this.processAuthWrapper(instance, wrapper, methodnames);
|
||||
}
|
||||
|
||||
processAuthWrapper (instance, wrapper, methodnames) {
|
||||
if (methodnames.includes("componentDidMount")) {
|
||||
this.addSettingsTitleBar(wrapper);
|
||||
}
|
||||
else if (methodnames.includes("componentWillUnmount")) {
|
||||
BDFDB.removeEles(".settingsTitlebarOTB");
|
||||
BDFDB.removeClass(document.body, "settingsTitlebarOTB-added");
|
||||
this.addTitleBar();
|
||||
}
|
||||
}
|
||||
|
||||
addTitleBar () {
|
||||
this.removeTitleBar();
|
||||
BDFDB.removeEles(".headerbarOTB");
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
let activityfeed = document.querySelector(BDFDB.dotCN.activityfeed), container;
|
||||
if (activityfeed) {
|
||||
container = $(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.flex2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifyend + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.channelheaderheaderbar} headerbarOTB" style="flex: 0 0 auto;"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.flex2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}" style="flex: 0 0 auto;"></div></div>`);
|
||||
container.insertBefore(activityfeed.firstElementChild);
|
||||
container = container.children().first();
|
||||
if (BDFDB.getData("addOldBar", this, "settings")) {
|
||||
var headerbar = BDFDB.htmlToElement(`<span class="headerbarOTB ${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}"></span>`);
|
||||
this.createButtons(headerbar);
|
||||
let headerbaricon = document.querySelector(BDFDB.dotCNS.channelheaderheaderbardrag + BDFDB.dotCN.flex + " > " + BDFDB.dotCN.channelheadericonmargin);
|
||||
if (headerbaricon) headerbaricon.parentElement.appendChild(headerbar);
|
||||
this.changeMaximizeButtons();
|
||||
}
|
||||
container = container ? container : $(BDFDB.dotCN.channelheaderdivider).parent().has(BDFDB.dotCN.channelheadericoninactive);
|
||||
if (settings.reloadButton) {
|
||||
container
|
||||
.append(this.dividerMarkup)
|
||||
.append(this.reloadButtonMarkup)
|
||||
.on("click." + this.name, ".reloadButtonOTB", () => {
|
||||
this.doReload();
|
||||
})
|
||||
.on("mouseenter." + this.name, ".reloadButtonOTB", (e) => {
|
||||
this.createReloadToolTip(e);
|
||||
});
|
||||
}
|
||||
container
|
||||
.append(this.dividerMarkup)
|
||||
.append(this.minButtonMarkup)
|
||||
.append(require("electron").remote.getCurrentWindow().isMaximized() ? this.maxButtonIsMaxMarkup : this.maxButtonIsMinMarkup)
|
||||
.append(this.closeButtonMarkup)
|
||||
.on("click." + this.name, ".minButtonOTB", () => {
|
||||
this.doMinimize();
|
||||
})
|
||||
.on("click." + this.name, ".maxButtonOTB", () => {
|
||||
this.doMaximize();
|
||||
})
|
||||
.on("click." + this.name, ".closeButtonOTB", () => {
|
||||
this.doClose();
|
||||
})
|
||||
.parent().css("-webkit-app-region", "drag");
|
||||
}
|
||||
|
||||
|
||||
addSettingsTitleBar (settingspane) {
|
||||
if (!settingspane.querySelector(".dividerOTB, .reloadButtonOTB, .minButtonOTB, .maxButtonOTB, .closeButtonOTB")) {
|
||||
var settingsbar = $(`<div class="settings-titlebar-OTB headerbarOTB"></div>`);
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
if (settings.reloadButton) {
|
||||
settingsbar
|
||||
.append(this.reloadButtonMarkup)
|
||||
.on("click." + this.name, ".reloadButtonOTB", () => {
|
||||
this.doReload();
|
||||
})
|
||||
.on("mouseenter." + this.name, ".reloadButtonOTB", (e) => {
|
||||
this.createReloadToolTip(e);
|
||||
});
|
||||
}
|
||||
settingsbar
|
||||
.append(this.minButtonMarkup)
|
||||
.append(require("electron").remote.getCurrentWindow().isMaximized() ? this.maxButtonIsMaxMarkup : this.maxButtonIsMinMarkup)
|
||||
.append(this.closeButtonMarkup)
|
||||
.on("click." + this.name, ".minButtonOTB", () => {
|
||||
this.doMinimize();
|
||||
})
|
||||
.on("click." + this.name, ".maxButtonOTB", () => {
|
||||
this.doMaximize();
|
||||
})
|
||||
.on("click." + this.name, ".closeButtonOTB", () => {
|
||||
this.doClose();
|
||||
});
|
||||
|
||||
$(settingspane).append(settingsbar);
|
||||
BDFDB.removeEles(".settingsTitlebarOTB");
|
||||
if (BDFDB.getData("addToSettings", this, "settings")) {
|
||||
BDFDB.addClass(document.body, "settingsTitlebarOTB-added");
|
||||
var settingsbar = BDFDB.htmlToElement(`<div class="settingsTitlebarOTB"></div>`);
|
||||
this.createButtons(settingsbar);
|
||||
settingspane.parentElement.appendChild(settingsbar);
|
||||
this.changeMaximizeButtons();
|
||||
}
|
||||
}
|
||||
|
||||
doReload () {
|
||||
require("electron").remote.getCurrentWindow().reload();
|
||||
}
|
||||
|
||||
doMinimize () {
|
||||
require("electron").remote.getCurrentWindow().minimize();
|
||||
}
|
||||
|
||||
doMaximize () {
|
||||
if (require("electron").remote.getCurrentWindow().isMaximized()) {
|
||||
var newWidth = this.oldWidth ? this.oldWidth : Math.round(screen.availWidth - Math.round(screen.availWidth/10));
|
||||
var newHeight = this.oldHeight ? this.oldHeight : Math.round(screen.availHeight - Math.round(screen.availHeight/10));
|
||||
var newLeft = this.oldLeft ? this.oldLeft : Math.round((screen.availWidth - newWidth)/2);
|
||||
var newTop = this.oldTop ? this.oldTop : Math.round((screen.availHeight - newHeight)/2);
|
||||
|
||||
require("electron").remote.getCurrentWindow().setPosition(newLeft, newTop);
|
||||
require("electron").remote.getCurrentWindow().setSize(newWidth, newHeight);
|
||||
|
||||
createButtons (bar) {
|
||||
var settings = BDFDB.containsClass(bar, "settingsTitlebarOTB");
|
||||
if (BDFDB.getData("reloadButton", this, "settings")) {
|
||||
if (!settings) bar.appendChild(BDFDB.htmlToElement(this.dividerMarkup));
|
||||
var reloadbutton = BDFDB.htmlToElement(this.reloadButtonMarkup);
|
||||
bar.appendChild(reloadbutton);
|
||||
var reloadbuttonicon = reloadbutton.querySelector(BDFDB.dotCN.channelheadericon);
|
||||
reloadbuttonicon.addEventListener("click", () => {this.window.reload();});
|
||||
reloadbuttonicon.addEventListener("mouseenter", e => {
|
||||
BDFDB.createTooltip("Reload", reloadbuttonicon, {type:"bottom",selector:"reload-button-tooltip"});
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.oldLeft = window.screenX;
|
||||
this.oldTop = window.screenY;
|
||||
this.oldWidth = window.outerWidth;
|
||||
this.oldHeight = window.outerHeight;
|
||||
require("electron").remote.getCurrentWindow().maximize();
|
||||
}
|
||||
}
|
||||
|
||||
doClose () {
|
||||
require("electron").remote.getCurrentWindow().close();
|
||||
}
|
||||
|
||||
changeMaximizeButton () {
|
||||
var maxButtonHTML = require("electron").remote.getCurrentWindow().isMaximized() ? this.maxButtonIsMaxMarkup : this.maxButtonIsMinMarkup;
|
||||
document.querySelectorAll(".maxButtonOTB").forEach(maxButton => {
|
||||
maxButton.outerHTML = maxButtonHTML;
|
||||
if (!settings) bar.appendChild(BDFDB.htmlToElement(this.dividerMarkup));
|
||||
var minbutton = BDFDB.htmlToElement(this.minButtonMarkup);
|
||||
bar.appendChild(minbutton);
|
||||
minbutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {this.window.minimize();});
|
||||
var maxbutton = BDFDB.htmlToElement(this.maxButtonMarkup);
|
||||
bar.appendChild(maxbutton);
|
||||
maxbutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {
|
||||
if (this.window.isMaximized()) this.window.unmaximize();
|
||||
else this.window.maximize();
|
||||
this.changeMaximizeButtons();
|
||||
});
|
||||
var closebutton = BDFDB.htmlToElement(this.closeButtonMarkup);
|
||||
bar.appendChild(closebutton);
|
||||
closebutton.querySelector(BDFDB.dotCN.channelheadericon).addEventListener("click", () => {this.window.close();});
|
||||
}
|
||||
|
||||
removeTitleBar () {
|
||||
$(".headerbarOTB").remove();
|
||||
|
||||
$(BDFDB.dotCN.channelheaderdivider).parent().has(BDFDB.dotCN.channelheadericoninactive)
|
||||
.off("click." + this.name)
|
||||
.off("mouseenter." + this.name)
|
||||
.find(".dividerOTB, .reloadButtonOTB, .minButtonOTB, .maxButtonOTB, .closeButtonOTB").remove();
|
||||
|
||||
$(BDFDB.dotCN.channelheaderdivider).parent().has(BDFDB.dotCN.channelheadericoninactive).parent().css("-webkit-app-region", "initial");
|
||||
|
||||
changeMaximizeButtons () {
|
||||
var innerHTML = this.window.isMaximized() ? this.maxButtonInnerMax : this.maxButtonInnerMin;
|
||||
document.querySelectorAll(".maxButtonOTB g").forEach(g => {g.innerHTML = innerHTML;});
|
||||
}
|
||||
|
||||
createReloadToolTip (e) {
|
||||
BDFDB.createTooltip("Reload", e.currentTarget, {type:"bottom",selector:"reload-button-tooltip"});
|
||||
|
||||
patchMainScreen (enable) {
|
||||
if (BdApi.getWindowPreference("frame") != enable) {
|
||||
BdApi.setWindowPreference("frame", enable);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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${key == "displayNative" ? " nativetitlebar-switch" : ""}"${settings[key] ? " checked" : ""}></div></div>`;
|
||||
}
|
||||
settingshtml += `</div>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
this.addTitleBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,102 +1,151 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.pinDMEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitem} pindm-item">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_pindm_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
this.patchModules = {
|
||||
"Guilds":"componentDidMount",
|
||||
"DirectMessage":["componentDidMount","componentDidUpdate","componentWillUnmount"],
|
||||
"LazyScroller":"render"
|
||||
};
|
||||
|
||||
this.dmContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} pindms-item ${BDFDB.disCN.contextmenuitemsubmenu}">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_pindm_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.pinDMsHeaderMarkup =
|
||||
`<header class="pinneddms-header">REPLACE_header_pinneddms_text</header>`;
|
||||
|
||||
this.pinnedDMMarkup =
|
||||
`<div class="${BDFDB.disCNS.dmchannel + BDFDB.disCN.dmchannelprivate} pinned" style="height: 42px; opacity: 1;">
|
||||
<a>
|
||||
<div class="${BDFDB.disCNS.avatarwrapper + BDFDB.disCNS.avatarsmall + BDFDB.disCNS.forcedarktheme + BDFDB.disCN.avatarsmallold}">
|
||||
<div class="${BDFDB.disCN.avatarsmallold} stop-animation"></div>
|
||||
<div class="${BDFDB.disCNS.status + BDFDB.disCNS.statusold + BDFDB.disCN.avatarsmall}"></div>
|
||||
</div>
|
||||
<div class="${BDFDB.disCN.dmchannelname}">
|
||||
<label style="cursor: pointer;"></label>
|
||||
<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.dmchannelactivity}" style="flex: 1 1 auto;">
|
||||
<div class="${BDFDB.disCN.dmchannelactivitytext}"></div>
|
||||
</div>
|
||||
|
||||
this.dmContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} pindms-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} pindm-channel-item">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_pinchannel_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
<button class="${BDFDB.disCN.dmchannelclose}"></button>
|
||||
</a>
|
||||
<div class="${BDFDB.disCN.contextmenuitem} unpindm-channel-item ${BDFDB.disCN.contextmenuitemdanger}">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_unpinchannel_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
<div class="${BDFDB.disCN.contextmenuitem} pindm-guild-item">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_pinguild_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
<div class="${BDFDB.disCN.contextmenuitem} unpindm-guild-item ${BDFDB.disCN.contextmenuitemdanger}">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_unpinguild_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.richActivityMarkup =
|
||||
`<svg name="RichActivity" class="${BDFDB.disCN.dmchannelactivityicon}" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path class="${BDFDB.disCN.dmchannelactivityiconforeground}" fill="currentColor" d="M6,7 L2,7 L2,6 L6,6 L6,7 Z M8,5 L2,5 L2,4 L8,4 L8,5 Z M8,3 L2,3 L2,2 L8,2 L8,3 Z M8.88888889,0 L1.11111111,0 C0.494444444,0 0,0.494444444 0,1.11111111 L0,8.88888889 C0,9.50253861 0.497461389,10 1.11111111,10 L8.88888889,10 C9.50253861,10 10,9.50253861 10,8.88888889 L10,1.11111111 C10,0.494444444 9.5,0 8.88888889,0 Z" transform="translate(3 3)"></path>
|
||||
</svg>`;
|
||||
|
||||
this.dmPinContextMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} pinneddm-contextmenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} pindm-guild-item">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_pinguild_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.dmUnpinContextMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} pinneddm-contextmenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} unpindm-guild-item ${BDFDB.disCN.contextmenuitemdanger}">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_unpinguild_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.recentDMMarkup =
|
||||
`<div class="${BDFDB.disCN.guild} pinned" style="transform: translateX(0px);">
|
||||
<div class="${BDFDB.disCN.guildinner}" draggable="false" style="border-radius: 25px;">
|
||||
<div class="${BDFDB.disCNS.avatarwrapper + BDFDB.disCNS.avatarsmall + BDFDB.disCNS.guildavatar + BDFDB.disCN.avatarsizesmall}">
|
||||
<a draggable="false" class="${BDFDB.disCNS.guildavatarinner + BDFDB.disCNS.avatarinner + BDFDB.disCN.avatarstopanimation}"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.badge + BDFDB.disCN.badgewrapper}" style="display: none !important;">0</div>
|
||||
</div>`;
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.guild}.pinned:after {
|
||||
background-position: 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 16px;
|
||||
border-radius: 12px;
|
||||
content: " ";
|
||||
height: 24px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: -6px;
|
||||
top: -6px;
|
||||
width: 24px;
|
||||
background-image: url('data:image/svg+xml; utf8, <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-90 -80 700 700" xml:space="preserve"><g fill="#FFF"><path d="M291.31,402.761L109.241,220.693C79.073,190.525,30.166,190.526,0,220.692l291.31,291.31C321.474,481.835,321.476,432.927,291.31,402.761z"/><polygon points="273.104,111.449 154.758,211.589 300.412,357.242 400.55,238.898"/><path d="M500.688,175.174L336.827,11.313c-15.085-15.085-39.539-15.083-54.621,0c-15.082,15.082-15.082,39.538,0,54.62 l163.861,163.861c15.083,15.085,39.539,15.085,54.621,0.001C515.773,214.712,515.773,190.257,500.688,175.174z"/><polygon points="91.032,366.346 0,512 145.655,420.967"/></g></svg>');
|
||||
}
|
||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.guild}.pinned:after {
|
||||
background-color: #202225;
|
||||
}
|
||||
${BDFDB.dotCNS.themedark + BDFDB.dotCN.guild}.pinned:after {
|
||||
background-color: #202225;
|
||||
}`;
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.ActivityStore = BDFDB.WebModules.findByProperties("getStatuses", "getActivities");
|
||||
this.ChannelStore = BDFDB.WebModules.findByProperties("getDMFromUserId");
|
||||
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels", "getChannel");
|
||||
this.PrivateChannelUtils = BDFDB.WebModules.findByProperties("ensurePrivateChannel");
|
||||
this.ChannelSwitchUtils = BDFDB.WebModules.findByProperties("selectPrivateChannel");
|
||||
this.UserContextMenuUtils = BDFDB.WebModules.findByProperties("openUserContextMenu");
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.nodeType == 1 && node.className.includes(BDFDB.disCN.contextmenu)) {
|
||||
this.onContextMenu(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.UnreadUtils = BDFDB.WebModules.findByProperties("getUnreadCount");
|
||||
this.DiscordConstants = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes", "StatusTypes");
|
||||
this.Animations = BDFDB.WebModules.findByProperties("spring");
|
||||
|
||||
BDFDB.addEventListener(this, document, "click", BDFDB.dotCNS.dmchannels + BDFDB.dotCN.dmchannel, e => {
|
||||
let instance = BDFDB.getReactInstance(e.currentTarget);
|
||||
if (BDFDB.getReactValue(instance, "return.return.return.memoizedProps.ispin")) {
|
||||
let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller);
|
||||
if (dmsscroller) {
|
||||
this.oldScrollerPos = dmsscroller.scrollTop;
|
||||
setTimeout(() => {this.oldScrollerPos = null;},1000);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"dmContextObserver",instance:observer}, {childList: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.classList && node.classList.contains("btn-friends")) {
|
||||
$(BDFDB.dotCN.dmchannel + BDFDB.dotCN.dmchannelprivate + ".pinned, header.pinneddms-header").remove();
|
||||
this.addAllPinnedDMs();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
BDFDB.addEventListener(this, document, "click", BDFDB.dotCNS.dmchannels + BDFDB.dotCNS.dmchannel + BDFDB.dotCN.dmchannelclose, e => {
|
||||
let instance = BDFDB.getReactInstance(e.currentTarget);
|
||||
if (BDFDB.getReactValue(instance, "return.return.return.return.return.memoizedProps.ispin")) {
|
||||
e.originalEvent.stopPropagation();
|
||||
e.originalEvent.preventDefault();
|
||||
this.removePinnedDM(BDFDB.getReactValue(instance, "return.return.return.return.return.memoizedProps.channel.id"));
|
||||
}
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller, {name:"friendButtonObserver",instance:observer}, {childList: true});
|
||||
|
||||
setTimeout(() => {this.onSwitch();},1000);
|
||||
|
||||
this.forceAdding = true;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
delete this.forceAdding;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -107,11 +156,32 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
$(BDFDB.dotCN.dmchannel + BDFDB.dotCN.dmchannelprivate + ".pinned, header.pinneddms-header").remove();
|
||||
|
||||
clearInterval(this.statusInterval);
|
||||
|
||||
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;
|
||||
let amount = 0;
|
||||
let insertpoint = null;
|
||||
for (let i in dms) {
|
||||
let ele = dms[i];
|
||||
if (ele && ele.pinned) {
|
||||
delete ele.pinned;
|
||||
if (ele.props.ispin) {
|
||||
if (ele.type == "header") insertpoint = i;
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dms.splice(insertpoint, amount);
|
||||
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
||||
}
|
||||
|
||||
for (let info of BDFDB.readDmList()) {
|
||||
this.unhideNativeDM(info.id);
|
||||
if (info.div) info.div.removeEventListener("contextmenu", info.div.PinDMsContextMenuListener);
|
||||
}
|
||||
BDFDB.removeEles(BDFDB.dotCNS.dms + BDFDB.dotCN.guild + ".pinned");
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -119,278 +189,547 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (!document.querySelector(BDFDB.dotCNS.guildactive + BDFDB.dotCN.friendsicon) || document.querySelector(BDFDB.dotCN.dmchannel + BDFDB.dotCN.dmchannelprivate + ".pinned")) return;
|
||||
|
||||
this.addAllPinnedDMs();
|
||||
|
||||
BDFDB.addObserver(this, BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller, {name:"friendButtonObserver"}, {childList: true});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.pinDMsHeaderMarkup = this.pinDMsHeaderMarkup.replace("REPLACE_header_pinneddms_text", this.labels.header_pinneddms_text);
|
||||
|
||||
this.pinDMEntryMarkup = this.pinDMEntryMarkup.replace("REPLACE_context_pindm_text", this.labels.context_pindm_text);
|
||||
this.dmContextEntryMarkup = this.dmContextEntryMarkup.replace("REPLACE_context_pindm_text", this.labels.context_pindm_text);
|
||||
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_pinchannel_text", this.labels.context_pinchannel_text);
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_unpinchannel_text", this.labels.context_unpinchannel_text);
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_pinguild_text", this.labels.context_pinguild_text);
|
||||
this.dmContextSubMenuMarkup = this.dmContextSubMenuMarkup.replace("REPLACE_context_unpinguild_text", this.labels.context_unpinguild_text);
|
||||
|
||||
this.dmPinContextMarkup = this.dmPinContextMarkup.replace("REPLACE_context_pinguild_text", this.labels.context_pinguild_text);
|
||||
|
||||
this.dmUnpinContextMarkup = this.dmUnpinContextMarkup.replace("REPLACE_context_unpinguild_text", this.labels.context_unpinguild_text);
|
||||
}
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!document.querySelector(BDFDB.dotCNS.guildactive + BDFDB.dotCN.friendsicon) || !context || !context.tagName || !context.parentElement || context.querySelector(".pindm-item")) return;
|
||||
var info = BDFDB.getKeyInformation({"node":context, "key":"user"}), ele = null;
|
||||
if (info && BDFDB.getKeyInformation({"node":context, "key":"handleClose"})) {
|
||||
ele = context.querySelectorAll(BDFDB.dotCN.contextmenuitem)[3];
|
||||
}
|
||||
else {
|
||||
info = BDFDB.getKeyInformation({"node":context, "key":"channel"});
|
||||
if (info && BDFDB.getKeyInformation({"node":context, "key":"handleChangeIcon"})) {
|
||||
ele = context.querySelectorAll(BDFDB.dotCN.contextmenuitem)[1];
|
||||
|
||||
onUserContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.user && !menu.querySelector(".pindms-item")) {
|
||||
let closeentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleClose"]}));
|
||||
if (closeentry) {
|
||||
let id = this.ChannelUtils.getDMFromUserId(instance.props.user.id);
|
||||
if (id) this.appendItem(instance, id, closeentry);
|
||||
else this.PrivateChannelUtils.ensurePrivateChannel(BDFDB.myData.id, instance.props.user.id).then(id => {this.appendItem(instance, id, closeentry);});
|
||||
}
|
||||
}
|
||||
if (ele) {
|
||||
$(this.pinDMEntryMarkup).insertBefore(ele)
|
||||
.on("click", (e) => {
|
||||
$(context).hide();
|
||||
var pinnedDMs = BDFDB.loadAllData(this, "pinnedDMs");
|
||||
if (typeof pinnedDMs[info.id] == "undefined") {
|
||||
var pos = Object.keys(pinnedDMs).length;
|
||||
pinnedDMs[info.id] = pos;
|
||||
BDFDB.saveAllData(pinnedDMs, this, "pinnedDMs")
|
||||
this.addPinnedDM(info.id, pos);
|
||||
}
|
||||
|
||||
onGroupDMContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.channelId && !menu.querySelector(".pindms-item")) {
|
||||
let changeentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleChangeIcon"]}));
|
||||
if (changeentry) {
|
||||
this.appendItem(instance, instance.props.channelId, changeentry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appendItem (instance, id, target) {
|
||||
let dmContextEntry = BDFDB.htmlToElement(this.dmContextEntryMarkup);
|
||||
target.parentElement.insertBefore(dmContextEntry, target);
|
||||
let pindmsitem = dmContextEntry.querySelector(".pindms-item");
|
||||
pindmsitem.addEventListener("mouseenter", () => {
|
||||
let dmContextSubMenu = BDFDB.htmlToElement(this.dmContextSubMenuMarkup);
|
||||
let pinchannelitem = dmContextSubMenu.querySelector(".pindm-channel-item");
|
||||
let unpinchannelitem = dmContextSubMenu.querySelector(".unpindm-channel-item");
|
||||
let pinguilditem = dmContextSubMenu.querySelector(".pindm-guild-item");
|
||||
let unpinguilditem = dmContextSubMenu.querySelector(".unpindm-guild-item");
|
||||
let pinnedDMs = BDFDB.loadAllData(this, "pinnedDMs");
|
||||
if (pinnedDMs[id] == undefined) {
|
||||
BDFDB.removeEles(unpinchannelitem);
|
||||
pinchannelitem.addEventListener("click", () => {
|
||||
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
||||
let dmsscrollerinstance = BDFDB.getReactInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
|
||||
if (dmsscrollerinstance) {
|
||||
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
|
||||
let insertpoint = this.getInsertPoint(dms);
|
||||
this.addPinnedDM(id, dms, insertpoint);
|
||||
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
||||
}
|
||||
pinnedDMs[id] = Object.keys(pinnedDMs).length;
|
||||
BDFDB.saveAllData(pinnedDMs, this, "pinnedDMs");
|
||||
});
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
}
|
||||
|
||||
addAllPinnedDMs () {
|
||||
var pinnedDMs = BDFDB.loadAllData(this, "pinnedDMs");
|
||||
var sortedDMs = [];
|
||||
for (let id in pinnedDMs) sortedDMs[pinnedDMs[id]] = id;
|
||||
for (let pos in sortedDMs.reverse()) {
|
||||
this.addPinnedDM(sortedDMs[pos], pos);
|
||||
}
|
||||
}
|
||||
|
||||
addPinnedDM (id, pos) {
|
||||
if (!document.querySelector(BDFDB.dotCN.dmchannel + BDFDB.dotCN.friendsbutton + " + header.pinneddms-header")) {
|
||||
$(this.pinDMsHeaderMarkup).insertBefore(BDFDB.dotCN.dmchannel + BDFDB.dotCN.friendsbutton + " + header");
|
||||
this.startUpdateInterval();
|
||||
}
|
||||
let user = this.UserStore.getUser(id);
|
||||
let channel = this.ChannelStore.getChannel(id);
|
||||
if (user || channel) {
|
||||
let DMid = user ? this.ChannelStore.getDMFromUserId(user.id) : channel.id;
|
||||
let pinnedDM = $(this.pinnedDMMarkup);
|
||||
pinnedDM.attr("user-id", user ? user.id : null).attr("channel-id", DMid).insertAfter(BDFDB.dotCN.dmchannel + BDFDB.dotCN.friendsbutton + " + header.pinneddms-header")
|
||||
.on("contextmenu." + this.name, (e) => {
|
||||
if (user && DMid) this.UserContextMenuUtils.openUserContextMenu(e, user, this.ChannelStore.getChannel(DMid));
|
||||
else {
|
||||
var channelObj = BDFDB.getDivOfChannel(channel.id);
|
||||
if (channelObj && channelObj.div) BDFDB.getKeyInformation({"node":channelObj.div,"key":"onContextMenu"})(e);
|
||||
else BDFDB.showToast("Could not open ContextMenu, make sure the DM exists, Group DMs habe to be loaded in the list.", {type:"error"});
|
||||
}
|
||||
})
|
||||
.on("click." + this.name, (e) => {
|
||||
if (e.target.classList && e.target.classList.contains(BDFDB.disCN.dmchannelclose)) return;
|
||||
if (DMid) this.ChannelSwitchUtils.selectPrivateChannel(DMid);
|
||||
else BDFDB.showToast("Could not open DM, make sure it exists.", {type:"error"});
|
||||
})
|
||||
.on("click." + this.name, BDFDB.dotCN.dmchannelclose, () => {
|
||||
pinnedDM.remove();
|
||||
BDFDB.removeData(user ? user.id : DMid, this, "pinnedDMs");
|
||||
this.updatePinnedDMPositions();
|
||||
});
|
||||
|
||||
this.setPinnedDM(pinnedDM[0]);
|
||||
}
|
||||
}
|
||||
|
||||
setPinnedDM (pinnedDM) {
|
||||
if (pinnedDM && pinnedDM.parentElement) {
|
||||
let id = pinnedDM.getAttribute("user-id");
|
||||
let user = this.UserStore.getUser(id);
|
||||
if (user) {
|
||||
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
|
||||
let activity = this.ActivityStore.getActivity(user.id);
|
||||
pinnedDM.querySelector(BDFDB.dotCN.avatarsmallold + ":not(" + BDFDB.dotCN.avatarwrapper + ")").style.backgroundImage = `url(${data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(user.id))})`;
|
||||
pinnedDM.querySelector(BDFDB.dotCN.status).classList.add(BDFDB.disCN[`status${BDFDB.getUserStatus(user.id)}`]);
|
||||
pinnedDM.querySelector(BDFDB.dotCN.dmchannelname + " > label").textContent = data.name ? data.name : user.username;
|
||||
pinnedDM.querySelector(BDFDB.dotCN.dmchannelname).style.color = data.color1 ? BDFDB.color2RGB(data.color1) : "";
|
||||
pinnedDM.querySelector(BDFDB.dotCN.dmchannelname).style.background = data.color2 ? BDFDB.color2RGB(data.color2) : "";
|
||||
pinnedDM.querySelector(BDFDB.dotCN.dmchannelactivitytext).innerHTML = activity ? this.getActivityString(activity.type, activity.name) : "";
|
||||
if (activity && activity.application_id && activity.session_id) {
|
||||
if (!pinnedDM.querySelector(BDFDB.dotCN.dmchannelactivityicon)) $(BDFDB.dotCN.dmchannelactivity, pinnedDM).append(this.richActivityMarkup);
|
||||
}
|
||||
else $(BDFDB.dotCN.dmchannelactivityicon, pinnedDM).remove();
|
||||
}
|
||||
else {
|
||||
id = pinnedDM.getAttribute("channel-id")
|
||||
let channel = this.ChannelStore.getChannel(id);
|
||||
if (channel) {
|
||||
pinnedDM.querySelector(BDFDB.dotCN.avatarsmallold + ":not(" + BDFDB.dotCN.avatarwrapper + ")").style.backgroundImage = `url(${BDFDB.getChannelAvatar(channel.id)})`;
|
||||
var channelname = channel.name;
|
||||
if (!channelname && channel.recipients.length > 0) {
|
||||
for (let dmmemberID of channel.recipients) {
|
||||
channelname = channelname ? channelname + ", " : channelname;
|
||||
channelname = channelname + this.UserStore.getUser(dmmemberID).username;
|
||||
}
|
||||
BDFDB.removeEles(pinchannelitem);
|
||||
unpinchannelitem.addEventListener("click", () => {
|
||||
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
||||
this.removePinnedDM(id);
|
||||
});
|
||||
}
|
||||
let pinnedRecents = BDFDB.loadAllData(this, "pinnedRecents");
|
||||
if (pinnedRecents[id] == undefined) {
|
||||
BDFDB.removeEles(unpinguilditem);
|
||||
pinguilditem.addEventListener("click", () => {
|
||||
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
||||
this.addPinnedRecent(id);
|
||||
pinnedRecents[id] = Object.keys(pinnedRecents).length;
|
||||
BDFDB.saveAllData(pinnedRecents, this, "pinnedRecents");
|
||||
});
|
||||
}
|
||||
else {
|
||||
BDFDB.removeEles(pinguilditem);
|
||||
unpinguilditem.addEventListener("click", () => {
|
||||
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
||||
BDFDB.removeEles(document.querySelector(`${BDFDB.dotCNS.dms + BDFDB.dotCN.guild}.pinned[channelid="${id}"]`));
|
||||
this.unhideNativeDM(id);
|
||||
delete pinnedRecents[id];
|
||||
BDFDB.saveAllData(pinnedRecents, this, "pinnedRecents");
|
||||
});
|
||||
}
|
||||
BDFDB.appendSubMenu(pindmsitem, dmContextSubMenu);
|
||||
});
|
||||
}
|
||||
|
||||
processGuilds (instance, wrapper) {
|
||||
let dms = wrapper.querySelector(BDFDB.dotCN.dms);
|
||||
if (dms) for (let id of this.sortAndUpdate("pinnedRecents")) this.addPinnedRecent(id);
|
||||
}
|
||||
|
||||
processDirectMessage (instance, wrapper, methodnames) {
|
||||
if (instance.props && instance.props.channel) {
|
||||
if (methodnames.includes("componentDidMount")) {
|
||||
wrapper.removeEventListener("contextmenu", wrapper.PinDMsContextMenuListener);
|
||||
wrapper.PinDMsContextMenuListener = e => {
|
||||
let freshPinnedRecents = BDFDB.loadAllData(this, "pinnedRecents");
|
||||
if (freshPinnedRecents[instance.props.channel.id] == undefined) {
|
||||
let dmContext = BDFDB.htmlToElement(this.dmPinContextMarkup);
|
||||
dmContext.querySelector(".pindm-guild-item").addEventListener("click", () => {
|
||||
BDFDB.removeEles(dmContext);
|
||||
this.addPinnedRecent(instance.props.channel.id);
|
||||
freshPinnedRecents[instance.props.channel.id] = Object.keys(freshPinnedRecents).length;
|
||||
BDFDB.saveAllData(freshPinnedRecents, this, "pinnedRecents");
|
||||
});
|
||||
BDFDB.appendContextMenu(dmContext, e);
|
||||
}
|
||||
pinnedDM.querySelector(BDFDB.dotCN.dmchannelname + " > label").textContent = channelname ? channelname : BDFDB.LanguageStrings.UNNAMED;
|
||||
pinnedDM.querySelectorAll(BDFDB.dotCNC.status + BDFDB.dotCN.dmchannelactivitytext).forEach(ele => {ele.remove();});
|
||||
pinnedDM.querySelector(BDFDB.dotCN.dmchannelactivity).innerHTML = channel.recipients.length+1 + " " + (channel.recipients.length+1 == 1 ? BDFDB.LanguageStrings.MEMBER : BDFDB.LanguageStrings.MEMBERS);
|
||||
}
|
||||
};
|
||||
wrapper.addEventListener("contextmenu", wrapper.PinDMsContextMenuListener);
|
||||
}
|
||||
let pinnedRecents = BDFDB.loadAllData(this, "pinnedRecents");
|
||||
if (pinnedRecents[instance.props.channel.id] != undefined) {
|
||||
if (methodnames.includes("componentDidMount")) this.hideNativeDM(instance.props.channel.id);
|
||||
this.updateUnreadCount(instance.props.channel.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startUpdateInterval () {
|
||||
this.statusInterval = setInterval(() => {
|
||||
for (let pinnedDM of document.querySelectorAll(BDFDB.dotCN.dmchannel + BDFDB.dotCN.dmchannelprivate + ".pinned")) this.setPinnedDM(pinnedDM);
|
||||
if (!document.querySelector(BDFDB.dotCN.dmchannel + BDFDB.dotCN.friendsbutton + " + header.pinneddms-header")) clearInterval(this.statusInterval);
|
||||
},10000);
|
||||
}
|
||||
|
||||
getActivityString (type, name) {
|
||||
let stringname = "";
|
||||
switch (type) {
|
||||
case 0:
|
||||
stringname = "PLAYING_GAME";
|
||||
break;
|
||||
case 1:
|
||||
stringname = "STREAMING";
|
||||
break;
|
||||
case 2:
|
||||
stringname = "LISTENING_TO";
|
||||
break;
|
||||
case 3:
|
||||
stringname = "WATCHING";
|
||||
break;
|
||||
|
||||
processLazyScroller (instance, wrapper) {
|
||||
let privateChannelIds = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.privateChannelIds");
|
||||
if (privateChannelIds) {
|
||||
if (this.forceAdding || !instance.props.PinDMsPatched) {
|
||||
instance.props.PinDMsPatched = true;
|
||||
let dms = instance.props.children;
|
||||
let sortedDMs = this.sortAndUpdate("pinnedDMs");
|
||||
if (sortedDMs.length > 0) {
|
||||
let insertpoint = this.getInsertPoint(dms);
|
||||
for (let pos in sortedDMs) this.addPinnedDM(sortedDMs[pos], dms, insertpoint);
|
||||
}
|
||||
this.forceUpdateScroller(instance.getScrollerNode());
|
||||
}
|
||||
if (this.oldScrollerPos != null) {
|
||||
instance.getScrollerNode().scrollTop = this.oldScrollerPos;
|
||||
}
|
||||
}
|
||||
|
||||
let string = BDFDB.LanguageStrings[stringname] || "";
|
||||
|
||||
return string.replace("**!!{name}!!**", `<strong>${name}</strong>`).replace("**!!{game}!!**", `<strong>${name}</strong>`);
|
||||
}
|
||||
|
||||
updatePinnedDMPositions () {
|
||||
let pinnedDMs = BDFDB.loadAllData(this, "pinnedDMs");
|
||||
let pinnedDMEles = document.querySelectorAll(BDFDB.dotCN.dmchannel + BDFDB.dotCN.dmchannelprivate + ".pinned");
|
||||
for (let i = 0; i < pinnedDMEles.length; i++) {
|
||||
pinnedDMs[pinnedDMEles[i].id] = i;
|
||||
|
||||
getInsertPoint (dms) {
|
||||
let insertpoint = null;
|
||||
for (let i in dms) {
|
||||
let ele = dms[i];
|
||||
if (ele && ele.type == "header") {
|
||||
insertpoint = parseInt(i);
|
||||
if (!ele.pinned && !ele.props.ispin) {
|
||||
ele.pinned = true;
|
||||
let headerpin = Object.assign({},ele);
|
||||
headerpin.key = "pin" + headerpin.key;
|
||||
headerpin.props = {children:this.labels.header_pinneddms_text,ispin:true};
|
||||
dms.splice(insertpoint, 0, headerpin);
|
||||
}
|
||||
insertpoint++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pinnedDMEles.length == 0) $(BDFDB.dotCN.dmchannel + BDFDB.dotCN.friendsbutton + " + header.pinneddms-header").remove();
|
||||
BDFDB.saveAllData(pinnedDMs, this, "pinnedDMs")
|
||||
return insertpoint;
|
||||
}
|
||||
|
||||
|
||||
addPinnedDM (id, dms, insertpoint) {
|
||||
for (let ele of dms) if (ele && !ele.pinned && id == ele.key) {
|
||||
ele.pinned = true;
|
||||
let dmpin = Object.assign({ispin:true},ele);
|
||||
dmpin.key = "pin" + ele.key;
|
||||
dmpin.props = {channel:ele.props.channel,selected:ele.props.selected,ispin:true};
|
||||
dms.splice(insertpoint, 0, dmpin);
|
||||
}
|
||||
}
|
||||
|
||||
removePinnedDM (id) {
|
||||
if (!id) return;
|
||||
BDFDB.removeData(id, this, "pinnedDMs");
|
||||
let dmsscrollerinstance = BDFDB.getReactInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
|
||||
if (dmsscrollerinstance) {
|
||||
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
|
||||
let existingDMs = this.sortAndUpdate("pinnedDMs");
|
||||
let removepoint = null;
|
||||
for (let i in dms) {
|
||||
let ele = dms[i];
|
||||
if (ele && ele.pinned && (id == ele.key || ("pin" + id) == ele.key)) {
|
||||
delete ele.pinned;
|
||||
if (ele.props.ispin) removepoint = parseInt(i);
|
||||
}
|
||||
}
|
||||
if (removepoint) {
|
||||
let offset = existingDMs.length ? 0 : 1;
|
||||
if (offset) delete dms[removepoint + offset].pinned;
|
||||
dms.splice(removepoint-offset,1+offset);
|
||||
}
|
||||
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
||||
}
|
||||
}
|
||||
|
||||
sortAndUpdate (type) {
|
||||
let pinnedDMs = BDFDB.loadAllData(this, type);
|
||||
delete pinnedDMs[""];
|
||||
let sortedDMs = [], existingDMs = [], sortDM = (id) => {
|
||||
if (typeof sortedDMs[pinnedDMs[id]] == "undefined") sortedDMs[pinnedDMs[id]] = id;
|
||||
else sortDM(sortedDMs, pinnedDMs[id]+1, id);
|
||||
};
|
||||
for (let id in pinnedDMs) sortDM(id);
|
||||
sortedDMs = sortedDMs.filter(n => n);
|
||||
for (let pos in sortedDMs) {
|
||||
pinnedDMs[sortedDMs[pos]] = parseInt(pos);
|
||||
if (this.ChannelUtils.getChannel(sortedDMs[pos])) existingDMs.push(sortedDMs[pos]);
|
||||
}
|
||||
BDFDB.saveAllData(pinnedDMs, this, type);
|
||||
return existingDMs;
|
||||
}
|
||||
|
||||
forceUpdateScroller (scroller) {
|
||||
if (this.updatingScroller) return;
|
||||
this.updatingScroller = true;
|
||||
var stateNode = BDFDB.getReactValue(scroller, "return.return.return.stateNode");
|
||||
if (stateNode) stateNode.updater.enqueueForceUpdate(stateNode);
|
||||
setTimeout(() => {delete this.updatingScroller;},1000);
|
||||
}
|
||||
|
||||
addPinnedRecent (id) {
|
||||
let dms = document.querySelector(BDFDB.dotCN.dms);
|
||||
if (dms && !dms.querySelector(`${BDFDB.dotCN.guild}.pinned[channelid="${id}"]`)) {
|
||||
let info = this.ChannelUtils.getChannel(id);
|
||||
if (info) {
|
||||
let dmdiv = BDFDB.htmlToElement(this.recentDMMarkup);
|
||||
let user = info.type == 1 ? this.UserUtils.getUser(info.recipients[0]) : null;
|
||||
dmdiv.setAttribute("channelid", id);
|
||||
dms.insertBefore(dmdiv, dms.firstElementChild);
|
||||
let avatar = dmdiv.querySelector(BDFDB.dotCN.avatarinner);
|
||||
let dmname = info.name;
|
||||
if (!dmname && info.recipients.length > 0) {
|
||||
for (let dmuser_id of info.recipients) {
|
||||
dmname = dmname ? dmname + ", " : dmname;
|
||||
dmname = dmname + this.UserUtils.getUser(dmuser_id).username;
|
||||
}
|
||||
}
|
||||
let EditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? bdplugins.EditUsers.plugin.getUserData(user.id, dmdiv) : {};
|
||||
if (!EditUsersData.removeIcon) avatar.style.setProperty("background-image", `url(${EditUsersData.url || BDFDB.getChannelIcon(id)})`);
|
||||
avatar.setAttribute("channel", dmname);
|
||||
if (user) avatar.setAttribute("user", user.username);
|
||||
dmdiv.addEventListener("mouseenter", () => {
|
||||
let FreshEditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? bdplugins.EditUsers.plugin.getUserData(user.id, dmdiv) : {};
|
||||
BDFDB.createTooltip(FreshEditUsersData.name || dmname, dmdiv, {selector:(BDFDB.isObjectEmpty(FreshEditUsersData) ? "" : "EditUsers-tooltip"),type:"right"});
|
||||
});
|
||||
dmdiv.addEventListener("click", () => {
|
||||
this.ChannelSwitchUtils.selectPrivateChannel(id);
|
||||
});
|
||||
dmdiv.addEventListener("contextmenu", e => {
|
||||
let dmContext = BDFDB.htmlToElement(this.dmUnpinContextMarkup);
|
||||
dmContext.querySelector(".unpindm-guild-item").addEventListener("click", () => {
|
||||
BDFDB.removeEles(dmdiv, dmContext);
|
||||
this.unhideNativeDM(id);
|
||||
BDFDB.removeData(id, this, "pinnedRecents");
|
||||
});
|
||||
BDFDB.appendContextMenu(dmContext, e);
|
||||
});
|
||||
this.addHoverBehaviour(dmdiv);
|
||||
this.updateUnreadCount(id);
|
||||
this.hideNativeDM(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateUnreadCount (id) {
|
||||
let dmdiv = document.querySelector(`${BDFDB.dotCNS.dms + BDFDB.dotCN.guild}.pinned[channelid="${id}"]`);
|
||||
if (Node.prototype.isPrototypeOf(dmdiv)) {
|
||||
let count = this.UnreadUtils.getUnreadCount(dmdiv.getAttribute("channelid"));
|
||||
let badge = dmdiv.querySelector(BDFDB.dotCN.badge);
|
||||
BDFDB.toggleEles(badge, count > 0);
|
||||
BDFDB.toggleClass(dmdiv, "has-new-messages", count > 0);
|
||||
badge.innerText = count;
|
||||
}
|
||||
}
|
||||
|
||||
hideNativeDM (id) {
|
||||
let dmdiv = BDFDB.getDmDiv(id);
|
||||
if (Node.prototype.isPrototypeOf(dmdiv)) {
|
||||
BDFDB.toggleEles(dmdiv, false);
|
||||
BDFDB.addClass(dmdiv, "hidden-by-pin");
|
||||
}
|
||||
}
|
||||
|
||||
unhideNativeDM (id) {
|
||||
let dmdiv = BDFDB.getDmDiv(id);
|
||||
if (Node.prototype.isPrototypeOf(dmdiv) && BDFDB.containsClass(dmdiv, "hidden-by-pin")) {
|
||||
BDFDB.toggleEles(dmdiv, true);
|
||||
BDFDB.removeClass(dmdiv, "hidden-by-pin");
|
||||
}
|
||||
}
|
||||
|
||||
addHoverBehaviour (div) {
|
||||
/* based on stuff from Zerebos */
|
||||
let divinner = div.querySelector(BDFDB.dotCN.guildinner);
|
||||
let divicon = div.querySelector(BDFDB.dotCN.guildicon);
|
||||
let backgroundColor = new this.Animations.Value(0);
|
||||
backgroundColor
|
||||
.interpolate({
|
||||
inputRange: [0, 1],
|
||||
outputRange: [this.DiscordConstants.Colors.CHANNELS_GREY, this.DiscordConstants.Colors.BRAND_PURPLE]
|
||||
})
|
||||
.addListener((value) => {
|
||||
if (BDFDB.containsClass(divicon, BDFDB.disCN.avatarnoicon)) {
|
||||
let comp = BDFDB.colorCONVERT(value.value, "RGBCOMP");
|
||||
if (comp) divinner.style.setProperty("background-color", `rgb(${comp[0]}, ${comp[1]}, ${comp[2]})`);
|
||||
}
|
||||
});
|
||||
|
||||
let borderRadius = new this.Animations.Value(0);
|
||||
borderRadius
|
||||
.interpolate({
|
||||
inputRange: [0, 1],
|
||||
outputRange: [25, 15]
|
||||
})
|
||||
.addListener((value) => {
|
||||
divinner.style.setProperty("border-radius", `${value.value}px`);
|
||||
});
|
||||
|
||||
let animate = (v) => {
|
||||
this.Animations.parallel([
|
||||
this.Animations.timing(backgroundColor, {toValue: v, duration: 200}),
|
||||
this.Animations.spring(borderRadius, {toValue: v, friction: 3})
|
||||
]).start();
|
||||
};
|
||||
|
||||
div.addEventListener("mouseenter", () => {animate(1);})
|
||||
div.addEventListener("mouseleave", () => {if (!BDFDB.containsClass(div, BDFDB.disCN.guildselected)) animate(0);});
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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;">Unpin all DMs.</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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
|
||||
BDFDB.openConfirmModal(this, "Are you sure you want to unpin all pinned DMs?", () => {
|
||||
BDFDB.removeAllData(this, "pinnedDMs");
|
||||
BDFDB.removeAllData(this, "pinnedRecents");
|
||||
});
|
||||
});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
return {
|
||||
context_pindm_text: "Prikljucite Izravnu Dopisivanje",
|
||||
header_pinneddms_text: "Prikvačene izravne poruke"
|
||||
context_pindm_text: "Prikljucite Izravnu Poruku",
|
||||
context_pinchannel_text: "Priložite popisu kanala",
|
||||
context_unpinchannel_text: "Ukloni s popisa kanala",
|
||||
context_pinguild_text: "Priložite popisu poslužitelja",
|
||||
context_unpinguild_text: "Ukloni s popisa poslužitelja",
|
||||
header_pinneddms_text: "Prikvačene Izravne Poruke"
|
||||
};
|
||||
case "da": //danish
|
||||
return {
|
||||
context_pindm_text: "Pin DB",
|
||||
context_pindm_text: "Fastgør PB",
|
||||
context_pinchannel_text: "Vedhæft til kanalliste",
|
||||
context_unpinchannel_text: "Fjern fra kanalliste",
|
||||
context_pinguild_text: "Vedhæft til serverliste",
|
||||
context_unpinguild_text: "Fjern fra serverliste",
|
||||
header_pinneddms_text: "Pinned Privat Beskeder"
|
||||
};
|
||||
case "de": //german
|
||||
return {
|
||||
context_pindm_text: "Direktnachricht anpinnen",
|
||||
context_pindm_text: "Direktnachricht anheften",
|
||||
context_pinchannel_text: "An Kanalliste anheften",
|
||||
context_unpinchannel_text: "Von Kanalliste loslösen",
|
||||
context_pinguild_text: "An Serverliste anheften",
|
||||
context_unpinguild_text: "Von Serverliste loslösen",
|
||||
header_pinneddms_text: "Gepinnte Direktnachrichten"
|
||||
};
|
||||
case "es": //spanish
|
||||
return {
|
||||
context_pindm_text: "Pin MD",
|
||||
context_pindm_text: "Anclar MD",
|
||||
context_pinchannel_text: "Adjuntar a la lista de canales",
|
||||
context_unpinchannel_text: "Deshazte de la lista de canales",
|
||||
context_pinguild_text: "Adjuntar a la lista de servidores",
|
||||
context_unpinguild_text: "Deshazte de la lista de servidores",
|
||||
header_pinneddms_text: "Mensajes Directos Fijados"
|
||||
};
|
||||
case "fr": //french
|
||||
return {
|
||||
context_pindm_text: "Épingler MP",
|
||||
context_pinchannel_text: "Épingler à la liste des chaînes",
|
||||
context_unpinchannel_text: "Détacher de la liste des chaînes",
|
||||
context_pinguild_text: "Épingler à la liste de serveurs",
|
||||
context_unpinguild_text: "Détacher de la liste de serveurs",
|
||||
header_pinneddms_text: "Messages Prives Épinglés"
|
||||
};
|
||||
case "it": //italian
|
||||
return {
|
||||
context_pindm_text: "Appuntare il messaggio diretto",
|
||||
context_pindm_text: "Fissa il messaggio diretto",
|
||||
context_pinchannel_text: "Allega alla lista dei canali",
|
||||
context_unpinchannel_text: "Rimuovi dalla lista dei canali",
|
||||
context_pinguild_text: "Allega alla lista dei server",
|
||||
context_unpinguild_text: "Rimuovi dalla lista dei server",
|
||||
header_pinneddms_text: "Messaggi Diretti Aggiunti"
|
||||
};
|
||||
case "nl": //dutch
|
||||
return {
|
||||
context_pindm_text: "PB vastpinnen",
|
||||
context_pindm_text: "PB pinnen",
|
||||
context_pinchannel_text: "Pin naar de kanalenlijst",
|
||||
context_unpinchannel_text: "Losmaken van kanalenlijst",
|
||||
context_pinguild_text: "Pin naar de serverlijst",
|
||||
context_unpinguild_text: "Losmaken van serverlijst",
|
||||
header_pinneddms_text: "Vastgezette Persoonluke Berichten"
|
||||
};
|
||||
case "no": //norwegian
|
||||
return {
|
||||
context_pindm_text: "Pinne DM",
|
||||
context_pindm_text: "Fest DM",
|
||||
context_pinchannel_text: "Fest på kanalliste",
|
||||
context_unpinchannel_text: "Fjern fra kanalliste",
|
||||
context_pinguild_text: "Fest på serverliste",
|
||||
context_unpinguild_text: "Fjern fra serverlisten",
|
||||
header_pinneddms_text: "Pinned Direktemeldinger"
|
||||
};
|
||||
case "pl": //polish
|
||||
return {
|
||||
context_pindm_text: "Przypnij PW",
|
||||
context_pinchannel_text: "Dołącz do listy kanałów",
|
||||
context_unpinchannel_text: "Usuń z listy kanałów",
|
||||
context_pinguild_text: "Dołącz do listy serwerów",
|
||||
context_unpinguild_text: "Usuń z listy serwerów",
|
||||
header_pinneddms_text: "Prywatne Wiadomości Bezpośrednie"
|
||||
};
|
||||
case "pt-BR": //portuguese (brazil)
|
||||
return {
|
||||
context_pindm_text: "Fixar MD",
|
||||
context_pinchannel_text: "Anexar à lista de canais",
|
||||
context_unpinchannel_text: "Remover da lista de canais",
|
||||
context_pinguild_text: "Anexar à lista de servidores",
|
||||
context_unpinguild_text: "Remover da lista de servidores",
|
||||
header_pinneddms_text: "Mensagens diretas fixadas"
|
||||
};
|
||||
case "fi": //finnish
|
||||
return {
|
||||
context_pindm_text: "Kiinnitä yksityisviestit",
|
||||
context_pinchannel_text: "Liitä kanavaluetteloon",
|
||||
context_unpinchannel_text: "Poista kanavaluettelosta",
|
||||
context_pinguild_text: "Liitä palvelinluetteloon",
|
||||
context_unpinguild_text: "Poista palvelinluettelosta",
|
||||
header_pinneddms_text: "Liitetyt yksityisviestit"
|
||||
};
|
||||
case "sv": //swedish
|
||||
return {
|
||||
context_pindm_text: "Peka DM",
|
||||
context_pindm_text: "Fäst DM",
|
||||
context_pinchannel_text: "Fäst till kanallista",
|
||||
context_unpinchannel_text: "Ta bort från kanallistan",
|
||||
context_pinguild_text: "Fäst till servernlista",
|
||||
context_unpinguild_text: "Ta bort från servernlista",
|
||||
header_pinneddms_text: "Inlagda Direktmeddelanden"
|
||||
};
|
||||
case "tr": //turkish
|
||||
return {
|
||||
context_pindm_text: "DM'yi Sabitle",
|
||||
context_pinchannel_text: "Kanal listesine ekle",
|
||||
context_unpinchannel_text: "Kanal listesinden kaldır",
|
||||
context_pinguild_text: "Sunucu listesine ekle",
|
||||
context_unpinguild_text: "Sunucu listesinden kaldır",
|
||||
header_pinneddms_text: "Direkt Mesajlar Sabitleyin"
|
||||
};
|
||||
case "cs": //czech
|
||||
return {
|
||||
context_pindm_text: "Připojte PZ",
|
||||
header_pinneddms_text: "Připojené přímá zpráva"
|
||||
context_pindm_text: "Připnout PZ",
|
||||
context_pinchannel_text: "Připojení k seznamu kanálů",
|
||||
context_unpinchannel_text: "Odstranit ze seznamu kanálů",
|
||||
context_pinguild_text: "Připojit ke seznamu serverů",
|
||||
context_unpinguild_text: "Odstranit ze seznamu serverů",
|
||||
header_pinneddms_text: "Připojené Přímá Zpráva"
|
||||
};
|
||||
case "bg": //bulgarian
|
||||
return {
|
||||
context_pindm_text: "Закачете",
|
||||
context_pindm_text: "Закачени ДС",
|
||||
context_pinchannel_text: "Прикачете към списъка с канали",
|
||||
context_unpinchannel_text: "Премахване от списъка с канали",
|
||||
context_pinguild_text: "Прикачване към списъка със сървъри",
|
||||
context_unpinguild_text: "Премахване от списъка със сървъри",
|
||||
header_pinneddms_text: "Свързани директни съобщения"
|
||||
};
|
||||
case "ru": //russian
|
||||
return {
|
||||
context_pindm_text: "Подключить ЛС",
|
||||
header_pinneddms_text: "Прикрепленные Личные сообщения"
|
||||
context_pindm_text: "Закрепить ЛС",
|
||||
context_pinchannel_text: "Прикрепить к списку каналов",
|
||||
context_unpinchannel_text: "Удалить из списка каналов",
|
||||
context_pinguild_text: "Присоединить к списку серверов",
|
||||
context_unpinguild_text: "Удалить из списка серверов",
|
||||
header_pinneddms_text: "Прикрепленные Личные Сообщения"
|
||||
};
|
||||
case "uk": //ukrainian
|
||||
return {
|
||||
context_pindm_text: "Прикріпити ОП",
|
||||
context_pindm_text: "Закріпити ОП",
|
||||
context_pinchannel_text: "Додайте до списку каналів",
|
||||
context_unpinchannel_text: "Видалити зі списку каналів",
|
||||
context_pinguild_text: "Додайте до списку серверів",
|
||||
context_unpinguild_text: "Видалити зі списку серверів",
|
||||
header_pinneddms_text: "Прикріплені oсобисті повідомлення"
|
||||
};
|
||||
case "ja": //japanese
|
||||
return {
|
||||
context_pindm_text: "DMをピン留めする",
|
||||
context_pindm_text: "DMピン",
|
||||
context_pinchannel_text: "チャンネルリストに添付",
|
||||
context_unpinchannel_text: "チャンネルリストから削除",
|
||||
context_pinguild_text: "サーバーリストに添付",
|
||||
context_unpinguild_text: "サーバーリストから削除",
|
||||
header_pinneddms_text: "固定された直接メッセージ"
|
||||
};
|
||||
case "zh-TW": //chinese (traditional)
|
||||
return {
|
||||
context_pindm_text: "引用私人信息",
|
||||
context_pindm_text: "引腳直接留言",
|
||||
context_pinchannel_text: "附加到頻道列表",
|
||||
context_unpinchannel_text: "從頻道列表中刪除",
|
||||
context_pinguild_text: "附加到服務器列表",
|
||||
context_unpinguild_text: "從服務器列表中刪除",
|
||||
header_pinneddms_text: "固定私人信息"
|
||||
};
|
||||
case "ko": //korean
|
||||
return {
|
||||
context_pindm_text: "개인 메시지 비공개",
|
||||
context_pindm_text: "비공개 메시지 고정",
|
||||
context_pinchannel_text: "채널 목록에 첨부",
|
||||
context_unpinchannel_text: "채널 목록에서 삭제",
|
||||
context_pinguild_text: "서버 목록에 첨부",
|
||||
context_unpinguild_text: "서버 목록에서 제거",
|
||||
header_pinneddms_text: "고정 된 비공개 메시지"
|
||||
};
|
||||
default: //default: english
|
||||
return {
|
||||
context_pindm_text: "Pin DM",
|
||||
context_pinchannel_text: "Pin to Channellist",
|
||||
context_unpinchannel_text: "Unpin from Channellist",
|
||||
context_pinguild_text: "Pin to Serverlist",
|
||||
context_unpinguild_text: "Unpin from Serverlist",
|
||||
header_pinneddms_text: "Pinned Direct Messages"
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.bd-pub-buttonMarkup =
|
||||
`<div class="${BDFDB.disCN.guild}" id="bd-pub-li" style="height: 20px; width: 50px; margin-bottom: 10px; margin-right: auto; margin-left: auto">
|
||||
<div class="${BDFDB.disCN.guildinner}" style="height: 20px; width: 50px; border-radius: 4px;">
|
||||
this.patchModules = {
|
||||
"Guilds":"componentDidMount",
|
||||
"RecentMentions":"componentDidMount"
|
||||
};
|
||||
|
||||
this.RANbuttonMarkup =
|
||||
`<div class="${BDFDB.disCN.guild} RANbutton-frame" id="bd-pub-li" style="height: 20px; margin-bottom: 10px;">
|
||||
<div class="${BDFDB.disCN.guildinner}" style="height: 20px; border-radius: 4px;">
|
||||
<a>
|
||||
<div id="bd-pub-button" style="line-height: 20px; font-size: 12px;">read all</div>
|
||||
<div class="RANbutton" id="bd-pub-button" style="line-height: 20px; font-size: 12px;">read all</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.RAMbuttonMarkup =
|
||||
`<button type="button" id="RAMbutton" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow}" style="flex: 0 0 auto; margin-top: -5px; height: 25px;">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">Clear all Mentions</div>
|
||||
`<button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemin + BDFDB.disCN.buttongrow} RAMbutton" style="flex: 0 0 auto; margin-left: 25px; height: 25px;">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">Clear Mentions</div>
|
||||
</button>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
includeMuted: {value:false, description:"Include muted Servers (means more API-Requests):"}
|
||||
|
@ -27,69 +30,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
var mentionspopout = null;
|
||||
if (node && node.tagName && (mentionspopout = node.querySelector(BDFDB.dotCN.recentmentionspopout)) != null) {
|
||||
let filter = node.querySelector(BDFDB.dotCN.recentmentionsmentionfilter);
|
||||
if (filter) {
|
||||
$(this.RAMbuttonMarkup).insertBefore(BDFDB.dotCN.recentmentionsmentionfilter, mentionspopout)
|
||||
.on("click", () => {
|
||||
var loadinterval = setInterval(() => {
|
||||
if (!mentionspopout || !mentionspopout.parentElement) clearInterval(loadinterval);
|
||||
var loadbutton = mentionspopout.querySelector(BDFDB.dotCNS.messagespopouthasmore + "button");
|
||||
var closebuttons = mentionspopout.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
|
||||
if (!loadbutton) {
|
||||
closebuttons.forEach((btn) => {btn.click();});
|
||||
clearInterval(loadinterval);
|
||||
}
|
||||
else {
|
||||
closebuttons.forEach((btn,i) => {if (closebuttons.length-1 > i) btn.click();});
|
||||
loadbutton.click();
|
||||
}
|
||||
},2000);
|
||||
});
|
||||
mentionspopout.classList.add("RAM-added");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"mentionsPopoutObserver",instance:observer}, {childList: true});
|
||||
|
||||
$(this.bd-pub-buttonMarkup).insertBefore(document.querySelector(BDFDB.dotCN.guildseparator))
|
||||
.on("click", "#bd-pub-button", () => {
|
||||
let servers = BDFDB.getData("includeMuted", this, "settings") ? BDFDB.readServerList() : BDFDB.readUnreadServerList();
|
||||
BDFDB.clearReadNotifications(servers);
|
||||
});
|
||||
|
||||
$(BDFDB.dotCN.guilds).addClass("RAN-added");
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -100,11 +63,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
$("#bd-pub-li, #RAMbutton").remove();
|
||||
|
||||
$(".RAN-added").removeClass("RAN-added");
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".RANbutton-frame", ".RAMbutton");
|
||||
BDFDB.removeClasses("RAN-added", "RAM-added");
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -112,30 +74,58 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
var settings = {};
|
||||
for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
|
||||
settings[input.value] = input.checked;
|
||||
processGuilds (instance, wrapper) {
|
||||
BDFDB.removeEles(".RANbutton-frame");
|
||||
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());
|
||||
});
|
||||
BDFDB.addClass(wrapper, "RAN-added");
|
||||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
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>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
processRecentMentions (instance, wrapper) {
|
||||
BDFDB.removeEles(".RAMbutton");
|
||||
if (instance.props && instance.props.popoutName == "RECENT_MENTIONS_POPOUT") {
|
||||
let recentmentionstitle = wrapper.querySelector(BDFDB.dotCN.recentmentionstitle);
|
||||
if (recentmentionstitle) {
|
||||
let ranbutton = BDFDB.htmlToElement(this.RAMbuttonMarkup);
|
||||
recentmentionstitle.appendChild(ranbutton);
|
||||
ranbutton.addEventListener("click", () => {this.clearMentions(instance, wrapper);});
|
||||
BDFDB.addClass(wrapper, "RAM-added");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearMentions (instance, wrapper) {
|
||||
let closebuttons = wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton);
|
||||
for (let btn of wrapper.querySelectorAll(BDFDB.dotCN.messagespopoutclosebutton)) btn.click();
|
||||
if (closebuttons.length) {
|
||||
instance.loadMore();
|
||||
setTimeout(() => {this.clearMentions(instance, wrapper);},3000);
|
||||
}
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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></div>`;
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,110 +1,56 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.updateUsers = false;
|
||||
|
||||
this.patchModules = {
|
||||
"NameTag":"componentDidMount",
|
||||
"FluxContainer(TypingUsers)":"componentDidUpdate",
|
||||
"MessageUsername":"componentDidMount",
|
||||
"Clickable":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
replaceOwn: {value:false, description:"Replace your own name:"},
|
||||
addNickname: {value:false, description:"Add nickname as parentheses:"}
|
||||
addNickname: {value:false, description:"Add nickname as parentheses:"},
|
||||
swapPositions: {value:false, description:"Swap the position of username and nickname:"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.MemberPerms = BDFDB.WebModules.findByProperties("getNicknames", "getNick");
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.tagName && node.querySelector(BDFDB.dotCN.voiceuserdefault)) {
|
||||
this.loadUser(node.querySelector(BDFDB.dotCN.voiceuserdefault).parentElement, "voice", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.channels, {name:"channelListObserver",instance:observer}, {childList: true, subtree: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.tagName && node.querySelector(BDFDB.dotCN.memberusername)) {
|
||||
this.loadUser(node, "list", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.members, {name:"userListObserver",instance:observer}, {childList:true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
var compact = document.querySelector(BDFDB.dotCN.messagegroup + BDFDB.dotCN.messagecompact);
|
||||
if (!compact) {
|
||||
if (node && node.tagName && node.querySelector(BDFDB.dotCN.messageusernamewrapper)) {
|
||||
this.loadUser(node, "chat", compact);
|
||||
}
|
||||
else if (node && node.classList && node.classList.contains(BDFDB.disCN.messagetext)) {
|
||||
this.loadUser($(BDFDB.dotCN.messagegroup).has(node)[0], "chat", compact);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (node && node.tagName && node.querySelector(BDFDB.dotCN.messageusernamewrapper)) {
|
||||
if (node.classList.contains(BDFDB.disCN.messagemarkup)) {
|
||||
this.loadUser(node, "chat", compact);
|
||||
}
|
||||
else {
|
||||
var markups = node.querySelectorAll(BDFDB.dotCN.messagemarkup);
|
||||
for (var i = 0; i < markups.length; i++) {
|
||||
this.loadUser(markups[i], "chat", compact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
this.loadAllUsers();
|
||||
this.reseting = false;
|
||||
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
|
||||
this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
|
||||
this.MemberStore = BDFDB.WebModules.findByProperties("getNicknames", "getNick");
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -116,9 +62,11 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
this.resetAllUsers();
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
this.reseting = true;
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -126,133 +74,89 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
this.loadAllUsers();
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.members, {name:"userListObserver"}, {childList:true});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver"}, {childList:true, subtree:true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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.updateUsers = true;
|
||||
getNewName (info) {
|
||||
if (!info) return null;
|
||||
let EditUsersData = BDFDB.isPluginEnabled("EditUsers") ? BDFDB.loadData(info.id, "EditUsers", "users") : null;
|
||||
if (EditUsersData && EditUsersData.name) return EditUsersData.name;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let member = this.MemberStore.getMember(this.LastGuildStore.getGuildId(), info.id);
|
||||
if (!member || !member.nick || info.id == BDFDB.myData.id && !settings.replaceOwn) return info.username;
|
||||
if (this.reseting) return member.nick || info.username;
|
||||
return settings.addNickname ? (settings.swapPositions ? (member.nick + " (" + info.username + ")") : (info.username + " (" + member.nick + ")")) : info.username;
|
||||
}
|
||||
|
||||
loadAllUsers () {
|
||||
for (let user of document.querySelectorAll(BDFDB.dotCN.member)) {
|
||||
this.loadUser(user, "list", false);
|
||||
}
|
||||
for (let user of document.querySelectorAll(BDFDB.dotCN.messagegroup)) {
|
||||
let compact = user.classList.contains(BDFDB.disCN.messagecompact);
|
||||
if (!compact) {
|
||||
this.loadUser(user, "chat", compact);
|
||||
}
|
||||
else {
|
||||
for (let markup of user.querySelectorAll(BDFDB.dotCN.messagemarkup)) {
|
||||
this.loadUser(markup, "chat", compact);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let user of document.querySelectorAll(BDFDB.dotCN.voiceuserdefault)) {
|
||||
this.loadUser(user.parentElement, "voice", false);
|
||||
processNameTag (instance, wrapper) {
|
||||
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));
|
||||
}
|
||||
|
||||
processMessageUsername (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message) {
|
||||
let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
|
||||
if (username) BDFDB.setInnerText(username, this.getNewName(message.author));
|
||||
}
|
||||
}
|
||||
|
||||
loadUser (div, type, compact) {
|
||||
if (!div || $(div).attr("removed-nickname") || !div.tagName) return;
|
||||
|
||||
let usernameWrapper = this.getNameWrapper(div);
|
||||
if (!usernameWrapper) return;
|
||||
|
||||
$(div).data("compact", compact);
|
||||
|
||||
var info = this.getUserInfo(compact ? $(BDFDB.dotCN.messagegroup).has(div)[0] : div);
|
||||
if (!info) return;
|
||||
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
if (info.id == BDFDB.myData.id && !settings.replaceOwn) return;
|
||||
|
||||
var serverObj = BDFDB.getSelectedServer();
|
||||
if (!serverObj) return;
|
||||
|
||||
var member = this.MemberPerms.getMember(serverObj.id, info.id);
|
||||
if (!member || !member.nick) return;
|
||||
|
||||
BDFDB.setInnerText(usernameWrapper, settings.addNickname ? info.username + " (" + member.nick + ")" : info.username);
|
||||
|
||||
$(div).attr("removed-nickname", true);
|
||||
}
|
||||
|
||||
resetAllUsers () {
|
||||
document.querySelectorAll("[removed-nickname]").forEach((div) => {
|
||||
let usernameWrapper = this.getNameWrapper(div);
|
||||
if (!usernameWrapper) return;
|
||||
|
||||
var info = this.getUserInfo($(div).data(BDFDB.disCN.messagecompact) ? $(BDFDB.dotCN.messagegroup).has(div)[0] : div);
|
||||
if (!info) return;
|
||||
|
||||
var serverObj = BDFDB.getSelectedServer();
|
||||
if (!serverObj) return;
|
||||
|
||||
var member = this.MemberPerms.getMember(serverObj.id, info.id);
|
||||
if (!member || !member.nick) return;
|
||||
|
||||
BDFDB.setInnerText(usernameWrapper, member.nick);
|
||||
|
||||
$(div).removeAttr("removed-nickname");
|
||||
|
||||
processFluxContainerTypingUsers (instance, wrapper) {
|
||||
let users = !instance.state.typingUsers ? [] : Object.keys(instance.state.typingUsers).filter(id => id != BDFDB.myData.id).filter(id => !this.RelationshipUtils.isBlocked(id)).map(id => this.UserUtils.getUser(id)).filter(id => id != null);
|
||||
wrapper.querySelectorAll("strong").forEach((username, i) => {
|
||||
if (users[i] && username) BDFDB.setInnerText(username, this.getNewName(users[i]));
|
||||
});
|
||||
}
|
||||
|
||||
getNameWrapper (div) {
|
||||
return div.querySelector(BDFDB.dotCNC.memberusername + BDFDB.dotCNC.voicenamedefault + BDFDB.dotCN.messageusername);
|
||||
}
|
||||
|
||||
getUserInfo (div) {
|
||||
var info = BDFDB.getKeyInformation({"node":div,"key":"user"});
|
||||
if (!info) {
|
||||
info = BDFDB.getKeyInformation({"node":div,"key":"message"});
|
||||
if (info) info = info.author;
|
||||
else {
|
||||
info = BDFDB.getKeyInformation({"node":div,"key":"channel"});
|
||||
if (info) info = {"id":info.recipients[0]};
|
||||
else {
|
||||
info = BDFDB.getKeyInformation({"node":$(BDFDB.dotCN.messagegroup).has(div)[0],"key":"message"});
|
||||
if (info) info = info.author;
|
||||
}
|
||||
|
||||
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 (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));
|
||||
}
|
||||
}
|
||||
return info && info.id ? this.UserStore.getUser(info.id) : null;
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
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>`;
|
||||
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mention) > -1) {
|
||||
let render = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.stateNode.props.render");
|
||||
if (typeof render == "function") BDFDB.setInnerText(wrapper, "@" + this.getNewName(render().props.user));
|
||||
}
|
||||
settingshtml += `</div>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.voiceuser) > -1) {
|
||||
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.user");
|
||||
if (user) {
|
||||
let username = wrapper.querySelector(BDFDB.dotCN.voicename);
|
||||
if (username) BDFDB.setInnerText(username, this.getNewName(user));
|
||||
}
|
||||
}
|
||||
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) {
|
||||
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.user");
|
||||
if (user) {
|
||||
let username = wrapper.querySelector(BDFDB.dotCN.marginleft8);
|
||||
if (username) BDFDB.setInnerText(username, this.getNewName(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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></div>`;
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
;
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateUsers) {
|
||||
this.resetAllUsers();
|
||||
this.loadAllUsers();
|
||||
this.updateUsers = false;
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.imgUrlReplaceString = "DEVILBRO_BD_REVERSEIMAGESEARCH_REPLACE_IMAGEURL";
|
||||
|
||||
|
||||
this.defaults = {
|
||||
engines: {
|
||||
_all: {value:true, name:BDFDB.getLibraryStrings().btn_all_text, url:null},
|
||||
|
@ -30,56 +28,42 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.messageContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} reverseImageSearchSubMenu">
|
||||
`<div class="${BDFDB.disCN.contextmenu} reverseimagesearch-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} alldisabled-item ${BDFDB.disCN.contextmenuitemdisabled}">
|
||||
<span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_submenu_disabled_text</div></span>
|
||||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
${Object.keys(this.defaults.engines).map((key, i) => `<div engine="${key}" class="${BDFDB.disCN.contextmenuitem} RIS-item"><span>${this.defaults.engines[key].name}</span><div class="${BDFDB.disCN.contextmenuhint}"></div></div>`).join("")}
|
||||
${Object.keys(this.defaults.engines).map((key, i) => `<div engine="${key}" class="${BDFDB.disCN.contextmenuitem} RIS-item"><span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">${this.defaults.engines[key].name}</div></span><div class="${BDFDB.disCN.contextmenuhint}"></div></div>`).join("")}
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
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});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -90,7 +74,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -98,93 +82,67 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.messageContextSubMenuMarkup = this.messageContextSubMenuMarkup.replace("REPLACE_submenu_disabled_text", this.labels.submenu_disabled_text);
|
||||
}
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
var settings = {};
|
||||
for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
|
||||
settings[input.value] = input.checked;
|
||||
|
||||
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);
|
||||
}
|
||||
BDFDB.saveAllData(settings, this, "engines");
|
||||
}
|
||||
|
||||
onContextMenu (context) {
|
||||
if (!context || !context.tagName || !context.parentElement || context.querySelector(".reverseimagesearch-item")) return;
|
||||
var url = BDFDB.getKeyInformation({"node":context, "key":"src"});
|
||||
if (url) {
|
||||
if (url.indexOf("discordapp.com/assets/") == -1) {
|
||||
if (url.indexOf("https://images-ext-1.discordapp.net/external/") > -1) {
|
||||
if (url.split("/https/").length != 1) {
|
||||
url = "https://" + url.split("/https/")[url.split("/https/").length-1];
|
||||
|
||||
onMessageContextMenu (instance, menu) {
|
||||
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".reverseimagesearch-item")) {
|
||||
if (instance.props.attachment) {
|
||||
this.appendItem(instance, menu, instance.props.attachment.url);
|
||||
}
|
||||
if (instance.props.target.tagName == "A") {
|
||||
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);
|
||||
}
|
||||
else if (url.split("/http/").length != 1) {
|
||||
url = "http://" + url.split("/http/")[url.split("/http/").length-1];
|
||||
}
|
||||
}
|
||||
|
||||
$(context).append(this.messageContextEntryMarkup)
|
||||
.on("mouseenter", ".reverseimagesearch-item", (e) => {
|
||||
this.createContextSubMenu(url, e, context);
|
||||
});
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
BDFDB.toggleEles(menu, true);
|
||||
BDFDB.updateContextPosition(menu);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createContextSubMenu (imageurl, e, context) {
|
||||
var messageContextSubMenu = $(this.messageContextSubMenuMarkup);
|
||||
|
||||
messageContextSubMenu
|
||||
.on("click", ".RIS-item", (e2) => {
|
||||
$(context).hide();
|
||||
var engine = e2.currentTarget.getAttribute("engine");
|
||||
if (engine == "_all") {
|
||||
var engines = BDFDB.getAllData(this, "engines");
|
||||
for (let key in engines) {
|
||||
if (key != "_all" && engines[key]) window.open(this.defaults.engines[key].url.replace(this.imgUrlReplaceString, encodeURIComponent(imageurl)), "_blank");
|
||||
}
|
||||
|
||||
appendItem (instance, menu, url) {
|
||||
if (instance && menu && url) {
|
||||
if (url.indexOf("discordapp.com/assets/") == -1) {
|
||||
if (url.indexOf("https://images-ext-1.discordapp.net/external/") > -1) {
|
||||
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];
|
||||
}
|
||||
else {
|
||||
window.open(this.defaults.engines[engine].url.replace(this.imgUrlReplaceString, encodeURIComponent(imageurl)), "_blank");
|
||||
}
|
||||
});
|
||||
|
||||
var engines = BDFDB.getAllData(this, "engines");
|
||||
for (let key in engines) {
|
||||
if (!engines[key]) messageContextSubMenu.find("[engine='" + key + "']").remove();
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (messageContextSubMenu.find(".RIS-item").length > 0) {
|
||||
messageContextSubMenu.find(".alldisabled-item").remove();
|
||||
}
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, messageContextSubMenu);
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var engines = BDFDB.getAllData(this, "engines");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-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: 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>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount"
|
||||
};
|
||||
|
||||
this.messageDelay = 1000; //changing at own risk, might result in bans or mutes
|
||||
|
||||
|
||||
this.css = `
|
||||
.${this.name}-modal textarea {
|
||||
rows: 0;
|
||||
|
@ -17,11 +19,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
resize: none;
|
||||
}
|
||||
.${this.name}-modal #warning-message {
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
|
||||
.${this.name}-modal #character-counter {
|
||||
float: right;
|
||||
color: white;
|
||||
|
@ -29,7 +29,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}`;
|
||||
|
||||
this.sendMessageModalMarkup =
|
||||
`<span class=""${this.name}-modal DevilBro-modal"">
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
<div class="${BDFDB.disCN.modal}">
|
||||
<div class="${BDFDB.disCN.modalinner}">
|
||||
|
@ -39,19 +39,23 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<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>
|
||||
</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>
|
||||
<button type="button" class="${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">
|
||||
<svg name="Close" width="18" height="18" viewBox="0 0 12 12" style="flex: 0 1 auto;">
|
||||
<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>
|
||||
</button>
|
||||
</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.disCN.modalsubinner}" 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.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstart + BDFDB.disCNS.nowrap + BDFDB.disCNS.modalsubinner + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;">
|
||||
<h5 id="warning-message" 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;"></h5>
|
||||
<h5 id="character-counter" 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;"></h5>
|
||||
<h5 id="warning-message" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightbold + BDFDB.disCNS.h5defaultmargin}" style="flex: 1 1 auto;"></h5>
|
||||
<h5 id="character-counter" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightmedium + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;"></h5>
|
||||
</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-send ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
||||
|
@ -65,28 +69,31 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
this.MessageUtils = BDFDB.WebModules.findByProperties("parse","isMentioned");
|
||||
|
||||
this.bindEventToTextArea();
|
||||
|
||||
this.clipboard = require("electron").clipboard;
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -98,7 +105,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -106,14 +113,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
this.bindEventToTextArea();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
|
@ -121,87 +122,81 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
this.sendMessageModalMarkup = this.sendMessageModalMarkup.replace("REPLACE_btn_cancel_text", this.labels.btn_cancel_text);
|
||||
this.sendMessageModalMarkup = this.sendMessageModalMarkup.replace("REPLACE_btn_send_text", this.labels.btn_send_text);
|
||||
}
|
||||
|
||||
bindEventToTextArea () {
|
||||
var checkTextarea = (textarea, text) => {
|
||||
if (BDFDB.getParsedLength(text) > 1950) {
|
||||
textarea.selectionStart = 0;
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
document.execCommand("insertText", false, "");
|
||||
this.showSendModal(text);
|
||||
}
|
||||
};
|
||||
$(BDFDB.dotCNS.textareawrapchat + "textarea")
|
||||
.off("input." + this.name)
|
||||
.on("input." + this.name, e => {
|
||||
checkTextarea(e.currentTarget, e.currentTarget.value);
|
||||
})
|
||||
.off("paste." + this.name)
|
||||
.on("paste." + this.name, e => {
|
||||
setImmediate(() => {
|
||||
checkTextarea(e.currentTarget, e.currentTarget.value);
|
||||
});
|
||||
|
||||
processChannelTextArea (instance, wrapper) {
|
||||
if (instance.props && instance.props.type && instance.props.type == "normal") {
|
||||
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) {
|
||||
var sendMessageModal = $(this.sendMessageModalMarkup);
|
||||
var textinput = sendMessageModal.find("#modal-inputtext");
|
||||
var warning = sendMessageModal.find("#warning-message");
|
||||
var counter = sendMessageModal.find("#character-counter");
|
||||
|
||||
var updateCounter = () => {
|
||||
var parsedlength = BDFDB.getParsedLength(textinput.val());
|
||||
var 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);
|
||||
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.value);
|
||||
let messageAmount = Math.ceil(parsedlength/1900);
|
||||
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();
|
||||
var 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.name + " click." + this.name)
|
||||
.on("keydown." + this.name + " click." + this.name, () => {
|
||||
|
||||
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.name)
|
||||
.on("mousedown." + this.name, () => {
|
||||
$(document)
|
||||
.off("mouseup." + this.name)
|
||||
.on("mouseup." + this.name, () => {
|
||||
$(document)
|
||||
.off("mouseup." + this.name)
|
||||
.off("mousemove." + this.name);
|
||||
})
|
||||
.off("mousemove." + this.name)
|
||||
.on("mousemove." + this.name, () => {
|
||||
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) {
|
||||
text = text.replace(new RegExp("\t", 'g'), " ");
|
||||
var longwords = text.match(/[\S]{1800,}/gm);
|
||||
for (var i in longwords) {
|
||||
let longwords = text.match(/[\S]{1800,}/gm);
|
||||
for (let i in longwords) {
|
||||
let longword = longwords[i];
|
||||
let count1 = 0;
|
||||
let shortwords = [];
|
||||
|
@ -211,15 +206,15 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
});
|
||||
text = text.replace(longword, shortwords.join(" "));
|
||||
}
|
||||
var messages = [];
|
||||
var count2 = 0;
|
||||
let messages = [];
|
||||
let count2 = 0;
|
||||
text.split(" ").forEach((word) => {
|
||||
if (messages[count2] && BDFDB.getParsedLength(messages[count2] + "" + word) > 1900) count2++;
|
||||
messages[count2] = messages[count2] ? messages[count2] + " " + word : word;
|
||||
});
|
||||
|
||||
var insertCodeBlock = null, insertCodeLine = null;
|
||||
for (var j = 0; j < messages.length; j++) {
|
||||
|
||||
let insertCodeBlock = null, insertCodeLine = null;
|
||||
for (let j = 0; j < messages.length; j++) {
|
||||
if (insertCodeBlock) {
|
||||
messages[j] = insertCodeBlock + messages[j];
|
||||
insertCodeBlock = null;
|
||||
|
@ -228,10 +223,10 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
messages[j] = insertCodeLine + messages[j];
|
||||
insertCodeLine = null;
|
||||
}
|
||||
|
||||
var codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
|
||||
var codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
|
||||
|
||||
|
||||
let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
|
||||
let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
|
||||
|
||||
if (codeBlocks && codeBlocks.length % 2 == 1) {
|
||||
messages[j] = messages[j] + "```";
|
||||
insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n";
|
||||
|
@ -241,18 +236,21 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
messages[j] = messages[j] + insertCodeLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
sendMessage (text) {
|
||||
var textarea = document.querySelector(BDFDB.dotCNS.textareawrapchat + "textarea");
|
||||
let textarea = document.querySelector(BDFDB.dotCNS.textareawrapchat + "textarea");
|
||||
if (textarea) {
|
||||
BDFDB.getOwnerInstance({"node":textarea, "name":"ChannelTextAreaForm", "up":true}).setState({textValue:text});
|
||||
BDFDB.triggerSend(textarea);
|
||||
let instance = BDFDB.getOwnerInstance({"node":textarea.parentElement, "name":"ChannelTextAreaForm", "up":true});
|
||||
if (instance) {
|
||||
instance.setState({textValue:text});
|
||||
BDFDB.triggerSend(textarea);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,63 +1,16 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.labels = {};
|
||||
|
||||
this.css = `
|
||||
.${this.name}-modal .entry ${BDFDB.dotCN.guild} {
|
||||
height: 50px;
|
||||
position: relative;
|
||||
width: 50px;
|
||||
z-index: 1;
|
||||
}
|
||||
.${this.name}-modal .entry ${BDFDB.dotCN.guildinner} {
|
||||
background: #2f3136;
|
||||
border-radius: 25px !important;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
line-height: 50px;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
.${this.name}-modal .entry ${BDFDB.dotCNS.guild + BDFDB.dotCN.avatarsmallold} {
|
||||
background-repeat: no-repeat;
|
||||
background-size: 50px 50px;
|
||||
border-radius: 0;
|
||||
color: #fff;
|
||||
display: block;
|
||||
float: left;
|
||||
margin: 0;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
.${this.name}-modal .entry ${BDFDB.dotCNS.guild + BDFDB.dotCN.badge} {
|
||||
background-clip: padding-box;
|
||||
background-color: #f04747;
|
||||
border-radius: 3px;
|
||||
bottom: -2px;
|
||||
box-shadow: 0 1px 0 rgba(0,0,0,.25), inset 0 1px 0 hsla(0,0%,100%,.15);
|
||||
color: #fff;
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 12px;
|
||||
padding: 3px 6px;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: -2px;
|
||||
text-shadow: 0 1px 0 rgba(0,0,0,.25);
|
||||
}
|
||||
.${this.name}-modal .folderhideCheckboxWrapper {
|
||||
right: 8px;
|
||||
}`;
|
||||
|
||||
|
||||
|
||||
this.patchModules = {
|
||||
"Guild":"componentDidMount"
|
||||
};
|
||||
|
||||
this.serverHiderModalMarkup =
|
||||
`<span class=""${this.name}-modal DevilBro-modal"">
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
<div class="${BDFDB.disCN.modal}">
|
||||
<div class="${BDFDB.disCN.modalinner}">
|
||||
|
@ -67,26 +20,22 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<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>
|
||||
</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.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.modalsubinner + BDFDB.disCN.marginbottom8} folderhideSettings" style="flex: 0 0 auto;">
|
||||
<div class="${BDFDB.disCN.flexchild}" 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;">REPLACE_modal_folderhide_text</h3>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault} folderhideCheckboxWrapper" style="flex: 0 0 auto;">
|
||||
<input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} folderhideCheckbox">
|
||||
</div>
|
||||
<button type="button" class="${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">
|
||||
<svg name="Close" width="18" height="18" viewBox="0 0 12 12" style="flex: 0 1 auto;">
|
||||
<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>
|
||||
</button>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.themeghosthairline}">
|
||||
<div class="${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner} entries"></div>
|
||||
</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}">
|
||||
<button type="button" class="btn-ok ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_btn_ok_text</div>
|
||||
</button>
|
||||
<button type="button" class="btn-all ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlooklink + BDFDB.disCNS.buttoncolortransparent + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
||||
|
@ -105,8 +54,6 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} serverhiderCheckbox">
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
this.dividerMarkup = `<div class="${BDFDB.disCNS.modaldivider + BDFDB.disCN.modaldividerdefault}"></div>`;
|
||||
|
||||
this.serverContextEntryMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -115,7 +62,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} serverhider-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
||||
|
@ -132,66 +79,31 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
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:"serverContextObserver",instance:observer}, {childList: true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.classList && node.classList.contains(BDFDB.disCN.guild) && !node.querySelector(BDFDB.dotCN.guildserror)) {
|
||||
var info = BDFDB.getKeyInformation({"node":node, "key":"guild"});
|
||||
if (info) {
|
||||
var data = BDFDB.loadData(info.id, this, "servers");
|
||||
if (data) {
|
||||
$(node).toggle(data.visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true});
|
||||
|
||||
$(BDFDB.dotCN.guilds).on("mouseleave." + this.name, () => {this.updateAllServers(false);});
|
||||
|
||||
this.updateAllServers(true);
|
||||
if (BDFDB.isPluginEnabled("HideUtils") && !BDFDB.loadData("hideutils", this, "warnings")) BDFDB.openConfirmModal(this, this.name + " is not compartible with the plugin HideUtils by Arashiryuu. You might expierence bugs like Servers that should be hidden by " + this.name + " still being visible in the Guildlist. To avoid this disable the Plugin HideUtils. Press the " + BDFDB.getLibraryStrings().btn_ok_text + "-Button to not show this Message again.", "Warning", () => {BDFDB.saveData("hideutils", true, this, "warnings")});
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -202,11 +114,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
BDFDB.readServerList().forEach(serverObj => {
|
||||
if (!serverObj.div.getAttribute("folder")) $(serverObj.div).show();
|
||||
});
|
||||
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -215,176 +125,128 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
resetAll () {
|
||||
if (confirm("Are you sure you want to reset all servers?")) {
|
||||
BDFDB.removeAllData(this, "servers");
|
||||
BDFDB.readServerList().forEach(serverObj => {
|
||||
if (!serverObj.div.getAttribute("folder")) $(serverObj.div).show();
|
||||
});
|
||||
}
|
||||
}
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.serverContextEntryMarkup = this.serverContextEntryMarkup.replace("REPLACE_context_serverhider_text", this.labels.context_serverhider_text);
|
||||
|
||||
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_hideserver_text", this.labels.submenu_hideserver_text);
|
||||
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_openhidemenu_text", this.labels.submenu_openhidemenu_text);
|
||||
|
||||
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_modal_folderhide_text", this.labels.modal_folderhide_text);
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_btn_ok_text", this.labels.btn_ok_text);
|
||||
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_btn_all_text", this.labels.btn_all_text);
|
||||
|
||||
|
||||
this.serverEntryMarkup = this.serverEntryMarkup.replace("REPLACE_btn_visible_text", this.labels.btn_visible_text);
|
||||
}
|
||||
|
||||
onContextMenu (context) {
|
||||
if (document.querySelector("." + this.name + "-modal") || !context || !context.tagName || !context.parentElement || context.querySelector(".serverhider-item")) return;
|
||||
var info = BDFDB.getKeyInformation({"node":context, "key":"guild"});
|
||||
var valid = false;
|
||||
if (info && BDFDB.getKeyInformation({"node":context, "key":"displayName", "value":"GuildLeaveGroup"})) {
|
||||
valid = true;
|
||||
}
|
||||
else if (BDFDB.getKeyInformation({"node":context, "key":"handleGuildCreate"})) {
|
||||
info = {guildCreate:true};
|
||||
valid = true;
|
||||
}
|
||||
if (valid) {
|
||||
$(context).append(this.serverContextEntryMarkup)
|
||||
.on("mouseenter", ".serverhider-item", (e) => {
|
||||
this.createContextSubMenu(info, e, context);
|
||||
|
||||
onGuildContextMenu (instance, menu) {
|
||||
if (document.querySelector(".DevilBro-modal")) return;
|
||||
if (instance.props && instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(".serverhider-item")) {
|
||||
let serverContextEntry = BDFDB.htmlToElement(this.serverContextEntryMarkup);
|
||||
menu.appendChild(serverContextEntry);
|
||||
let hideritem = serverContextEntry.querySelector(".serverhider-item");
|
||||
hideritem.addEventListener("mouseenter", () => {
|
||||
let serverContextSubMenu = BDFDB.htmlToElement(this.serverContextSubMenuMarkup);
|
||||
let openitem = serverContextSubMenu.querySelector(".openhidemenu-item");
|
||||
openitem.addEventListener("click", () => {
|
||||
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
||||
this.showServerModal();
|
||||
});
|
||||
|
||||
BDFDB.updateContextPosition(context);
|
||||
}
|
||||
}
|
||||
|
||||
createContextSubMenu (info, e, context) {
|
||||
var serverContextSubMenu = $(this.serverContextSubMenuMarkup);
|
||||
|
||||
serverContextSubMenu
|
||||
.on("click", ".openhidemenu-item", () => {
|
||||
$(context).hide();
|
||||
this.showServerModal();
|
||||
if (instance.props.guild && !instance.props.target.getAttribute("folder")) {
|
||||
let hideitem = serverContextSubMenu.querySelector(".hideserver-item");
|
||||
BDFDB.removeClass(hideitem, BDFDB.disCN.contextmenuitemdisabled);
|
||||
hideitem.addEventListener("click", () => {
|
||||
instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
||||
this.toggleServer(instance.props.guild, instance.props.target, false);
|
||||
});
|
||||
}
|
||||
BDFDB.appendSubMenu(hideritem, serverContextSubMenu);
|
||||
});
|
||||
|
||||
if (!info.guildCreate) {
|
||||
serverContextSubMenu
|
||||
.find(".hideserver-item")
|
||||
.removeClass(BDFDB.disCN.contextmenuitemdisabled)
|
||||
.on("click", () => {
|
||||
$(context).hide();
|
||||
this.hideServer(info);
|
||||
});
|
||||
}
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, serverContextSubMenu);
|
||||
}
|
||||
|
||||
hideServer (info) {
|
||||
var serverObj = BDFDB.getDivOfServer(info.id);
|
||||
|
||||
if (!serverObj) return;
|
||||
|
||||
$(serverObj.div).hide();
|
||||
|
||||
BDFDB.saveData(info.id, {visible:false}, this, "servers");
|
||||
processGuild (instance, wrapper) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || [];
|
||||
this.toggleServer(instance.props.guild, wrapper, !hiddenservers.includes(instance.props.guild.id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showServerModal () {
|
||||
var serverObjs = BDFDB.readServerList();
|
||||
|
||||
var serverHiderModal = $(this.serverHiderModalMarkup);
|
||||
serverHiderModal
|
||||
.on("click", ".folderhideCheckbox", (e) => {
|
||||
serverHiderModal.find(".hidefolder").toggle(!$(e.target).prop("checked"));
|
||||
})
|
||||
.on("click", ".btn-all", () => {
|
||||
var hideAll = $(serverObjs[0].div).is(":visible");
|
||||
for (let serverObj of serverObjs) {
|
||||
$(serverObj.div).toggle(!hideAll);
|
||||
BDFDB.saveData(serverObj.id, {visible:!hideAll}, this, "servers");
|
||||
}
|
||||
$(".serverhiderCheckbox").each((_, checkBox) => {if ($(checkBox).prop("checked") == hideAll) checkBox.click();});
|
||||
let serverHiderModal = BDFDB.htmlToElement(this.serverHiderModalMarkup);
|
||||
let container = serverHiderModal.querySelector(".entries");
|
||||
if (!container) return;
|
||||
|
||||
BDFDB.addChildEventListener(serverHiderModal, "click", ".btn-all", () => {
|
||||
let firstcheckbox = serverHiderModal.querySelector(".serverhiderCheckbox");
|
||||
firstcheckbox.click();
|
||||
serverHiderModal.querySelectorAll(".serverhiderCheckbox").forEach(checkbox => {
|
||||
if (checkbox != firstcheckbox && checkbox.checked != firstcheckbox.checked) checkbox.click();
|
||||
});
|
||||
|
||||
if (!BDFDB.isPluginEnabled("ServerFolders")) serverHiderModal.find(".folderhideSettings").hide();
|
||||
|
||||
for (let serverObj of serverObjs) {
|
||||
|
||||
let badge = serverObj.div.querySelector(BDFDB.dotCN.badge);
|
||||
|
||||
let entry = $(this.serverEntryMarkup);
|
||||
let divider = $(this.dividerMarkup);
|
||||
let isHiddenByFolder = $(serverObj.div).attr("folder") ? true : false;
|
||||
entry.toggleClass("hidefolder", isHiddenByFolder);
|
||||
divider.toggleClass("hidefolder", isHiddenByFolder);
|
||||
serverHiderModal.find(".entries").append(entry).append(divider);
|
||||
entry.find(".serverhiderName")
|
||||
.before(this.createCopyOfServer(serverObj))
|
||||
.text(serverObj.name);
|
||||
entry.find(".serverhiderCheckbox")
|
||||
.prop("checked", $(serverObj.div).is(":visible"))
|
||||
.on("click", (event) => {
|
||||
var visible = $(event.target).prop("checked");
|
||||
$(serverObj.div).toggle(visible);
|
||||
BDFDB.saveData(serverObj.id, {visible:visible}, this, "servers");
|
||||
});
|
||||
|
||||
for (let info of BDFDB.readServerList()) {
|
||||
if (!info.div.getAttribute("folder")) {
|
||||
if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.modaldivider}"></div>`));
|
||||
let entry = BDFDB.htmlToElement(this.serverEntryMarkup);
|
||||
container.appendChild(entry);
|
||||
let name = entry.querySelector(".serverhiderName");
|
||||
name.innerText = info.name || "";
|
||||
name.parentElement.insertBefore(this.createCopyOfServer(info), name);
|
||||
let hidecheckbox = entry.querySelector(".serverhiderCheckbox");
|
||||
hidecheckbox.checked = !BDFDB.isEleHidden(info.div);
|
||||
hidecheckbox.addEventListener("click", e => {
|
||||
this.toggleServer(info, info.div, e.currentTarget.checked);
|
||||
});
|
||||
}
|
||||
}
|
||||
BDFDB.appendModal(serverHiderModal);
|
||||
}
|
||||
|
||||
createCopyOfServer (serverObj) {
|
||||
var serverDiv = serverObj.div;
|
||||
var serverCopy = serverDiv.cloneNode(true);
|
||||
$(serverCopy)
|
||||
.css("display", "")
|
||||
.on("click." + this.name, (e) => {
|
||||
e.preventDefault();
|
||||
serverDiv.querySelector("a").click();
|
||||
})
|
||||
.on("contextmenu." + this.name, (e) => {
|
||||
var handleContextMenu = BDFDB.getKeyInformation({"node":serverDiv.firstElementChild, "key":"handleContextMenu"});
|
||||
if (handleContextMenu) {
|
||||
var data = {
|
||||
preventDefault: a=>a,
|
||||
stopPropagation: a=>a,
|
||||
pageX: e.pageX,
|
||||
pageY: e.pageY,
|
||||
};
|
||||
|
||||
handleContextMenu(data);
|
||||
}
|
||||
});
|
||||
|
||||
createCopyOfServer (info) {
|
||||
let serverCopy = info.div.cloneNode(true);
|
||||
BDFDB.toggleEles(serverCopy, true);
|
||||
BDFDB.removeClass(serverCopy, BDFDB.disCN.guildunread, BDFDB.disCN.guildselected);
|
||||
serverCopy.addEventListener("click", e => {
|
||||
e.preventDefault();
|
||||
info.div.querySelector("a").click();
|
||||
});
|
||||
serverCopy.addEventListener("contextmenu", e => {BDFDB.openGuildContextMenu(info.div, e);});
|
||||
return serverCopy;
|
||||
}
|
||||
|
||||
updateAllServers (write) {
|
||||
for (let serverObj of BDFDB.readServerList()) {
|
||||
var data = BDFDB.loadData(serverObj.id, this, "servers");
|
||||
|
||||
var visible = data && write ? data.visible : $(serverObj.div).is(":visible");
|
||||
$(serverObj.div).toggle(visible);
|
||||
|
||||
BDFDB.saveData(serverObj.id, {visible}, this, "servers");
|
||||
}
|
||||
|
||||
toggleServer (info, target, visible) {
|
||||
if (!info || !target) return;
|
||||
let guilddiv = BDFDB.getParentEle(BDFDB.dotCN.guild, target);
|
||||
if (!guilddiv || guilddiv.getAttribute("folder")) return;
|
||||
BDFDB.toggleEles(guilddiv, visible);
|
||||
let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || [];
|
||||
BDFDB.removeFromArray(hiddenservers, info.id);
|
||||
if (!visible) hiddenservers.push(info.id);
|
||||
BDFDB.saveData("hiddenservers", hiddenservers, this, "hiddenservers");
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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;">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>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", ".reset-button", () => {this.resetAll();});
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, 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.readServerList().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, false);});
|
||||
});
|
||||
});
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.updateHiddenCategory = false;
|
||||
|
||||
this.patchModules = {
|
||||
"Channels":["componentDidMount","componentDidUpdate"],
|
||||
"ChannelItem":"componentDidMount",
|
||||
"ChannelCategoryItem":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
this.categoryMarkup =
|
||||
`<div class="container-hidden">
|
||||
<div class="${BDFDB.disCN.categorycontainerdefault}">
|
||||
<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.categorywrapperdefault + BDFDB.disCN.cursorpointer}" style="flex: 1 1 auto;">
|
||||
<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>
|
||||
</svg>
|
||||
<div class="${BDFDB.disCNS.categorynamedefault + BDFDB.disCNS.categorycolortransition + BDFDB.disCN.overflowellipsis}" style="flex: 1 1 auto;">hidden</div>
|
||||
<div class="${BDFDB.disCNS.categorynamedefault + BDFDB.disCNS.categorycolortransition + BDFDB.disCN.categoryoverflowellipsis}" style="flex: 1 1 auto;">hidden</div>
|
||||
</div>
|
||||
</div>
|
||||
</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;">
|
||||
|
@ -29,97 +32,95 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<path class="${BDFDB.disCN.channelforeground}" fill="currentColor" fill-rule="nonzero" d="M15.1,3.2 L15.1,2 C15.1,0.88 14.05,0 13,0 C11.95,0 10.9,0.88 10.9,2 L10.9,3.2 C10.45,3.2 10,3.68 10,4.16 L10,6.96 C10,7.52 10.45,8 10.9,8 L15.025,8 C15.55,8 16,7.52 16,7.04 L16,4.24 C16,3.68 15.55,3.2 15.1,3.2 Z M14,3 L12,3 L12,1.92857143 C12,1.35714286 12.4666667,1 13,1 C13.5333333,1 14,1.35714286 14,1.92857143 L14,3 Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.channelnamedefaulttext + BDFDB.disCNS.channelname + BDFDB.disCN.overflowellipsis}" style="flex: 1 1 auto;"></div>
|
||||
<div class="${BDFDB.disCNS.channelnamedefaulttext + BDFDB.disCNS.channelname + BDFDB.disCN.channeloverflowellipsis}" style="flex: 1 1 auto;"></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.marginreset}" style="flex: 0 1 auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</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;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="${BDFDB.disCNS.channelcolordefaultvoice + BDFDB.disCN.channelicon}">
|
||||
<path class=${BDFDB.disCN.channelbackground}" fill="currentColor" d="M13.6005009,10 C12.8887426,11.8438372 11.2906136,13.2480521 9.33333333,13.6933333 L9.33333333,12.3133333 C10.5512947,11.950895 11.5614504,11.1062412 12.1398042,10 L13.6005009,10 Z M10.7736513,8.99497564 C10.4978663,9.6613459 9.98676114,10.2040442 9.33333333,10.5133333 L9.33333333,8.99497564 L10.7736513,8.99497564 Z M2,5.84666667 L4.66666667,5.84666667 L8,2.51333333 L8,13.18 L4.66666667,9.84666667 L2,9.84666667 L2,5.84666667 Z"></path>
|
||||
<path class="${BDFDB.disCN.channelbackground}" fill="currentColor" d="M13.6005009,10 C12.8887426,11.8438372 11.2906136,13.2480521 9.33333333,13.6933333 L9.33333333,12.3133333 C10.5512947,11.950895 11.5614504,11.1062412 12.1398042,10 L13.6005009,10 Z M10.7736513,8.99497564 C10.4978663,9.6613459 9.98676114,10.2040442 9.33333333,10.5133333 L9.33333333,8.99497564 L10.7736513,8.99497564 Z M2,5.84666667 L4.66666667,5.84666667 L8,2.51333333 L8,13.18 L4.66666667,9.84666667 L2,9.84666667 L2,5.84666667 Z"></path>
|
||||
<path class="${BDFDB.disCN.channelforeground}" fill="currentColor" fill-rule="nonzero" d="M15.1,3.2 L15.1,2 C15.1,0.88 14.05,0 13,0 C11.95,0 10.9,0.88 10.9,2 L10.9,3.2 C10.45,3.2 10,3.68 10,4.16 L10,6.96 C10,7.52 10.45,8 10.9,8 L15.025,8 C15.55,8 16,7.52 16,7.04 L16,4.24 C16,3.68 15.55,3.2 15.1,3.2 Z M14,3 L12,3 L12,1.92857143 C12,1.35714286 12.4666667,1 13,1 C13.5333333,1 14,1.35714286 14,1.92857143 L14,3 Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.channelnamedefaultvoice + BDFDB.disCNS.channelname + BDFDB.disCN.overflowellipsis}" style="flex: 1 1 auto;"></div>
|
||||
<div class="${BDFDB.disCNS.channelnamedefaultvoice + BDFDB.disCNS.channelname + BDFDB.disCN.channeloverflowellipsis}" style="flex: 1 1 auto;"></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.marginreset}" style="flex: 0 1 auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</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.closed + BDFDB.disCN.categoryiconcollapsed}" width="12" height="12" viewBox="0 0 24 24">
|
||||
<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>
|
||||
</svg>
|
||||
<div class="${BDFDB.disCNS.categorycolortransition + BDFDB.disCNS.overflowellipsis + BDFDB.disCN.categorynamecollapsed}" style="flex: 1 1 auto;"></div>
|
||||
<div class="${BDFDB.disCNS.categorycolortransition + BDFDB.disCNS.categoryoverflowellipsis + BDFDB.disCN.categorynamecollapsed}" style="flex: 1 1 auto;"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.css = `
|
||||
.container-hidden .containerDefault-1ZnADq .iconTransition-2pOJ7l {
|
||||
position: static;
|
||||
}`;
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showText: {value:true, description:"Show hidden Textchannels:"},
|
||||
showVoice: {value:true, description:"Show hidden Voicechannels:"},
|
||||
showCategory: {value:false, description:"Show hidden Categories:"},
|
||||
showAllowedRoles: {value:true, description:"Show allowed Roles on hover:"},
|
||||
showAllowedUsers: {value:true, description:"Show specifically allowed Users on hover:"},
|
||||
showOverWrittenRoles: {value:true, description:"Include overwritten Roles in allowed Roles:"},
|
||||
showDeniedRoles: {value:true, description:"Show denied Roles on hover:"},
|
||||
showDeniedUsers: {value:true, description:"Show denied Users on hover:"},
|
||||
showForNormal: {value:false, description:"Also show Roles/Users for allowed channels:"},
|
||||
showTopic: {value:false, description:"Show the topic of hidden channels:"}
|
||||
},
|
||||
amounts: {
|
||||
hoverDelay: {value:0, description:"Tooltip delay in millisec:"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.React = BDFDB.WebModules.findByProperties("createElement", "cloneElement");
|
||||
this.ChannelTypes = BDFDB.WebModules.findByProperties("ChannelTypes").ChannelTypes;
|
||||
this.UserStore = BDFDB.WebModules.findByProperties("getUsers", "getUser");
|
||||
this.MemberStore = BDFDB.WebModules.findByProperties("getMember", "getMembers");
|
||||
this.GuildStore = BDFDB.WebModules.findByProperties("getGuilds", "getGuild");
|
||||
this.ChannelStore = BDFDB.WebModules.findByProperties("getChannels", "getDMFromUserId");
|
||||
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});
|
||||
|
||||
this.displayHiddenChannels();
|
||||
BDFDB.WebModules.forceAllUpdates(this, "Channels");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -130,9 +131,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
$(".container-hidden").remove();
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".container-hidden");
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -140,273 +140,262 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
processChannels (instance, wrapper, methodnames) {
|
||||
if (instance.props && instance.props.guild) {
|
||||
if (methodnames.includes("componentDidMount")) this.appendHiddenContainer(instance.props.guild);
|
||||
if (methodnames.includes("componentDidUpdate")) this.reappendHiddenContainer(instance.props.guild);
|
||||
}
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
this.updateHiddenCategory = true;
|
||||
}
|
||||
|
||||
displayHiddenChannels () {
|
||||
var serverObj = BDFDB.getSelectedServer();
|
||||
if (serverObj) {
|
||||
var serverID = serverObj.id;
|
||||
if (!document.querySelector(".container-hidden.server" + serverID)) {
|
||||
$(".container-hidden").remove();
|
||||
var types = {
|
||||
"text":0,
|
||||
"voice":2,
|
||||
"category":4
|
||||
};
|
||||
var allChannels = this.ChannelStore.getChannels();
|
||||
var shownChannels = this.GuildChannels.getChannels(serverID);
|
||||
var hiddenChannels = {};
|
||||
|
||||
for (let type in types) hiddenChannels[types[type]] = [];
|
||||
|
||||
for (let channelID in allChannels) {
|
||||
var channel = allChannels[channelID];
|
||||
if (channel.guild_id == serverID) {
|
||||
var isHidden = true;
|
||||
if (channel.type == types.category) {
|
||||
for (let type in types) {
|
||||
for (let shownChannel of shownChannels[types[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);
|
||||
|
||||
processChannelItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel) this.reappendHiddenContainer(this.GuildStore.getGuild(instance.props.channel.guild_id));
|
||||
}
|
||||
|
||||
processChannelCategoryItem (instance, wrapper) {
|
||||
if (instance.props && instance.props.channel) this.reappendHiddenContainer(this.GuildStore.getGuild(instance.props.channel.guild_id));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var count = 0;
|
||||
for (let type in types) {
|
||||
if (!settings.showText && type == "text" || !settings.showVoice && type == "voice" || !settings.showCategory && type == "category") {
|
||||
hiddenChannels[types[type]] = [];
|
||||
else {
|
||||
for (let shownChannel of shownChannels[channel.type]) if (shownChannel.channel.id == channel.id) {
|
||||
isHidden = false;
|
||||
break;
|
||||
}
|
||||
BDFDB.sortArrayByKey(hiddenChannels[types[type]], "name");
|
||||
count += hiddenChannels[types[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)
|
||||
.addClass("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.closed);
|
||||
name.classList.toggle(BDFDB.disCN.categorynamehovered);
|
||||
name.classList.toggle(BDFDB.disCN.categorynamehoveredcollapsed);
|
||||
|
||||
$(category).find(BDFDB.dotCN.channelcontainerdefault).toggle(!svg.classList.contains(BDFDB.disCN.closed));
|
||||
BDFDB.saveData(serverID, !svg.classList.contains(BDFDB.disCN.closed), this, "categorystatus");
|
||||
})
|
||||
.on("mouseenter mouseleave", BDFDB.dotCN.categorycontainerdefault + " > " + BDFDB.dotCN.flex, () => {
|
||||
if (!category.querySelector(BDFDB.dotCN.closed)) {
|
||||
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);
|
||||
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(hiddenChannel, 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);
|
||||
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(hiddenChannel, 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);
|
||||
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(hiddenChannel, 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.closed);
|
||||
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.name);
|
||||
if (BDFDB.getData("showForNormal", this, "settings")) {
|
||||
$(channelist).on("mouseenter." + this.name, BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault, (e) => {
|
||||
var channel = BDFDB.getKeyInformation({"node":e.currentTarget,"key":"channel"});
|
||||
if (channel) this.showAccessRoles(serverObj, channel, e, true);
|
||||
});
|
||||
}
|
||||
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, 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
createHiddenObjContextMenu (hiddenObj, e) {
|
||||
|
||||
reappendHiddenContainer (guild, category = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCNS.scroller + ".container-hidden")) {
|
||||
if (!guild) return;
|
||||
if (guild.id != this.currentGuild) this.appendHiddenContainer(guild);
|
||||
else if (category) {
|
||||
var scroller = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
|
||||
if (!scroller || scroller.lastChild.previousSibling == category) 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 (guild, channel, type, e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var contextMenu = $(`<div class="${BDFDB.disCN.contextmenu} ShowHiddenChannelsContextMenu"><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>`);
|
||||
contextMenu
|
||||
.on("click." + this.name, ".copyid-item", (e2) => {
|
||||
contextMenu.remove();
|
||||
require("electron").clipboard.write({text: hiddenObj.id});
|
||||
});
|
||||
|
||||
BDFDB.appendContextMenu(contextMenu[0], e);
|
||||
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, e);
|
||||
}
|
||||
|
||||
showAccessRoles (serverObj, channel, e, allowed) {
|
||||
if (e.type != "mouseenter" || !serverObj || !channel) return;
|
||||
|
||||
showAccessRoles (guild, channel, e, allowed) {
|
||||
if ((e.type != "mouseenter" && e.type != "mouseover") || !guild || !channel) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
if (!settings.showAllowedRoles && !settings.showDeniedRoles) return;
|
||||
var myMember = this.MemberStore.getMember(serverObj.id, BDFDB.myData.id);
|
||||
var allowedRoles = [], overwrittenRoles = [], deniedRoles = [], deniedUsers = [];
|
||||
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(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));
|
||||
}
|
||||
}
|
||||
|
@ -414,25 +403,33 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
allowedRoles.push({"name":"@everyone"});
|
||||
}
|
||||
var htmlString = ``;
|
||||
if (settings.showTopic && !allowed && channel.topic) {
|
||||
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Topic:</div><div class="${BDFDB.disCNS.flex + BDFDB.disCN.wrap}"><div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-topic" style="border-color: rgba(255, 255, 255, 0.6); height: unset !important; padding-top: 5px; padding-bottom: 5px; max-width: ${window.outerWidth/3}px">${channel.topic}</div></div>`;
|
||||
if (settings.showTopic && !allowed && channel.topic && channel.topic.replace(/[\t\n\r\s]/g, "")) {
|
||||
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Topic:</div><div class="${BDFDB.disCNS.flex + BDFDB.disCN.wrap}"><div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-topic" style="border-color: rgba(255, 255, 255, 0.6); height: unset !important; padding-top: 5px; padding-bottom: 5px; max-width: ${window.outerWidth/3}px">${BDFDB.encodeToHTML(channel.topic)}</div></div>`;
|
||||
}
|
||||
if (allowedRoles.length > 0 || overwrittenRoles.length > 0) {
|
||||
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Allowed Roles:</div><div class="${BDFDB.disCNS.flex + BDFDB.disCN.wrap}">`;
|
||||
for (let role of allowedRoles) {
|
||||
let color = role.colorString ? BDFDB.color2COMP(role.colorString) : [255,255,255];
|
||||
let color = role.colorString ? BDFDB.colorCONVERT(role.colorString, "RGBCOMP") : [255,255,255];
|
||||
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-allowedrole" style="border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCNS.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(role.name)}</div></div>`;
|
||||
}
|
||||
for (let role of overwrittenRoles) {
|
||||
let color = role.colorString ? BDFDB.color2COMP(role.colorString) : [255,255,255];
|
||||
let color = role.colorString ? BDFDB.colorCONVERT(role.colorString, "RGBCOMP") : [255,255,255];
|
||||
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-overwrittenrole" style="border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCNS.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}" style="text-decoration: line-through !important;">${BDFDB.encodeToHTML(role.name)}</div></div>`;
|
||||
}
|
||||
htmlString += `</div>`;
|
||||
}
|
||||
if (allowedUsers.length > 0) {
|
||||
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Allowed Users:</div><div class="${BDFDB.disCNS.flex + BDFDB.disCN.wrap}">`;
|
||||
for (let user of allowedUsers) {
|
||||
let color = user.colorString ? BDFDB.colorCONVERT(user.colorString, "RGBCOMP") : [255,255,255];
|
||||
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-denieduser" style="border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCNS.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(user.nick ? user.nick : user.name)}</div></div>`;
|
||||
}
|
||||
htmlString += `</div>`;
|
||||
}
|
||||
if (deniedRoles.length > 0) {
|
||||
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Denied Roles:</div><div class="${BDFDB.disCNS.flex + BDFDB.disCN.wrap}">`;
|
||||
for (let role of deniedRoles) {
|
||||
let color = role.colorString ? BDFDB.color2COMP(role.colorString) : [255,255,255];
|
||||
let color = role.colorString ? BDFDB.colorCONVERT(role.colorString, "RGBCOMP") : [255,255,255];
|
||||
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-deniedrole" style="border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCNS.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(role.name)}</div></div>`;
|
||||
}
|
||||
htmlString += `</div>`;
|
||||
|
@ -440,47 +437,48 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
if (deniedUsers.length > 0) {
|
||||
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Denied Users:</div><div class="${BDFDB.disCNS.flex + BDFDB.disCN.wrap}">`;
|
||||
for (let user of deniedUsers) {
|
||||
let color = user.colorString ? BDFDB.color2COMP(user.colorString) : [255,255,255];
|
||||
let color = user.colorString ? BDFDB.colorCONVERT(user.colorString, "RGBCOMP") : [255,255,255];
|
||||
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCN.wrap + BDFDB.disCNS.size12 + BDFDB.disCN.weightmedium} SHC-denieduser" style="border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCNS.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(user.nick ? user.nick : user.name)}</div></div>`;
|
||||
}
|
||||
htmlString += `</div>`;
|
||||
}
|
||||
if (htmlString) {
|
||||
var customTooltipCSS = `
|
||||
.showhiddenchannels-tooltip {
|
||||
max-width: ${window.outerWidth/2}px !important;
|
||||
}`;
|
||||
var tooltip = BDFDB.createTooltip(htmlString, e.currentTarget, {type:"right", selector:"showhiddenchannels-tooltip", html:true, css:customTooltipCSS});
|
||||
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";
|
||||
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")});
|
||||
var style = getComputedStyle(e.currentTarget);
|
||||
tooltip.style.setProperty("top", BDFDB.getRects(tooltip).top - style.paddingBottom.replace("px","")/2 + style.paddingTop.replace("px","")/2 + "px");
|
||||
}
|
||||
}
|
||||
|
||||
appendToChannelList (category) {
|
||||
var channelList = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
|
||||
if (channelList && category) channelList.insertBefore(category,channelList.lastChild);
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
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>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var amounts = BDFDB.getAllData(this, "amounts");
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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>`;
|
||||
}
|
||||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateHiddenCategory) {
|
||||
document.querySelectorAll(".container-hidden").forEach(category => {category.remove();});
|
||||
this.displayHiddenChannels();
|
||||
this.updateHiddenCategory = false;
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.WebModules.forceAllUpdates(this, "Channels");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"LazyImageZoomable":"componentDidMount",
|
||||
"StandardSidebarView":"componentWillUnmount"
|
||||
};
|
||||
|
||||
this.css = `
|
||||
.image-details .image-details-size {
|
||||
margin: 0 10px;
|
||||
|
@ -16,54 +19,41 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
margin: 10px 0;
|
||||
}
|
||||
`;
|
||||
|
||||
this.updateDetails = false;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showOnHover: {value:false, description:"Show the details as Tooltip instead:"}
|
||||
},
|
||||
amounts: {
|
||||
hoverDelay: {value:0, description:"Tooltip delay in millisec:"}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return return;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.tagName && (node.querySelector(BDFDB.dotCN.message) || node.classList.contains(BDFDB.disCN.message))) {
|
||||
this.addDetails(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
this.addDetails(document);
|
||||
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -74,9 +64,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -84,94 +74,71 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
this.addDetails(document);
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver"}, {childList:true, subtree:true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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.updateDetails = true;
|
||||
}
|
||||
|
||||
addDetails (container) {
|
||||
let scroller = document.querySelector(BDFDB.dotCNS.chat + BDFDB.dotCN.messages);
|
||||
if (!container || typeof container.querySelectorAll != "function" || !scroller) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
container.querySelectorAll(BDFDB.dotCN.messageaccessory + " > " + BDFDB.dotCN.imagewrapper).forEach(image => {
|
||||
var data = this.getImageData(image);
|
||||
if (data) {
|
||||
image.classList.add("image-details-added");
|
||||
if (!settings.showOnHover) {
|
||||
$(`<div class="image-details-wrapper"><div class="image-details"><a class="image-details-link" title="${data.url}" href="${data.url}" target="_blank" rel="noreferrer noopener">${data.filename}</a><label class="image-details-size ${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">${BDFDB.formatBytes(data.size)}</label><label class="image-details-dimensions ${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.modedefault + BDFDB.disCN.primary}">${data.width}x${data.height}px</label></div></div>`).insertBefore(image).append(image);
|
||||
scroller.scrollTop += image.parentElement.getBoundingClientRect().height - image.getBoundingClientRect().height;
|
||||
}
|
||||
else {
|
||||
$(image).on("mouseenter." + this.name, () => {
|
||||
BDFDB.createTooltip(`<div class="image-details-tooltip-name">${data.filename}</div><div class="image-details-tooltip-size">${BDFDB.formatBytes(data.size)}</div><div class="image-details-tooltip-dimensions">${data.width}x${data.height}px</div>`, image, {type:"right", html:true, selector:"image-details-tooltip"});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
resetImage (image) {
|
||||
image.classList.remove("image-details-added");
|
||||
$(image).off("." + this.name);
|
||||
var wrapper = image.parentElement;
|
||||
if (wrapper.classList.contains("image-details-wrapper")) {
|
||||
BDFDB.removeClass(image, "image-details-added");
|
||||
image.removeEventListener("mouseenter", image.mouseenterShowImageDetails);
|
||||
let wrapper = image.parentElement;
|
||||
if (BDFDB.containsClass(wrapper, "image-details-wrapper")) {
|
||||
wrapper.parentElement.insertBefore(image, wrapper);
|
||||
wrapper.remove();
|
||||
}
|
||||
}
|
||||
|
||||
getImageData (attachment) {
|
||||
var messageInfo = BDFDB.getKeyInformation({"node":attachment,"key":"message","up":true,"time":1000});
|
||||
if (messageInfo) {
|
||||
var message = null, temp = attachment;
|
||||
while (message == null || temp.parentElement) {
|
||||
temp = temp.parentElement;
|
||||
if (temp.classList && temp.classList.contains(BDFDB.disCN.message)) message = temp;
|
||||
|
||||
processLazyImageZoomable (instance, image) {
|
||||
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);
|
||||
}
|
||||
if (message) {
|
||||
var pos = $(message).find(BDFDB.dotCN.imagewrapper).index(attachment);
|
||||
var info = messageInfo.attachments;
|
||||
if (info && pos > -1) info = info[pos];
|
||||
return info;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
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>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);})
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let amounts = BDFDB.getAllData(this, "amounts");
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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>`;
|
||||
}
|
||||
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 = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateDetails) {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);});
|
||||
this.addDetails(document);
|
||||
this.updateDetails = false;
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount"
|
||||
};
|
||||
|
||||
this.languages = {};
|
||||
this.langDictionary = [];
|
||||
this.dictionary = [];
|
||||
|
@ -20,7 +22,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.similarWordsContextSubMenuMarkup =
|
||||
`<div class="${BDFDB.disCN.contextmenu} spellcheck-submenu">
|
||||
<div class="${BDFDB.disCN.contextmenuitem} nosimilars-item">
|
||||
|
@ -28,20 +30,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
this.spellCheckLayerMarkup =
|
||||
`<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,
|
||||
|
@ -55,8 +49,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
background-repeat: repeat-x;
|
||||
background-position: bottom;
|
||||
}`;
|
||||
|
||||
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
disableDiscordSpellcheck: {value:true, description:"Disable Discord's internal Spellcheck:"}
|
||||
|
@ -71,64 +65,34 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -138,11 +102,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
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();
|
||||
|
||||
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -151,77 +116,103 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
changeLanguageStrings () {
|
||||
this.spellCheckContextEntryMarkup = this.spellCheckContextEntryMarkup.replace("REPLACE_context_spellcheck_text", this.labels.context_spellcheck_text);
|
||||
this.spellCheckContextEntryMarkup = this.spellCheckContextEntryMarkup.replace("REPLACE_context_similarwords_text", this.labels.context_similarwords_text);
|
||||
|
||||
|
||||
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"));
|
||||
});
|
||||
|
||||
BDFDB.appendSubMenu(e.currentTarget, similarWordsContextSubMenu);
|
||||
}
|
||||
|
||||
|
||||
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("background", "none", "important");
|
||||
spellcheck.style.setProperty("mask", "none", "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.addEventListener(this, textarea, "scroll", e => {
|
||||
spellcheck.scrollTop = textarea.scrollTop;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
replaceWord (textarea, word, replacement) {
|
||||
if (!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"));
|
||||
textarea.dispatchEvent(new Event("keyup"));
|
||||
textarea.dispatchEvent(new Event("change"));
|
||||
}
|
||||
|
||||
|
||||
addToOwnDictionary (word) {
|
||||
word = word.split(" ")[0].split("\n")[0].split("\r")[0].split("\t")[0];
|
||||
if (word) {
|
||||
|
@ -238,7 +229,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeFromOwnDictionary (e) {
|
||||
var entry = e.currentTarget.parentElement;
|
||||
var word = entry.querySelector(".entryword").textContent;
|
||||
|
@ -249,27 +240,28 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
BDFDB.saveData(lang, ownDictionary, this, "owndics");
|
||||
this.dictionary = this.langDictionary.concat(ownDictionary);
|
||||
}
|
||||
|
||||
|
||||
openDropdownMenu (settingspanel, e) {
|
||||
var selectControl = e.currentTarget;
|
||||
var selectWrap = selectControl.parentElement;
|
||||
|
||||
if (selectWrap.classList.contains(BDFDB.disCN.selectisopen)) return;
|
||||
|
||||
let selectControl = e.currentTarget;
|
||||
let selectWrap = selectControl.parentElement;
|
||||
let plugincard = BDFDB.getParentEle("li", selectWrap);
|
||||
|
||||
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.name, 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;
|
||||
this.setDictionary(language);
|
||||
BDFDB.saveData(type, language, this, "choices");
|
||||
|
||||
|
||||
var listcontainer = settingspanel.querySelector(".word-list");
|
||||
if (listcontainer) {
|
||||
var ownDictionary = BDFDB.loadData(language, this, "owndics") || [];
|
||||
|
@ -280,15 +272,18 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
listcontainer.innerHTML = containerhtml;
|
||||
}
|
||||
});
|
||||
$(document).on("mousedown.select" + this.name, (e2) => {
|
||||
if (e2.target.parentElement == selectMenu) return;
|
||||
$(document).off("mousedown.select" + this.name);
|
||||
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) {
|
||||
var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
|
||||
for (var key in this.languages) {
|
||||
|
@ -296,50 +291,9 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
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];
|
||||
return BDFDB.htmlToElement(menuhtml);
|
||||
}
|
||||
|
||||
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.name).off("scroll." + this.name)
|
||||
.on("keyup." + this.name, (e) => {
|
||||
clearTimeout(textarea.spellchecktimeout);
|
||||
textarea.spellchecktimeout = setTimeout(() => {updateSpellcheck();},100);
|
||||
})
|
||||
.on("scroll." + this.name, (e) => {
|
||||
$(spellcheck).scrollTop(textarea.scrollTop);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setDictionary (lang) {
|
||||
this.dictionary = BDFDB.loadData(lang, this, "owndics") || [];
|
||||
this.killLanguageToast();
|
||||
|
@ -362,29 +316,29 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
killLanguageToast () {
|
||||
if (this.languageToast && typeof this.languageToast.close == "function") {
|
||||
clearInterval(this.languageToast.interval);
|
||||
this.languageToast.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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(" ");
|
||||
}
|
||||
|
||||
|
||||
isWordNotInDictionary (word) {
|
||||
var wordLow = word.toLowerCase();
|
||||
var wordWithoutSymbols = wordLow.replace(/[0-9\µ\@\$\£\€\¥\¢\²\³\>\<\|\,\;\.\:\_\#\+\*\~\?\¿\\\´\`\}\=\]\)\[\(\{\/\&\%\§\"\!\¡\^\°\n\t\r]/g, "");
|
||||
return (wordLow.indexOf("http://") != 0 && wordLow.indexOf("https://") != 0 && wordWithoutSymbols && Array.isArray(this.dictionary) && this.dictionary.length > 0 && !this.dictionary.includes(wordLow) && !this.dictionary.includes(wordWithoutSymbols));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
getSimilarWords (word) {
|
||||
var maxAmount = BDFDB.getData("maxSimilarAmount", this, "amounts"), similarWords = [];
|
||||
if (maxAmount > 0) {
|
||||
|
@ -409,7 +363,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
return similarWords;
|
||||
}
|
||||
|
||||
|
||||
wordSimilarity (a, b) {
|
||||
var temp;
|
||||
if (a.length === 0 || b.length === 0 || a.length - b.length > 3 || b.length - a.length > 3) { return 0; }
|
||||
|
@ -432,12 +386,13 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var choices = BDFDB.getAllData(this, "choices");
|
||||
var amounts = BDFDB.getAllData(this, "amounts");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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>`;
|
||||
|
@ -451,21 +406,21 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
settingshtml += `<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} entryword">${word}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-word"></div></div>`;
|
||||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(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");
|
||||
});
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
setLabelsByLanguage () {
|
||||
switch (BDFDB.getDiscordLanguage().id) {
|
||||
case "hr": //croatian
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.stalkerOnlineList = {};
|
||||
|
||||
|
||||
this.checkInterval = null;
|
||||
|
||||
|
||||
this.timeLog = [];
|
||||
|
||||
this.timeLogModalMarkup =
|
||||
`<span class=""${this.name}-modal DevilBro-modal"">
|
||||
`<span class="${this.name}-modal DevilBro-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
<div class="${BDFDB.disCN.modal}">
|
||||
<div class="${BDFDB.disCN.modalinner}">
|
||||
|
@ -21,12 +19,16 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<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}">User LogIn/-Out Timelog</h4>
|
||||
</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>
|
||||
<button type="button" class="${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">
|
||||
<svg name="Close" width="18" height="18" viewBox="0 0 12 12" style="flex: 0 1 auto;">
|
||||
<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>
|
||||
</button>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.themeghosthairline}">
|
||||
<div class="${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner} entries">
|
||||
|
@ -48,15 +50,12 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
<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.disCNS.modaldivider + BDFDB.disCN.modaldividerdefault}"></div>`;
|
||||
|
||||
|
||||
this.dividerMarkup = `<div class="${BDFDB.disCN.modaldivider}"></div>`;
|
||||
|
||||
this.css = `
|
||||
.guilds > .friends-online {
|
||||
cursor: pointer;
|
||||
}
|
||||
.${this.name}-modal .log-time {
|
||||
width: 100px;
|
||||
width: 110px;
|
||||
}
|
||||
.${this.name}-modal .log-avatar {
|
||||
width: 35px;
|
||||
|
@ -65,25 +64,25 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
background-position: center;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.StalkerNotifications-settings .avatar-list {
|
||||
.${this.name}-settings .avatar-list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.StalkerNotifications-settings .type-toast, .StalkerNotifications-settings .type-desktop {
|
||||
.${this.name}-settings .type-toast, .${this.name}-settings .type-desktop {
|
||||
border-radius: 3px;
|
||||
padding: 0 3px;
|
||||
}
|
||||
.StalkerNotifications-settings .type-toast {
|
||||
.${this.name}-settings .type-toast {
|
||||
background-color: #7289DA;
|
||||
}
|
||||
.StalkerNotifications-settings .type-desktop {
|
||||
.${this.name}-settings .type-desktop {
|
||||
background-color: #43B581;
|
||||
}
|
||||
.StalkerNotifications-settings .settings-avatar.desktop {
|
||||
.${this.name}-settings .settings-avatar.desktop {
|
||||
border-color: #43B581;
|
||||
}
|
||||
.StalkerNotifications-settings .settings-avatar {
|
||||
.${this.name}-settings .settings-avatar {
|
||||
margin: 5px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
|
@ -94,32 +93,34 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
}
|
||||
.StalkerNotifications-settings .settings-avatar.desktop {
|
||||
.${this.name}-settings .settings-avatar.desktop {
|
||||
border-color: #43B581;
|
||||
}
|
||||
.StalkerNotifications-settings .settings-avatar.disabled {
|
||||
.${this.name}-settings .settings-avatar.disabled {
|
||||
border-color: #36393F;
|
||||
filter: grayscale(100%) brightness(50%);
|
||||
}
|
||||
.StalkerNotifications-settings .settings-avatar ${BDFDB.dotCN.hovercardbutton} {
|
||||
.${this.name}-settings .settings-avatar ${BDFDB.dotCN.hovercardbutton} {
|
||||
position: relative;
|
||||
top: -10px;
|
||||
right: -25px;
|
||||
}
|
||||
.StalkerNotifications-settings .settings-avatar:not(:hover) ${BDFDB.dotCN.hovercardbutton} {
|
||||
.${this.name}-settings .settings-avatar:not(:hover) ${BDFDB.dotCN.hovercardbutton} {
|
||||
opacity: 1;
|
||||
}
|
||||
.StalkerNotifications-settings .disable-all {
|
||||
color: white;
|
||||
background-color: #36393F;
|
||||
}`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
muteOnDND: {value:false, description:"Do not notify me when I am DnD:"},
|
||||
onlyOnOnline: {value:false, description:"Only notify me when a User logs in:"},
|
||||
openOnClick: {value:false, description:"Open the DM when you click a Notification:"}
|
||||
},
|
||||
notificationsounds: {
|
||||
toastonline: {value:{url:null,song:null,mute:false}},
|
||||
toastoffline: {value:{url:null,song:null,mute:false}},
|
||||
desktoponline: {value:{url:null,song:null,mute:false}},
|
||||
desktopoffline: {value:{url:null,song:null,mute:false}}
|
||||
},
|
||||
amounts: {
|
||||
checkInterval: {value:10, description:"Check Users every X seconds:"}
|
||||
}
|
||||
|
@ -127,36 +128,39 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.ChannelUtils = BDFDB.WebModules.findByProperties("getDMFromUserId");
|
||||
this.ChannelSwitchUtils = BDFDB.WebModules.findByProperties("selectPrivateChannel");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatuses", "getOnlineFriendCount");
|
||||
this.PrivateChannelUtils = BDFDB.WebModules.findByProperties("openPrivateChannel");
|
||||
this.UserMetaStore = BDFDB.WebModules.findByProperties("getStatus", "getOnlineFriendCount");
|
||||
this.UserUtils = BDFDB.WebModules.findByProperties("getUsers");
|
||||
|
||||
|
||||
for (let id in BDFDB.loadAllData(this, "users")) {
|
||||
this.stalkerOnlineList[id] = this.UserMetaStore.getStatus(id) != "offline";
|
||||
}
|
||||
|
||||
this.startInterval();
|
||||
|
||||
this.startInterval();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -166,7 +170,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
clearInterval(this.checkInterval);
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
|
@ -175,80 +179,28 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
createSettingsAvatarHtml (user, settings) {
|
||||
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
|
||||
return `<div class="settings-avatar${settings.desktop ? " desktop" : ""}${settings.disabled ? " disabled" : ""}" user-id="${user.id}" style="background-image: url(${data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(user.id))});"><div class="${BDFDB.disCN.hovercardbutton} remove-user"></div></div>`;
|
||||
}
|
||||
|
||||
startInterval () {
|
||||
clearInterval(this.checkInterval);
|
||||
this.checkInterval = setInterval(() => {
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let notificationsound = BDFDB.loadAllData(this, "notificationsound");
|
||||
let users = BDFDB.loadAllData(this, "users");
|
||||
for (let id in users) {
|
||||
let online = this.UserMetaStore.getStatus(id) != "offline";
|
||||
let user = this.UserUtils.getUser(id);
|
||||
if (user && this.stalkerOnlineList[id] != online && !users[id].disabled) {
|
||||
this.timeLog.push({user, online, time: new Date()});
|
||||
if (!(settings.onlyOnOnline && !online) && !(settings.muteOnDND && BDFDB.getUserStatus() == "dnd")) {
|
||||
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
|
||||
let string = `${BDFDB.encodeToHTML(data.name ? data.name : user.username)} is ${online ? "online" : "offline"}.`;
|
||||
let avatar = data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(user.id));
|
||||
let openChannel = () => {
|
||||
if (settings.openOnClick){
|
||||
let DMid = this.ChannelUtils.getDMFromUserId(user.id);
|
||||
if (DMid) {
|
||||
require("electron").remote.getCurrentWindow().maximize();
|
||||
this.ChannelSwitchUtils.selectPrivateChannel(DMid);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!users[id].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});
|
||||
$(toast).on("click." + this.name, openChannel);
|
||||
}
|
||||
else {
|
||||
let notificationsound = BDFDB.loadAllData(this, "notificationsound");
|
||||
BDFDB.showDesktopNotification(string, {icon:avatar, timeout:5000, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.stalkerOnlineList[id] = online;
|
||||
}
|
||||
},BDFDB.getData("checkInterval", this, "amounts") * 1000);
|
||||
}
|
||||
|
||||
saveAudio (settingspanel) {
|
||||
var successSavedAudio = (parsedurl, parseddata) => {
|
||||
saveAudio (settingspanel, option) {
|
||||
let successSavedAudio = (parsedurl, parseddata) => {
|
||||
if (parsedurl && parseddata) BDFDB.showToast(`Sound was saved successfully.`, {type:"success"});
|
||||
let notificationsound = BDFDB.loadAllData(this, "notificationsound");
|
||||
let notificationsound = BDFDB.getData(option, this, "notificationsounds");
|
||||
notificationsound.url = parsedurl;
|
||||
notificationsound.song = parseddata;
|
||||
BDFDB.saveAllData(notificationsound, this, "notificationsound");
|
||||
BDFDB.saveData(option, notificationsound, this, "notificationsounds");
|
||||
};
|
||||
|
||||
var url = settingspanel.querySelector(".songInput").value;
|
||||
|
||||
let url = settingspanel.querySelector(`.songInput[option="${option}"]`).value;
|
||||
if (url.length == 0) {
|
||||
BDFDB.showToast(`Sound was set to the default sound.`, {type:"warn"});
|
||||
BDFDB.showToast(`Sound file was removed.`, {type:"warn"});
|
||||
successSavedAudio(url, url);
|
||||
}
|
||||
else if (url.indexOf("http") == 0) {
|
||||
require("request")(url, (error, response, result) => {
|
||||
if (response) {
|
||||
var type = response.headers["content-type"];
|
||||
let type = response.headers["content-type"];
|
||||
if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) {
|
||||
successSavedAudio(url, url);
|
||||
return;
|
||||
|
@ -259,46 +211,95 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
else {
|
||||
require("fs").readFile(url, (error, response) => {
|
||||
if (error) {
|
||||
BDFDB.showToast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
||||
}
|
||||
else {
|
||||
successSavedAudio(url, `data:audio/mpeg;base64,${response.toString("base64")}`);
|
||||
}
|
||||
if (error) BDFDB.showToast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
||||
else successSavedAudio(url, `data:audio/mpeg;base64,${response.toString("base64")}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
showTimeLog () {
|
||||
var timeLogModal = $(this.timeLogModalMarkup);
|
||||
|
||||
createSettingsAvatarHtml (user, settings) {
|
||||
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
|
||||
return `<div class="settings-avatar${settings.desktop ? " desktop" : ""}${settings.disabled ? " disabled" : ""}" user-id="${user.id}" style="background-image: url(${data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(user.id))});"><div class="${BDFDB.disCN.hovercardbutton} remove-user"></div></div>`;
|
||||
}
|
||||
|
||||
startInterval () {
|
||||
clearInterval(this.checkInterval);
|
||||
this.checkInterval = setInterval(() => {
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let users = BDFDB.loadAllData(this, "users");
|
||||
for (let id in users) {
|
||||
let online = this.UserMetaStore.getStatus(id) != "offline";
|
||||
let user = this.UserUtils.getUser(id);
|
||||
if (user && !user.disabled && this.stalkerOnlineList[id] != online) {
|
||||
this.timeLog.push({user, online, time: new Date()});
|
||||
if (!(settings.onlyOnOnline && !online) && !(settings.muteOnDND && BDFDB.getUserStatus() == "dnd")) {
|
||||
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
|
||||
let string = `${BDFDB.encodeToHTML(data.name ? data.name : user.username)} is ${online ? "online" : "offline"}.`;
|
||||
let avatar = data.removeIcon ? "" : (data.url ? data.url : BDFDB.getUserAvatar(user.id));
|
||||
let openChannel = () => {
|
||||
if (settings.openOnClick) {
|
||||
let DMid = this.ChannelUtils.getDMFromUserId(user.id)
|
||||
if (DMid) this.ChannelSwitchUtils.selectPrivateChannel(DMid);
|
||||
else this.PrivateChannelUtils.openPrivateChannel(BDFDB.myData.id, user.id);
|
||||
require("electron").remote.getCurrentWindow().maximize();
|
||||
}
|
||||
};
|
||||
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.addEventListener("click", openChannel);
|
||||
let notificationsound = BDFDB.getData(online ? "toastonline" : "toastoffline", this, "notificationsounds");
|
||||
if (!notificationsound.mute && notificationsound.song) {
|
||||
let audio = new Audio();
|
||||
audio.src = notificationsound.song;
|
||||
audio.play();
|
||||
}
|
||||
}
|
||||
else {
|
||||
let notificationsound = BDFDB.getData(online ? "desktoponline" : "desktopoffline", this, "notificationsounds");
|
||||
BDFDB.showDesktopNotification(string, {icon:avatar, timeout:5000, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.stalkerOnlineList[id] = online;
|
||||
}
|
||||
},BDFDB.getData("checkInterval", this, "amounts") * 1000);
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
timeLogModal.find(BDFDB.dotCN.modaldivider + ":last-of-type").remove();
|
||||
BDFDB.appendModal(timeLogModal);
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var amounts = BDFDB.getAllData(this, "amounts");
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var users = BDFDB.loadAllData(this, "users");
|
||||
var notificationsound = BDFDB.loadAllData(this, "notificationsound");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
|
||||
let amounts = BDFDB.getAllData(this, "amounts");
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let users = BDFDB.loadAllData(this, "users");
|
||||
let notificationsounds = BDFDB.getAllData(this, "notificationsounds");
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">Add User:</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" value="" placeholder="UserID" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.size16}" id="input-userid"></div><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-add btn-adduser" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></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>`;
|
||||
}
|
||||
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>`;
|
||||
}
|
||||
if ("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;">Desktop 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" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} mute-checkbox"${notificationsound.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" value="${notificationsound.url ? notificationsound.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" 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>`;
|
||||
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;">Click on a Icon to toggle <label class="type-toast">Toast</label> Notifications for that User:</h3></div>`;
|
||||
if ("Notification" in window) 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;">Rightclick on a Icon to toggle <label class="type-desktop">Desktop</label> Notifications for that User:</h3></div>`;
|
||||
settingshtml += `<div class="avatar-list ${BDFDB.disCN.marginbottom8}">`;
|
||||
|
@ -309,74 +310,72 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
settingshtml += `</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;">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 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;">Timelog of LogIns/-Outs:</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-timelog" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Timelog</div></button></div>`;
|
||||
settingshtml += `</div>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", ".settings-checkbox", () => {this.updateSettings(settingspanel);})
|
||||
.on("click", ".btn-savesong", () => {this.saveAudio(settingspanel);})
|
||||
.on("click", ".mute-checkbox", (e) => {
|
||||
var notificationsound = BDFDB.loadAllData(this, "notificationsound");
|
||||
notificationsound.mute = e.currentTarget.checked;
|
||||
BDFDB.saveAllData(notificationsound, this, "notificationsound");
|
||||
})
|
||||
.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, {"desktop":desktopoff,"disabled":false}, this, "users");
|
||||
})
|
||||
.on("click", ".settings-avatar", (e) => {
|
||||
if (e.target.classList.contains("remove-user")) return;
|
||||
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, {"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");
|
||||
avatar.classList.toggle("disabled", disableon);
|
||||
avatar.classList.toggle("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");
|
||||
settingspanel.querySelectorAll(".settings-avatar").forEach(entry => {entry.remove();});
|
||||
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");
|
||||
settingspanel.querySelectorAll(".settings-avatar").forEach(entry => {entry.remove();});
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
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.name + "-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.name + "-settings .settings-avatar");
|
||||
let listhtml = `<div class="avatar-list ${BDFDB.disCN.marginbottom8}">`;
|
||||
let users = BDFDB.loadAllData(this, "users");
|
||||
for (let id in users) {
|
||||
|
@ -385,19 +384,19 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
$(document).on("click." + this.name, "a[href^='https://steamcommunity.com/profiles/']", (e) => {
|
||||
if (require("electron").shell.openExternal("steam://openurl/" + e.currentTarget.href)) {
|
||||
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");
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
@ -41,9 +41,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
$(document).off("click." + this.name, "a[href^='https://steamcommunity.com/profiles/']");
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"NameTag":"componentDidMount",
|
||||
"MessageUsername":"componentDidMount"
|
||||
};
|
||||
|
||||
this.css = `
|
||||
.TRE-tag {
|
||||
border-radius: 3px;
|
||||
|
@ -16,20 +19,20 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
height: 15px;
|
||||
line-height: 13px;
|
||||
margin-left: 6px;
|
||||
overflow: hidden;
|
||||
padding: 1px 2px;
|
||||
text-overflow: ellipsis;
|
||||
text-transform: uppercase;
|
||||
text-indent: 0px !important;
|
||||
vertical-align: top;
|
||||
}
|
||||
%{BDFDB.dotCN.messagecompact} .TRE-tag {
|
||||
${BDFDB.dotCN.messagegroupcompact} .TRE-tag {
|
||||
margin-left: 2px;
|
||||
margin-right: 6px;
|
||||
}`;
|
||||
|
||||
this.updateTags = false;
|
||||
|
||||
|
||||
this.tagMarkup = `<span class="TRE-tag"><span class="role-inner"></span></span>`;
|
||||
|
||||
|
||||
this.defaults = {
|
||||
settings: {
|
||||
showInChat: {value:true, description:"Show Tag in Chat Window."},
|
||||
|
@ -45,83 +48,33 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
|
||||
this.GuildPerms = BDFDB.WebModules.findByProperties("getHighestRole");
|
||||
this.GuildStore = BDFDB.WebModules.findByProperties("getGuild");
|
||||
this.UserGuildState = BDFDB.WebModules.findByProperties("getGuildId", "getLastSelectedGuildId");
|
||||
|
||||
var observer = null;
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (node && node.querySelector(BDFDB.dotCN.memberusername) && BDFDB.getData("showInMemberList", this, "settings")) {
|
||||
this.addRoleTag(node, "list", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.members, {name:"userListObserver",instance:observer}, {childList:true});
|
||||
|
||||
observer = new MutationObserver((changes, _) => {
|
||||
changes.forEach(
|
||||
(change, i) => {
|
||||
if (change.addedNodes) {
|
||||
change.addedNodes.forEach((node) => {
|
||||
if (BDFDB.getData("showInChat", this, "settings")) {
|
||||
var compact = document.querySelector(BDFDB.dotCN.messagegroup + BDFDB.dotCN.messagecompact);
|
||||
if (!compact) {
|
||||
if (node && node.tagName && node.querySelector(BDFDB.dotCN.messageusernamewrapper)) {
|
||||
this.addRoleTag(node, "chat", compact);
|
||||
}
|
||||
else if (node && node.classList && node.classList.contains(BDFDB.disCN.messagetext)) {
|
||||
this.addRoleTag($(BDFDB.dotCN.messagegroup).has(node)[0], "chat", compact);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (node && node.tagName && node.querySelector(BDFDB.dotCN.messageusernamewrapper)) {
|
||||
if (node.classList.contains(BDFDB.disCN.messagemarkup)) {
|
||||
this.addRoleTag(node, "chat", compact);
|
||||
}
|
||||
else {
|
||||
var markups = node.querySelectorAll(BDFDB.dotCN.messagemarkup);
|
||||
for (var i = 0; i < markups.length; i++) {
|
||||
this.addRoleTag(markups[i], "chat", compact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver",instance:observer}, {childList:true, subtree:true});
|
||||
|
||||
this.loadRoleTags();
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -132,9 +85,8 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
document.querySelectorAll(".TRE-tag").forEach(node=>{node.remove();});
|
||||
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.removeEles(".TRE-tag");
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -142,168 +94,122 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
onSwitch () {
|
||||
if (typeof BDFDB === "object") {
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.members, {name:"userListObserver"}, {childList:true});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.messages, {name:"chatWindowObserver"}, {childList:true, subtree:true});
|
||||
this.loadRoleTags();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
updateSettings (settingspanel) {
|
||||
var settings = {};
|
||||
for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) {
|
||||
settings[input.value] = input.checked;
|
||||
}
|
||||
this.updateTags = true;
|
||||
BDFDB.saveAllData(settings, this, "settings");
|
||||
}
|
||||
|
||||
loadRoleTags() {
|
||||
document.querySelectorAll(".TRE-tag").forEach(node=>{node.remove();});
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
if (settings.showInMemberList) {
|
||||
for (let user of document.querySelectorAll(BDFDB.dotCN.member)) {
|
||||
this.addRoleTag(user, "list", false);
|
||||
}
|
||||
}
|
||||
if (settings.showInChat) {
|
||||
for (let user of document.querySelectorAll(BDFDB.dotCN.messagegroup)) {
|
||||
let compact = user.classList.contains(BDFDB.disCN.messagecompact);
|
||||
if (!compact) {
|
||||
this.addRoleTag(user, "chat", compact);
|
||||
}
|
||||
else {
|
||||
for (let message of document.querySelectorAll(BDFDB.dotCN.messagemarkup)) {
|
||||
this.addRoleTag(message, "chat", compact);
|
||||
}
|
||||
}
|
||||
}
|
||||
processNameTag (instance, wrapper) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
addRoleTag (wrapper, type, compact) {
|
||||
if (!wrapper || !BDFDB.getSelectedServer()) return;
|
||||
var guild = this.GuildStore.getGuild(this.UserGuildState.getGuildId());
|
||||
var member = wrapper.querySelector(BDFDB.dotCN.memberusername) || wrapper.querySelector(BDFDB.dotCN.messageusernamewrapper);
|
||||
if (compact) wrapper = $(BDFDB.dotCN.messagegroup).has(wrapper)[0];
|
||||
if (member && member.tagName && !member.querySelector(".TRE-tag")) {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var userInfo =
|
||||
compact ? BDFDB.getKeyInformation({"node":wrapper,"key":"message"}).author : BDFDB.getKeyInformation({"node":wrapper,"key":"user"});
|
||||
if (!userInfo || (userInfo.bot && settings.disableForBots)) return;
|
||||
var userID = userInfo.id;
|
||||
var role = this.GuildPerms.getHighestRole(guild, userID);
|
||||
|
||||
if ((role && (role.colorString || settings.includeColorless)) || userID == 278543574059057154) {
|
||||
var roleColor = role && role.colorString ? BDFDB.color2COMP(role.colorString) : [255,255,255];
|
||||
var roleName = role ? role.name : "";
|
||||
var totalwidth, oldwidth, newwidth, maxwidth;
|
||||
if (type == "list") {
|
||||
totalwidth = member.style.width
|
||||
oldwidth = wrapper.querySelector(BDFDB.dotCN.memberinner).style.width;
|
||||
if (oldwidth && totalwidth) {
|
||||
totalwidth = parseInt(totalwidth.replace("px",""));
|
||||
oldwidth = parseInt(oldwidth.replace("px",""));
|
||||
}
|
||||
}
|
||||
var tag = $(this.tagMarkup)[0];
|
||||
member.appendChild(tag);
|
||||
|
||||
var borderColor = "rgba(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ", 0.5)";
|
||||
var textColor = "rgb(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ")";
|
||||
var bgColor = "rgba(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ", 0.1)";
|
||||
var bgInner = "none";
|
||||
var roleText = roleName;
|
||||
processMessageUsername (instance, wrapper) {
|
||||
let message = BDFDB.getReactValue(instance, "props.message");
|
||||
if (message) {
|
||||
let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
|
||||
if (username && BDFDB.getData("showInChat", this, "settings")) this.addRoleTag(message.author, username, "chat");
|
||||
}
|
||||
}
|
||||
|
||||
addRoleTag (info, username, type) {
|
||||
if (!info || !username) return;
|
||||
BDFDB.removeEles(username.parentElement.querySelectorAll(".TRE-tag"));
|
||||
let guild = this.GuildStore.getGuild(this.UserGuildState.getGuildId());
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
if (!guild || info.bot && settings.disableForBots) return;
|
||||
let role = this.GuildPerms.getHighestRole(guild, info.id);
|
||||
if ((role && (role.colorString || settings.includeColorless)) || info.id == 278543574059057154) {
|
||||
let roleColor = role && role.colorString ? BDFDB.colorCONVERT(role.colorString, "RGBCOMP") : [255,255,255];
|
||||
let roleName = role ? role.name : "";
|
||||
let oldwidth;
|
||||
if (type == "list") oldwidth = BDFDB.getRects(username).width;
|
||||
let tag = BDFDB.htmlToElement(this.tagMarkup);
|
||||
username.parentElement.insertBefore(tag, username.parentElement.querySelector("svg[name=MobileDevice]"));
|
||||
|
||||
let borderColor = "rgba(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ", 0.5)";
|
||||
let textColor = "rgb(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ")";
|
||||
let bgColor = "rgba(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ", 0.1)";
|
||||
let bgInner = "none";
|
||||
let roleText = roleName;
|
||||
if (settings.useOtherStyle) {
|
||||
borderColor = "transparent";
|
||||
bgColor = "rgb(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ")";
|
||||
textColor = roleColor[0] > 180 && roleColor[1] > 180 && roleColor[2] > 180 ? "black" : "white";
|
||||
}
|
||||
if (info.id == 278543574059057154) {
|
||||
bgColor = "linear-gradient(to right, rgba(255,0,0,0.1), rgba(255,127,0,0.1) , rgba(255,255,0,0.1), rgba(127,255,0,0.1), rgba(0,255,0,0.1), rgba(0,255,127,0.1), rgba(0,255,255,0.1), rgba(0,127,255,0.1), rgba(0,0,255,0.1), rgba(127,0,255,0.1), rgba(255,0,255,0.1), rgba(255,0,127,0.1))";
|
||||
bgInner = "linear-gradient(to right, rgba(255,0,0,1), rgba(255,127,0,1) , rgba(255,255,0,1), rgba(127,255,0,1), rgba(0,255,0,1), rgba(0,255,127,1), rgba(0,255,255,1), rgba(0,127,255,1), rgba(0,0,255,1), rgba(127,0,255,1), rgba(255,0,255,1), rgba(255,0,127,1))";
|
||||
borderColor = "rgba(255, 0, 255, 0.5)";
|
||||
textColor = "transparent";
|
||||
roleText = "Plugin Creator";
|
||||
if (settings.useOtherStyle) {
|
||||
bgColor = "linear-gradient(to right, rgba(180,0,0,1), rgba(180,90,0,1) , rgba(180,180,0,1), rgba(90,180,0,1), rgba(0,180,0,1), rgba(0,180,90,1), rgba(0,180,180,1), rgba(0,90,180,1), rgba(0,0,180,1), rgba(90,0,180,1), rgba(180,0,180,1), rgba(180,0,90,1))";
|
||||
borderColor = "transparent";
|
||||
bgColor = "rgba(" + roleColor[0] + ", " + roleColor[1] + ", " + roleColor[2] + ", 1)";
|
||||
textColor = roleColor[0] > 180 && roleColor[1] > 180 && roleColor[2] > 180 ? "black" : "white";
|
||||
}
|
||||
if (userID == 278543574059057154) {
|
||||
bgColor = "linear-gradient(to right, rgba(255,0,0,0.1), rgba(255,127,0,0.1) , rgba(255,255,0,0.1), rgba(127,255,0,0.1), rgba(0,255,0,0.1), rgba(0,255,127,0.1), rgba(0,255,255,0.1), rgba(0,127,255,0.1), rgba(0,0,255,0.1), rgba(127,0,255,0.1), rgba(255,0,255,0.1), rgba(255,0,127,0.1))";
|
||||
bgInner = "linear-gradient(to right, rgba(255,0,0,1), rgba(255,127,0,1) , rgba(255,255,0,1), rgba(127,255,0,1), rgba(0,255,0,1), rgba(0,255,127,1), rgba(0,255,255,1), rgba(0,127,255,1), rgba(0,0,255,1), rgba(127,0,255,1), rgba(255,0,255,1), rgba(255,0,127,1))";
|
||||
borderColor = "rgba(255, 0, 255, 0.5)";
|
||||
textColor = "transparent";
|
||||
roleText = "Plugin Creator";
|
||||
if (settings.useOtherStyle) {
|
||||
bgColor = "linear-gradient(to right, rgba(180,0,0,1), rgba(180,90,0,1) , rgba(180,180,0,1), rgba(90,180,0,1), rgba(0,180,0,1), rgba(0,180,90,1), rgba(0,180,180,1), rgba(0,90,180,1), rgba(0,0,180,1), rgba(90,0,180,1), rgba(180,0,180,1), rgba(180,0,90,1))";
|
||||
textColor = "white";
|
||||
}
|
||||
}
|
||||
else if (settings.showOwnerRole && userID == guild.ownerId) {
|
||||
roleText = "Owner";
|
||||
tag.classList.add("owner-tag");
|
||||
}
|
||||
tag.classList.add(type + "-tag");
|
||||
tag.style.border = "1px solid " + borderColor;
|
||||
tag.style.background = bgColor;
|
||||
var inner = tag.querySelector(".role-inner");
|
||||
inner.style.color = textColor;
|
||||
inner.style.backgroundImage = bgInner;
|
||||
inner.style.webkitBackgroundClip = "text";
|
||||
inner.textContent = roleText;
|
||||
|
||||
if (oldwidth && totalwidth) {
|
||||
newwidth = member.querySelector(BDFDB.dotCN.memberinner).style.width;
|
||||
if (newwidth) {
|
||||
newwidth = parseInt(newwidth.replace("px",""));
|
||||
if (newwidth < 100 && oldwidth < 100) {
|
||||
maxwidth = totalwidth - oldwidth - 15;
|
||||
tag.style.maxWidth = maxwidth+"px";
|
||||
}
|
||||
}
|
||||
textColor = "white";
|
||||
}
|
||||
}
|
||||
if (type == "chat" && settings.addUserID) {
|
||||
var idtag = $(this.tagMarkup)[0];
|
||||
member.appendChild(idtag);
|
||||
var idColor = settings.darkIdTag ? [33,33,33] : [222,222,222];
|
||||
var borderColorID = "rgba(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ", 0.5)";
|
||||
var textColorID = "rgb(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ")";
|
||||
var bgColorID = "rgba(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ", 0.1)";
|
||||
var bgInnerID = "none";
|
||||
if (settings.useOtherStyle) {
|
||||
borderColorID = "transparent";
|
||||
bgColorID = "rgba(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ", 1)";
|
||||
textColorID = idColor[0] > 180 && idColor[1] > 180 && idColor[2] > 180 ? "black" : "white";
|
||||
}
|
||||
idtag.classList.add("id-tag");
|
||||
idtag.style.border = "1px solid " + borderColorID;
|
||||
idtag.style.background = bgColorID;
|
||||
var idinner = idtag.querySelector(".role-inner");
|
||||
idinner.style.color = textColorID;
|
||||
idinner.style.backgroundImage = bgInnerID;
|
||||
idinner.style.webkitBackgroundClip = "text";
|
||||
idinner.textContent = userID;
|
||||
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");
|
||||
let inner = tag.querySelector(".role-inner");
|
||||
inner.style.setProperty("color", textColor);
|
||||
inner.style.setProperty("background-image", bgInner);
|
||||
inner.style.setProperty("-webkit-background-clip", "text");
|
||||
inner.textContent = roleText;
|
||||
|
||||
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) {
|
||||
let idtag = BDFDB.htmlToElement(this.tagMarkup);
|
||||
username.parentElement.insertBefore(idtag, username.parentElement.querySelector("svg[name=MobileDevice]"));
|
||||
let idColor = settings.darkIdTag ? [33,33,33] : [222,222,222];
|
||||
let idBorderColor = "rgba(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ", 0.5)";
|
||||
let idTextColor = "rgb(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ")";
|
||||
let idBgColor = "rgba(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ", 0.1)";
|
||||
let idBgInner = "none";
|
||||
if (settings.useOtherStyle) {
|
||||
idBorderColor = "transparent";
|
||||
idBgColor = "rgb(" + idColor[0] + ", " + idColor[1] + ", " + idColor[2] + ")";
|
||||
idTextColor = settings.darkIdTag ? "white" : "black";
|
||||
}
|
||||
BDFDB.addClass(idtag, "id-tag");
|
||||
idtag.style.setProperty("border", "1px solid " + idBorderColor);
|
||||
idtag.style.setProperty("background", idBgColor);
|
||||
idtag.style.setProperty("order", 12, "important");
|
||||
let idinner = idtag.querySelector(".role-inner");
|
||||
idinner.style.setProperty("color", idTextColor);
|
||||
idinner.style.setProperty("background-image", idBgInner);
|
||||
idinner.style.setProperty("-webkit-background-clip", "text");
|
||||
idinner.textContent = info.id;
|
||||
}
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
var settings = BDFDB.getAllData(this, "settings");
|
||||
var settingshtml = `<div class="DevilBro-settings ${this.name}-settings">`;
|
||||
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>`;
|
||||
|
||||
var settingspanel = $(settingshtml)[0];
|
||||
|
||||
$(settingspanel)
|
||||
.on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);});
|
||||
|
||||
getSettingsPanel () {
|
||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
let settings = BDFDB.getAllData(this, "settings");
|
||||
let settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</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></div>`;
|
||||
|
||||
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
return settingspanel;
|
||||
}
|
||||
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.updateTags) {
|
||||
this.loadRoleTags();
|
||||
this.updateTags = false;
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
BDFDB.removeEles(".TRE-tag");
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,37 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
if (typeof BDFDB !== "object") global.BDFDB = {$: Vendor.$, BDv2Api: Api};
|
||||
|
||||
const {$} = Vendor;
|
||||
if (!global.BDFDB || typeof BDFDB != "object") global.BDFDB = {BDv2Api: Api};
|
||||
|
||||
return class extends Plugin {
|
||||
initConstructor () {
|
||||
this.patchModules = {
|
||||
"ChannelTextArea":"componentDidMount",
|
||||
};
|
||||
}
|
||||
|
||||
onStart () {
|
||||
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();});
|
||||
return true;
|
||||
}
|
||||
|
||||
initialize () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
if (this.started) return true;
|
||||
BDFDB.loadMessage(this);
|
||||
|
||||
var observer = null;
|
||||
|
||||
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.bindEventToTextArea(node.querySelector(BDFDB.dotCN.textarea));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
BDFDB.addObserver(this, BDFDB.dotCN.appmount, {name:"textareaObserver",instance:observer}, {childList: true, subtree:true});
|
||||
|
||||
document.querySelectorAll("textarea" + BDFDB.dotCN.textarea).forEach(textarea => {this.bindEventToTextArea(textarea);});
|
||||
BDFDB.WebModules.forceAllUpdates(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -52,7 +42,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
|
||||
onStop () {
|
||||
if (typeof BDFDB === "object") {
|
||||
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
||||
BDFDB.unloadMessage(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -61,39 +51,34 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// begin of own functions
|
||||
|
||||
bindEventToTextArea (textarea) {
|
||||
if (!textarea) return;
|
||||
$(textarea)
|
||||
.off("keyup." + this.name)
|
||||
.on("keyup." + this.name, () => {
|
||||
clearTimeout(textarea.writeuppercasetimeout);
|
||||
textarea.writeuppercasetimeout = setTimeout(() => {this.formatText(textarea);},1);
|
||||
|
||||
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;
|
||||
if (string.length > 0) {
|
||||
let newstring = string;
|
||||
let first = string.charAt(0);
|
||||
let position = textarea.selectionStart;
|
||||
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) newstring = string.charAt(0).toLowerCase() + string.slice(1);
|
||||
else if (first === first.toLowerCase() && first !== first.toUpperCase() && string.toLowerCase().indexOf("http") != 0 && string.toLowerCase().indexOf("s/") != 0) newstring = string.charAt(0).toUpperCase() + string.slice(1);
|
||||
if (string != newstring) {
|
||||
textarea.focus();
|
||||
textarea.selectionStart = 0;
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
document.execCommand("insertText", false, newstring);
|
||||
textarea.selectionStart = position;
|
||||
textarea.selectionEnd = position;
|
||||
}
|
||||
}
|
||||
},1);
|
||||
});
|
||||
}
|
||||
|
||||
formatText (textarea) {
|
||||
var string = textarea.value;
|
||||
if (string.length > 0) {
|
||||
var newstring = string;
|
||||
var first = string.charAt(0);
|
||||
var position = textarea.selectionStart;
|
||||
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) {
|
||||
newstring = string.charAt(0).toLowerCase() + string.slice(1);
|
||||
}
|
||||
else if (first === first.toLowerCase() && first !== first.toUpperCase() && string.toLowerCase().indexOf("http") != 0 && string.toLowerCase().indexOf("s/") != 0) {
|
||||
newstring = string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
if (string != newstring) {
|
||||
textarea.focus();
|
||||
textarea.selectionStart = 0;
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
document.execCommand("insertText", false, newstring);
|
||||
textarea.selectionStart = position;
|
||||
textarea.selectionEnd = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue