//META{"name":"ReadAllNotificationsButton"}*// class ReadAllNotificationsButton { getName () {return "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 = `
read all
`; this.RAMbuttonMarkup = ``; 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"); var settingshtml = `
${this.getName()}
`; for (let key in settings) { settingshtml += `

${this.defaults.settings[key].description}

`; } settingshtml += `
`; let settingspanel = BDFDB.htmlToElement(settingshtml); BDFDB.initElements(settingspanel, this); return settingspanel; } //legacy load () {} start () { var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]'); if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) { if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); libraryScript.setAttribute("type", "text/javascript"); libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"); libraryScript.setAttribute("date", performance.now()); libraryScript.addEventListener("load", () => { BDFDB.loaded = true; this.initialize(); }); document.head.appendChild(libraryScript); } else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize(); this.startTimeout = setTimeout(() => {this.initialize();}, 30000); } initialize () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (this.started) return; BDFDB.loadMessage(this); BDFDB.WebModules.forceAllUpdates(this); } else { console.error(this.getName() + ": Fatal Error: Could not load BD functions!"); } } stop () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { BDFDB.removeEles(".RANbutton-frame", ".RAMbutton"); BDFDB.removeClasses("RAN-added", "RAM-added"); BDFDB.unloadMessage(this); } } // begin of own functions 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"); } } 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); } } }