GGn User Notes

Adds per-user notes box to profile.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

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