Adds per-user notes box to profile.
// ==UserScript==
// @name GGn User Notes
// @namespace https://greasyfork.org
// @version 1.0
// @description Adds per-user notes box to profile.
// @match https://gazellegames.net/user.php*
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
(async function () {
'use strict';
const userId = new URLSearchParams(location.search).get('id');
if (!userId) return;
const header = document.getElementById('username');
if (!header) return;
const anchor = header.querySelector('#tip_user')?.previousElementSibling || header.lastElementChild || header;
const key = `user_notes_${userId}`;
const notesToggle = document.createElement('a');
notesToggle.href = '#';
notesToggle.textContent = '[Notes]';
const wrapper = document.createElement('span');
wrapper.className = 'user_notes';
wrapper.style.marginLeft = '0.2em';
wrapper.appendChild(notesToggle);
const notesTextbox = document.createElement('div');
notesTextbox.style.marginTop = '6px';
notesTextbox.hidden = true;
const textarea = document.createElement('textarea');
textarea.style.width = '98%';
textarea.style.minHeight = '80px';
textarea.style.resize = 'vertical';
textarea.style.fontSize = '0.8em';
textarea.value = await GM_getValue(key, '');
textarea.oninput = () => GM_setValue(key, textarea.value);
notesTextbox.appendChild(textarea);
header.appendChild(notesTextbox);
notesToggle.onclick = (e) => {
e.preventDefault();
notesTextbox.toggleAttribute('hidden');
};
anchor.insertAdjacentElement('afterend', wrapper);
})();