//META{"name":"ReadAllNotificationsButton"}*// class ReadAllNotificationsButton { 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):"} } }; } getName () {return "ReadAllNotificationsButton";} getDescription () {return "Adds a button to clear all notifications.";} getVersion () {return "1.3.7";} getAuthor () {return "DevilBro";} getSettingsPanel () { if (!this.started || typeof BDFDB !== "object") return; var settings = BDFDB.getAllData(this, "settings"); var settingshtml = `
${this.getName()}
`; for (let key in settings) { settingshtml += `

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

`; } settingshtml += `
`; var settingspanel = $(settingshtml)[0]; BDFDB.initElements(settingspanel); $(settingspanel) .on("click", BDFDB.dotCN.switchinner, () => {this.updateSettings(settingspanel);}); return settingspanel; } //legacy load () {} start () { var libraryScript = null; if (typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) { libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]'); if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); libraryScript.setAttribute("type", "text/javascript"); libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"); document.head.appendChild(libraryScript); } this.startTimeout = setTimeout(() => {this.initialize();}, 30000); if (typeof BDFDB === "object" && typeof BDFDB.isLibraryOutdated === "function") this.initialize(); else libraryScript.addEventListener("load", () => {this.initialize();}); } initialize () { if (typeof BDFDB === "object") { BDFDB.loadMessage(this); BDFDB.WebModules.forceAllUpdates(this); } else { console.error(this.getName() + ": Fatal Error: Could not load BD functions!"); } } stop () { if (typeof BDFDB === "object") { BDFDB.removeEles(".RANbutton-frame", ".RAMbutton"); BDFDB.removeClasses("RAN-added", "RAM-added"); BDFDB.unloadMessage(this); } } // begin of own functions updateSettings (settingspanel) { var settings = {}; for (var input of settingspanel.querySelectorAll(BDFDB.dotCN.switchinner)) { settings[input.value] = input.checked; } BDFDB.saveAllData(settings, this, "settings"); } processGuilds (instance, wrapper) { $(this.RANbuttonMarkup).insertBefore(wrapper.querySelector(BDFDB.dotCN.guildseparator)) .on("click", ".RANbutton", () => { BDFDB.clearReadNotifications(BDFDB.getData("includeMuted", this, "settings") ? BDFDB.readServerList() : BDFDB.readUnreadServerList()); }); wrapper.classList.add("RAN-added"); } processRecentMentions (instance, wrapper) { BDFDB.removeEles(".RAMbutton"); if (instance.props && instance.props.popoutName == "RECENT_MENTIONS_POPOUT") { wrapper.classList.add("RAM-added"); $(this.RAMbuttonMarkup).appendTo(wrapper.querySelector(BDFDB.dotCN.recentmentionstitle)) .on("click", () => {this.clearMentions(instance, wrapper);}); } } 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); } } }