GGn User Notes

Adds per-user notes box to profile.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);
})();