//META{"name":"UserNotes"}*// class UserNotes { getName () {return "UserNotes";} getVersion () {return "1.0.1";} getAuthor () {return "DevilBro";} getDescription () {return "Allows you to write your own user notes wihtout a character limit.";} initConstructor () { this.css = ` .${this.getName()}-modal textarea { rows: 0; cols: 0; height: 30vw; resize: none; }`; this.userContextEntryMarkup = `
${BDFDB.LanguageStrings.USERS + " " + BDFDB.LanguageStrings.NOTE}
`; this.userNotesModalMarkup = `

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

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

Remove all User Notes.

`; settingshtml += `
`; let settingspanel = BDFDB.htmlToElement(settingshtml); BDFDB.initElements(settingspanel, this); BDFDB.addEventListener(this, settingspanel, "click", ".remove-button", () => { BDFDB.openConfirmModal(this, "Are you sure you want to remove all usernotes?", () => { BDFDB.removeAllData(this, "notes"); }); }); return settingspanel; } //legacy load () {} start () { var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]'); if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) { if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); libraryScript.setAttribute("type", "text/javascript"); libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"); libraryScript.setAttribute("date", performance.now()); libraryScript.addEventListener("load", () => { BDFDB.loaded = true; this.initialize(); }); document.head.appendChild(libraryScript); } else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize(); this.startTimeout = setTimeout(() => {this.initialize();}, 30000); } initialize () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (this.started) return; BDFDB.loadMessage(this); } else { console.error(this.getName() + ": Fatal Error: Could not load BD functions!"); } } stop () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { BDFDB.unloadMessage(this); } } // begin of own functions onUserContextMenu (instance, menu) { if (instance.props && instance.props.user && !menu.querySelector(".localusernotes-item")) { let userContextEntry = BDFDB.htmlToElement(this.userContextEntryMarkup); userContextEntry.querySelector(".localusernotes-item").addEventListener("click", () => { instance._reactInternalFiber.return.memoizedProps.closeContextMenu(); this.openNotesModal(instance.props.user); }); menu.appendChild(userContextEntry); } } openNotesModal (info) { let note = BDFDB.loadData(info.id, this, "notes") || ""; let userNotesModal = BDFDB.htmlToElement(this.userNotesModalMarkup); let noteinput = userNotesModal.querySelector("#modal-inputtext") userNotesModal.querySelector(BDFDB.dotCN.modalguildname).text(info.username); noteinput.value = note; noteinput.setAttribute("placeholder", note); BDFDB.appendModal(userNotesModal); BDFDB.addChildEventListener(userNotesModal, "click", ".btn-save", (e) => { e.preventDefault(); BDFDB.saveData(info.id, noteinput.value, this, "notes") }); noteinput.focus(); } }