//META{"name":"UserNotes","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/UserNotes","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/UserNotes/UserNotes.plugin.js"}*// class UserNotes { getName () {return "UserNotes";} getVersion () {return "1.0.3";} getAuthor () {return "DevilBro";} getDescription () {return "Allows you to write your own user notes wihtout a character limit.";} constructor () { this.changelog = { "fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]] }; } initConstructor () { this.css = ` .${this.name}-modal textarea { rows: 0; cols: 0; height: 30vw; resize: none; }`; this.userNotesModalMarkup = `

${BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE}

`; } getSettingsPanel () { if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; let settings = BDFDB.DataUtils.get(this, "settings"); var settingshtml = `
${this.name}
`; settingshtml += `

Remove all User Notes.

`; settingshtml += `
`; let settingspanel = BDFDB.DOMUtils.create(settingshtml); BDFDB.initElements(settingspanel, this); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-button", () => { BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all usernotes?", () => { BDFDB.DataUtils.remove(this, "notes"); }); }); return settingspanel; } //legacy load () {} start () { if (!global.BDFDB) global.BDFDB = {myPlugins:{}}; if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this; var libraryScript = document.querySelector('head script#BDFDBLibraryScript'); if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) { if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); libraryScript.setAttribute("id", "BDFDBLibraryScript"); libraryScript.setAttribute("type", "text/javascript"); libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js"); libraryScript.setAttribute("date", performance.now()); libraryScript.addEventListener("load", () => {this.initialize();}); document.head.appendChild(libraryScript); } else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize(); this.startTimeout = setTimeout(() => { try {return this.initialize();} catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);} }, 30000); } initialize () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (this.started) return; BDFDB.PluginUtils.init(this); } else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!"); } stop () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { this.stopping = true; BDFDB.PluginUtils.clear(this); } } // begin of own functions onUserContextMenu (instance, menu, returnvalue) { if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuItem`)) { let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]}); const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, { label: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-usernote-contextMenuItem`, action: e => { BDFDB.ContextMenuUtils.close(menu); this.openNotesModal(instance.props.user); } }) ] }); if (index > -1) children.splice(index, 0, itemgroup); else children.push(itemgroup); } } openNotesModal (info) { let note = BDFDB.DataUtils.load(this, "notes", info.id) || ""; let userNotesModal = BDFDB.DOMUtils.create(this.userNotesModalMarkup); let noteinput = userNotesModal.querySelector("#modal-inputtext"); userNotesModal.querySelector(BDFDB.dotCN.modalguildname).innerText = info.username || ""; noteinput.value = note; noteinput.setAttribute("placeholder", note); BDFDB.appendModal(userNotesModal); BDFDB.ListenerUtils.addToChildren(userNotesModal, "click", ".btn-save", (e) => { e.preventDefault(); BDFDB.DataUtils.save(noteinput.value, this, "notes", info.id); }); noteinput.focus(); } }